diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2000-12-27 23:59:14 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2000-12-27 23:59:14 +0000 |
commit | 8609d4abf248f0eede4ed9505226da3f7e3e7c84 (patch) | |
tree | 39e5a813099835056d76dd385478069d01a8dcbf /contrib/array/array_iterator.c | |
parent | 97799fc4757fd2699e0238254875994253659582 (diff) | |
download | postgresql-8609d4abf248f0eede4ed9505226da3f7e3e7c84.tar.gz postgresql-8609d4abf248f0eede4ed9505226da3f7e3e7c84.zip |
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.
Diffstat (limited to 'contrib/array/array_iterator.c')
-rw-r--r-- | contrib/array/array_iterator.c | 39 |
1 files changed, 10 insertions, 29 deletions
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 <sys/types.h> #include <string.h> +#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) |