mirror of
https://github.com/postgres/postgres.git
synced 2025-06-11 20:28:21 +03:00
Fix up several contrib modules that were using varlena datatypes in not-so-obvious
ways. I'm not totally sure that I caught everything, but at least now they pass their regression tests with VARSIZE/SET_VARSIZE defined to reverse byte order.
This commit is contained in:
@ -147,7 +147,7 @@ g_intbig_compress(PG_FUNCTION_ARGS)
|
||||
ArrayType *in = (ArrayType *) PG_DETOAST_DATUM(entry->key);
|
||||
int4 *ptr;
|
||||
int num;
|
||||
GISTTYPE *res = (GISTTYPE *) palloc(CALCGTSIZE(0));
|
||||
GISTTYPE *res = (GISTTYPE *) palloc0(CALCGTSIZE(0));
|
||||
|
||||
CHECKARRVALID(in);
|
||||
if (ARRISVOID(in))
|
||||
@ -160,8 +160,7 @@ g_intbig_compress(PG_FUNCTION_ARGS)
|
||||
ptr = ARRPTR(in);
|
||||
num = ARRNELEMS(in);
|
||||
}
|
||||
memset(res, 0, CALCGTSIZE(0));
|
||||
res->len = CALCGTSIZE(0);
|
||||
SET_VARSIZE(res, CALCGTSIZE(0));
|
||||
|
||||
while (num--)
|
||||
{
|
||||
@ -192,7 +191,7 @@ g_intbig_compress(PG_FUNCTION_ARGS)
|
||||
);
|
||||
|
||||
res = (GISTTYPE *) palloc(CALCGTSIZE(ALLISTRUE));
|
||||
res->len = CALCGTSIZE(ALLISTRUE);
|
||||
SET_VARSIZE(res, CALCGTSIZE(ALLISTRUE));
|
||||
res->flag = ALLISTRUE;
|
||||
|
||||
retval = (GISTENTRY *) palloc(sizeof(GISTENTRY));
|
||||
@ -292,10 +291,11 @@ g_intbig_union(PG_FUNCTION_ARGS)
|
||||
|
||||
len = CALCGTSIZE(flag);
|
||||
result = (GISTTYPE *) palloc(len);
|
||||
*size = result->len = len;
|
||||
SET_VARSIZE(result, len);
|
||||
result->flag = flag;
|
||||
if (!ISALLTRUE(result))
|
||||
memcpy((void *) GETSIGN(result), (void *) base, sizeof(BITVEC));
|
||||
*size = len;
|
||||
|
||||
PG_RETURN_POINTER(result);
|
||||
}
|
||||
@ -389,26 +389,26 @@ g_intbig_picksplit(PG_FUNCTION_ARGS)
|
||||
if (ISALLTRUE(GETENTRY(entryvec, seed_1)))
|
||||
{
|
||||
datum_l = (GISTTYPE *) palloc(GTHDRSIZE);
|
||||
datum_l->len = GTHDRSIZE;
|
||||
SET_VARSIZE(datum_l, GTHDRSIZE);
|
||||
datum_l->flag = ALLISTRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
datum_l = (GISTTYPE *) palloc(GTHDRSIZE + SIGLEN);
|
||||
datum_l->len = GTHDRSIZE + SIGLEN;
|
||||
SET_VARSIZE(datum_l, GTHDRSIZE + SIGLEN);
|
||||
datum_l->flag = 0;
|
||||
memcpy((void *) GETSIGN(datum_l), (void *) GETSIGN(GETENTRY(entryvec, seed_1)), sizeof(BITVEC));
|
||||
}
|
||||
if (ISALLTRUE(GETENTRY(entryvec, seed_2)))
|
||||
{
|
||||
datum_r = (GISTTYPE *) palloc(GTHDRSIZE);
|
||||
datum_r->len = GTHDRSIZE;
|
||||
SET_VARSIZE(datum_r, GTHDRSIZE);
|
||||
datum_r->flag = ALLISTRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
datum_r = (GISTTYPE *) palloc(GTHDRSIZE + SIGLEN);
|
||||
datum_r->len = GTHDRSIZE + SIGLEN;
|
||||
SET_VARSIZE(datum_r, GTHDRSIZE + SIGLEN);
|
||||
datum_r->flag = 0;
|
||||
memcpy((void *) GETSIGN(datum_r), (void *) GETSIGN(GETENTRY(entryvec, seed_2)), sizeof(BITVEC));
|
||||
}
|
||||
|
Reference in New Issue
Block a user