diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2000-11-16 22:30:52 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2000-11-16 22:30:52 +0000 |
commit | a933ee38bbb8dffbc48a3363a94ff6f2a9f7964d (patch) | |
tree | 1c32737389b2530e7152dc2287161b36d9001e8c /src/backend/commands/vacuum.c | |
parent | cff23842a4c68301ddf34559c7af383bb5557054 (diff) | |
download | postgresql-a933ee38bbb8dffbc48a3363a94ff6f2a9f7964d.tar.gz postgresql-a933ee38bbb8dffbc48a3363a94ff6f2a9f7964d.zip |
Change SearchSysCache coding conventions so that a reference count is
maintained for each cache entry. A cache entry will not be freed until
the matching ReleaseSysCache call has been executed. This eliminates
worries about cache entries getting dropped while still in use. See
my posting to pg-hackers of even date for more info.
Diffstat (limited to 'src/backend/commands/vacuum.c')
-rw-r--r-- | src/backend/commands/vacuum.c | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c index 403d80942de..3aeae1409bd 100644 --- a/src/backend/commands/vacuum.c +++ b/src/backend/commands/vacuum.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.172 2000/11/16 05:50:59 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.173 2000/11/16 22:30:19 tgl Exp $ * *------------------------------------------------------------------------- @@ -356,7 +356,6 @@ getrels(NameData *VacRelP) static void vacuum_rel(Oid relid, bool analyze, bool is_toastrel) { - HeapTuple tuple; Relation onerel; VacPageListData vacuum_pages; /* List of pages to vacuum and/or clean * indices */ @@ -384,10 +383,9 @@ vacuum_rel(Oid relid, bool analyze, bool is_toastrel) * Race condition -- if the pg_class tuple has gone away since the * last time we saw it, we don't need to vacuum it. */ - tuple = SearchSysCacheTuple(RELOID, - ObjectIdGetDatum(relid), - 0, 0, 0); - if (!HeapTupleIsValid(tuple)) + if (!SearchSysCacheExists(RELOID, + ObjectIdGetDatum(relid), + 0, 0, 0)) { if (!is_toastrel) CommitTransactionCommand(); @@ -2237,17 +2235,17 @@ update_relstats(Oid relid, int num_pages, int num_tuples, bool hasindex, */ rd = heap_openr(RelationRelationName, RowExclusiveLock); - ctup = SearchSysCacheTupleCopy(RELOID, - ObjectIdGetDatum(relid), - 0, 0, 0); + ctup = SearchSysCache(RELOID, + ObjectIdGetDatum(relid), + 0, 0, 0); if (!HeapTupleIsValid(ctup)) elog(ERROR, "pg_class entry for relid %u vanished during vacuuming", relid); /* get the buffer cache tuple */ rtup.t_self = ctup->t_self; + ReleaseSysCache(ctup); heap_fetch(rd, SnapshotNow, &rtup, &buffer); - heap_freetuple(ctup); /* overwrite the existing statistics in the tuple */ pgcform = (Form_pg_class) GETSTRUCT(&rtup); @@ -2481,13 +2479,14 @@ get_index_desc(Relation onerel, int nindices, Relation *Irel) for (i = 0; i < nindices; i++) { - cachetuple = SearchSysCacheTuple(INDEXRELID, + cachetuple = SearchSysCache(INDEXRELID, ObjectIdGetDatum(RelationGetRelid(Irel[i])), - 0, 0, 0); + 0, 0, 0); if (!HeapTupleIsValid(cachetuple)) elog(ERROR, "get_index_desc: index %u not found", RelationGetRelid(Irel[i])); indexInfo[i] = BuildIndexInfo(cachetuple); + ReleaseSysCache(cachetuple); } return indexInfo; |