7
7
*
8
8
*
9
9
* IDENTIFICATION
10
- * $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.83 1998/10/07 17:12 :50 momjian Exp $
10
+ * $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.84 1998/10/07 22:31 :50 momjian Exp $
11
11
*
12
12
*-------------------------------------------------------------------------
13
13
*/
@@ -306,26 +306,11 @@ vc_getrels(NameData *VacRelP)
306
306
d = heap_getattr (tuple , Anum_pg_class_relname , tupdesc , & n );
307
307
rname = (char * ) d ;
308
308
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
-
323
309
d = heap_getattr (tuple , Anum_pg_class_relkind , tupdesc , & n );
324
310
325
311
rkind = DatumGetChar (d );
326
312
327
- /* skip system relations */
328
- if (rkind != 'r' )
313
+ if (rkind != RELKIND_RELATION )
329
314
{
330
315
elog (NOTICE , "Vacuum: can not process index and certain system tables" );
331
316
continue ;
@@ -372,8 +357,6 @@ vc_getrels(NameData *VacRelP)
372
357
static void
373
358
vc_vacone (Oid relid , bool analyze , List * va_cols )
374
359
{
375
- Relation rel ;
376
- TupleDesc tupdesc ;
377
360
HeapTuple tuple ,
378
361
typetuple ;
379
362
Relation onerel ;
@@ -389,9 +372,6 @@ vc_vacone(Oid relid, bool analyze, List *va_cols)
389
372
390
373
StartTransactionCommand ();
391
374
392
- rel = heap_openr (RelationRelationName );
393
- tupdesc = RelationGetDescr (rel );
394
-
395
375
/*
396
376
* Race condition -- if the pg_class tuple has gone away since the
397
377
* 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)
401
381
0 , 0 , 0 );
402
382
if (!HeapTupleIsValid (tuple ))
403
383
{
404
- heap_close (rel );
405
384
CommitTransactionCommand ();
406
385
return ;
407
386
}
@@ -573,7 +552,6 @@ vc_vacone(Oid relid, bool analyze, List *va_cols)
573
552
574
553
/* all done with this class */
575
554
heap_close (onerel );
576
- heap_close (rel );
577
555
578
556
/* update statistics in pg_class */
579
557
vc_updstats (vacrelstats -> relid , vacrelstats -> num_pages ,
@@ -1744,6 +1722,7 @@ vc_updstats(Oid relid, int num_pages, int num_tuples, bool hasindex, VRelStats *
1744
1722
sd ;
1745
1723
HeapScanDesc scan ;
1746
1724
HeapTuple rtup ,
1725
+ ctup ,
1747
1726
atup ,
1748
1727
stup ;
1749
1728
Form_pg_class pgcform ;
@@ -1754,18 +1733,19 @@ vc_updstats(Oid relid, int num_pages, int num_tuples, bool hasindex, VRelStats *
1754
1733
/*
1755
1734
* update number of tuples and number of pages in pg_class
1756
1735
*/
1757
- rtup = SearchSysCacheTuple (RELOID ,
1736
+ ctup = SearchSysCacheTupleCopy (RELOID ,
1758
1737
ObjectIdGetDatum (relid ),
1759
1738
0 , 0 , 0 );
1760
- if (!HeapTupleIsValid (rtup ))
1739
+ if (!HeapTupleIsValid (ctup ))
1761
1740
elog (ERROR , "pg_class entry for relid %d vanished during vacuuming" ,
1762
1741
relid );
1763
1742
1764
1743
rd = heap_openr (RelationRelationName );
1765
1744
1766
1745
/* 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
+
1769
1749
/* overwrite the existing statistics in the tuple */
1770
1750
vc_setpagelock (rd , ItemPointerGetBlockNumber (& rtup -> t_ctid ));
1771
1751
pgcform = (Form_pg_class ) GETSTRUCT (rtup );
@@ -2175,7 +2155,7 @@ vc_getindices(Oid relid, int *nindices, Relation **Irel)
2175
2155
k ++ ;
2176
2156
}
2177
2157
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 ]);
2179
2159
}
2180
2160
* nindices = k ;
2181
2161
pfree (ioid );
0 commit comments