From a933ee38bbb8dffbc48a3363a94ff6f2a9f7964d Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Thu, 16 Nov 2000 22:30:52 +0000 Subject: 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. --- contrib/array/array_iterator.c | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) (limited to 'contrib/array/array_iterator.c') 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 #include #include #include -#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); -- cgit v1.2.3