1313 *
1414 *
1515 * IDENTIFICATION
16- * $PostgreSQL: pgsql/src/backend/commands/vacuum.c,v 1.374 2008/05/15 00:17:39 tgl Exp $
16+ * $PostgreSQL: pgsql/src/backend/commands/vacuum.c,v 1.375 2008/06/05 15:47:32 alvherre Exp $
1717 *
1818 *-------------------------------------------------------------------------
1919 */
@@ -210,7 +210,7 @@ static BufferAccessStrategy vac_strategy;
210210
211211
212212/* non-export function prototypes */
213- static List * get_rel_oids (List * relids ,const RangeVar * vacrel ,
213+ static List * get_rel_oids (Oid relid ,const RangeVar * vacrel ,
214214const char * stmttype );
215215static void vac_truncate_clog (TransactionId frozenXID );
216216static void vacuum_rel (Oid relid ,VacuumStmt * vacstmt ,char expected_relkind ,
@@ -264,9 +264,9 @@ static Size PageGetFreeSpaceWithFillFactor(Relation relation, Page page);
264264/*
265265 * Primary entry point for VACUUM and ANALYZE commands.
266266 *
267- *relids is normallyNIL ; if it is not, then it provides thelist of
268- *relation OIDs to be processed, and vacstmt->relation is ignored.
269- *(The non-NIL case is currently only used by autovacuum.)
267+ *relid is normallyInvalidOid ; if it is not, then it provides therelation
268+ *OID to be processed, and vacstmt->relation is ignored. (The non-invalid
269+ * case is currently only used by autovacuum.)
270270 *
271271 * for_wraparound is used by autovacuum to let us know when it's forcing
272272 * a vacuum for wraparound, which should not be auto-cancelled.
@@ -276,12 +276,12 @@ static Size PageGetFreeSpaceWithFillFactor(Relation relation, Page page);
276276 *
277277 * isTopLevel should be passed down from ProcessUtility.
278278 *
279- * It is the caller's responsibility that vacstmt, relids, and bstrategy
279+ * It is the caller's responsibility that vacstmt and bstrategy
280280 * (if given) be allocated in a memory context that won't disappear
281281 * at transaction commit.
282282 */
283283void
284- vacuum (VacuumStmt * vacstmt ,List * relids ,
284+ vacuum (VacuumStmt * vacstmt ,Oid relid ,
285285BufferAccessStrategy bstrategy ,bool for_wraparound ,bool isTopLevel )
286286{
287287const char * stmttype = vacstmt -> vacuum ?"VACUUM" :"ANALYZE" ;
@@ -351,13 +351,13 @@ vacuum(VacuumStmt *vacstmt, List *relids,
351351vac_strategy = bstrategy ;
352352
353353/* Remember whether we are processing everything in the DB */
354- all_rels = (relids == NIL && vacstmt -> relation == NULL );
354+ all_rels = (! OidIsValid ( relid ) && vacstmt -> relation == NULL );
355355
356356/*
357357 * Build list of relations to process, unless caller gave us one. (If we
358358 * build one, we put it in vac_context for safekeeping.)
359359 */
360- relations = get_rel_oids (relids ,vacstmt -> relation ,stmttype );
360+ relations = get_rel_oids (relid ,vacstmt -> relation ,stmttype );
361361
362362/*
363363 * Decide whether we need to start/commit our own transactions.
@@ -531,16 +531,19 @@ vacuum(VacuumStmt *vacstmt, List *relids,
531531 * per-relation transactions.
532532 */
533533static List *
534- get_rel_oids (List * relids ,const RangeVar * vacrel ,const char * stmttype )
534+ get_rel_oids (Oid relid ,const RangeVar * vacrel ,const char * stmttype )
535535{
536536List * oid_list = NIL ;
537537MemoryContext oldcontext ;
538538
539- /* List supplied by VACUUM's caller? */
540- if (relids )
541- return relids ;
542-
543- if (vacrel )
539+ /* OID supplied by VACUUM's caller? */
540+ if (OidIsValid (relid ))
541+ {
542+ oldcontext = MemoryContextSwitchTo (vac_context );
543+ oid_list = lappend_oid (oid_list ,relid );
544+ MemoryContextSwitchTo (oldcontext );
545+ }
546+ else if (vacrel )
544547{
545548/* Process a specific relation */
546549Oid relid ;