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/optimizer/plan/createplan.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/optimizer/plan/createplan.c')
-rw-r--r-- | src/backend/optimizer/plan/createplan.c | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/src/backend/optimizer/plan/createplan.c b/src/backend/optimizer/plan/createplan.c index 4069ed66e58..bfb97bc1eb5 100644 --- a/src/backend/optimizer/plan/createplan.c +++ b/src/backend/optimizer/plan/createplan.c @@ -10,7 +10,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/createplan.c,v 1.100 2000/11/12 00:36:58 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/createplan.c,v 1.101 2000/11/16 22:30:24 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -396,17 +396,19 @@ create_indexscan_plan(Query *root, HeapTuple indexTuple; Form_pg_index index; - indexTuple = SearchSysCacheTuple(INDEXRELID, - ObjectIdGetDatum(lfirsti(ixid)), - 0, 0, 0); + indexTuple = SearchSysCache(INDEXRELID, + ObjectIdGetDatum(lfirsti(ixid)), + 0, 0, 0); if (!HeapTupleIsValid(indexTuple)) elog(ERROR, "create_plan: index %u not found", lfirsti(ixid)); index = (Form_pg_index) GETSTRUCT(indexTuple); if (index->indislossy) { lossy = true; + ReleaseSysCache(indexTuple); break; } + ReleaseSysCache(indexTuple); } /* @@ -904,18 +906,19 @@ fix_indxqual_references(List *indexquals, IndexPath *index_path) Form_pg_index index; /* Get the relam from the index's pg_class entry */ - indexTuple = SearchSysCacheTuple(RELOID, - ObjectIdGetDatum(indexid), - 0, 0, 0); + indexTuple = SearchSysCache(RELOID, + ObjectIdGetDatum(indexid), + 0, 0, 0); if (!HeapTupleIsValid(indexTuple)) elog(ERROR, "fix_indxqual_references: index %u not found in pg_class", indexid); relam = ((Form_pg_class) GETSTRUCT(indexTuple))->relam; + ReleaseSysCache(indexTuple); /* Need the index's pg_index entry for other stuff */ - indexTuple = SearchSysCacheTuple(INDEXRELID, - ObjectIdGetDatum(indexid), - 0, 0, 0); + indexTuple = SearchSysCache(INDEXRELID, + ObjectIdGetDatum(indexid), + 0, 0, 0); if (!HeapTupleIsValid(indexTuple)) elog(ERROR, "fix_indxqual_references: index %u not found in pg_index", indexid); @@ -927,6 +930,8 @@ fix_indxqual_references(List *indexquals, IndexPath *index_path) relam, index)); + ReleaseSysCache(indexTuple); + indexids = lnext(indexids); } return fixed_quals; |