aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/backend/Makefile6
-rw-r--r--src/backend/bootstrap/bootstrap.c15
-rw-r--r--src/backend/catalog/Makefile4
-rw-r--r--src/backend/catalog/system_views.sql6
-rw-r--r--src/backend/postmaster/Makefile4
-rw-r--r--src/backend/postmaster/postmaster.c179
-rw-r--r--src/backend/utils/misc/guc.c53
-rw-r--r--src/backend/utils/misc/postgresql.conf.sample10
-rw-r--r--src/include/bootstrap/bootstrap.h3
-rw-r--r--src/include/catalog/catversion.h4
-rw-r--r--src/include/postmaster/postmaster.h3
-rw-r--r--src/include/storage/proc.h5
-rw-r--r--src/include/utils/guc_tables.h3
-rw-r--r--src/test/regress/expected/rules.out4
14 files changed, 249 insertions, 50 deletions
diff --git a/src/backend/Makefile b/src/backend/Makefile
index b106353abc4..bee3ea44b67 100644
--- a/src/backend/Makefile
+++ b/src/backend/Makefile
@@ -4,7 +4,7 @@
#
# Copyright (c) 1994, Regents of the University of California
#
-# $PostgreSQL: pgsql/src/backend/Makefile,v 1.101 2004/07/19 17:03:56 tgl Exp $
+# $PostgreSQL: pgsql/src/backend/Makefile,v 1.102 2004/07/21 20:22:58 momjian Exp $
#
#-------------------------------------------------------------------------
@@ -29,13 +29,13 @@ endif
##########################################################################
-all: submake-libpgport postgres $(POSTGRES_IMP)
+all: submake-libpgport submake-libpq postgres $(POSTGRES_IMP)
ifneq ($(PORTNAME), cygwin)
ifneq ($(PORTNAME), win32)
postgres: $(OBJS)
- $(CC) $(CFLAGS) $(LDFLAGS) $(export_dynamic) $^ $(LIBS) -o $@
+ $(CC) $(CFLAGS) $(LDFLAGS) -I $(libpq_srcdir) $(export_dynamic) $^ $(LIBS) $(libpq) -o $@
endif
endif
diff --git a/src/backend/bootstrap/bootstrap.c b/src/backend/bootstrap/bootstrap.c
index 4e219df4f5b..43f69488631 100644
--- a/src/backend/bootstrap/bootstrap.c
+++ b/src/backend/bootstrap/bootstrap.c
@@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/bootstrap/bootstrap.c,v 1.187 2004/07/17 03:28:37 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/bootstrap/bootstrap.c,v 1.188 2004/07/21 20:22:58 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -34,6 +34,7 @@
#include "libpq/pqsignal.h"
#include "miscadmin.h"
#include "postmaster/bgwriter.h"
+#include "postmaster/pg_autovacuum.h"
#include "storage/freespace.h"
#include "storage/ipc.h"
#include "storage/pg_shmem.h"
@@ -355,6 +356,9 @@ BootstrapMain(int argc, char *argv[])
case BS_XLOG_BGWRITER:
statmsg = "writer process";
break;
+ case BS_XLOG_AUTOVAC:
+ statmsg = "auto vacuum process";
+ break;
default:
statmsg = "??? process";
break;
@@ -391,6 +395,9 @@ BootstrapMain(int argc, char *argv[])
case BS_XLOG_BGWRITER:
InitDummyProcess(DUMMY_PROC_BGWRITER);
break;
+ case BS_XLOG_AUTOVAC:
+ InitDummyProcess(DUMMY_PROC_AUTOVAC);
+ break;
default:
InitDummyProcess(DUMMY_PROC_DEFAULT);
@@ -427,6 +434,12 @@ BootstrapMain(int argc, char *argv[])
BackgroundWriterMain();
proc_exit(1); /* should never return */
+ case BS_XLOG_AUTOVAC:
+ /* don't set signals, autovac has its own agenda */
+ InitXLOGAccess();
+ AutoVacMain();
+ proc_exit(1); /* should never return */
+
default:
elog(PANIC, "unrecognized XLOG op: %d", xlogop);
proc_exit(1);
diff --git a/src/backend/catalog/Makefile b/src/backend/catalog/Makefile
index c63168a9bd5..4ed03b1d644 100644
--- a/src/backend/catalog/Makefile
+++ b/src/backend/catalog/Makefile
@@ -2,7 +2,7 @@
#
# Makefile for backend/catalog
#
-# $PostgreSQL: pgsql/src/backend/catalog/Makefile,v 1.51 2004/06/18 06:13:19 tgl Exp $
+# $PostgreSQL: pgsql/src/backend/catalog/Makefile,v 1.52 2004/07/21 20:22:59 momjian Exp $
#
#-------------------------------------------------------------------------
@@ -32,7 +32,7 @@ POSTGRES_BKI_SRCS := $(addprefix $(top_srcdir)/src/include/catalog/,\
pg_language.h pg_largeobject.h pg_aggregate.h pg_statistic.h \
pg_rewrite.h pg_trigger.h pg_listener.h pg_description.h pg_cast.h \
pg_namespace.h pg_conversion.h pg_database.h pg_shadow.h pg_group.h \
- pg_tablespace.h pg_depend.h indexing.h \
+ pg_tablespace.h pg_depend.h pg_autovacuum.h indexing.h \
)
pg_includes := $(sort -I$(top_srcdir)/src/include -I$(top_builddir)/src/include)
diff --git a/src/backend/catalog/system_views.sql b/src/backend/catalog/system_views.sql
index 9e2eca9b2ee..e94d7155e75 100644
--- a/src/backend/catalog/system_views.sql
+++ b/src/backend/catalog/system_views.sql
@@ -3,7 +3,7 @@
*
* Copyright 1996-2003, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/backend/catalog/system_views.sql,v 1.6 2004/04/26 15:24:41 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/catalog/system_views.sql,v 1.7 2004/07/21 20:22:59 momjian Exp $
*/
CREATE VIEW pg_user AS
@@ -41,22 +41,26 @@ CREATE VIEW pg_tables AS
SELECT
N.nspname AS schemaname,
C.relname AS tablename,
+ T.spcname AS tablespace,
pg_get_userbyid(C.relowner) AS tableowner,
C.relhasindex AS hasindexes,
C.relhasrules AS hasrules,
(C.reltriggers > 0) AS hastriggers
FROM pg_class C LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace)
+ LEFT JOIN pg_tablespace T ON (T.oid = C.reltablespace)
WHERE C.relkind = 'r';
CREATE VIEW pg_indexes AS
SELECT
N.nspname AS schemaname,
C.relname AS tablename,
+ T.spcname AS tablespace,
I.relname AS indexname,
pg_get_indexdef(I.oid) AS indexdef
FROM pg_index X JOIN pg_class C ON (C.oid = X.indrelid)
JOIN pg_class I ON (I.oid = X.indexrelid)
LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace)
+ LEFT JOIN pg_tablespace T ON (T.oid = C.reltablespace)
WHERE C.relkind = 'r' AND I.relkind = 'i';
CREATE VIEW pg_stats AS
diff --git a/src/backend/postmaster/Makefile b/src/backend/postmaster/Makefile
index 10d7cfcb8ef..d41790e0f79 100644
--- a/src/backend/postmaster/Makefile
+++ b/src/backend/postmaster/Makefile
@@ -4,7 +4,7 @@
# Makefile for src/backend/postmaster
#
# IDENTIFICATION
-# $PostgreSQL: pgsql/src/backend/postmaster/Makefile,v 1.16 2004/07/19 02:47:08 tgl Exp $
+# $PostgreSQL: pgsql/src/backend/postmaster/Makefile,v 1.17 2004/07/21 20:22:59 momjian Exp $
#
#-------------------------------------------------------------------------
@@ -12,7 +12,7 @@ subdir = src/backend/postmaster
top_builddir = ../../..
include $(top_builddir)/src/Makefile.global
-OBJS = postmaster.o bgwriter.o pgstat.o pgarch.o
+OBJS = postmaster.o bgwriter.o pgstat.o pgarch.o pg_autovacuum.o
all: SUBSYS.o
diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c
index d08d02c2cf6..661451411f4 100644
--- a/src/backend/postmaster/postmaster.c
+++ b/src/backend/postmaster/postmaster.c
@@ -37,7 +37,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.412 2004/07/19 02:47:08 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.413 2004/07/21 20:22:59 momjian Exp $
*
* NOTES
*
@@ -55,12 +55,6 @@
* The Postmaster cleans up after backends if they have an emergency
* exit and/or core dump.
*
- * Error Reporting:
- * Use write_stderr() only for reporting "interactive" errors
- * (essentially, bogus arguments on the command line). Once the
- * postmaster is launched, use ereport(). In particular, don't use
- * write_stderr() for anything that occurs after pmdaemonize.
- *
*-------------------------------------------------------------------------
*/
@@ -200,6 +194,7 @@ char *preload_libraries_string = NULL;
static pid_t StartupPID = 0,
BgWriterPID = 0,
PgArchPID = 0,
+ AutoVacPID = 0,
PgStatPID = 0;
/* Startup/shutdown state */
@@ -269,6 +264,7 @@ static void SignalChildren(int signal);
static int CountChildren(void);
static bool CreateOptsFile(int argc, char *argv[], char *fullprogname);
static pid_t StartChildProcess(int xlop);
+static void postmaster_error(const char *fmt,...);
#ifdef EXEC_BACKEND
@@ -299,6 +295,7 @@ static void ShmemBackendArrayRemove(pid_t pid);
#define StartupDataBase() StartChildProcess(BS_XLOG_STARTUP)
#define StartBackgroundWriter() StartChildProcess(BS_XLOG_BGWRITER)
+#define StartAutoVac() StartChildProcess(BS_XLOG_AUTOVAC)
/*
@@ -385,7 +382,7 @@ PostmasterMain(int argc, char *argv[])
#ifdef USE_ASSERT_CHECKING
SetConfigOption("debug_assertions", optarg, PGC_POSTMASTER, PGC_S_ARGV);
#else
- write_stderr("%s: assert checking is not compiled in\n", progname);
+ postmaster_error("assert checking is not compiled in");
#endif
break;
case 'a':
@@ -509,8 +506,9 @@ PostmasterMain(int argc, char *argv[])
}
default:
- write_stderr("Try \"%s --help\" for more information.\n",
- progname);
+ fprintf(stderr,
+ gettext("Try \"%s --help\" for more information.\n"),
+ progname);
ExitPostmaster(1);
}
}
@@ -520,10 +518,10 @@ PostmasterMain(int argc, char *argv[])
*/
if (optind < argc)
{
- write_stderr("%s: invalid argument: \"%s\"\n",
- progname, argv[optind]);
- write_stderr("Try \"%s --help\" for more information.\n",
- progname);
+ postmaster_error("invalid argument: \"%s\"", argv[optind]);
+ fprintf(stderr,
+ gettext("Try \"%s --help\" for more information.\n"),
+ progname);
ExitPostmaster(1);
}
@@ -594,13 +592,13 @@ PostmasterMain(int argc, char *argv[])
* for lack of buffers. The specific choices here are somewhat
* arbitrary.
*/
- write_stderr("%s: the number of buffers (-B) must be at least twice the number of allowed connections (-N) and at least 16\n", progname);
+ postmaster_error("the number of buffers (-B) must be at least twice the number of allowed connections (-N) and at least 16");
ExitPostmaster(1);
}
if (ReservedBackends >= MaxBackends)
{
- write_stderr("%s: superuser_reserved_connections must be less than max_connections\n", progname);
+ postmaster_error("superuser_reserved_connections must be less than max_connections");
ExitPostmaster(1);
}
@@ -609,7 +607,7 @@ PostmasterMain(int argc, char *argv[])
*/
if (!CheckDateTokenTables())
{
- write_stderr("%s: invalid datetoken tables, please fix\n", progname);
+ postmaster_error("invalid datetoken tables, please fix");
ExitPostmaster(1);
}
@@ -829,7 +827,7 @@ PostmasterMain(int argc, char *argv[])
* CAUTION: when changing this list, check for side-effects on the signal
* handling setup of child processes. See tcop/postgres.c,
* bootstrap/bootstrap.c, postmaster/bgwriter.c, postmaster/pgarch.c,
- * and postmaster/pgstat.c.
+ * postmaster/pgstat.c, and postmaster/pg_autovacuum.c.
*/
pqinitmask();
PG_SETMASK(&BlockSig);
@@ -978,10 +976,11 @@ checkDataDir(const char *checkdir)
fp = AllocateFile(path, PG_BINARY_R);
if (fp == NULL)
{
- write_stderr("%s: could not find the database system\n"
- "Expected to find it in the directory \"%s\",\n"
- "but could not open file \"%s\": %s\n",
- progname, checkdir, path, strerror(errno));
+ fprintf(stderr,
+ gettext("%s: could not find the database system\n"
+ "Expected to find it in the directory \"%s\",\n"
+ "but could not open file \"%s\": %s\n"),
+ progname, checkdir, path, strerror(errno));
ExitPostmaster(2);
}
FreeFile(fp);
@@ -1024,8 +1023,8 @@ pmdaemonize(void)
pid = fork();
if (pid == (pid_t) -1)
{
- write_stderr("%s: could not fork background process: %s\n",
- progname, strerror(errno));
+ postmaster_error("could not fork background process: %s",
+ strerror(errno));
ExitPostmaster(1);
}
else if (pid)
@@ -1046,8 +1045,8 @@ pmdaemonize(void)
#ifdef HAVE_SETSID
if (setsid() < 0)
{
- write_stderr("%s: could not dissociate from controlling TTY: %s\n",
- progname, strerror(errno));
+ postmaster_error("could not dissociate from controlling TTY: %s",
+ strerror(errno));
ExitPostmaster(1);
}
#endif
@@ -1114,9 +1113,9 @@ ServerLoop(void)
int nSockets;
time_t now,
last_touch_time;
- struct timeval earlier,
+ struct timeval earlier,
later;
- struct timezone tz;
+ struct timezone tz;
gettimeofday(&earlier, &tz);
last_touch_time = time(NULL);
@@ -1220,6 +1219,35 @@ ServerLoop(void)
kill(BgWriterPID, SIGUSR2);
}
+ /*
+ * If no AutoVacuum process is running, and we are not in
+ * a state that prevents it, start one. It doesn't matter if this
+ * fails, we'll just try again later.
+ */
+ if (autovacuum_start_daemon)
+ {
+ if (pgstat_collect_tuplelevel)
+ {
+ if (AutoVacPID == 0 && StartupPID == 0 && !FatalError)
+ {
+ AutoVacPID = StartAutoVac();
+ if(pgstat_collect_resetonpmstart)
+ elog(WARNING,"pg_autovacuum: stats_reset_on_server_start should be disabled for optimal performance");
+
+ /* If shutdown is pending, set it going */
+ if (Shutdown > NoShutdown && AutoVacPID != 0)
+ kill(AutoVacPID, SIGUSR2);
+ }
+ }
+ else
+ elog(WARNING, "pg_autovacuum: autovac is enabled, but requires stats_row_level which is not enabled");
+ }
+ else if(AutoVacPID > 0)
+ kill(AutoVacPID, SIGUSR2);
+
+ if (!autovacuum_start_daemon)
+ elog(DEBUG1, "pg_autovacuum: not enabled");
+
/* If we have lost the archiver, try to start a new one */
if (XLogArchivingActive() && PgArchPID == 0 &&
StartupPID == 0 && !FatalError && Shutdown == NoShutdown)
@@ -1587,6 +1615,21 @@ processCancelRequest(Port *port, void *pkt)
backendPID = (int) ntohl(canc->backendPID);
cancelAuthCode = (long) ntohl(canc->cancelAuthCode);
+ if (backendPID == BgWriterPID)
+ {
+ ereport(DEBUG2,
+ (errmsg_internal("ignoring cancel request for bgwriter process %d",
+ backendPID)));
+ return;
+ }
+ if (backendPID == AutoVacPID)
+ {
+ ereport(DEBUG2,
+ (errmsg_internal("ignoring cancel request for autovacuum process %d",
+ backendPID)));
+ return;
+ }
+
/*
* See if we have a matching backend. In the EXEC_BACKEND case, we
* can no longer access the postmaster's own backend list, and must
@@ -1770,6 +1813,8 @@ SIGHUP_handler(SIGNAL_ARGS)
kill(BgWriterPID, SIGHUP);
if (PgArchPID != 0)
kill(PgArchPID, SIGHUP);
+ if (AutoVacPID != 0)
+ kill(AutoVacPID, SIGHUP);
/* PgStatPID does not currently need SIGHUP */
load_hba();
load_ident();
@@ -1831,6 +1876,10 @@ pmdie(SIGNAL_ARGS)
/* Tell pgarch to shut down too; nothing left for it to do */
if (PgArchPID != 0)
kill(PgArchPID, SIGQUIT);
+ /* I don't think we need to Start the autovac process if not running */
+ /* And tell it to shut down */
+ if (AutoVacPID != 0)
+ kill(AutoVacPID, SIGUSR2);
/* Tell pgstat to shut down too; nothing left for it to do */
if (PgStatPID != 0)
kill(PgStatPID, SIGQUIT);
@@ -1878,6 +1927,9 @@ pmdie(SIGNAL_ARGS)
/* Tell pgarch to shut down too; nothing left for it to do */
if (PgArchPID != 0)
kill(PgArchPID, SIGQUIT);
+ /* And tell it to shut down */
+ if (AutoVacPID != 0)
+ kill(AutoVacPID, SIGUSR2);
/* Tell pgstat to shut down too; nothing left for it to do */
if (PgStatPID != 0)
kill(PgStatPID, SIGQUIT);
@@ -1898,6 +1950,8 @@ pmdie(SIGNAL_ARGS)
kill(BgWriterPID, SIGQUIT);
if (PgArchPID != 0)
kill(PgArchPID, SIGQUIT);
+ if (AutoVacPID != 0)
+ kill(AutoVacPID, SIGQUIT);
if (PgStatPID != 0)
kill(PgStatPID, SIGQUIT);
if (DLGetHead(BackendList))
@@ -2040,10 +2094,36 @@ reaper(SIGNAL_ARGS)
if (XLogArchivingActive() &&
StartupPID == 0 && !FatalError && Shutdown == NoShutdown)
PgArchPID = pgarch_start();
+ /*
+ * Shutdown autovac if a shutdown request was pending.
+ */
+ if (Shutdown > NoShutdown && AutoVacPID != 0)
+ kill(AutoVacPID, SIGUSR2);
+
continue;
}
/*
+ * Was it the autovac?
+ */
+ if (AutoVacPID != 0 && pid == AutoVacPID)
+ {
+ AutoVacPID = 0;
+ if (exitstatus != 0)
+ {
+ /*
+ * Any unexpected exit of the autovacuum is treated as a crash.
+ * FIXME: This is useful for debugging autovac, but I think it should be
+ * ripped out before final patch, autovac shouldn't crash the postmaster
+ */
+ LogChildExit(LOG, gettext("pg_autovacuum process"),
+ pid, exitstatus);
+ HandleChildCrash(pid, exitstatus);
+ continue;
+ }
+ }
+
+ /*
* Was it the statistics collector? If so, just try to start a new
* one; no need to force reset of the rest of the system. (If fail,
* we'll try again in future cycles of the main loop.)
@@ -2072,7 +2152,7 @@ reaper(SIGNAL_ARGS)
* StartupDataBase. (We can ignore the archiver and stats processes
* here since they are not connected to shmem.)
*/
- if (DLGetHead(BackendList) || StartupPID != 0 || BgWriterPID != 0)
+ if (DLGetHead(BackendList) || StartupPID != 0 || BgWriterPID != 0 || AutoVacPID != 0)
goto reaper_done;
ereport(LOG,
(errmsg("all server processes terminated; reinitializing")));
@@ -2095,6 +2175,9 @@ reaper(SIGNAL_ARGS)
/* And tell it to shut down */
if (BgWriterPID != 0)
kill(BgWriterPID, SIGUSR2);
+ /* Tell AutoVac to shut down */
+ if (AutoVacPID != 0)
+ kill(AutoVacPID, SIGUSR2);
}
reaper_done:
@@ -2254,6 +2337,20 @@ HandleChildCrash(int pid,
}
FatalError = true;
+
+ /* Take care of the autovacuum too */
+ if (pid == AutoVacPID)
+ AutoVacPID = 0;
+ else if (AutoVacPID != 0 && !FatalError)
+ {
+ ereport(DEBUG2,
+ (errmsg_internal("sending %s to process %d",
+ (SendStop ? "SIGSTOP" : "SIGQUIT"),
+ (int) AutoVacPID)));
+ kill(AutoVacPID, (SendStop ? SIGSTOP : SIGQUIT));
+ }
+
+ FatalError = true;
}
/*
@@ -3240,6 +3337,10 @@ StartChildProcess(int xlop)
ereport(LOG,
(errmsg("could not fork background writer process: %m")));
break;
+ case BS_XLOG_AUTOVAC:
+ ereport(LOG,
+ (errmsg("could not fork auto vacuum process: %m")));
+ break;
default:
ereport(LOG,
(errmsg("could not fork process: %m")));
@@ -3294,6 +3395,24 @@ CreateOptsFile(int argc, char *argv[], char *fullprogname)
return true;
}
+/*
+ * This should be used only for reporting "interactive" errors (essentially,
+ * bogus arguments on the command line). Once the postmaster is launched,
+ * use ereport. In particular, don't use this for anything that occurs
+ * after pmdaemonize.
+ */
+static void
+postmaster_error(const char *fmt,...)
+{
+ va_list ap;
+
+ fprintf(stderr, "%s: ", progname);
+ va_start(ap, fmt);
+ vfprintf(stderr, gettext(fmt), ap);
+ va_end(ap);
+ fprintf(stderr, "\n");
+}
+
#ifdef EXEC_BACKEND
@@ -3733,7 +3852,7 @@ win32_sigchld_waiter(LPVOID param)
if (r == WAIT_OBJECT_0)
pg_queue_signal(SIGCHLD);
else
- write_stderr("ERROR: failed to wait on child process handle: %d\n",
+ fprintf(stderr, "ERROR: failed to wait on child process handle: %d\n",
(int) GetLastError());
CloseHandle(procHandle);
return 0;
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index bc723e19606..ca0deb86c11 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -10,7 +10,7 @@
* Written by Peter Eisentraut <peter_e@gmx.net>.
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.221 2004/07/19 21:39:47 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.222 2004/07/21 20:23:01 momjian Exp $
*
*--------------------------------------------------------------------
*/
@@ -43,7 +43,9 @@
#include "optimizer/prep.h"
#include "parser/parse_expr.h"
#include "parser/parse_relation.h"
+#include "pgstat.h"
#include "postmaster/bgwriter.h"
+#include "postmaster/pg_autovacuum.h"
#include "postmaster/postmaster.h"
#include "storage/bufmgr.h"
#include "storage/fd.h"
@@ -55,7 +57,6 @@
#include "utils/builtins.h"
#include "utils/memutils.h"
#include "utils/pg_locale.h"
-#include "pgstat.h"
char *guc_pgdata;
char *guc_hbafile;
@@ -642,6 +643,14 @@ static struct config_bool ConfigureNamesBool[] =
&pgstat_collect_blocklevel,
false, NULL, NULL
},
+ {
+ {"autovacuum", PGC_SIGHUP, AUTOVACUUM,
+ gettext_noop("Starts the auto vacuum subprocess."),
+ NULL
+ },
+ &autovacuum_start_daemon,
+ false, NULL, NULL
+ },
{
{"trace_notify", PGC_USERSET, DEVELOPER_OPTIONS,
@@ -1284,6 +1293,30 @@ static struct config_int ConfigureNamesInt[] =
&block_size,
BLCKSZ, BLCKSZ, BLCKSZ, NULL, NULL
},
+ {
+ {"autovacuum_vacuum_threshold_base", PGC_SIGHUP, AUTOVACUUM,
+ gettext_noop("Minimum number of tuple updates or deletes prior to vacuum."),
+ NULL
+ },
+ &autovacuum_vacuum_base,
+ 1000, 0, INT_MAX, NULL, NULL
+ },
+ {
+ {"autovacuum_analyze_threshold_base", PGC_SIGHUP, AUTOVACUUM,
+ gettext_noop("Minimum number of tuple updates or deletes prior to analyze."),
+ NULL
+ },
+ &autovacuum_analyze_base,
+ 500, 0, INT_MAX, NULL, NULL
+ },
+ {
+ {"autovacuum_naptime", PGC_SIGHUP, AUTOVACUUM,
+ gettext_noop("Minimum number of tuple updates or deletes prior to analyze."),
+ NULL
+ },
+ &autovacuum_analyze_base,
+ 500, 0, INT_MAX, NULL, NULL
+ },
/* End-of-list marker */
{
@@ -1364,6 +1397,22 @@ static struct config_real ConfigureNamesReal[] =
&phony_random_seed,
0.5, 0.0, 1.0, assign_random_seed, show_random_seed
},
+ {
+ {"autovacuum_vacuum_threshold_sf", PGC_SIGHUP, AUTOVACUUM,
+ gettext_noop("Numer of tuple updates or deletes prior to vacuum as a factor of reltuples."),
+ NULL
+ },
+ &autovacuum_vacuum_scaling_factor,
+ 2, 0, 100, NULL, NULL
+ },
+ {
+ {"autovacuum_analyze_threshold_sf", PGC_SIGHUP, AUTOVACUUM,
+ gettext_noop("Numer of tuple updates or deletes prior to analyze as a factor of reltuples."),
+ NULL
+ },
+ &autovacuum_analyze_scaling_factor,
+ 1, 0, 100, NULL, NULL
+ },
/* End-of-list marker */
{
diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample
index 9dc1ec8d837..02c9abbcca3 100644
--- a/src/backend/utils/misc/postgresql.conf.sample
+++ b/src/backend/utils/misc/postgresql.conf.sample
@@ -238,6 +238,16 @@
#---------------------------------------------------------------------------
+# VACUUM DAEMON
+#---------------------------------------------------------------------------
+
+#autovacuum = false # requires stats_row_level = true
+#autovacuum_vacuum_threshold_base = 1000
+#autovacuum_vacuum_threshold_sf = 2
+#autovacuum_analyze_threshold_base = 500
+#autovacuum_analyze_threshold_sf = 1
+
+#---------------------------------------------------------------------------
# CLIENT CONNECTION DEFAULTS
#---------------------------------------------------------------------------
diff --git a/src/include/bootstrap/bootstrap.h b/src/include/bootstrap/bootstrap.h
index 21ed4828692..376f6fe447c 100644
--- a/src/include/bootstrap/bootstrap.h
+++ b/src/include/bootstrap/bootstrap.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/bootstrap/bootstrap.h,v 1.35 2004/05/29 22:48:22 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/bootstrap/bootstrap.h,v 1.36 2004/07/21 20:23:03 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -59,5 +59,6 @@ extern void Int_yyerror(const char *str);
#define BS_XLOG_BOOTSTRAP 1
#define BS_XLOG_STARTUP 2
#define BS_XLOG_BGWRITER 3
+#define BS_XLOG_AUTOVAC 4
#endif /* BOOTSTRAP_H */
diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h
index 067d7347866..8dac1fc362d 100644
--- a/src/include/catalog/catversion.h
+++ b/src/include/catalog/catversion.h
@@ -37,7 +37,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.244 2004/07/12 20:23:51 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.245 2004/07/21 20:23:03 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -53,6 +53,6 @@
*/
/* yyyymmddN */
-#define CATALOG_VERSION_NO 200407121
+#define CATALOG_VERSION_NO 200407211
#endif
diff --git a/src/include/postmaster/postmaster.h b/src/include/postmaster/postmaster.h
index 301f7652ffe..0b18842133b 100644
--- a/src/include/postmaster/postmaster.h
+++ b/src/include/postmaster/postmaster.h
@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/postmaster/postmaster.h,v 1.2 2004/05/30 03:50:15 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/postmaster/postmaster.h,v 1.3 2004/07/21 20:23:04 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -29,6 +29,7 @@ extern char *preload_libraries_string;
extern bool Log_connections;
extern bool log_hostname;
extern char *rendezvous_name;
+extern bool autovacuum_start_daemon;
#ifdef WIN32
extern HANDLE PostmasterHandle;
diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h
index 8645fb1fdb5..6dec47a2a0f 100644
--- a/src/include/storage/proc.h
+++ b/src/include/storage/proc.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/storage/proc.h,v 1.69 2004/07/17 03:31:26 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/storage/proc.h,v 1.70 2004/07/21 20:23:04 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -88,7 +88,8 @@ typedef struct PROC_HDR
#define DUMMY_PROC_DEFAULT 0
#define DUMMY_PROC_BGWRITER 1
-#define NUM_DUMMY_PROCS 2
+#define DUMMY_PROC_AUTOVAC 2
+#define NUM_DUMMY_PROCS 3
/* configurable options */
diff --git a/src/include/utils/guc_tables.h b/src/include/utils/guc_tables.h
index d522f6d5e94..b9212060413 100644
--- a/src/include/utils/guc_tables.h
+++ b/src/include/utils/guc_tables.h
@@ -7,7 +7,7 @@
*
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/include/utils/guc_tables.h,v 1.12 2004/07/01 00:51:44 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/utils/guc_tables.h,v 1.13 2004/07/21 20:23:05 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -71,6 +71,7 @@ enum config_group
COMPAT_OPTIONS_CLIENT,
DEVELOPER_OPTIONS,
COMPILE_OPTIONS,
+ AUTOVACUUM,
CUSTOM_OPTIONS
};
diff --git a/src/test/regress/expected/rules.out b/src/test/regress/expected/rules.out
index 92548e6f925..4b4a4d08cc3 100644
--- a/src/test/regress/expected/rules.out
+++ b/src/test/regress/expected/rules.out
@@ -1275,7 +1275,7 @@ SELECT viewname, definition FROM pg_views WHERE schemaname <> 'information_schem
viewname | definition
--------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
iexit | SELECT ih.name, ih.thepath, interpt_pp(ih.thepath, r.thepath) AS exit FROM ihighway ih, ramp r WHERE (ih.thepath ## r.thepath);
- pg_indexes | SELECT n.nspname AS schemaname, c.relname AS tablename, i.relname AS indexname, pg_get_indexdef(i.oid) AS indexdef FROM (((pg_index x JOIN pg_class c ON ((c.oid = x.indrelid))) JOIN pg_class i ON ((i.oid = x.indexrelid))) LEFT JOIN pg_namespace n ON ((n.oid = c.relnamespace))) WHERE ((c.relkind = 'r'::"char") AND (i.relkind = 'i'::"char"));
+ pg_indexes | SELECT n.nspname AS schemaname, c.relname AS tablename, t.spcname AS "tablespace", i.relname AS indexname, pg_get_indexdef(i.oid) AS indexdef FROM ((((pg_index x JOIN pg_class c ON ((c.oid = x.indrelid))) JOIN pg_class i ON ((i.oid = x.indexrelid))) LEFT JOIN pg_namespace n ON ((n.oid = c.relnamespace))) LEFT JOIN pg_tablespace t ON ((t.oid = c.reltablespace))) WHERE ((c.relkind = 'r'::"char") AND (i.relkind = 'i'::"char"));
pg_locks | SELECT l.relation, l."database", l."transaction", l.pid, l."mode", l.granted FROM pg_lock_status() l(relation oid, "database" oid, "transaction" xid, pid integer, "mode" text, granted boolean);
pg_rules | SELECT n.nspname AS schemaname, c.relname AS tablename, r.rulename, pg_get_ruledef(r.oid) AS definition FROM ((pg_rewrite r JOIN pg_class c ON ((c.oid = r.ev_class))) LEFT JOIN pg_namespace n ON ((n.oid = c.relnamespace))) WHERE (r.rulename <> '_RETURN'::name);
pg_settings | SELECT a.name, a.setting, a.category, a.short_desc, a.extra_desc, a.context, a.vartype, a.source, a.min_val, a.max_val FROM pg_show_all_settings() a(name text, setting text, category text, short_desc text, extra_desc text, context text, vartype text, source text, min_val text, max_val text);
@@ -1297,7 +1297,7 @@ SELECT viewname, definition FROM pg_views WHERE schemaname <> 'information_schem
pg_statio_user_sequences | SELECT pg_statio_all_sequences.relid, pg_statio_all_sequences.schemaname, pg_statio_all_sequences.relname, pg_statio_all_sequences.blks_read, pg_statio_all_sequences.blks_hit FROM pg_statio_all_sequences WHERE (((pg_statio_all_sequences.schemaname <> 'pg_catalog'::name) AND (pg_statio_all_sequences.schemaname <> 'pg_toast'::name)) AND (pg_statio_all_sequences.schemaname <> 'information_schema'::name));
pg_statio_user_tables | SELECT pg_statio_all_tables.relid, pg_statio_all_tables.schemaname, pg_statio_all_tables.relname, pg_statio_all_tables.heap_blks_read, pg_statio_all_tables.heap_blks_hit, pg_statio_all_tables.idx_blks_read, pg_statio_all_tables.idx_blks_hit, pg_statio_all_tables.toast_blks_read, pg_statio_all_tables.toast_blks_hit, pg_statio_all_tables.tidx_blks_read, pg_statio_all_tables.tidx_blks_hit FROM pg_statio_all_tables WHERE (((pg_statio_all_tables.schemaname <> 'pg_catalog'::name) AND (pg_statio_all_tables.schemaname <> 'pg_toast'::name)) AND (pg_statio_all_tables.schemaname <> 'information_schema'::name));
pg_stats | SELECT nspname AS schemaname, relname AS tablename, attname, stanullfrac AS null_frac, stawidth AS avg_width, stadistinct AS n_distinct, CASE 1 WHEN stakind1 THEN stavalues1 WHEN stakind2 THEN stavalues2 WHEN stakind3 THEN stavalues3 WHEN stakind4 THEN stavalues4 ELSE NULL::"unknown" END AS most_common_vals, CASE 1 WHEN stakind1 THEN stanumbers1 WHEN stakind2 THEN stanumbers2 WHEN stakind3 THEN stanumbers3 WHEN stakind4 THEN stanumbers4 ELSE NULL::real[] END AS most_common_freqs, CASE 2 WHEN stakind1 THEN stavalues1 WHEN stakind2 THEN stavalues2 WHEN stakind3 THEN stavalues3 WHEN stakind4 THEN stavalues4 ELSE NULL::"unknown" END AS histogram_bounds, CASE 3 WHEN stakind1 THEN stanumbers1[1] WHEN stakind2 THEN stanumbers2[1] WHEN stakind3 THEN stanumbers3[1] WHEN stakind4 THEN stanumbers4[1] ELSE NULL::real END AS correlation FROM (((pg_statistic s JOIN pg_class c ON ((c.oid = s.starelid))) JOIN pg_attribute a ON (((c.oid = a.attrelid) AND (a.attnum = s.staattnum)))) LEFT JOIN pg_namespace n ON ((n.oid = c.relnamespace))) WHERE has_table_privilege(c.oid, 'select'::text);
- pg_tables | SELECT n.nspname AS schemaname, c.relname AS tablename, pg_get_userbyid(c.relowner) AS tableowner, c.relhasindex AS hasindexes, c.relhasrules AS hasrules, (c.reltriggers > 0) AS hastriggers FROM (pg_class c LEFT JOIN pg_namespace n ON ((n.oid = c.relnamespace))) WHERE (c.relkind = 'r'::"char");
+ pg_tables | SELECT n.nspname AS schemaname, c.relname AS tablename, t.spcname AS "tablespace", pg_get_userbyid(c.relowner) AS tableowner, c.relhasindex AS hasindexes, c.relhasrules AS hasrules, (c.reltriggers > 0) AS hastriggers FROM ((pg_class c LEFT JOIN pg_namespace n ON ((n.oid = c.relnamespace))) LEFT JOIN pg_tablespace t ON ((t.oid = c.reltablespace))) WHERE (c.relkind = 'r'::"char");
pg_user | SELECT pg_shadow.usename, pg_shadow.usesysid, pg_shadow.usecreatedb, pg_shadow.usesuper, pg_shadow.usecatupd, '********'::text AS passwd, pg_shadow.valuntil, pg_shadow.useconfig FROM pg_shadow;
pg_views | SELECT n.nspname AS schemaname, c.relname AS viewname, pg_get_userbyid(c.relowner) AS viewowner, pg_get_viewdef(c.oid) AS definition FROM (pg_class c LEFT JOIN pg_namespace n ON ((n.oid = c.relnamespace))) WHERE (c.relkind = 'v'::"char");
rtest_v1 | SELECT rtest_t1.a, rtest_t1.b FROM rtest_t1;