From 9f652d430fbd1e757caaec9fe64d3e94c8693158 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Wed, 28 Feb 2007 22:44:38 +0000 Subject: 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. --- contrib/pg_trgm/trgm_gist.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'contrib/pg_trgm/trgm_gist.c') diff --git a/contrib/pg_trgm/trgm_gist.c b/contrib/pg_trgm/trgm_gist.c index 41a827ae0c..476cb1b976 100644 --- a/contrib/pg_trgm/trgm_gist.c +++ b/contrib/pg_trgm/trgm_gist.c @@ -120,7 +120,7 @@ gtrgm_compress(PG_FUNCTION_ARGS) len = CALCGTSIZE(SIGNKEY | ALLISTRUE, 0); res = (TRGM *) palloc(len); - res->len = len; + SET_VARSIZE(res, len); res->flag = SIGNKEY | ALLISTRUE; retval = (GISTENTRY *) palloc(sizeof(GISTENTRY)); @@ -235,10 +235,11 @@ gtrgm_union(PG_FUNCTION_ARGS) flag |= SIGNKEY; len = CALCGTSIZE(flag, 0); result = (TRGM *) 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); } @@ -486,26 +487,26 @@ gtrgm_picksplit(PG_FUNCTION_ARGS) if (cache[seed_1].allistrue) { datum_l = (TRGM *) palloc(CALCGTSIZE(SIGNKEY | ALLISTRUE, 0)); - datum_l->len = CALCGTSIZE(SIGNKEY | ALLISTRUE, 0); + SET_VARSIZE(datum_l, CALCGTSIZE(SIGNKEY | ALLISTRUE, 0)); datum_l->flag = SIGNKEY | ALLISTRUE; } else { datum_l = (TRGM *) palloc(CALCGTSIZE(SIGNKEY, 0)); - datum_l->len = CALCGTSIZE(SIGNKEY, 0); + SET_VARSIZE(datum_l, CALCGTSIZE(SIGNKEY, 0)); datum_l->flag = SIGNKEY; memcpy((void *) GETSIGN(datum_l), (void *) cache[seed_1].sign, sizeof(BITVEC)); } if (cache[seed_2].allistrue) { datum_r = (TRGM *) palloc(CALCGTSIZE(SIGNKEY | ALLISTRUE, 0)); - datum_r->len = CALCGTSIZE(SIGNKEY | ALLISTRUE, 0); + SET_VARSIZE(datum_r, CALCGTSIZE(SIGNKEY | ALLISTRUE, 0)); datum_r->flag = SIGNKEY | ALLISTRUE; } else { datum_r = (TRGM *) palloc(CALCGTSIZE(SIGNKEY, 0)); - datum_r->len = CALCGTSIZE(SIGNKEY, 0); + SET_VARSIZE(datum_r, CALCGTSIZE(SIGNKEY, 0)); datum_r->flag = SIGNKEY; memcpy((void *) GETSIGN(datum_r), (void *) cache[seed_2].sign, sizeof(BITVEC)); } -- cgit v1.2.1