diff options
Diffstat (limited to 'src/include/access/gist_private.h')
-rw-r--r-- | src/include/access/gist_private.h | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/src/include/access/gist_private.h b/src/include/access/gist_private.h index fc1a3115565..ed5b643885d 100644 --- a/src/include/access/gist_private.h +++ b/src/include/access/gist_private.h @@ -137,13 +137,30 @@ typedef struct GISTSearchItem /* we must store parentlsn to detect whether a split occurred */ GISTSearchHeapItem heap; /* heap info, if heap tuple */ } data; - double distances[FLEXIBLE_ARRAY_MEMBER]; /* numberOfOrderBys - * entries */ + + /* + * This data structure is followed by arrays of distance values and + * distance null flags. Size of both arrays is + * IndexScanDesc->numberOfOrderBys. See macros below for accessing those + * arrays. + */ } GISTSearchItem; #define GISTSearchItemIsHeap(item) ((item).blkno == InvalidBlockNumber) -#define SizeOfGISTSearchItem(n_distances) (offsetof(GISTSearchItem, distances) + sizeof(double) * (n_distances)) +#define SizeOfGISTSearchItem(n_distances) (DOUBLEALIGN(sizeof(GISTSearchItem)) + \ + (sizeof(double) + sizeof(bool)) * (n_distances)) + +/* + * We actually don't need n_distances compute pointer to distance values. + * Nevertheless take n_distances as argument to have same arguments list for + * GISTSearchItemDistanceValues() and GISTSearchItemDistanceNulls(). + */ +#define GISTSearchItemDistanceValues(item, n_distances) \ + ((double *) ((Pointer) (item) + DOUBLEALIGN(sizeof(GISTSearchItem)))) + +#define GISTSearchItemDistanceNulls(item, n_distances) \ + ((bool *) ((Pointer) (item) + DOUBLEALIGN(sizeof(GISTSearchItem)) + sizeof(double) * (n_distances))) /* * GISTScanOpaqueData: private state for a scan of a GiST index @@ -159,7 +176,8 @@ typedef struct GISTScanOpaqueData bool firstCall; /* true until first gistgettuple call */ /* pre-allocated workspace arrays */ - double *distances; /* output area for gistindex_keytest */ + double *distanceValues; /* output area for gistindex_keytest */ + bool *distanceNulls; /* info about killed items if any (killedItems is NULL if never used) */ OffsetNumber *killedItems; /* offset numbers of killed items */ |