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/executor/spi.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/executor/spi.c')
-rw-r--r-- | src/backend/executor/spi.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/backend/executor/spi.c b/src/backend/executor/spi.c index 07a05561a64..74a5dc44415 100644 --- a/src/backend/executor/spi.c +++ b/src/backend/executor/spi.c @@ -3,7 +3,7 @@ * spi.c * Server Programming Interface * - * $Id: spi.c,v 1.48 2000/10/26 21:35:15 tgl Exp $ + * $Id: spi.c,v 1.49 2000/11/16 22:30:22 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -447,6 +447,7 @@ char * SPI_gettype(TupleDesc tupdesc, int fnumber) { HeapTuple typeTuple; + char *result; SPI_result = 0; if (tupdesc->natts < fnumber || fnumber <= 0) @@ -455,9 +456,9 @@ SPI_gettype(TupleDesc tupdesc, int fnumber) return NULL; } - typeTuple = SearchSysCacheTuple(TYPEOID, + typeTuple = SearchSysCache(TYPEOID, ObjectIdGetDatum(tupdesc->attrs[fnumber - 1]->atttypid), - 0, 0, 0); + 0, 0, 0); if (!HeapTupleIsValid(typeTuple)) { @@ -465,7 +466,9 @@ SPI_gettype(TupleDesc tupdesc, int fnumber) return NULL; } - return pstrdup(NameStr(((Form_pg_type) GETSTRUCT(typeTuple))->typname)); + result = pstrdup(NameStr(((Form_pg_type) GETSTRUCT(typeTuple))->typname)); + ReleaseSysCache(typeTuple); + return result; } Oid |