summaryrefslogtreecommitdiff
path: root/src/backend/utils/init
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2005-07-14 05:13:45 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2005-07-14 05:13:45 +0000
commit29094193f526bf90671d71b59a2e007aad1fcae5 (patch)
tree51e632c843ab9c7eedbd0b01f4de5b27c202443e /src/backend/utils/init
parentf2bf2d2dc5cef3f5b9cf50493490fa9931f982b2 (diff)
downloadpostgresql-29094193f526bf90671d71b59a2e007aad1fcae5.tar.gz
Integrate autovacuum functionality into the backend. There's still a
few loose ends to be dealt with, but it seems to work. Alvaro Herrera, based on the contrib code by Matthew O'Connor.
Diffstat (limited to 'src/backend/utils/init')
-rw-r--r--src/backend/utils/init/miscinit.c5
-rw-r--r--src/backend/utils/init/postinit.c16
2 files changed, 13 insertions, 8 deletions
diff --git a/src/backend/utils/init/miscinit.c b/src/backend/utils/init/miscinit.c
index ffe7db5f7e..389ad06f2f 100644
--- a/src/backend/utils/init/miscinit.c
+++ b/src/backend/utils/init/miscinit.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/init/miscinit.c,v 1.145 2005/07/04 04:51:50 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/init/miscinit.c,v 1.146 2005/07/14 05:13:41 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -32,6 +32,7 @@
#include "catalog/pg_authid.h"
#include "libpq/libpq-be.h"
#include "miscadmin.h"
+#include "postmaster/autovacuum.h"
#include "storage/fd.h"
#include "storage/ipc.h"
#include "storage/pg_shmem.h"
@@ -394,7 +395,7 @@ void
InitializeSessionUserIdStandalone(void)
{
/* This function should only be called in a single-user backend. */
- AssertState(!IsUnderPostmaster);
+ AssertState(!IsUnderPostmaster || IsAutoVacuumProcess());
/* call only once */
AssertState(!OidIsValid(AuthenticatedUserId));
diff --git a/src/backend/utils/init/postinit.c b/src/backend/utils/init/postinit.c
index 18e60cab0f..d687c59ec6 100644
--- a/src/backend/utils/init/postinit.c
+++ b/src/backend/utils/init/postinit.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/init/postinit.c,v 1.152 2005/07/04 04:51:50 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/init/postinit.c,v 1.153 2005/07/14 05:13:41 tgl Exp $
*
*
*-------------------------------------------------------------------------
@@ -29,6 +29,7 @@
#include "libpq/hba.h"
#include "mb/pg_wchar.h"
#include "miscadmin.h"
+#include "postmaster/autovacuum.h"
#include "postmaster/postmaster.h"
#include "storage/backendid.h"
#include "storage/fd.h"
@@ -268,7 +269,8 @@ BaseInit(void)
* InitPostgres
* Initialize POSTGRES.
*
- * In bootstrap mode neither of the parameters are used.
+ * In bootstrap mode neither of the parameters are used. In autovacuum
+ * mode, the username parameter is not used.
*
* The return value indicates whether the userID is a superuser. (That
* can only be tested inside a transaction, so we want to do it during
@@ -282,6 +284,7 @@ bool
InitPostgres(const char *dbname, const char *username)
{
bool bootstrap = IsBootstrapProcessingMode();
+ bool autovacuum = IsAutoVacuumProcess();
bool am_superuser;
/*
@@ -402,10 +405,11 @@ InitPostgres(const char *dbname, const char *username)
RelationCacheInitializePhase2();
/*
- * Figure out our postgres user id. In standalone mode we use a fixed
- * id, otherwise we figure it out from the authenticated user name.
+ * Figure out our postgres user id. In standalone mode and in the
+ * autovacuum process, we use a fixed id, otherwise we figure it out from
+ * the authenticated user name.
*/
- if (bootstrap)
+ if (bootstrap || autovacuum)
InitializeSessionUserIdStandalone();
else if (!IsUnderPostmaster)
{
@@ -441,7 +445,7 @@ InitPostgres(const char *dbname, const char *username)
/*
* Check if user is a superuser.
*/
- if (bootstrap)
+ if (bootstrap || autovacuum)
am_superuser = true;
else
am_superuser = superuser();