From a933ee38bbb8dffbc48a3363a94ff6f2a9f7964d Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Thu, 16 Nov 2000 22:30:52 +0000 Subject: 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. --- src/backend/optimizer/plan/createplan.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'src/backend/optimizer/plan/createplan.c') 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; -- cgit v1.2.3