aboutsummaryrefslogtreecommitdiff
path: root/src/backend/tcop
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/tcop
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/tcop')
-rw-r--r--src/backend/tcop/fastpath.c30
-rw-r--r--src/backend/tcop/utility.c10
2 files changed, 20 insertions, 20 deletions
diff --git a/src/backend/tcop/fastpath.c b/src/backend/tcop/fastpath.c
index 05640b5be8f..c888ea012ac 100644
--- a/src/backend/tcop/fastpath.c
+++ b/src/backend/tcop/fastpath.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/tcop/fastpath.c,v 1.44 2000/10/24 20:59:35 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/tcop/fastpath.c,v 1.45 2000/11/16 22:30:30 tgl Exp $
*
* NOTES
* This cruft is the server side of PQfn.
@@ -202,14 +202,12 @@ update_fp_info(Oid func_id, struct fp_info * fip)
MemSet((char *) fip, 0, (int) sizeof(struct fp_info));
fip->funcid = InvalidOid;
- func_htp = SearchSysCacheTuple(PROCOID,
- ObjectIdGetDatum(func_id),
- 0, 0, 0);
+ func_htp = SearchSysCache(PROCOID,
+ ObjectIdGetDatum(func_id),
+ 0, 0, 0);
if (!HeapTupleIsValid(func_htp))
- {
elog(ERROR, "update_fp_info: cache lookup for function %u failed",
func_id);
- }
pp = (Form_pg_proc) GETSTRUCT(func_htp);
rettype = pp->prorettype;
argtypes = pp->proargtypes;
@@ -220,38 +218,38 @@ update_fp_info(Oid func_id, struct fp_info * fip)
{
if (OidIsValid(argtypes[i]))
{
- type_htp = SearchSysCacheTuple(TYPEOID,
- ObjectIdGetDatum(argtypes[i]),
- 0, 0, 0);
+ type_htp = SearchSysCache(TYPEOID,
+ ObjectIdGetDatum(argtypes[i]),
+ 0, 0, 0);
if (!HeapTupleIsValid(type_htp))
- {
elog(ERROR, "update_fp_info: bad argument type %u for %u",
argtypes[i], func_id);
- }
tp = (Form_pg_type) GETSTRUCT(type_htp);
fip->argbyval[i] = tp->typbyval;
fip->arglen[i] = tp->typlen;
+ ReleaseSysCache(type_htp);
} /* else it had better be VAR_LENGTH_ARG */
}
if (OidIsValid(rettype))
{
- type_htp = SearchSysCacheTuple(TYPEOID,
- ObjectIdGetDatum(rettype),
- 0, 0, 0);
+ type_htp = SearchSysCache(TYPEOID,
+ ObjectIdGetDatum(rettype),
+ 0, 0, 0);
if (!HeapTupleIsValid(type_htp))
- {
elog(ERROR, "update_fp_info: bad return type %u for %u",
rettype, func_id);
- }
tp = (Form_pg_type) GETSTRUCT(type_htp);
fip->retbyval = tp->typbyval;
fip->retlen = tp->typlen;
+ ReleaseSysCache(type_htp);
} /* else it had better by VAR_LENGTH_RESULT */
fip->xid = GetCurrentTransactionId();
fip->cid = GetCurrentCommandId();
+ ReleaseSysCache(func_htp);
+
/*
* This must be last!
*/
diff --git a/src/backend/tcop/utility.c b/src/backend/tcop/utility.c
index 63a43315286..e725ff391f4 100644
--- a/src/backend/tcop/utility.c
+++ b/src/backend/tcop/utility.c
@@ -10,7 +10,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.102 2000/11/14 18:37:43 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.103 2000/11/16 22:30:30 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -102,9 +102,9 @@ CheckDropPermissions(char *name, char rightkind)
break;
Assert(rentry->kind != '\0');
- tuple = SearchSysCacheTuple(RELNAME,
- PointerGetDatum(name),
- 0, 0, 0);
+ tuple = SearchSysCache(RELNAME,
+ PointerGetDatum(name),
+ 0, 0, 0);
if (!HeapTupleIsValid(tuple))
elog(ERROR, "%s \"%s\" does not exist", rentry->name, name);
@@ -120,6 +120,8 @@ CheckDropPermissions(char *name, char rightkind)
if (!allowSystemTableMods && IsSystemRelationName(name))
elog(ERROR, "%s \"%s\" is a system %s",
rentry->name, name, rentry->name);
+
+ ReleaseSysCache(tuple);
}