diff options
| author | Teodor Sigaev | 2004-03-30 15:45:33 +0000 |
|---|---|---|
| committer | Teodor Sigaev | 2004-03-30 15:45:33 +0000 |
| commit | 3f58637ed75db9fb5ca126332b82b051014b754b (patch) | |
| tree | c54d6e0a57a7fec660b9b55b70263303633cdd01 /contrib/intarray/_intbig_gist.c | |
| parent | 591e968f759f7cb720219b57a30d2b4f8fac5c24 (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/intarray/_intbig_gist.c')
| -rw-r--r-- | contrib/intarray/_intbig_gist.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/contrib/intarray/_intbig_gist.c b/contrib/intarray/_intbig_gist.c index e4588a0d4b..04d26d90f9 100644 --- a/contrib/intarray/_intbig_gist.c +++ b/contrib/intarray/_intbig_gist.c @@ -1,6 +1,6 @@ #include "_int.h" -#define GETENTRY(vec,pos) ((GISTTYPE *) DatumGetPointer(((GISTENTRY *) VARDATA(vec))[(pos)].key)) +#define GETENTRY(vec,pos) ((GISTTYPE *) DatumGetPointer((vec)->vector[(pos)].key)) /* ** _intbig methods */ @@ -231,16 +231,15 @@ unionkey(BITVECP sbase, GISTTYPE * add) Datum g_intbig_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); BITVEC base; - int4 len = (VARSIZE(entryvec) - VARHDRSZ) / sizeof(GISTENTRY); - int4 i; + int4 i, len; int4 flag = 0; GISTTYPE *result; MemSet((void *) base, 0, sizeof(BITVEC)); - for (i = 0; i < len; i++) { + for (i = 0; i < entryvec->n; i++) { if (unionkey(base, GETENTRY(entryvec, i))) { flag = ALLISTRUE; break; @@ -283,7 +282,7 @@ comparecost(const void *a, const void *b) { Datum g_intbig_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; @@ -306,7 +305,7 @@ g_intbig_picksplit(PG_FUNCTION_ARGS) { GISTTYPE *_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); |
