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/executor/functions.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'src/backend/executor/functions.c') diff --git a/src/backend/executor/functions.c b/src/backend/executor/functions.c index ca9c48e294d..98b28c61e10 100644 --- a/src/backend/executor/functions.c +++ b/src/backend/executor/functions.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/functions.c,v 1.40 2000/11/12 00:36:57 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/functions.c,v 1.41 2000/11/16 22:30:20 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -183,14 +183,11 @@ init_sql_fcache(FmgrInfo *finfo) /* ---------------- * get the procedure tuple corresponding to the given function Oid - * - * NB: use SearchSysCacheTupleCopy to ensure tuple lives long enough * ---------------- */ - procedureTuple = SearchSysCacheTupleCopy(PROCOID, - ObjectIdGetDatum(foid), - 0, 0, 0); - + procedureTuple = SearchSysCache(PROCOID, + ObjectIdGetDatum(foid), + 0, 0, 0); if (!HeapTupleIsValid(procedureTuple)) elog(ERROR, "init_sql_fcache: Cache lookup failed for procedure %u", foid); @@ -201,10 +198,9 @@ init_sql_fcache(FmgrInfo *finfo) * get the return type from the procedure tuple * ---------------- */ - typeTuple = SearchSysCacheTuple(TYPEOID, - ObjectIdGetDatum(procedureStruct->prorettype), - 0, 0, 0); - + typeTuple = SearchSysCache(TYPEOID, + ObjectIdGetDatum(procedureStruct->prorettype), + 0, 0, 0); if (!HeapTupleIsValid(typeTuple)) elog(ERROR, "init_sql_fcache: Cache lookup failed for type %u", procedureStruct->prorettype); @@ -286,7 +282,8 @@ init_sql_fcache(FmgrInfo *finfo) pfree(src); - heap_freetuple(procedureTuple); + ReleaseSysCache(typeTuple); + ReleaseSysCache(procedureTuple); finfo->fn_extra = (void *) fcache; } -- cgit v1.2.3