mirror of
https://github.com/postgres/postgres.git
synced 2025-11-10 17:42:29 +03:00
Use MyBackendType in more places to check what process this is
Remove IsBackgroundWorker, IsAutoVacuumLauncherProcess(), IsAutoVacuumWorkerProcess(), and IsLogicalSlotSyncWorker() in favor of new Am*Process() macros that use MyBackendType. For consistency with the existing Am*Process() macros. Reviewed-by: Andres Freund Discussion: https://www.postgresql.org/message-id/f3ecd4cb-85ee-4e54-8278-5fabfb3a4ed0@iki.fi
This commit is contained in:
@@ -115,7 +115,6 @@ pid_t PostmasterPid = 0;
|
||||
bool IsPostmasterEnvironment = false;
|
||||
bool IsUnderPostmaster = false;
|
||||
bool IsBinaryUpgrade = false;
|
||||
bool IsBackgroundWorker = false;
|
||||
|
||||
bool ExitOnAnyError = false;
|
||||
|
||||
|
||||
@@ -841,8 +841,8 @@ InitializeSessionUserIdStandalone(void)
|
||||
* This function should only be called in single-user mode, in autovacuum
|
||||
* workers, in slot sync worker and in background workers.
|
||||
*/
|
||||
Assert(!IsUnderPostmaster || IsAutoVacuumWorkerProcess() ||
|
||||
IsLogicalSlotSyncWorker() || IsBackgroundWorker);
|
||||
Assert(!IsUnderPostmaster || AmAutoVacuumWorkerProcess() ||
|
||||
AmLogicalSlotSyncWorkerProcess() || AmBackgroundWorkerProcess());
|
||||
|
||||
/* call only once */
|
||||
Assert(!OidIsValid(AuthenticatedUserId));
|
||||
|
||||
@@ -346,7 +346,7 @@ CheckMyDatabase(const char *name, bool am_superuser, bool override_allow_connect
|
||||
*
|
||||
* We do not enforce them for autovacuum worker processes either.
|
||||
*/
|
||||
if (IsUnderPostmaster && !IsAutoVacuumWorkerProcess())
|
||||
if (IsUnderPostmaster && !AmAutoVacuumWorkerProcess())
|
||||
{
|
||||
/*
|
||||
* Check that the database is currently allowing connections.
|
||||
@@ -828,7 +828,7 @@ InitPostgres(const char *in_dbname, Oid dboid,
|
||||
before_shmem_exit(ShutdownPostgres, 0);
|
||||
|
||||
/* The autovacuum launcher is done here */
|
||||
if (IsAutoVacuumLauncherProcess())
|
||||
if (AmAutoVacuumLauncherProcess())
|
||||
{
|
||||
/* report this backend in the PgBackendStatus array */
|
||||
pgstat_bestart();
|
||||
@@ -873,7 +873,7 @@ InitPostgres(const char *in_dbname, Oid dboid,
|
||||
* process, we use a fixed ID, otherwise we figure it out from the
|
||||
* authenticated user name.
|
||||
*/
|
||||
if (bootstrap || IsAutoVacuumWorkerProcess() || IsLogicalSlotSyncWorker())
|
||||
if (bootstrap || AmAutoVacuumWorkerProcess() || AmLogicalSlotSyncWorkerProcess())
|
||||
{
|
||||
InitializeSessionUserIdStandalone();
|
||||
am_superuser = true;
|
||||
@@ -889,7 +889,7 @@ InitPostgres(const char *in_dbname, Oid dboid,
|
||||
errhint("You should immediately run CREATE USER \"%s\" SUPERUSER;.",
|
||||
username != NULL ? username : "postgres")));
|
||||
}
|
||||
else if (IsBackgroundWorker)
|
||||
else if (AmBackgroundWorkerProcess())
|
||||
{
|
||||
if (username == NULL && !OidIsValid(useroid))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user