|
66 | 66 | static HeapTuple GetDatabaseTuple(const char *dbname);
|
67 | 67 | static HeapTuple GetDatabaseTupleByOid(Oid dboid);
|
68 | 68 | static void PerformAuthentication(Port *port);
|
69 |
| -static void CheckMyDatabase(const char *name, bool am_superuser); |
| 69 | +static void CheckMyDatabase(const char *name, bool am_superuser, bool override_allow_connections); |
70 | 70 | static void InitCommunication(void);
|
71 | 71 | static void ShutdownPostgres(int code, Datum arg);
|
72 | 72 | static void StatementTimeoutHandler(void);
|
@@ -290,7 +290,7 @@ PerformAuthentication(Port *port)
|
290 | 290 | * CheckMyDatabase -- fetch information from the pg_database entry for our DB
|
291 | 291 | */
|
292 | 292 | static void
|
293 |
| -CheckMyDatabase(const char *name, bool am_superuser) |
| 293 | +CheckMyDatabase(const char *name, bool am_superuser, bool override_allow_connections) |
294 | 294 | {
|
295 | 295 | HeapTuple tup;
|
296 | 296 | Form_pg_database dbform;
|
@@ -326,7 +326,7 @@ CheckMyDatabase(const char *name, bool am_superuser)
|
326 | 326 | /*
|
327 | 327 | * Check that the database is currently allowing connections.
|
328 | 328 | */
|
329 |
| - if (!dbform->datallowconn) |
| 329 | + if (!dbform->datallowconn && !override_allow_connections) |
330 | 330 | ereport(FATAL,
|
331 | 331 | (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
|
332 | 332 | errmsg("database \"%s\" is not currently accepting connections",
|
@@ -563,7 +563,7 @@ BaseInit(void)
|
563 | 563 | */
|
564 | 564 | void
|
565 | 565 | InitPostgres(const char *in_dbname, Oid dboid, const char *username,
|
566 |
| - Oid useroid, char *out_dbname) |
| 566 | + Oid useroid, char *out_dbname, bool override_allow_connections) |
567 | 567 | {
|
568 | 568 | bool bootstrap = IsBootstrapProcessingMode();
|
569 | 569 | bool am_superuser;
|
@@ -1006,7 +1006,7 @@ InitPostgres(const char *in_dbname, Oid dboid, const char *username,
|
1006 | 1006 | * user is a superuser, so the above stuff has to happen first.)
|
1007 | 1007 | */
|
1008 | 1008 | if (!bootstrap)
|
1009 |
| - CheckMyDatabase(dbname, am_superuser); |
| 1009 | + CheckMyDatabase(dbname, am_superuser, override_allow_connections); |
1010 | 1010 |
|
1011 | 1011 | /*
|
1012 | 1012 | * Now process any command-line switches and any additional GUC variable
|
|
0 commit comments