mirror of
https://github.com/postgres/postgres.git
synced 2025-06-11 20:28:21 +03:00
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.
This commit is contained in:
@ -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)
|
||||
|
Reference in New Issue
Block a user