1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-15 03:41:20 +03:00

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.
This commit is contained in:
Tom Lane
2000-11-16 22:30:52 +00:00
parent cff23842a4
commit a933ee38bb
95 changed files with 2672 additions and 2314 deletions

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/fmgr/dfmgr.c,v 1.44 2000/07/05 23:11:40 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/fmgr/dfmgr.c,v 1.45 2000/11/16 22:30:34 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -59,9 +59,9 @@ fmgr_dynamic(Oid functionId)
PGFunction user_fn;
bool isnull;
procedureTuple = SearchSysCacheTuple(PROCOID,
ObjectIdGetDatum(functionId),
0, 0, 0);
procedureTuple = SearchSysCache(PROCOID,
ObjectIdGetDatum(functionId),
0, 0, 0);
if (!HeapTupleIsValid(procedureTuple))
elog(ERROR, "fmgr_dynamic: function %u: cache lookup failed",
functionId);
@@ -88,6 +88,8 @@ fmgr_dynamic(Oid functionId)
pfree(prosrcstring);
pfree(probinstring);
ReleaseSysCache(procedureTuple);
return user_fn;
}

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/fmgr/fmgr.c,v 1.46 2000/08/24 03:29:07 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/fmgr/fmgr.c,v 1.47 2000/11/16 22:30:34 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -134,9 +134,9 @@ fmgr_info(Oid functionId, FmgrInfo *finfo)
}
/* Otherwise we need the pg_proc entry */
procedureTuple = SearchSysCacheTuple(PROCOID,
ObjectIdGetDatum(functionId),
0, 0, 0);
procedureTuple = SearchSysCache(PROCOID,
ObjectIdGetDatum(functionId),
0, 0, 0);
if (!HeapTupleIsValid(procedureTuple))
elog(ERROR, "fmgr_info: function %u: cache lookup failed",
functionId);
@@ -149,6 +149,7 @@ fmgr_info(Oid functionId, FmgrInfo *finfo)
if (!procedureStruct->proistrusted)
{
finfo->fn_addr = fmgr_untrusted;
ReleaseSysCache(procedureTuple);
return;
}
@@ -202,14 +203,12 @@ fmgr_info(Oid functionId, FmgrInfo *finfo)
/*
* Might be a created procedural language; try to look it up.
*/
languageTuple = SearchSysCacheTuple(LANGOID,
ObjectIdGetDatum(language),
0, 0, 0);
languageTuple = SearchSysCache(LANGOID,
ObjectIdGetDatum(language),
0, 0, 0);
if (!HeapTupleIsValid(languageTuple))
{
elog(ERROR, "fmgr_info: cache lookup for language %u failed",
language);
}
languageStruct = (Form_pg_language) GETSTRUCT(languageTuple);
if (languageStruct->lanispl)
{
@@ -231,8 +230,11 @@ fmgr_info(Oid functionId, FmgrInfo *finfo)
elog(ERROR, "fmgr_info: function %u: unsupported language %u",
functionId, language);
}
ReleaseSysCache(languageTuple);
break;
}
ReleaseSysCache(procedureTuple);
}