diff options
author | Teodor Sigaev | 2004-03-30 15:45:33 +0000 |
---|---|---|
committer | Teodor Sigaev | 2004-03-30 15:45:33 +0000 |
commit | f2c064afcbfad4999d7e9ccb644a8aa99463a1ac (patch) | |
tree | a630e42b10478f1d88b637a96114945016faa2e0 /contrib/ltree/_ltree_gist.c | |
parent | 8d9a28eeefc477638cca58d0685635271eae49d6 (diff) |
Cleanup vectors of GISTENTRY and eliminate problem with 64-bit strict-aligned
boxes. Change interface to user-defined GiST support methods union and
picksplit. Now instead of bytea struct it used special GistEntryVector
structure.
Diffstat (limited to 'contrib/ltree/_ltree_gist.c')
-rw-r--r-- | contrib/ltree/_ltree_gist.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/contrib/ltree/_ltree_gist.c b/contrib/ltree/_ltree_gist.c index 412fafa1ff8..f1b2efb157c 100644 --- a/contrib/ltree/_ltree_gist.c +++ b/contrib/ltree/_ltree_gist.c @@ -29,7 +29,7 @@ Datum _ltree_picksplit(PG_FUNCTION_ARGS); PG_FUNCTION_INFO_V1(_ltree_consistent); Datum _ltree_consistent(PG_FUNCTION_ARGS); -#define GETENTRY(vec,pos) ((ltree_gist *) DatumGetPointer(((GISTENTRY *) VARDATA(vec))[(pos)].key)) +#define GETENTRY(vec,pos) ((ltree_gist *) DatumGetPointer((vec)->vector[(pos)].key)) #define NEXTVAL(x) ( (ltree*)( (char*)(x) + INTALIGN( VARSIZE(x) ) ) ) #define SUMBIT(val) ( \ GETBITBYTE(val,0) + \ @@ -172,16 +172,15 @@ unionkey(BITVECP sbase, ltree_gist * add) Datum _ltree_union(PG_FUNCTION_ARGS) { - bytea *entryvec = (bytea *) PG_GETARG_POINTER(0); + GistEntryVector *entryvec = (GistEntryVector *) PG_GETARG_POINTER(0); int *size = (int *) PG_GETARG_POINTER(1); ABITVEC base; - int4 len = (VARSIZE(entryvec) - VARHDRSZ) / sizeof(GISTENTRY); - int4 i; + int4 i,len; int4 flag = 0; ltree_gist *result; MemSet((void *) base, 0, sizeof(ABITVEC)); - for (i = 0; i < len; i++) + for (i = 0; i < entryvec->n; i++) { if (unionkey(base, GETENTRY(entryvec, i))) { @@ -264,7 +263,7 @@ comparecost(const void *a, const void *b) Datum _ltree_picksplit(PG_FUNCTION_ARGS) { - bytea *entryvec = (bytea *) PG_GETARG_POINTER(0); + GistEntryVector *entryvec = (GistEntryVector *) PG_GETARG_POINTER(0); GIST_SPLITVEC *v = (GIST_SPLITVEC *) PG_GETARG_POINTER(1); OffsetNumber k, j; @@ -287,7 +286,7 @@ _ltree_picksplit(PG_FUNCTION_ARGS) ltree_gist *_k, *_j; - maxoff = ((VARSIZE(entryvec) - VARHDRSZ) / sizeof(GISTENTRY)) - 2; + maxoff = entryvec->n - 2; nbytes = (maxoff + 2) * sizeof(OffsetNumber); v->spl_left = (OffsetNumber *) palloc(nbytes); v->spl_right = (OffsetNumber *) palloc(nbytes); |