From 8609d4abf248f0eede4ed9505226da3f7e3e7c84 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Wed, 27 Dec 2000 23:59:14 +0000 Subject: Fix portability problems recently exposed by regression tests on Alphas. 1. Distinguish cases where a Datum representing a tuple datatype is an OID from cases where it is a pointer to TupleTableSlot, and make sure we use the right typlen in each case. 2. Make fetchatt() and related code support 8-byte by-value datatypes on machines where Datum is 8 bytes. Centralize knowledge of the available by-value datatype sizes in two macros in tupmacs.h, so that this will be easier if we ever have to do it again. --- contrib/array/array_iterator.c | 39 ++++++++++----------------------------- 1 file changed, 10 insertions(+), 29 deletions(-) (limited to 'contrib/array/array_iterator.c') diff --git a/contrib/array/array_iterator.c b/contrib/array/array_iterator.c index 653979ada86..3622cf98195 100644 --- a/contrib/array/array_iterator.c +++ b/contrib/array/array_iterator.c @@ -21,6 +21,7 @@ #include #include +#include "access/tupmacs.h" #include "access/xact.h" #include "fmgr.h" #include "miscadmin.h" @@ -80,37 +81,17 @@ array_iterator(Oid elemtype, Oid proc, int and, ArrayType *array, Datum value) p = ARR_DATA_PTR(array); for (i = 0; i < nitems; i++) { - if (typbyval) - { - switch (typlen) - { - case 1: - result = FunctionCall2(&finfo, - CharGetDatum(*p), - value); - break; - case 2: - result = FunctionCall2(&finfo, - Int16GetDatum(*(int16 *) p), - value); - break; - case 3: - case 4: - result = FunctionCall2(&finfo, - Int32GetDatum(*(int32 *) p), - value); - break; - } + Datum itemvalue; + + itemvalue = fetch_att(p, typbyval, typlen); + + if (typlen > 0) p += typlen; - } else - { - result = FunctionCall2(&finfo, PointerGetDatum(p), value); - if (typlen > 0) - p += typlen; - else - p += INTALIGN(*(int32 *) p); - } + p += INTALIGN(*(int32 *) p); + + result = FunctionCall2(&finfo, itemvalue, value); + if (DatumGetBool(result)) { if (!and) -- cgit v1.2.3