PostgreSQL Source Code git master
spgist_private.h
Go to the documentation of this file.
1/*-------------------------------------------------------------------------
2 *
3 * spgist_private.h
4 * Private declarations for SP-GiST access method.
5 *
6 *
7 * Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
8 * Portions Copyright (c) 1994, Regents of the University of California
9 *
10 * src/include/access/spgist_private.h
11 *
12 *-------------------------------------------------------------------------
13 */
14#ifndef SPGIST_PRIVATE_H
15#define SPGIST_PRIVATE_H
16
17#include "access/itup.h"
18#include "access/spgist.h"
19#include "catalog/pg_am_d.h"
20#include "nodes/tidbitmap.h"
21#include "storage/buf.h"
22#include "utils/geo_decls.h"
23#include "utils/relcache.h"
24
25
26typedef struct SpGistOptions
27{
28 int32 varlena_header_; /* varlena header (do not touch directly!) */
29 int fillfactor; /* page fill factor in percent (0..100) */
31
32#define SpGistGetFillFactor(relation) \
33 (AssertMacro(relation->rd_rel->relkind == RELKIND_INDEX && \
34 relation->rd_rel->relam == SPGIST_AM_OID), \
35 (relation)->rd_options ? \
36 ((SpGistOptions *) (relation)->rd_options)->fillfactor : \
37 SPGIST_DEFAULT_FILLFACTOR)
38#define SpGistGetTargetPageFreeSpace(relation) \
39 (BLCKSZ * (100 - SpGistGetFillFactor(relation)) / 100)
40
41
42/* SPGiST leaf tuples have one key column, optionally have included columns */
43#define spgKeyColumn 0
44#define spgFirstIncludeColumn 1
45
46/* Page numbers of fixed-location pages */
47#define SPGIST_METAPAGE_BLKNO (0) /* metapage */
48#define SPGIST_ROOT_BLKNO (1) /* root for normal entries */
49#define SPGIST_NULL_BLKNO (2) /* root for null-value entries */
50#define SPGIST_LAST_FIXED_BLKNO SPGIST_NULL_BLKNO
51
52#define SpGistBlockIsRoot(blkno) \
53 ((blkno) == SPGIST_ROOT_BLKNO || (blkno) == SPGIST_NULL_BLKNO)
54#define SpGistBlockIsFixed(blkno) \
55 ((BlockNumber) (blkno) <= (BlockNumber) SPGIST_LAST_FIXED_BLKNO)
56
57/*
58 * Contents of page special space on SPGiST index pages
59 */
61{
62 uint16 flags; /* see bit definitions below */
63 uint16 nRedirection; /* number of redirection tuples on page */
64 uint16 nPlaceholder; /* number of placeholder tuples on page */
65 /* note there's no count of either LIVE or DEAD tuples ... */
66 uint16 spgist_page_id; /* for identification of SP-GiST indexes */
68
70
71/* Flag bits in page special space */
72#define SPGIST_META (1<<0)
73#define SPGIST_DELETED (1<<1) /* never set, but keep for backwards
74 * compatibility */
75#define SPGIST_LEAF (1<<2)
76#define SPGIST_NULLS (1<<3)
78#define SpGistPageGetOpaque(page) ((SpGistPageOpaque) PageGetSpecialPointer(page))
79#define SpGistPageIsMeta(page) (SpGistPageGetOpaque(page)->flags & SPGIST_META)
80#define SpGistPageIsDeleted(page) (SpGistPageGetOpaque(page)->flags & SPGIST_DELETED)
81#define SpGistPageIsLeaf(page) (SpGistPageGetOpaque(page)->flags & SPGIST_LEAF)
82#define SpGistPageStoresNulls(page) (SpGistPageGetOpaque(page)->flags & SPGIST_NULLS)
83
84/*
85 * The page ID is for the convenience of pg_filedump and similar utilities,
86 * which otherwise would have a hard time telling pages of different index
87 * types apart. It should be the last 2 bytes on the page. This is more or
88 * less "free" due to alignment considerations.
89 *
90 * See comments above GinPageOpaqueData.
91 */
92#define SPGIST_PAGE_ID 0xFF82
93
94/*
95 * Each backend keeps a cache of last-used page info in its index->rd_amcache
96 * area. This is initialized from, and occasionally written back to,
97 * shared storage in the index metapage.
98 */
99typedef struct SpGistLastUsedPage
101 BlockNumber blkno; /* block number, or InvalidBlockNumber */
102 int freeSpace; /* page's free space (could be obsolete!) */
104
105/* Note: indexes in cachedPage[] match flag assignments for SpGistGetBuffer */
106#define SPGIST_CACHED_PAGES 8
108typedef struct SpGistLUPCache
112
113/*
114 * metapage
115 */
116typedef struct SpGistMetaPageData
118 uint32 magicNumber; /* for identity cross-check */
119 SpGistLUPCache lastUsedPages; /* shared storage of last-used info */
122#define SPGIST_MAGIC_NUMBER (0xBA0BABEE)
124#define SpGistPageGetMeta(p) \
125 ((SpGistMetaPageData *) PageGetContents(p))
126
127/*
128 * Private state of index AM. SpGistState is common to both insert and
129 * search code; SpGistScanOpaque is for searches only.
130 */
132typedef struct SpGistLeafTupleData *SpGistLeafTuple; /* forward reference */
133
134/* Per-datatype info needed in SpGistState */
135typedef struct SpGistTypeDesc
144typedef struct SpGistState
146 Relation index; /* index we're working with */
148 spgConfigOut config; /* filled in by opclass config method */
150 SpGistTypeDesc attType; /* type of values to be indexed/restored */
151 SpGistTypeDesc attLeafType; /* type of leaf-tuple values */
152 SpGistTypeDesc attPrefixType; /* type of inner-tuple prefix values */
153 SpGistTypeDesc attLabelType; /* type of node label values */
154
155 /* leafTupDesc typically points to index's tupdesc, but not always */
156 TupleDesc leafTupDesc; /* descriptor for leaf-level tuples */
158 char *deadTupleStorage; /* workspace for spgFormDeadTuple */
160 TransactionId redirectXid; /* XID to use when creating a redirect tuple */
161 bool isBuild; /* true if doing index build */
163
164/* Item to be re-examined later during a search */
165typedef struct SpGistSearchItem
167 pairingheap_node phNode; /* pairing heap node */
168 Datum value; /* value reconstructed from parent, or
169 * leafValue if isLeaf */
170 SpGistLeafTuple leafTuple; /* whole leaf tuple, if needed */
171 void *traversalValue; /* opclass-specific traverse value */
172 int level; /* level of items on this page */
173 ItemPointerData heapPtr; /* heap info, if heap tuple */
174 bool isNull; /* SearchItem is NULL item */
175 bool isLeaf; /* SearchItem is heap item */
176 bool recheck; /* qual recheck is needed */
177 bool recheckDistances; /* distance recheck is needed */
178
179 /* array with numberOfOrderBys entries */
183#define SizeOfSpGistSearchItem(n_distances) \
184 (offsetof(SpGistSearchItem, distances) + sizeof(double) * (n_distances))
185
186/*
187 * Private state of an index scan
188 */
189typedef struct SpGistScanOpaqueData
191 SpGistState state; /* see above */
192 pairingheap *scanQueue; /* queue of to be visited items */
193 MemoryContext tempCxt; /* short-lived memory context */
194 MemoryContext traversalCxt; /* single scan lifetime memory context */
195
196 /* Control flags showing whether to search nulls and/or non-nulls */
197 bool searchNulls; /* scan matches (all) null entries */
198 bool searchNonNulls; /* scan matches (some) non-null entries */
199
200 /* Index quals to be passed to opclass (null-related quals removed) */
201 int numberOfKeys; /* number of index qualifier conditions */
202 ScanKey keyData; /* array of index qualifier descriptors */
203 int numberOfOrderBys; /* number of ordering operators */
204 int numberOfNonNullOrderBys; /* number of ordering operators
205 * with non-NULL arguments */
206 ScanKey orderByData; /* array of ordering op descriptors */
207 Oid *orderByTypes; /* array of ordering op return types */
208 int *nonNullOrderByOffsets; /* array of offset of non-NULL
209 * ordering keys in the original array */
210 Oid indexCollation; /* collation of index column */
211
212 /* Opclass defined functions: */
215
216 /* Pre-allocated workspace arrays: */
218 double *infDistances;
219
220 /* These fields are only used in amgetbitmap scans: */
221 TIDBitmap *tbm; /* bitmap being filled */
222 int64 ntids; /* number of TIDs passed to bitmap */
223
224 /* These fields are only used in amgettuple scans: */
225 bool want_itup; /* are we reconstructing tuples? */
226 TupleDesc reconTupDesc; /* if so, descriptor for reconstructed tuples */
227 int nPtrs; /* number of TIDs found on current page */
228 int iPtr; /* index for scanning through same */
230 bool recheck[MaxIndexTuplesPerPage]; /* their recheck flags */
231 bool recheckDistances[MaxIndexTuplesPerPage]; /* distance recheck
232 * flags */
233 HeapTuple reconTups[MaxIndexTuplesPerPage]; /* reconstructed tuples */
234
235 /* distances (for recheck) */
237
238 /*
239 * Note: using MaxIndexTuplesPerPage above is a bit hokey since
240 * SpGistLeafTuples aren't exactly IndexTuples; however, they are larger,
241 * so this is safe.
242 */
246
247/*
248 * This struct is what we actually keep in index->rd_amcache. It includes
249 * static configuration information as well as the lastUsedPages cache.
250 */
251typedef struct SpGistCache
253 spgConfigOut config; /* filled in by opclass config method */
255 SpGistTypeDesc attType; /* type of values to be indexed/restored */
256 SpGistTypeDesc attLeafType; /* type of leaf-tuple values */
257 SpGistTypeDesc attPrefixType; /* type of inner-tuple prefix values */
258 SpGistTypeDesc attLabelType; /* type of node label values */
260 SpGistLUPCache lastUsedPages; /* local storage of last-used info */
262
263
264/*
265 * SPGiST tuple types. Note: inner, leaf, and dead tuple structs
266 * must have the same tupstate field in the same position! Real inner and
267 * leaf tuples always have tupstate = LIVE; if the state is something else,
268 * use the SpGistDeadTuple struct to inspect the tuple.
269 */
270
271/* values of tupstate (see README for more info) */
272#define SPGIST_LIVE 0 /* normal live tuple (either inner or leaf) */
273#define SPGIST_REDIRECT 1 /* temporary redirection placeholder */
274#define SPGIST_DEAD 2 /* dead, cannot be removed because of links */
275#define SPGIST_PLACEHOLDER 3 /* placeholder, used to preserve offsets */
276
277/*
278 * SPGiST inner tuple: list of "nodes" that subdivide a set of tuples
279 *
280 * Inner tuple layout:
281 * header/optional prefix/array of nodes, which are SpGistNodeTuples
282 *
283 * size and prefixSize must be multiples of MAXALIGN
284 *
285 * If the prefix datum is of a pass-by-value type, it is stored in its
286 * Datum representation, that is its on-disk representation is of length
287 * sizeof(Datum). This is a fairly unfortunate choice, because in no other
288 * place does Postgres use Datum as an on-disk representation; it creates
289 * an unnecessary incompatibility between 32-bit and 64-bit builds. But the
290 * compatibility loss is mostly theoretical since MAXIMUM_ALIGNOF typically
291 * differs between such builds, too. Anyway we're stuck with it now.
292 */
293typedef struct SpGistInnerTupleData
295 unsigned int tupstate:2, /* LIVE/REDIRECT/DEAD/PLACEHOLDER */
296 allTheSame:1, /* all nodes in tuple are equivalent */
297 nNodes:13, /* number of nodes within inner tuple */
298 prefixSize:16; /* size of prefix, or 0 if none */
299 uint16 size; /* total size of inner tuple */
300 /* On most machines there will be a couple of wasted bytes here */
301 /* prefix datum follows, then nodes */
305
306/* these must match largest values that fit in bit fields declared above */
307#define SGITMAXNNODES 0x1FFF
308#define SGITMAXPREFIXSIZE 0xFFFF
309#define SGITMAXSIZE 0xFFFF
311#define SGITHDRSZ MAXALIGN(sizeof(SpGistInnerTupleData))
312#define _SGITDATA(x) (((char *) (x)) + SGITHDRSZ)
313#define SGITDATAPTR(x) ((x)->prefixSize ? _SGITDATA(x) : NULL)
314#define SGITDATUM(x, s) ((x)->prefixSize ? \
315 ((s)->attPrefixType.attbyval ? \
316 *(Datum *) _SGITDATA(x) : \
317 PointerGetDatum(_SGITDATA(x))) \
318 : (Datum) 0)
319#define SGITNODEPTR(x) ((SpGistNodeTuple) (_SGITDATA(x) + (x)->prefixSize))
320
321/* Macro for iterating through the nodes of an inner tuple */
322#define SGITITERATE(x, i, nt) \
323 for ((i) = 0, (nt) = SGITNODEPTR(x); \
324 (i) < (x)->nNodes; \
325 (i)++, (nt) = (SpGistNodeTuple) (((char *) (nt)) + IndexTupleSize(nt)))
326
327/*
328 * SPGiST node tuple: one node within an inner tuple
329 *
330 * Node tuples use the same header as ordinary Postgres IndexTuples, but
331 * we do not use a null bitmap, because we know there is only one column
332 * so the INDEX_NULL_MASK bit suffices. Also, pass-by-value datums are
333 * stored in Datum form, the same convention as for inner tuple prefixes.
334 */
340#define SGNTHDRSZ MAXALIGN(sizeof(SpGistNodeTupleData))
341#define SGNTDATAPTR(x) (((char *) (x)) + SGNTHDRSZ)
342#define SGNTDATUM(x, s) ((s)->attLabelType.attbyval ? \
343 *(Datum *) SGNTDATAPTR(x) : \
344 PointerGetDatum(SGNTDATAPTR(x)))
345
346/*
347 * SPGiST leaf tuple: carries a leaf datum and a heap tuple TID,
348 * and optionally some "included" columns.
349 *
350 * In the simplest case, the leaf datum is the same as the indexed value;
351 * but it could also be a suffix or some other sort of delta that permits
352 * reconstruction given knowledge of the prefix path traversed to get here.
353 * Any included columns are stored without modification.
354 *
355 * A nulls bitmap is present if there are included columns AND any of the
356 * datums are NULL. We do not need a nulls bitmap for the case of a null
357 * leaf datum without included columns, as we can infer whether the leaf
358 * datum is null from whether the tuple is stored on a nulls page. (This
359 * provision is mostly for backwards compatibility, but it does save space
360 * on 32-bit machines.) As with other PG index tuple designs, if the nulls
361 * bitmap exists then it's of size INDEX_MAX_KEYS bits regardless of the
362 * actual number of attributes. For the usual choice of INDEX_MAX_KEYS,
363 * this costs nothing because of alignment considerations.
364 *
365 * The size field is wider than could possibly be needed for an on-disk leaf
366 * tuple, but this allows us to form leaf tuples even when the datum is too
367 * wide to be stored immediately, and it costs nothing because of alignment
368 * considerations.
369 *
370 * t_info holds the nextOffset field (14 bits wide, enough for supported
371 * page sizes) plus the has-nulls-bitmap flag bit; another flag bit is free.
372 *
373 * Normally, nextOffset links to the next tuple belonging to the same parent
374 * node (which must be on the same page), or it's 0 if there is no next tuple.
375 * But when the root page is a leaf page, we don't chain its tuples,
376 * so nextOffset is always 0 on the root.
377 *
378 * size must be a multiple of MAXALIGN; also, it must be at least SGDTSIZE
379 * so that the tuple can be converted to REDIRECT status later. (This
380 * restriction only adds bytes for a NULL leaf datum stored on a 32-bit
381 * machine; otherwise alignment restrictions force it anyway.)
382 */
383typedef struct SpGistLeafTupleData
385 unsigned int tupstate:2, /* LIVE/REDIRECT/DEAD/PLACEHOLDER */
386 size:30; /* large enough for any palloc'able value */
387 uint16 t_info; /* nextOffset, which links to the next tuple
388 * in chain, plus two flag bits */
389 ItemPointerData heapPtr; /* TID of represented heap tuple */
390 /* nulls bitmap follows if the flag bit for it is set */
391 /* leaf datum, then any included datums, follows on a MAXALIGN boundary */
393
394/* Macros to access nextOffset and bit fields inside t_info */
395#define SGLT_GET_NEXTOFFSET(spgLeafTuple) \
396 ((spgLeafTuple)->t_info & 0x3FFF)
397#define SGLT_GET_HASNULLMASK(spgLeafTuple) \
398 (((spgLeafTuple)->t_info & 0x8000) ? true : false)
399#define SGLT_SET_NEXTOFFSET(spgLeafTuple, offsetNumber) \
400 ((spgLeafTuple)->t_info = \
401 ((spgLeafTuple)->t_info & 0xC000) | ((offsetNumber) & 0x3FFF))
402#define SGLT_SET_HASNULLMASK(spgLeafTuple, hasnulls) \
403 ((spgLeafTuple)->t_info = \
404 ((spgLeafTuple)->t_info & 0x7FFF) | ((hasnulls) ? 0x8000 : 0))
406#define SGLTHDRSZ(hasnulls) \
407 ((hasnulls) ? MAXALIGN(sizeof(SpGistLeafTupleData) + \
408 sizeof(IndexAttributeBitMapData)) : \
409 MAXALIGN(sizeof(SpGistLeafTupleData)))
410#define SGLTDATAPTR(x) (((char *) (x)) + SGLTHDRSZ(SGLT_GET_HASNULLMASK(x)))
411#define SGLTDATUM(x, s) fetch_att(SGLTDATAPTR(x), \
412 (s)->attLeafType.attbyval, \
413 (s)->attLeafType.attlen)
414
415/*
416 * SPGiST dead tuple: declaration for examining non-live tuples
417 *
418 * The tupstate field of this struct must match those of regular inner and
419 * leaf tuples, and its size field must match a leaf tuple's.
420 * Also, the pointer field must be in the same place as a leaf tuple's heapPtr
421 * field, to satisfy some Asserts that we make when replacing a leaf tuple
422 * with a dead tuple.
423 * We don't use t_info, but it's needed to align the pointer field.
424 * pointer and xid are only valid when tupstate = REDIRECT, and in some
425 * cases xid can be InvalidTransactionId even then; see initSpGistState.
426 */
427typedef struct SpGistDeadTupleData
429 unsigned int tupstate:2, /* LIVE/REDIRECT/DEAD/PLACEHOLDER */
431 uint16 t_info; /* not used in dead tuples */
432 ItemPointerData pointer; /* redirection inside index */
433 TransactionId xid; /* ID of xact that inserted this tuple */
438#define SGDTSIZE MAXALIGN(sizeof(SpGistDeadTupleData))
439
440/*
441 * Macros for doing free-space calculations. Note that when adding up the
442 * space needed for tuples, we always consider each tuple to need the tuple's
443 * size plus sizeof(ItemIdData) (for the line pointer). This works correctly
444 * so long as tuple sizes are always maxaligned.
445 */
446
447/* Page capacity after allowing for fixed header and special space */
448#define SPGIST_PAGE_CAPACITY \
449 MAXALIGN_DOWN(BLCKSZ - \
450 SizeOfPageHeaderData - \
451 MAXALIGN(sizeof(SpGistPageOpaqueData)))
452
453/*
454 * Compute free space on page, assuming that up to n placeholders can be
455 * recycled if present (n should be the number of tuples to be inserted)
456 */
457#define SpGistPageGetFreeSpace(p, n) \
458 (PageGetExactFreeSpace(p) + \
459 Min(SpGistPageGetOpaque(p)->nPlaceholder, n) * \
460 (SGDTSIZE + sizeof(ItemIdData)))
461
462/*
463 * XLOG stuff
464 */
466#define STORE_STATE(s, d) \
467 do { \
468 (d).redirectXid = (s)->redirectXid; \
469 (d).isBuild = (s)->isBuild; \
470 } while(0)
471
472/*
473 * The "flags" argument for SpGistGetBuffer should be either GBUF_LEAF to
474 * get a leaf page, or GBUF_INNER_PARITY(blockNumber) to get an inner
475 * page in the same triple-parity group as the specified block number.
476 * (Typically, this should be GBUF_INNER_PARITY(parentBlockNumber + 1)
477 * to follow the rule described in spgist/README.)
478 * In addition, GBUF_NULLS can be OR'd in to get a page for storage of
479 * null-valued tuples.
480 *
481 * Note: these flag values are used as indexes into lastUsedPages.
482 */
483#define GBUF_LEAF 0x03
484#define GBUF_INNER_PARITY(x) ((x) % 3)
485#define GBUF_NULLS 0x04
487#define GBUF_PARITY_MASK 0x03
488#define GBUF_REQ_LEAF(flags) (((flags) & GBUF_PARITY_MASK) == GBUF_LEAF)
489#define GBUF_REQ_NULLS(flags) ((flags) & GBUF_NULLS)
490
491/* spgutils.c */
492
493/* reloption parameters */
494#define SPGIST_MIN_FILLFACTOR 10
495#define SPGIST_DEFAULT_FILLFACTOR 80
496
502extern Buffer SpGistGetBuffer(Relation index, int flags,
503 int needSpace, bool *isNew);
504extern void SpGistSetLastUsedPage(Relation index, Buffer buffer);
505extern void SpGistInitPage(Page page, uint16 f);
506extern void SpGistInitBuffer(Buffer b, uint16 f);
507extern void SpGistInitMetapage(Page page);
508extern unsigned int SpGistGetInnerTypeSize(SpGistTypeDesc *att, Datum datum);
509extern Size SpGistGetLeafTupleSize(TupleDesc tupleDescriptor,
510 const Datum *datums, const bool *isnulls);
512 ItemPointer heapPtr,
513 const Datum *datums, const bool *isnulls);
515 Datum label, bool isnull);
517 bool hasPrefix, Datum prefix,
518 int nNodes, SpGistNodeTuple *nodes);
520 BlockNumber blkno, OffsetNumber offnum);
521extern void spgDeformLeafTuple(SpGistLeafTuple tup, TupleDesc tupleDescriptor,
522 Datum *datums, bool *isnulls,
523 bool keyColumnIsNull);
525 SpGistInnerTuple innerTuple);
527 Item item, Size size,
528 OffsetNumber *startOffset,
529 bool errorOK);
530extern bool spgproperty(Oid index_oid, int attno,
531 IndexAMProperty prop, const char *propname,
532 bool *res, bool *isnull);
533
534/* spgdoinsert.c */
535extern void spgUpdateNodeLink(SpGistInnerTuple tup, int nodeN,
536 BlockNumber blkno, OffsetNumber offset);
538 OffsetNumber *itemnos, int nitems,
539 int firststate, int reststate,
540 BlockNumber blkno, OffsetNumber offnum);
542 ItemPointer heapPtr, Datum *datums, bool *isnulls);
543
544/* spgproc.c */
545extern double *spg_key_orderbys_distances(Datum key, bool isLeaf,
546 ScanKey orderbys, int norderbys);
547extern BOX *box_copy(BOX *orig);
548
549#endif /* SPGIST_PRIVATE_H */
IndexAMProperty
Definition: amapi.h:35
uint32 BlockNumber
Definition: block.h:31
int Buffer
Definition: buf.h:23
PageData * Page
Definition: bufpage.h:82
int64_t int64
Definition: c.h:485
#define FLEXIBLE_ARRAY_MEMBER
Definition: c.h:420
int16_t int16
Definition: c.h:483
int32_t int32
Definition: c.h:484
uint16_t uint16
Definition: c.h:487
uint32_t uint32
Definition: c.h:488
uint32 TransactionId
Definition: c.h:609
size_t Size
Definition: c.h:562
#define nitems(x)
Definition: indent.h:31
int b
Definition: isn.c:69
Pointer Item
Definition: item.h:17
#define MaxIndexTuplesPerPage
Definition: itup.h:167
uint16 OffsetNumber
Definition: off.h:24
static char * label
uintptr_t Datum
Definition: postgres.h:69
unsigned int Oid
Definition: postgres_ext.h:32
static pg_noinline void Size size
Definition: slab.c:607
BOX * box_copy(BOX *orig)
Definition: spgproc.c:82
SpGistDeadTupleData * SpGistDeadTuple
Datum * spgExtractNodeLabels(SpGistState *state, SpGistInnerTuple innerTuple)
Definition: spgutils.c:1155
void initSpGistState(SpGistState *state, Relation index)
Definition: spgutils.c:343
struct SpGistPageOpaqueData SpGistPageOpaqueData
void SpGistUpdateMetaPage(Relation index)
Definition: spgutils.c:445
SpGistPageOpaqueData * SpGistPageOpaque
TupleDesc getSpGistTupleDesc(Relation index, SpGistTypeDesc *keyType)
Definition: spgutils.c:310
Buffer SpGistNewBuffer(Relation index)
Definition: spgutils.c:389
SpGistInnerTupleData * SpGistInnerTuple
struct SpGistDeadTupleData SpGistDeadTupleData
SpGistInnerTuple spgFormInnerTuple(SpGistState *state, bool hasPrefix, Datum prefix, int nNodes, SpGistNodeTuple *nodes)
Definition: spgutils.c:997
SpGistLeafTuple spgFormLeafTuple(SpGistState *state, ItemPointer heapPtr, const Datum *datums, const bool *isnulls)
Definition: spgutils.c:866
bool spgdoinsert(Relation index, SpGistState *state, ItemPointer heapPtr, Datum *datums, bool *isnulls)
Definition: spgdoinsert.c:1914
SpGistCache * spgGetCache(Relation index)
Definition: spgutils.c:183
void spgPageIndexMultiDelete(SpGistState *state, Page page, OffsetNumber *itemnos, int nitems, int firststate, int reststate, BlockNumber blkno, OffsetNumber offnum)
Definition: spgdoinsert.c:131
struct SpGistState SpGistState
void spgDeformLeafTuple(SpGistLeafTuple tup, TupleDesc tupleDescriptor, Datum *datums, bool *isnulls, bool keyColumnIsNull)
Definition: spgutils.c:1110
SpGistDeadTuple spgFormDeadTuple(SpGistState *state, int tupstate, BlockNumber blkno, OffsetNumber offnum)
Definition: spgutils.c:1080
IndexTupleData SpGistNodeTupleData
SpGistScanOpaqueData * SpGistScanOpaque
struct SpGistInnerTupleData SpGistInnerTupleData
unsigned int SpGistGetInnerTypeSize(SpGistTypeDesc *att, Datum datum)
Definition: spgutils.c:774
struct SpGistOptions SpGistOptions
struct SpGistCache SpGistCache
void SpGistInitBuffer(Buffer b, uint16 f)
Definition: spgutils.c:717
void spgUpdateNodeLink(SpGistInnerTuple tup, int nodeN, BlockNumber blkno, OffsetNumber offset)
Definition: spgdoinsert.c:52
double * spg_key_orderbys_distances(Datum key, bool isLeaf, ScanKey orderbys, int norderbys)
Definition: spgproc.c:63
SpGistNodeTupleData * SpGistNodeTuple
struct SpGistMetaPageData SpGistMetaPageData
struct SpGistLastUsedPage SpGistLastUsedPage
Buffer SpGistGetBuffer(Relation index, int flags, int needSpace, bool *isNew)
Definition: spgutils.c:564
struct SpGistLeafTupleData * SpGistLeafTuple
#define SPGIST_CACHED_PAGES
bool spgproperty(Oid index_oid, int attno, IndexAMProperty prop, const char *propname, bool *res, bool *isnull)
Definition: spgutils.c:1293
void SpGistSetLastUsedPage(Relation index, Buffer buffer)
Definition: spgutils.c:668
struct SpGistScanOpaqueData SpGistScanOpaqueData
OffsetNumber SpGistPageAddNewItem(SpGistState *state, Page page, Item item, Size size, OffsetNumber *startOffset, bool errorOK)
Definition: spgutils.c:1198
struct SpGistTypeDesc SpGistTypeDesc
struct SpGistSearchItem SpGistSearchItem
Size SpGistGetLeafTupleSize(TupleDesc tupleDescriptor, const Datum *datums, const bool *isnulls)
Definition: spgutils.c:813
void SpGistInitPage(Page page, uint16 f)
Definition: spgutils.c:703
struct SpGistLeafTupleData SpGistLeafTupleData
SpGistNodeTuple spgFormNodeTuple(SpGistState *state, Datum label, bool isnull)
Definition: spgutils.c:955
void SpGistInitMetapage(Page page)
Definition: spgutils.c:727
struct SpGistLUPCache SpGistLUPCache
Definition: geo_decls.h:141
Definition: fmgr.h:57
SpGistTypeDesc attPrefixType
SpGistTypeDesc attLeafType
SpGistTypeDesc attType
SpGistLUPCache lastUsedPages
spgConfigOut config
SpGistTypeDesc attLabelType
unsigned int tupstate
ItemPointerData pointer
unsigned int prefixSize
unsigned int allTheSame
SpGistLastUsedPage cachedPage[SPGIST_CACHED_PAGES]
unsigned int tupstate
ItemPointerData heapPtr
SpGistLUPCache lastUsedPages
int32 varlena_header_
HeapTuple reconTups[MaxIndexTuplesPerPage]
ItemPointerData heapPtrs[MaxIndexTuplesPerPage]
MemoryContext traversalCxt
pairingheap * scanQueue
bool recheckDistances[MaxIndexTuplesPerPage]
MemoryContext tempCxt
IndexOrderByDistance * distances[MaxIndexTuplesPerPage]
bool recheck[MaxIndexTuplesPerPage]
pairingheap_node phNode
SpGistLeafTuple leafTuple
ItemPointerData heapPtr
double distances[FLEXIBLE_ARRAY_MEMBER]
Relation index
SpGistTypeDesc attType
SpGistTypeDesc attPrefixType
TupleDesc leafTupDesc
char * deadTupleStorage
spgConfigOut config
TransactionId redirectXid
SpGistTypeDesc attLabelType
SpGistTypeDesc attLeafType
Definition: type.h:96
Definition: regguts.h:323