mirror of
https://github.com/postgres/postgres.git
synced 2025-07-02 09:02:37 +03:00
Allow background workers to bypass datallowconn
THis adds a "flags" field to the BackgroundWorkerInitializeConnection() and BackgroundWorkerInitializeConnectionByOid(). For now only one flag, BGWORKER_BYPASS_ALLOWCONN, is defined, which allows the worker to ignore datallowconn.
This commit is contained in:
@ -66,7 +66,7 @@
|
||||
static HeapTuple GetDatabaseTuple(const char *dbname);
|
||||
static HeapTuple GetDatabaseTupleByOid(Oid dboid);
|
||||
static void PerformAuthentication(Port *port);
|
||||
static void CheckMyDatabase(const char *name, bool am_superuser);
|
||||
static void CheckMyDatabase(const char *name, bool am_superuser, bool override_allow_connections);
|
||||
static void InitCommunication(void);
|
||||
static void ShutdownPostgres(int code, Datum arg);
|
||||
static void StatementTimeoutHandler(void);
|
||||
@ -290,7 +290,7 @@ PerformAuthentication(Port *port)
|
||||
* CheckMyDatabase -- fetch information from the pg_database entry for our DB
|
||||
*/
|
||||
static void
|
||||
CheckMyDatabase(const char *name, bool am_superuser)
|
||||
CheckMyDatabase(const char *name, bool am_superuser, bool override_allow_connections)
|
||||
{
|
||||
HeapTuple tup;
|
||||
Form_pg_database dbform;
|
||||
@ -326,7 +326,7 @@ CheckMyDatabase(const char *name, bool am_superuser)
|
||||
/*
|
||||
* Check that the database is currently allowing connections.
|
||||
*/
|
||||
if (!dbform->datallowconn)
|
||||
if (!dbform->datallowconn && !override_allow_connections)
|
||||
ereport(FATAL,
|
||||
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
|
||||
errmsg("database \"%s\" is not currently accepting connections",
|
||||
@ -563,7 +563,7 @@ BaseInit(void)
|
||||
*/
|
||||
void
|
||||
InitPostgres(const char *in_dbname, Oid dboid, const char *username,
|
||||
Oid useroid, char *out_dbname)
|
||||
Oid useroid, char *out_dbname, bool override_allow_connections)
|
||||
{
|
||||
bool bootstrap = IsBootstrapProcessingMode();
|
||||
bool am_superuser;
|
||||
@ -1006,7 +1006,7 @@ InitPostgres(const char *in_dbname, Oid dboid, const char *username,
|
||||
* user is a superuser, so the above stuff has to happen first.)
|
||||
*/
|
||||
if (!bootstrap)
|
||||
CheckMyDatabase(dbname, am_superuser);
|
||||
CheckMyDatabase(dbname, am_superuser, override_allow_connections);
|
||||
|
||||
/*
|
||||
* Now process any command-line switches and any additional GUC variable
|
||||
|
Reference in New Issue
Block a user