summaryrefslogtreecommitdiff
path: root/contrib/tsearch/gistidx.c
diff options
context:
space:
mode:
authorTeodor Sigaev2004-03-30 15:45:33 +0000
committerTeodor Sigaev2004-03-30 15:45:33 +0000
commitf2c064afcbfad4999d7e9ccb644a8aa99463a1ac (patch)
treea630e42b10478f1d88b637a96114945016faa2e0 /contrib/tsearch/gistidx.c
parent8d9a28eeefc477638cca58d0685635271eae49d6 (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/tsearch/gistidx.c')
-rw-r--r--contrib/tsearch/gistidx.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/contrib/tsearch/gistidx.c b/contrib/tsearch/gistidx.c
index 9fe40fb087..5b00960e1c 100644
--- a/contrib/tsearch/gistidx.c
+++ b/contrib/tsearch/gistidx.c
@@ -42,7 +42,7 @@ Datum gtxtidx_penalty(PG_FUNCTION_ARGS);
PG_FUNCTION_INFO_V1(gtxtidx_picksplit);
Datum gtxtidx_picksplit(PG_FUNCTION_ARGS);
-#define GETENTRY(vec,pos) ((GISTTYPE *) DatumGetPointer(((GISTENTRY *) VARDATA(vec))[(pos)].key))
+#define GETENTRY(vec,pos) ((GISTTYPE *) DatumGetPointer((vec)->vector[(pos)].key))
#define SUMBIT(val) ( \
GETBITBYTE(val,0) + \
GETBITBYTE(val,1) + \
@@ -326,16 +326,15 @@ unionkey(BITVECP sbase, GISTTYPE * add)
Datum
gtxtidx_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)))
{
@@ -513,7 +512,7 @@ comparecost(const void *a, const void *b)
Datum
gtxtidx_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;
@@ -544,7 +543,7 @@ gtxtidx_picksplit(PG_FUNCTION_ARGS)
char valtmp;
SPLITCOST *costvector;
- 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);