1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-14 18:42:34 +03:00

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.
This commit is contained in:
Teodor Sigaev
2004-03-30 15:45:33 +00:00
parent 8d9a28eeef
commit f2c064afcb
24 changed files with 185 additions and 195 deletions

View File

@ -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);