Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9319fd8

Browse files
committed
Modify vacuum() to accept a single relation OID instead of a list (which we
always pass as a single element anyway.) In passing, fix an outdated comment.
1 parentf23b791 commit9319fd8

File tree

4 files changed

+27
-34
lines changed

4 files changed

+27
-34
lines changed

‎src/backend/commands/vacuum.c

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
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-
staticList*get_rel_oids(List*relids,constRangeVar*vacrel,
213+
staticList*get_rel_oids(Oidrelid,constRangeVar*vacrel,
214214
constchar*stmttype);
215215
staticvoidvac_truncate_clog(TransactionIdfrozenXID);
216216
staticvoidvacuum_rel(Oidrelid,VacuumStmt*vacstmt,charexpected_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 OIDsto be processed, and vacstmt->relation is ignored.
269-
*(The non-NILcase is currently only used by autovacuum.)
267+
*relid is normallyInvalidOid; if it is not, then it provides therelation
268+
*OIDto 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
*/
283283
void
284-
vacuum(VacuumStmt*vacstmt,List*relids,
284+
vacuum(VacuumStmt*vacstmt,Oidrelid,
285285
BufferAccessStrategybstrategy,boolfor_wraparound,boolisTopLevel)
286286
{
287287
constchar*stmttype=vacstmt->vacuum ?"VACUUM" :"ANALYZE";
@@ -351,13 +351,13 @@ vacuum(VacuumStmt *vacstmt, List *relids,
351351
vac_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
*/
533533
staticList*
534-
get_rel_oids(List*relids,constRangeVar*vacrel,constchar*stmttype)
534+
get_rel_oids(Oidrelid,constRangeVar*vacrel,constchar*stmttype)
535535
{
536536
List*oid_list=NIL;
537537
MemoryContextoldcontext;
538538

539-
/* List supplied by VACUUM's caller? */
540-
if (relids)
541-
returnrelids;
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+
elseif (vacrel)
544547
{
545548
/* Process a specific relation */
546549
Oidrelid;

‎src/backend/postmaster/autovacuum.c

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
*
5656
*
5757
* IDENTIFICATION
58-
* $PostgreSQL: pgsql/src/backend/postmaster/autovacuum.c,v 1.78 2008/05/15 00:17:40 tgl Exp $
58+
* $PostgreSQL: pgsql/src/backend/postmaster/autovacuum.c,v 1.79 2008/06/05 15:47:32 alvherre Exp $
5959
*
6060
*-------------------------------------------------------------------------
6161
*/
@@ -1244,8 +1244,7 @@ do_start_worker(void)
12441244
* left to do_start_worker.
12451245
*
12461246
* This routine is also expected to insert an entry into the database list if
1247-
* the selected database was previously absent from the list. It returns the
1248-
* new database list.
1247+
* the selected database was previously absent from the list.
12491248
*/
12501249
staticvoid
12511250
launch_worker(TimestampTznow)
@@ -2601,8 +2600,6 @@ autovacuum_do_vac_analyze(Oid relid, bool dovacuum, bool doanalyze,
26012600
BufferAccessStrategybstrategy)
26022601
{
26032602
VacuumStmtvacstmt;
2604-
List*relids;
2605-
MemoryContextold_cxt;
26062603

26072604
/* Set up command parameters --- use a local variable instead of palloc */
26082605
MemSet(&vacstmt,0,sizeof(vacstmt));
@@ -2613,21 +2610,13 @@ autovacuum_do_vac_analyze(Oid relid, bool dovacuum, bool doanalyze,
26132610
vacstmt.analyze=doanalyze;
26142611
vacstmt.freeze_min_age=freeze_min_age;
26152612
vacstmt.verbose= false;
2616-
vacstmt.relation=NULL;/* not used since we pass arelids list */
2613+
vacstmt.relation=NULL;/* not used since we pass arelid */
26172614
vacstmt.va_cols=NIL;
26182615

2619-
/*
2620-
* The list must survive transaction boundaries, so make sure we create it
2621-
* in a long-lived context
2622-
*/
2623-
old_cxt=MemoryContextSwitchTo(AutovacMemCxt);
2624-
relids=list_make1_oid(relid);
2625-
MemoryContextSwitchTo(old_cxt);
2626-
26272616
/* Let pgstat know what we're doing */
26282617
autovac_report_activity(&vacstmt,relid);
26292618

2630-
vacuum(&vacstmt,relids,bstrategy,for_wraparound, true);
2619+
vacuum(&vacstmt,relid,bstrategy,for_wraparound, true);
26312620
}
26322621

26332622
/*

‎src/backend/tcop/utility.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/backend/tcop/utility.c,v 1.291 2008/03/19 18:38:30 tgl Exp $
13+
* $PostgreSQL: pgsql/src/backend/tcop/utility.c,v 1.292 2008/06/05 15:47:32 alvherre Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -1032,7 +1032,8 @@ ProcessUtility(Node *parsetree,
10321032
break;
10331033

10341034
caseT_VacuumStmt:
1035-
vacuum((VacuumStmt*)parsetree,NIL,NULL, false,isTopLevel);
1035+
vacuum((VacuumStmt*)parsetree,InvalidOid,NULL, false,
1036+
isTopLevel);
10361037
break;
10371038

10381039
caseT_ExplainStmt:

‎src/include/commands/vacuum.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/include/commands/vacuum.h,v 1.76 2008/03/14 17:25:59 alvherre Exp $
10+
* $PostgreSQL: pgsql/src/include/commands/vacuum.h,v 1.77 2008/06/05 15:47:32 alvherre Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -113,7 +113,7 @@ extern intvacuum_freeze_min_age;
113113

114114

115115
/* in commands/vacuum.c */
116-
externvoidvacuum(VacuumStmt*vacstmt,List*relids,
116+
externvoidvacuum(VacuumStmt*vacstmt,Oidrelid,
117117
BufferAccessStrategybstrategy,boolfor_wraparound,boolisTopLevel);
118118
externvoidvac_open_indexes(Relationrelation,LOCKMODElockmode,
119119
int*nindexes,Relation**Irel);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp