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 /contrib/array/array_iterator.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 'contrib/array/array_iterator.c')
-rw-r--r-- | contrib/array/array_iterator.c | 24 |
1 files changed, 7 insertions, 17 deletions
diff --git a/contrib/array/array_iterator.c b/contrib/array/array_iterator.c index c480f7dfc70..653979ada86 100644 --- a/contrib/array/array_iterator.c +++ b/contrib/array/array_iterator.c @@ -14,30 +14,29 @@ * either version 2, or (at your option) any later version. */ +#include "postgres.h" + #include <ctype.h> #include <stdio.h> #include <sys/types.h> #include <string.h> -#include "postgres.h" -#include "miscadmin.h" #include "access/xact.h" #include "fmgr.h" -#include "catalog/pg_type.h" +#include "miscadmin.h" #include "utils/array.h" #include "utils/builtins.h" #include "utils/memutils.h" -#include "utils/syscache.h" +#include "utils/lsyscache.h" #include "array_iterator.h" + static int32 array_iterator(Oid elemtype, Oid proc, int and, ArrayType *array, Datum value) { - HeapTuple typ_tuple; - Form_pg_type typ_struct; + int16 typlen; bool typbyval; - int typlen; int nitems, i; Datum result; @@ -66,16 +65,7 @@ array_iterator(Oid elemtype, Oid proc, int and, ArrayType *array, Datum value) } /* Lookup element type information */ - typ_tuple = SearchSysCacheTuple(TYPEOID, ObjectIdGetDatum(elemtype), - 0, 0, 0); - if (!HeapTupleIsValid(typ_tuple)) - { - elog(ERROR, "array_iterator: cache lookup failed for type %u", elemtype); - return 0; - } - typ_struct = (Form_pg_type) GETSTRUCT(typ_tuple); - typlen = typ_struct->typlen; - typbyval = typ_struct->typbyval; + get_typlenbyval(elemtype, &typlen, &typbyval); /* Lookup the function entry point */ fmgr_info(proc, &finfo); |