diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2000-11-16 22:30:52 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2000-11-16 22:30:52 +0000 |
commit | a933ee38bbb8dffbc48a3363a94ff6f2a9f7964d (patch) | |
tree | 1c32737389b2530e7152dc2287161b36d9001e8c /src/backend/tcop/fastpath.c | |
parent | cff23842a4c68301ddf34559c7af383bb5557054 (diff) | |
download | postgresql-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/fastpath.c')
-rw-r--r-- | src/backend/tcop/fastpath.c | 30 |
1 files changed, 14 insertions, 16 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! */ |