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

Commitcb4292e

Browse files
committed
vacuum cleanups
1 parent9549a8c commitcb4292e

File tree

1 file changed

+9
-29
lines changed

1 file changed

+9
-29
lines changed

‎src/backend/commands/vacuum.c

Lines changed: 9 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.83 1998/10/0717:12:50 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.84 1998/10/0722:31:50 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -306,26 +306,11 @@ vc_getrels(NameData *VacRelP)
306306
d=heap_getattr(tuple,Anum_pg_class_relname,tupdesc,&n);
307307
rname= (char*)d;
308308

309-
/*
310-
* don't vacuum large objects for now - something breaks when we
311-
* do
312-
*/
313-
if ((strlen(rname) >=5)&&rname[0]=='x'&&
314-
rname[1]=='i'&&rname[2]=='n'&&
315-
(rname[3]=='v'||rname[3]=='x')&&
316-
rname[4] >='0'&&rname[4] <='9')
317-
{
318-
elog(NOTICE,"Rel %s: can't vacuum LargeObjects now",
319-
rname);
320-
continue;
321-
}
322-
323309
d=heap_getattr(tuple,Anum_pg_class_relkind,tupdesc,&n);
324310

325311
rkind=DatumGetChar(d);
326312

327-
/* skip system relations */
328-
if (rkind!='r')
313+
if (rkind!=RELKIND_RELATION)
329314
{
330315
elog(NOTICE,"Vacuum: can not process index and certain system tables");
331316
continue;
@@ -372,8 +357,6 @@ vc_getrels(NameData *VacRelP)
372357
staticvoid
373358
vc_vacone(Oidrelid,boolanalyze,List*va_cols)
374359
{
375-
Relationrel;
376-
TupleDesctupdesc;
377360
HeapTupletuple,
378361
typetuple;
379362
Relationonerel;
@@ -389,9 +372,6 @@ vc_vacone(Oid relid, bool analyze, List *va_cols)
389372

390373
StartTransactionCommand();
391374

392-
rel=heap_openr(RelationRelationName);
393-
tupdesc=RelationGetDescr(rel);
394-
395375
/*
396376
* Race condition -- if the pg_class tuple has gone away since the
397377
* last time we saw it, we don't need to vacuum it.
@@ -401,7 +381,6 @@ vc_vacone(Oid relid, bool analyze, List *va_cols)
401381
0,0,0);
402382
if (!HeapTupleIsValid(tuple))
403383
{
404-
heap_close(rel);
405384
CommitTransactionCommand();
406385
return;
407386
}
@@ -573,7 +552,6 @@ vc_vacone(Oid relid, bool analyze, List *va_cols)
573552

574553
/* all done with this class */
575554
heap_close(onerel);
576-
heap_close(rel);
577555

578556
/* update statistics in pg_class */
579557
vc_updstats(vacrelstats->relid,vacrelstats->num_pages,
@@ -1744,6 +1722,7 @@ vc_updstats(Oid relid, int num_pages, int num_tuples, bool hasindex, VRelStats *
17441722
sd;
17451723
HeapScanDescscan;
17461724
HeapTuplertup,
1725+
ctup,
17471726
atup,
17481727
stup;
17491728
Form_pg_classpgcform;
@@ -1754,18 +1733,19 @@ vc_updstats(Oid relid, int num_pages, int num_tuples, bool hasindex, VRelStats *
17541733
/*
17551734
* update number of tuples and number of pages in pg_class
17561735
*/
1757-
rtup=SearchSysCacheTuple(RELOID,
1736+
ctup=SearchSysCacheTupleCopy(RELOID,
17581737
ObjectIdGetDatum(relid),
17591738
0,0,0);
1760-
if (!HeapTupleIsValid(rtup))
1739+
if (!HeapTupleIsValid(ctup))
17611740
elog(ERROR,"pg_class entry for relid %d vanished during vacuuming",
17621741
relid);
17631742

17641743
rd=heap_openr(RelationRelationName);
17651744

17661745
/* get the buffer cache tuple */
1767-
rtup=heap_fetch(rd,SnapshotNow,&rtup->t_ctid,&buffer);
1768-
1746+
rtup=heap_fetch(rd,SnapshotNow,&ctup->t_ctid,&buffer);
1747+
pfree(ctup);
1748+
17691749
/* overwrite the existing statistics in the tuple */
17701750
vc_setpagelock(rd,ItemPointerGetBlockNumber(&rtup->t_ctid));
17711751
pgcform= (Form_pg_class)GETSTRUCT(rtup);
@@ -2175,7 +2155,7 @@ vc_getindices(Oid relid, int *nindices, Relation **Irel)
21752155
k++;
21762156
}
21772157
else
2178-
elog(NOTICE,"CAN't OPEN INDEX %u - SKIP IT",ioid[i]);
2158+
elog(NOTICE,"CAN'T OPEN INDEX %u - SKIP IT",ioid[i]);
21792159
}
21802160
*nindices=k;
21812161
pfree(ioid);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp