aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/backend/commands/vacuum.c33
-rw-r--r--src/backend/postmaster/autovacuum.c19
-rw-r--r--src/backend/tcop/utility.c5
-rw-r--r--src/include/commands/vacuum.h4
4 files changed, 27 insertions, 34 deletions
diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c
index f8b8c5b064a..176bd006931 100644
--- a/src/backend/commands/vacuum.c
+++ b/src/backend/commands/vacuum.c
@@ -13,7 +13,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/commands/vacuum.c,v 1.374 2008/05/15 00:17:39 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/vacuum.c,v 1.375 2008/06/05 15:47:32 alvherre Exp $
*
*-------------------------------------------------------------------------
*/
@@ -210,7 +210,7 @@ static BufferAccessStrategy vac_strategy;
/* non-export function prototypes */
-static List *get_rel_oids(List *relids, const RangeVar *vacrel,
+static List *get_rel_oids(Oid relid, const RangeVar *vacrel,
const char *stmttype);
static void vac_truncate_clog(TransactionId frozenXID);
static void vacuum_rel(Oid relid, VacuumStmt *vacstmt, char expected_relkind,
@@ -264,9 +264,9 @@ static Size PageGetFreeSpaceWithFillFactor(Relation relation, Page page);
/*
* Primary entry point for VACUUM and ANALYZE commands.
*
- * relids is normally NIL; if it is not, then it provides the list of
- * relation OIDs to be processed, and vacstmt->relation is ignored.
- * (The non-NIL case is currently only used by autovacuum.)
+ * relid is normally InvalidOid; if it is not, then it provides the relation
+ * OID to be processed, and vacstmt->relation is ignored. (The non-invalid
+ * case is currently only used by autovacuum.)
*
* for_wraparound is used by autovacuum to let us know when it's forcing
* a vacuum for wraparound, which should not be auto-cancelled.
@@ -276,12 +276,12 @@ static Size PageGetFreeSpaceWithFillFactor(Relation relation, Page page);
*
* isTopLevel should be passed down from ProcessUtility.
*
- * It is the caller's responsibility that vacstmt, relids, and bstrategy
+ * It is the caller's responsibility that vacstmt and bstrategy
* (if given) be allocated in a memory context that won't disappear
* at transaction commit.
*/
void
-vacuum(VacuumStmt *vacstmt, List *relids,
+vacuum(VacuumStmt *vacstmt, Oid relid,
BufferAccessStrategy bstrategy, bool for_wraparound, bool isTopLevel)
{
const char *stmttype = vacstmt->vacuum ? "VACUUM" : "ANALYZE";
@@ -351,13 +351,13 @@ vacuum(VacuumStmt *vacstmt, List *relids,
vac_strategy = bstrategy;
/* Remember whether we are processing everything in the DB */
- all_rels = (relids == NIL && vacstmt->relation == NULL);
+ all_rels = (!OidIsValid(relid) && vacstmt->relation == NULL);
/*
* Build list of relations to process, unless caller gave us one. (If we
* build one, we put it in vac_context for safekeeping.)
*/
- relations = get_rel_oids(relids, vacstmt->relation, stmttype);
+ relations = get_rel_oids(relid, vacstmt->relation, stmttype);
/*
* Decide whether we need to start/commit our own transactions.
@@ -531,16 +531,19 @@ vacuum(VacuumStmt *vacstmt, List *relids,
* per-relation transactions.
*/
static List *
-get_rel_oids(List *relids, const RangeVar *vacrel, const char *stmttype)
+get_rel_oids(Oid relid, const RangeVar *vacrel, const char *stmttype)
{
List *oid_list = NIL;
MemoryContext oldcontext;
- /* List supplied by VACUUM's caller? */
- if (relids)
- return relids;
-
- if (vacrel)
+ /* OID supplied by VACUUM's caller? */
+ if (OidIsValid(relid))
+ {
+ oldcontext = MemoryContextSwitchTo(vac_context);
+ oid_list = lappend_oid(oid_list, relid);
+ MemoryContextSwitchTo(oldcontext);
+ }
+ else if (vacrel)
{
/* Process a specific relation */
Oid relid;
diff --git a/src/backend/postmaster/autovacuum.c b/src/backend/postmaster/autovacuum.c
index 5711093d9e9..7ac0bae1c58 100644
--- a/src/backend/postmaster/autovacuum.c
+++ b/src/backend/postmaster/autovacuum.c
@@ -55,7 +55,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/postmaster/autovacuum.c,v 1.78 2008/05/15 00:17:40 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/postmaster/autovacuum.c,v 1.79 2008/06/05 15:47:32 alvherre Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1244,8 +1244,7 @@ do_start_worker(void)
* left to do_start_worker.
*
* This routine is also expected to insert an entry into the database list if
- * the selected database was previously absent from the list. It returns the
- * new database list.
+ * the selected database was previously absent from the list.
*/
static void
launch_worker(TimestampTz now)
@@ -2601,8 +2600,6 @@ autovacuum_do_vac_analyze(Oid relid, bool dovacuum, bool doanalyze,
BufferAccessStrategy bstrategy)
{
VacuumStmt vacstmt;
- List *relids;
- MemoryContext old_cxt;
/* Set up command parameters --- use a local variable instead of palloc */
MemSet(&vacstmt, 0, sizeof(vacstmt));
@@ -2613,21 +2610,13 @@ autovacuum_do_vac_analyze(Oid relid, bool dovacuum, bool doanalyze,
vacstmt.analyze = doanalyze;
vacstmt.freeze_min_age = freeze_min_age;
vacstmt.verbose = false;
- vacstmt.relation = NULL; /* not used since we pass a relids list */
+ vacstmt.relation = NULL; /* not used since we pass a relid */
vacstmt.va_cols = NIL;
- /*
- * The list must survive transaction boundaries, so make sure we create it
- * in a long-lived context
- */
- old_cxt = MemoryContextSwitchTo(AutovacMemCxt);
- relids = list_make1_oid(relid);
- MemoryContextSwitchTo(old_cxt);
-
/* Let pgstat know what we're doing */
autovac_report_activity(&vacstmt, relid);
- vacuum(&vacstmt, relids, bstrategy, for_wraparound, true);
+ vacuum(&vacstmt, relid, bstrategy, for_wraparound, true);
}
/*
diff --git a/src/backend/tcop/utility.c b/src/backend/tcop/utility.c
index df3887b1dc9..1bebfec182b 100644
--- a/src/backend/tcop/utility.c
+++ b/src/backend/tcop/utility.c
@@ -10,7 +10,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/tcop/utility.c,v 1.291 2008/03/19 18:38:30 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/tcop/utility.c,v 1.292 2008/06/05 15:47:32 alvherre Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1032,7 +1032,8 @@ ProcessUtility(Node *parsetree,
break;
case T_VacuumStmt:
- vacuum((VacuumStmt *) parsetree, NIL, NULL, false, isTopLevel);
+ vacuum((VacuumStmt *) parsetree, InvalidOid, NULL, false,
+ isTopLevel);
break;
case T_ExplainStmt:
diff --git a/src/include/commands/vacuum.h b/src/include/commands/vacuum.h
index d5ebec00102..6496fe78687 100644
--- a/src/include/commands/vacuum.h
+++ b/src/include/commands/vacuum.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/commands/vacuum.h,v 1.76 2008/03/14 17:25:59 alvherre Exp $
+ * $PostgreSQL: pgsql/src/include/commands/vacuum.h,v 1.77 2008/06/05 15:47:32 alvherre Exp $
*
*-------------------------------------------------------------------------
*/
@@ -113,7 +113,7 @@ extern int vacuum_freeze_min_age;
/* in commands/vacuum.c */
-extern void vacuum(VacuumStmt *vacstmt, List *relids,
+extern void vacuum(VacuumStmt *vacstmt, Oid relid,
BufferAccessStrategy bstrategy, bool for_wraparound, bool isTopLevel);
extern void vac_open_indexes(Relation relation, LOCKMODE lockmode,
int *nindexes, Relation **Irel);