aboutsummaryrefslogtreecommitdiff
path: root/contrib/intarray/_intbig_gist.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2007-02-28 22:44:38 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2007-02-28 22:44:38 +0000
commit9f652d430fbd1e757caaec9fe64d3e94c8693158 (patch)
tree9215d2131d85e73caeb96fe23ba442c17b8d4575 /contrib/intarray/_intbig_gist.c
parentd1ce4f7396aac34233e075d0342ac704593799ce (diff)
downloadpostgresql-9f652d430fbd1e757caaec9fe64d3e94c8693158.tar.gz
postgresql-9f652d430fbd1e757caaec9fe64d3e94c8693158.zip
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.
Diffstat (limited to 'contrib/intarray/_intbig_gist.c')
-rw-r--r--contrib/intarray/_intbig_gist.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/contrib/intarray/_intbig_gist.c b/contrib/intarray/_intbig_gist.c
index cb80d8f6f24..ffbbe71a956 100644
--- a/contrib/intarray/_intbig_gist.c
+++ b/contrib/intarray/_intbig_gist.c
@@ -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));
}