diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2007-02-28 22:44:38 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2007-02-28 22:44:38 +0000 |
commit | 9f652d430fbd1e757caaec9fe64d3e94c8693158 (patch) | |
tree | 9215d2131d85e73caeb96fe23ba442c17b8d4575 /contrib/pg_trgm/trgm_gist.c | |
parent | d1ce4f7396aac34233e075d0342ac704593799ce (diff) |
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/pg_trgm/trgm_gist.c')
-rw-r--r-- | contrib/pg_trgm/trgm_gist.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/contrib/pg_trgm/trgm_gist.c b/contrib/pg_trgm/trgm_gist.c index 41a827ae0c3..476cb1b9763 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)); } |