aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access/gist
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2000-11-16 22:30:52 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2000-11-16 22:30:52 +0000
commita933ee38bbb8dffbc48a3363a94ff6f2a9f7964d (patch)
tree1c32737389b2530e7152dc2287161b36d9001e8c /src/backend/access/gist
parentcff23842a4c68301ddf34559c7af383bb5557054 (diff)
downloadpostgresql-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/access/gist')
-rw-r--r--src/backend/access/gist/gist.c29
1 files changed, 15 insertions, 14 deletions
diff --git a/src/backend/access/gist/gist.c b/src/backend/access/gist/gist.c
index d7bfeb1287d..d8e9005e933 100644
--- a/src/backend/access/gist/gist.c
+++ b/src/backend/access/gist/gist.c
@@ -6,7 +6,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/gist/gist.c,v 1.64 2000/11/08 22:09:53 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/gist/gist.c,v 1.65 2000/11/16 22:30:15 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1140,6 +1140,7 @@ initGISTstate(GISTSTATE *giststate, Relation index)
equal_proc;
HeapTuple htup;
Form_pg_index itupform;
+ Oid indexrelid;
consistent_proc = index_getprocid(index, 1, GIST_CONSISTENT_PROC);
union_proc = index_getprocid(index, 1, GIST_UNION_PROC);
@@ -1157,32 +1158,32 @@ initGISTstate(GISTSTATE *giststate, Relation index)
fmgr_info(equal_proc, &giststate->equalFn);
/* see if key type is different from type of attribute being indexed */
- htup = SearchSysCacheTuple(INDEXRELID,
- ObjectIdGetDatum(RelationGetRelid(index)),
- 0, 0, 0);
- itupform = (Form_pg_index) GETSTRUCT(htup);
+ htup = SearchSysCache(INDEXRELID,
+ ObjectIdGetDatum(RelationGetRelid(index)),
+ 0, 0, 0);
if (!HeapTupleIsValid(htup))
elog(ERROR, "initGISTstate: index %u not found",
RelationGetRelid(index));
+ itupform = (Form_pg_index) GETSTRUCT(htup);
giststate->haskeytype = itupform->indhaskeytype;
+ indexrelid = itupform->indexrelid;
+ ReleaseSysCache(htup);
+
if (giststate->haskeytype)
{
/* key type is different -- is it byval? */
- htup = SearchSysCacheTuple(ATTNUM,
- ObjectIdGetDatum(itupform->indexrelid),
- UInt16GetDatum(FirstOffsetNumber),
- 0, 0);
+ htup = SearchSysCache(ATTNUM,
+ ObjectIdGetDatum(indexrelid),
+ UInt16GetDatum(FirstOffsetNumber),
+ 0, 0);
if (!HeapTupleIsValid(htup))
- {
elog(ERROR, "initGISTstate: no attribute tuple %u %d",
- itupform->indexrelid, FirstOffsetNumber);
- return;
- }
+ indexrelid, FirstOffsetNumber);
giststate->keytypbyval = (((Form_pg_attribute) htup)->attbyval);
+ ReleaseSysCache(htup);
}
else
giststate->keytypbyval = FALSE;
- return;
}