PostgreSQL Source Code  git master
gist_private.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * gist_private.h
4  * private declarations for GiST -- declarations related to the
5  * internal implementation of GiST, not the public API
6  *
7  * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
8  * Portions Copyright (c) 1994, Regents of the University of California
9  *
10  * src/include/access/gist_private.h
11  *
12  *-------------------------------------------------------------------------
13  */
14 #ifndef GIST_PRIVATE_H
15 #define GIST_PRIVATE_H
16 
17 #include "access/amapi.h"
18 #include "access/gist.h"
19 #include "access/itup.h"
20 #include "lib/pairingheap.h"
21 #include "storage/bufmgr.h"
22 #include "storage/buffile.h"
23 #include "utils/hsearch.h"
24 #include "access/genam.h"
25 
26 /*
27  * Maximum number of "halves" a page can be split into in one operation.
28  * Typically a split produces 2 halves, but can be more if keys have very
29  * different lengths, or when inserting multiple keys in one operation (as
30  * when inserting downlinks to an internal node). There is no theoretical
31  * limit on this, but in practice if you get more than a handful page halves
32  * in one split, there's something wrong with the opclass implementation.
33  * GIST_MAX_SPLIT_PAGES is an arbitrary limit on that, used to size some
34  * local arrays used during split. Note that there is also a limit on the
35  * number of buffers that can be held locked at a time, MAX_SIMUL_LWLOCKS,
36  * so if you raise this higher than that limit, you'll just get a different
37  * error.
38  */
39 #define GIST_MAX_SPLIT_PAGES 75
40 
41 /* Buffer lock modes */
42 #define GIST_SHARE BUFFER_LOCK_SHARE
43 #define GIST_EXCLUSIVE BUFFER_LOCK_EXCLUSIVE
44 #define GIST_UNLOCK BUFFER_LOCK_UNLOCK
45 
46 typedef struct
47 {
50  char tupledata[FLEXIBLE_ARRAY_MEMBER];
52 
53 #define BUFFER_PAGE_DATA_OFFSET MAXALIGN(offsetof(GISTNodeBufferPage, tupledata))
54 /* Returns free space in node buffer page */
55 #define PAGE_FREE_SPACE(nbp) (nbp->freespace)
56 /* Checks if node buffer page is empty */
57 #define PAGE_IS_EMPTY(nbp) (nbp->freespace == BLCKSZ - BUFFER_PAGE_DATA_OFFSET)
58 /* Checks if node buffers page don't contain sufficient space for index tuple */
59 #define PAGE_NO_SPACE(nbp, itup) (PAGE_FREE_SPACE(nbp) < \
60  MAXALIGN(IndexTupleSize(itup)))
61 
62 /*
63  * GISTSTATE: information needed for any GiST index operation
64  *
65  * This struct retains call info for the index's opclass-specific support
66  * functions (per index column), plus the index's tuple descriptor.
67  *
68  * scanCxt holds the GISTSTATE itself as well as any data that lives for the
69  * lifetime of the index operation. We pass this to the support functions
70  * via fn_mcxt, so that they can store scan-lifespan data in it. The
71  * functions are invoked in tempCxt, which is typically short-lifespan
72  * (that is, it's reset after each tuple). However, tempCxt can be the same
73  * as scanCxt if we're not bothering with per-tuple context resets.
74  */
75 typedef struct GISTSTATE
76 {
77  MemoryContext scanCxt; /* context for scan-lifespan data */
78  MemoryContext tempCxt; /* short-term context for calling functions */
79 
80  TupleDesc leafTupdesc; /* index's tuple descriptor */
81  TupleDesc nonLeafTupdesc; /* truncated tuple descriptor for non-leaf
82  * pages */
83  TupleDesc fetchTupdesc; /* tuple descriptor for tuples returned in an
84  * index-only scan */
85 
95 
96  /* Collations to pass to the support functions */
99 
100 
101 /*
102  * During a GiST index search, we must maintain a queue of unvisited items,
103  * which can be either individual heap tuples or whole index pages. If it
104  * is an ordered search, the unvisited items should be visited in distance
105  * order. Unvisited items at the same distance should be visited in
106  * depth-first order, that is heap items first, then lower index pages, then
107  * upper index pages; this rule avoids doing extra work during a search that
108  * ends early due to LIMIT.
109  *
110  * To perform an ordered search, we use a pairing heap to manage the
111  * distance-order queue. In a non-ordered search (no order-by operators),
112  * we use it to return heap tuples before unvisited index pages, to
113  * ensure depth-first order, but all entries are otherwise considered
114  * equal.
115  */
116 
117 /* Individual heap tuple to be visited */
118 typedef struct GISTSearchHeapItem
119 {
121  bool recheck; /* T if quals must be rechecked */
122  bool recheckDistances; /* T if distances must be rechecked */
123  HeapTuple recontup; /* data reconstructed from the index, used in
124  * index-only scans */
125  OffsetNumber offnum; /* track offset in page to mark tuple as
126  * LP_DEAD */
128 
129 /* Unvisited item, either index page or heap tuple */
130 typedef struct GISTSearchItem
131 {
133  BlockNumber blkno; /* index page number, or InvalidBlockNumber */
134  union
135  {
136  GistNSN parentlsn; /* parent page's LSN, if index page */
137  /* we must store parentlsn to detect whether a split occurred */
138  GISTSearchHeapItem heap; /* heap info, if heap tuple */
139  } data;
140 
141  /* numberOfOrderBys entries */
144 
145 #define GISTSearchItemIsHeap(item) ((item).blkno == InvalidBlockNumber)
146 
147 #define SizeOfGISTSearchItem(n_distances) \
148  (offsetof(GISTSearchItem, distances) + \
149  sizeof(IndexOrderByDistance) * (n_distances))
150 
151 /*
152  * GISTScanOpaqueData: private state for a scan of a GiST index
153  */
154 typedef struct GISTScanOpaqueData
155 {
156  GISTSTATE *giststate; /* index information, see above */
157  Oid *orderByTypes; /* datatypes of ORDER BY expressions */
158 
159  pairingheap *queue; /* queue of unvisited items */
160  MemoryContext queueCxt; /* context holding the queue */
161  bool qual_ok; /* false if qual can never be satisfied */
162  bool firstCall; /* true until first gistgettuple call */
163 
164  /* pre-allocated workspace arrays */
165  IndexOrderByDistance *distances; /* output area for gistindex_keytest */
166 
167  /* info about killed items if any (killedItems is NULL if never used) */
168  OffsetNumber *killedItems; /* offset numbers of killed items */
169  int numKilled; /* number of currently stored items */
170  BlockNumber curBlkno; /* current number of block */
171  GistNSN curPageLSN; /* pos in the WAL stream when page was read */
172 
173  /* In a non-ordered search, returnable heap items are stored here: */
175  OffsetNumber nPageData; /* number of valid items in array */
176  OffsetNumber curPageData; /* next item to return */
177  MemoryContext pageDataCxt; /* context holding the fetched tuples, for
178  * index-only scans */
180 
182 
183 /* despite the name, gistxlogPage is not part of any xlog record */
184 typedef struct gistxlogPage
185 {
187  int num; /* number of index tuples following */
189 
190 /* SplitPageLayout - gistSplit function result */
191 typedef struct SplitPageLayout
192 {
195  int lenlist;
196  IndexTuple itup; /* union key for page */
197  Page page; /* to operate */
198  Buffer buffer; /* to write after all proceed */
199 
202 
203 /*
204  * GISTInsertStack used for locking buffers and transfer arguments during
205  * insertion
206  */
207 typedef struct GISTInsertStack
208 {
209  /* current page */
213 
214  /*
215  * log sequence number from page->lsn to recognize page update and compare
216  * it with page's nsn to recognize page split
217  */
219 
220  /*
221  * If set, we split the page while descending the tree to find an
222  * insertion target. It means that we need to retry from the parent,
223  * because the downlink of this page might no longer cover the new key.
224  */
226 
227  /* offset of the downlink in the parent page, that points to this page */
229 
230  /* pointer to parent */
233 
234 /* Working state and results for multi-column split logic in gistsplit.c */
235 typedef struct GistSplitVector
236 {
237  GIST_SPLITVEC splitVector; /* passed to/from user PickSplit method */
238 
239  Datum spl_lattr[INDEX_MAX_KEYS]; /* Union of subkeys in
240  * splitVector.spl_left */
242 
243  Datum spl_rattr[INDEX_MAX_KEYS]; /* Union of subkeys in
244  * splitVector.spl_right */
246 
247  bool *spl_dontcare; /* flags tuples which could go to either side
248  * of the split for zero penalty */
250 
251 typedef struct
252 {
255  Size freespace; /* free space to be left */
256  bool is_build;
257 
260 
261 /* root page of a gist index */
262 #define GIST_ROOT_BLKNO 0
263 
264 /*
265  * Before PostgreSQL 9.1, we used to rely on so-called "invalid tuples" on
266  * inner pages to finish crash recovery of incomplete page splits. If a crash
267  * happened in the middle of a page split, so that the downlink pointers were
268  * not yet inserted, crash recovery inserted a special downlink pointer. The
269  * semantics of an invalid tuple was that it if you encounter one in a scan,
270  * it must always be followed, because we don't know if the tuples on the
271  * child page match or not.
272  *
273  * We no longer create such invalid tuples, we now mark the left-half of such
274  * an incomplete split with the F_FOLLOW_RIGHT flag instead, and finish the
275  * split properly the next time we need to insert on that page. To retain
276  * on-disk compatibility for the sake of pg_upgrade, we still store 0xffff as
277  * the offset number of all inner tuples. If we encounter any invalid tuples
278  * with 0xfffe during insertion, we throw an error, though scans still handle
279  * them. You should only encounter invalid tuples if you pg_upgrade a pre-9.1
280  * gist index which already has invalid tuples in it because of a crash. That
281  * should be rare, and you are recommended to REINDEX anyway if you have any
282  * invalid tuples in an index, so throwing an error is as far as we go with
283  * supporting that.
284  */
285 #define TUPLE_IS_VALID 0xffff
286 #define TUPLE_IS_INVALID 0xfffe
287 
288 #define GistTupleIsInvalid(itup) ( ItemPointerGetOffsetNumber( &((itup)->t_tid) ) == TUPLE_IS_INVALID )
289 #define GistTupleSetValid(itup) ItemPointerSetOffsetNumber( &((itup)->t_tid), TUPLE_IS_VALID )
290 
291 
292 
293 
294 /*
295  * A buffer attached to an internal node, used when building an index in
296  * buffering mode.
297  */
298 typedef struct
299 {
300  BlockNumber nodeBlocknum; /* index block # this buffer is for */
301  int32 blocksCount; /* current # of blocks occupied by buffer */
302 
303  BlockNumber pageBlocknum; /* temporary file block # */
304  GISTNodeBufferPage *pageBuffer; /* in-memory buffer page */
305 
306  /* is this buffer queued for emptying? */
308 
309  /* is this a temporary copy, not in the hash table? */
310  bool isTemp;
311 
312  int level; /* 0 == leaf */
314 
315 /*
316  * Does specified level have buffers? (Beware of multiple evaluation of
317  * arguments.)
318  */
319 #define LEVEL_HAS_BUFFERS(nlevel, gfbb) \
320  ((nlevel) != 0 && (nlevel) % (gfbb)->levelStep == 0 && \
321  (nlevel) != (gfbb)->rootlevel)
322 
323 /* Is specified buffer at least half-filled (should be queued for emptying)? */
324 #define BUFFER_HALF_FILLED(nodeBuffer, gfbb) \
325  ((nodeBuffer)->blocksCount > (gfbb)->pagesPerBuffer / 2)
326 
327 /*
328  * Is specified buffer full? Our buffers can actually grow indefinitely,
329  * beyond the "maximum" size, so this just means whether the buffer has grown
330  * beyond the nominal maximum size.
331  */
332 #define BUFFER_OVERFLOWED(nodeBuffer, gfbb) \
333  ((nodeBuffer)->blocksCount > (gfbb)->pagesPerBuffer)
334 
335 /*
336  * Data structure with general information about build buffers.
337  */
338 typedef struct GISTBuildBuffers
339 {
340  /* Persistent memory context for the buffers and metadata. */
342 
343  BufFile *pfile; /* Temporary file to store buffers in */
344  long nFileBlocks; /* Current size of the temporary file */
345 
346  /*
347  * resizable array of free blocks.
348  */
349  long *freeBlocks;
350  int nFreeBlocks; /* # of currently free blocks in the array */
351  int freeBlocksLen; /* current allocated length of the array */
352 
353  /* Hash for buffers by block number */
355 
356  /* List of buffers scheduled for emptying */
358 
359  /*
360  * Parameters to the buffering build algorithm. levelStep determines which
361  * levels in the tree have buffers, and pagesPerBuffer determines how
362  * large each buffer is.
363  */
366 
367  /* Array of lists of buffers on each level, for final emptying */
370 
371  /*
372  * Dynamically-sized array of buffers that currently have their last page
373  * loaded in main memory.
374  */
376  int loadedBuffersCount; /* # of entries in loadedBuffers */
377  int loadedBuffersLen; /* allocated size of loadedBuffers */
378 
379  /* Level of the current root node (= height of the index tree - 1) */
382 
383 /* GiSTOptions->buffering_mode values */
385 {
390 
391 /*
392  * Storage type for GiST's reloptions
393  */
394 typedef struct GiSTOptions
395 {
396  int32 vl_len_; /* varlena header (do not touch directly!) */
397  int fillfactor; /* page fill factor in percent (0..100) */
398  GistOptBufferingMode buffering_mode; /* buffering build mode */
400 
401 /* gist.c */
402 extern void gistbuildempty(Relation index);
403 extern bool gistinsert(Relation r, Datum *values, bool *isnull,
404  ItemPointer ht_ctid, Relation heapRel,
405  IndexUniqueCheck checkUnique,
406  bool indexUnchanged,
407  struct IndexInfo *indexInfo);
410 extern void freeGISTstate(GISTSTATE *giststate);
411 extern void gistdoinsert(Relation r,
412  IndexTuple itup,
413  Size freespace,
414  GISTSTATE *giststate,
415  Relation heapRel,
416  bool is_build);
417 
418 /* A List of these is returned from gistplacetopage() in *splitinfo */
419 typedef struct
420 {
421  Buffer buf; /* the split page "half" */
422  IndexTuple downlink; /* downlink for this half. */
424 
425 extern bool gistplacetopage(Relation rel, Size freespace, GISTSTATE *giststate,
426  Buffer buffer,
427  IndexTuple *itup, int ntup,
428  OffsetNumber oldoffnum, BlockNumber *newblkno,
429  Buffer leftchildbuf,
430  List **splitinfo,
431  bool markfollowright,
432  Relation heapRel,
433  bool is_build);
434 
435 extern SplitPageLayout *gistSplit(Relation r, Page page, IndexTuple *itup,
436  int len, GISTSTATE *giststate);
437 
438 /* gistxlog.c */
439 extern XLogRecPtr gistXLogPageDelete(Buffer buffer,
440  FullTransactionId xid, Buffer parentBuffer,
441  OffsetNumber downlinkOffset);
442 
443 extern void gistXLogPageReuse(Relation rel, Relation heaprel, BlockNumber blkno,
444  FullTransactionId deleteXid);
445 
446 extern XLogRecPtr gistXLogUpdate(Buffer buffer,
447  OffsetNumber *todelete, int ntodelete,
448  IndexTuple *itup, int ituplen,
449  Buffer leftchildbuf);
450 
451 extern XLogRecPtr gistXLogDelete(Buffer buffer, OffsetNumber *todelete,
452  int ntodelete, TransactionId snapshotConflictHorizon,
453  Relation heaprel);
454 
455 extern XLogRecPtr gistXLogSplit(bool page_is_leaf,
456  SplitPageLayout *dist,
457  BlockNumber origrlink, GistNSN orignsn,
458  Buffer leftchildbuf, bool markfollowright);
459 
460 extern XLogRecPtr gistXLogAssignLSN(void);
461 
462 /* gistget.c */
463 extern bool gistgettuple(IndexScanDesc scan, ScanDirection dir);
464 extern int64 gistgetbitmap(IndexScanDesc scan, TIDBitmap *tbm);
465 extern bool gistcanreturn(Relation index, int attno);
466 
467 /* gistvalidate.c */
468 extern bool gistvalidate(Oid opclassoid);
469 extern void gistadjustmembers(Oid opfamilyoid,
470  Oid opclassoid,
471  List *operators,
472  List *functions);
473 
474 /* gistutil.c */
475 
476 #define GiSTPageSize \
477  ( BLCKSZ - SizeOfPageHeaderData - MAXALIGN(sizeof(GISTPageOpaqueData)) )
478 
479 #define GIST_MIN_FILLFACTOR 10
480 #define GIST_DEFAULT_FILLFACTOR 90
481 
482 extern bytea *gistoptions(Datum reloptions, bool validate);
483 extern bool gistproperty(Oid index_oid, int attno,
484  IndexAMProperty prop, const char *propname,
485  bool *res, bool *isnull);
486 extern bool gistfitpage(IndexTuple *itvec, int len);
487 extern bool gistnospace(Page page, IndexTuple *itvec, int len, OffsetNumber todelete, Size freespace);
488 extern void gistcheckpage(Relation rel, Buffer buf);
489 extern Buffer gistNewBuffer(Relation r, Relation heaprel);
490 extern bool gistPageRecyclable(Page page);
491 extern void gistfillbuffer(Page page, IndexTuple *itup, int len,
492  OffsetNumber off);
493 extern IndexTuple *gistextractpage(Page page, int *len /* out */ );
494 extern IndexTuple *gistjoinvector(IndexTuple *itvec, int *len,
495  IndexTuple *additvec, int addlen);
496 extern IndexTupleData *gistfillitupvec(IndexTuple *vec, int veclen, int *memlen);
497 
498 extern IndexTuple gistunion(Relation r, IndexTuple *itvec,
499  int len, GISTSTATE *giststate);
501  IndexTuple oldtup,
502  IndexTuple addtup,
503  GISTSTATE *giststate);
504 extern IndexTuple gistFormTuple(GISTSTATE *giststate,
505  Relation r, const Datum *attdata, const bool *isnull, bool isleaf);
506 extern void gistCompressValues(GISTSTATE *giststate, Relation r,
507  const Datum *attdata, const bool *isnull, bool isleaf, Datum *compatt);
508 
510  IndexTuple it,
511  GISTSTATE *giststate);
512 
513 extern void GISTInitBuffer(Buffer b, uint32 f);
514 extern void gistinitpage(Page page, uint32 f);
515 extern void gistdentryinit(GISTSTATE *giststate, int nkey, GISTENTRY *e,
516  Datum k, Relation r, Page pg, OffsetNumber o,
517  bool l, bool isNull);
518 
519 extern float gistpenalty(GISTSTATE *giststate, int attno,
520  GISTENTRY *orig, bool isNullOrig,
521  GISTENTRY *add, bool isNullAdd);
522 extern void gistMakeUnionItVec(GISTSTATE *giststate, IndexTuple *itvec, int len,
523  Datum *attr, bool *isnull);
524 extern bool gistKeyIsEQ(GISTSTATE *giststate, int attno, Datum a, Datum b);
525 extern void gistDeCompressAtt(GISTSTATE *giststate, Relation r, IndexTuple tuple, Page p,
526  OffsetNumber o, GISTENTRY *attdata, bool *isnull);
527 extern HeapTuple gistFetchTuple(GISTSTATE *giststate, Relation r,
528  IndexTuple tuple);
529 extern void gistMakeUnionKey(GISTSTATE *giststate, int attno,
530  GISTENTRY *entry1, bool isnull1,
531  GISTENTRY *entry2, bool isnull2,
532  Datum *dst, bool *dstisnull);
533 
535 
536 /* gistvacuum.c */
538  IndexBulkDeleteResult *stats,
540  void *callback_state);
542  IndexBulkDeleteResult *stats);
543 
544 /* gistsplit.c */
545 extern void gistSplitByKey(Relation r, Page page, IndexTuple *itup,
546  int len, GISTSTATE *giststate,
547  GistSplitVector *v,
548  int attno);
549 
550 /* gistbuild.c */
552  struct IndexInfo *indexInfo);
553 
554 /* gistbuildbuffers.c */
555 extern GISTBuildBuffers *gistInitBuildBuffers(int pagesPerBuffer, int levelStep,
556  int maxLevel);
558  GISTSTATE *giststate,
559  BlockNumber nodeBlocknum, int level);
561  GISTNodeBuffer *nodeBuffer, IndexTuple itup);
563  GISTNodeBuffer *nodeBuffer, IndexTuple *itup);
564 extern void gistFreeBuildBuffers(GISTBuildBuffers *gfbb);
566  GISTSTATE *giststate, Relation r,
567  int level, Buffer buffer,
568  List *splitinfo);
569 extern void gistUnloadNodeBuffers(GISTBuildBuffers *gfbb);
570 
571 #endif /* GIST_PRIVATE_H */
IndexAMProperty
Definition: amapi.h:35
uint32 BlockNumber
Definition: block.h:31
static Datum values[MAXATTR]
Definition: bootstrap.c:152
int Buffer
Definition: buf.h:23
Pointer Page
Definition: bufpage.h:78
unsigned int uint32
Definition: c.h:506
signed int int32
Definition: c.h:494
#define FLEXIBLE_ARRAY_MEMBER
Definition: c.h:398
uint32 TransactionId
Definition: c.h:652
size_t Size
Definition: c.h:605
bool(* IndexBulkDeleteCallback)(ItemPointer itemptr, void *state)
Definition: genam.h:87
IndexUniqueCheck
Definition: genam.h:116
XLogRecPtr GistNSN
Definition: gist.h:62
IndexBulkDeleteResult * gistbulkdelete(IndexVacuumInfo *info, IndexBulkDeleteResult *stats, IndexBulkDeleteCallback callback, void *callback_state)
Definition: gistvacuum.c:59
void gistDeCompressAtt(GISTSTATE *giststate, Relation r, IndexTuple tuple, Page p, OffsetNumber o, GISTENTRY *attdata, bool *isnull)
Definition: gistutil.c:296
void gistadjustmembers(Oid opfamilyoid, Oid opclassoid, List *operators, List *functions)
Definition: gistvalidate.c:295
void gistPushItupToNodeBuffer(GISTBuildBuffers *gfbb, GISTNodeBuffer *nodeBuffer, IndexTuple itup)
bool gistinsert(Relation r, Datum *values, bool *isnull, ItemPointer ht_ctid, Relation heapRel, IndexUniqueCheck checkUnique, bool indexUnchanged, struct IndexInfo *indexInfo)
Definition: gist.c:159
XLogRecPtr gistXLogAssignLSN(void)
Definition: gistxlog.c:576
void gistdoinsert(Relation r, IndexTuple itup, Size freespace, GISTSTATE *giststate, Relation heapRel, bool is_build)
Definition: gist.c:634
struct SplitPageLayout SplitPageLayout
void gistRelocateBuildBuffersOnSplit(GISTBuildBuffers *gfbb, GISTSTATE *giststate, Relation r, int level, Buffer buffer, List *splitinfo)
Buffer gistNewBuffer(Relation r, Relation heaprel)
Definition: gistutil.c:824
bool gistproperty(Oid index_oid, int attno, IndexAMProperty prop, const char *propname, bool *res, bool *isnull)
Definition: gistutil.c:933
struct GISTSearchHeapItem GISTSearchHeapItem
XLogRecPtr gistXLogSplit(bool page_is_leaf, SplitPageLayout *dist, BlockNumber origrlink, GistNSN orignsn, Buffer leftchildbuf, bool markfollowright)
Definition: gistxlog.c:495
bool gistPageRecyclable(Page page)
Definition: gistutil.c:888
void gistMakeUnionKey(GISTSTATE *giststate, int attno, GISTENTRY *entry1, bool isnull1, GISTENTRY *entry2, bool isnull2, Datum *dst, bool *dstisnull)
Definition: gistutil.c:233
XLogRecPtr gistXLogPageDelete(Buffer buffer, FullTransactionId xid, Buffer parentBuffer, OffsetNumber downlinkOffset)
Definition: gistxlog.c:552
XLogRecPtr gistXLogDelete(Buffer buffer, OffsetNumber *todelete, int ntodelete, TransactionId snapshotConflictHorizon, Relation heaprel)
Definition: gistxlog.c:670
bool gistvalidate(Oid opclassoid)
Definition: gistvalidate.c:33
GISTBuildBuffers * gistInitBuildBuffers(int pagesPerBuffer, int levelStep, int maxLevel)
bool gistgettuple(IndexScanDesc scan, ScanDirection dir)
Definition: gistget.c:612
void gistMakeUnionItVec(GISTSTATE *giststate, IndexTuple *itvec, int len, Datum *attr, bool *isnull)
Definition: gistutil.c:155
bool gistnospace(Page page, IndexTuple *itvec, int len, OffsetNumber todelete, Size freespace)
Definition: gistutil.c:59
bool gistplacetopage(Relation rel, Size freespace, GISTSTATE *giststate, Buffer buffer, IndexTuple *itup, int ntup, OffsetNumber oldoffnum, BlockNumber *newblkno, Buffer leftchildbuf, List **splitinfo, bool markfollowright, Relation heapRel, bool is_build)
Definition: gist.c:225
HeapTuple gistFetchTuple(GISTSTATE *giststate, Relation r, IndexTuple tuple)
Definition: gistutil.c:667
bool gistKeyIsEQ(GISTSTATE *giststate, int attno, Datum a, Datum b)
Definition: gistutil.c:281
int64 gistgetbitmap(IndexScanDesc scan, TIDBitmap *tbm)
Definition: gistget.c:743
GISTSTATE * initGISTstate(Relation index)
Definition: gist.c:1525
void gistfillbuffer(Page page, IndexTuple *itup, int len, OffsetNumber off)
Definition: gistutil.c:34
void gistbuildempty(Relation index)
Definition: gist.c:133
GistOptBufferingMode
Definition: gist_private.h:385
@ GIST_OPTION_BUFFERING_OFF
Definition: gist_private.h:388
@ GIST_OPTION_BUFFERING_AUTO
Definition: gist_private.h:386
@ GIST_OPTION_BUFFERING_ON
Definition: gist_private.h:387
void gistFreeBuildBuffers(GISTBuildBuffers *gfbb)
IndexTuple gistFormTuple(GISTSTATE *giststate, Relation r, const Datum *attdata, const bool *isnull, bool isleaf)
Definition: gistutil.c:575
IndexTuple * gistextractpage(Page page, int *len)
Definition: gistutil.c:95
struct GISTSearchItem GISTSearchItem
struct GISTScanOpaqueData GISTScanOpaqueData
void gistdentryinit(GISTSTATE *giststate, int nkey, GISTENTRY *e, Datum k, Relation r, Page pg, OffsetNumber o, bool l, bool isNull)
Definition: gistutil.c:547
GISTScanOpaqueData * GISTScanOpaque
Definition: gist_private.h:181
bool gistfitpage(IndexTuple *itvec, int len)
Definition: gistutil.c:79
IndexTuple gistgetadjusted(Relation r, IndexTuple oldtup, IndexTuple addtup, GISTSTATE *giststate)
Definition: gistutil.c:316
OffsetNumber gistchoose(Relation r, Page p, IndexTuple it, GISTSTATE *giststate)
Definition: gistutil.c:374
MemoryContext createTempGistContext(void)
Definition: gist.c:122
GISTNodeBuffer * gistGetNodeBuffer(GISTBuildBuffers *gfbb, GISTSTATE *giststate, BlockNumber nodeBlocknum, int level)
void gistSplitByKey(Relation r, Page page, IndexTuple *itup, int len, GISTSTATE *giststate, GistSplitVector *v, int attno)
Definition: gistsplit.c:623
struct GISTInsertStack GISTInsertStack
XLogRecPtr gistGetFakeLSN(Relation rel)
Definition: gistutil.c:1016
struct GISTSTATE GISTSTATE
void gistCompressValues(GISTSTATE *giststate, Relation r, const Datum *attdata, const bool *isnull, bool isleaf, Datum *compatt)
Definition: gistutil.c:596
void gistXLogPageReuse(Relation rel, Relation heaprel, BlockNumber blkno, FullTransactionId deleteXid)
Definition: gistxlog.c:594
bool gistcanreturn(Relation index, int attno)
Definition: gistget.c:793
XLogRecPtr gistXLogUpdate(Buffer buffer, OffsetNumber *todelete, int ntodelete, IndexTuple *itup, int ituplen, Buffer leftchildbuf)
Definition: gistxlog.c:629
void freeGISTstate(GISTSTATE *giststate)
Definition: gist.c:1653
SplitPageLayout * gistSplit(Relation r, Page page, IndexTuple *itup, int len, GISTSTATE *giststate)
Definition: gist.c:1438
bool gistPopItupFromNodeBuffer(GISTBuildBuffers *gfbb, GISTNodeBuffer *nodeBuffer, IndexTuple *itup)
IndexTuple * gistjoinvector(IndexTuple *itvec, int *len, IndexTuple *additvec, int addlen)
Definition: gistutil.c:114
struct GistSplitVector GistSplitVector
void gistinitpage(Page page, uint32 f)
Definition: gistutil.c:757
void gistUnloadNodeBuffers(GISTBuildBuffers *gfbb)
bytea * gistoptions(Datum reloptions, bool validate)
Definition: gistutil.c:912
struct GiSTOptions GiSTOptions
IndexTuple gistunion(Relation r, IndexTuple *itvec, int len, GISTSTATE *giststate)
Definition: gistutil.c:219
IndexBuildResult * gistbuild(Relation heap, Relation index, struct IndexInfo *indexInfo)
Definition: gistbuild.c:179
void GISTInitBuffer(Buffer b, uint32 f)
Definition: gistutil.c:773
struct gistxlogPage gistxlogPage
IndexTupleData * gistfillitupvec(IndexTuple *vec, int veclen, int *memlen)
Definition: gistutil.c:127
void gistcheckpage(Relation rel, Buffer buf)
Definition: gistutil.c:785
IndexBulkDeleteResult * gistvacuumcleanup(IndexVacuumInfo *info, IndexBulkDeleteResult *stats)
Definition: gistvacuum.c:75
float gistpenalty(GISTSTATE *giststate, int attno, GISTENTRY *orig, bool isNullOrig, GISTENTRY *add, bool isNullAdd)
Definition: gistutil.c:724
struct GISTBuildBuffers GISTBuildBuffers
int b
Definition: isn.c:70
int a
Definition: isn.c:69
struct IndexTupleData IndexTupleData
uint16 OffsetNumber
Definition: off.h:24
#define INDEX_MAX_KEYS
const void size_t len
static char * buf
Definition: pg_test_fsync.c:73
uintptr_t Datum
Definition: postgres.h:64
unsigned int Oid
Definition: postgres_ext.h:31
e
Definition: preproc-init.c:82
static const struct fns functions
Definition: regcomp.c:356
ScanDirection
Definition: sdir.h:25
Definition: fmgr.h:57
GISTNodeBuffer ** loadedBuffers
Definition: gist_private.h:375
List * bufferEmptyingQueue
Definition: gist_private.h:357
List ** buffersOnLevels
Definition: gist_private.h:368
MemoryContext context
Definition: gist_private.h:341
BlockNumber blkno
Definition: gist_private.h:210
OffsetNumber downlinkoffnum
Definition: gist_private.h:228
struct GISTInsertStack * parent
Definition: gist_private.h:231
Relation heapRel
Definition: gist_private.h:254
GISTInsertStack * stack
Definition: gist_private.h:258
BlockNumber prev
Definition: gist_private.h:48
GISTNodeBufferPage * pageBuffer
Definition: gist_private.h:304
BlockNumber pageBlocknum
Definition: gist_private.h:303
BlockNumber nodeBlocknum
Definition: gist_private.h:300
bool queuedForEmptying
Definition: gist_private.h:307
IndexTuple downlink
Definition: gist_private.h:422
FmgrInfo fetchFn[INDEX_MAX_KEYS]
Definition: gist_private.h:94
TupleDesc leafTupdesc
Definition: gist_private.h:80
TupleDesc fetchTupdesc
Definition: gist_private.h:83
TupleDesc nonLeafTupdesc
Definition: gist_private.h:81
FmgrInfo penaltyFn[INDEX_MAX_KEYS]
Definition: gist_private.h:90
MemoryContext tempCxt
Definition: gist_private.h:78
Oid supportCollation[INDEX_MAX_KEYS]
Definition: gist_private.h:97
FmgrInfo distanceFn[INDEX_MAX_KEYS]
Definition: gist_private.h:93
FmgrInfo consistentFn[INDEX_MAX_KEYS]
Definition: gist_private.h:86
MemoryContext scanCxt
Definition: gist_private.h:77
FmgrInfo decompressFn[INDEX_MAX_KEYS]
Definition: gist_private.h:89
FmgrInfo compressFn[INDEX_MAX_KEYS]
Definition: gist_private.h:88
FmgrInfo equalFn[INDEX_MAX_KEYS]
Definition: gist_private.h:92
FmgrInfo unionFn[INDEX_MAX_KEYS]
Definition: gist_private.h:87
FmgrInfo picksplitFn[INDEX_MAX_KEYS]
Definition: gist_private.h:91
OffsetNumber * killedItems
Definition: gist_private.h:168
pairingheap * queue
Definition: gist_private.h:159
OffsetNumber nPageData
Definition: gist_private.h:175
GISTSTATE * giststate
Definition: gist_private.h:156
MemoryContext queueCxt
Definition: gist_private.h:160
OffsetNumber curPageData
Definition: gist_private.h:176
GISTSearchHeapItem pageData[BLCKSZ/sizeof(IndexTupleData)]
Definition: gist_private.h:174
IndexOrderByDistance * distances
Definition: gist_private.h:165
BlockNumber curBlkno
Definition: gist_private.h:170
MemoryContext pageDataCxt
Definition: gist_private.h:177
ItemPointerData heapPtr
Definition: gist_private.h:120
OffsetNumber offnum
Definition: gist_private.h:125
union GISTSearchItem::@46 data
GISTSearchHeapItem heap
Definition: gist_private.h:138
BlockNumber blkno
Definition: gist_private.h:133
IndexOrderByDistance distances[FLEXIBLE_ARRAY_MEMBER]
Definition: gist_private.h:142
GistNSN parentlsn
Definition: gist_private.h:136
pairingheap_node phNode
Definition: gist_private.h:132
GistOptBufferingMode buffering_mode
Definition: gist_private.h:398
GIST_SPLITVEC splitVector
Definition: gist_private.h:237
Datum spl_lattr[INDEX_MAX_KEYS]
Definition: gist_private.h:239
bool spl_lisnull[INDEX_MAX_KEYS]
Definition: gist_private.h:241
Datum spl_rattr[INDEX_MAX_KEYS]
Definition: gist_private.h:243
bool spl_risnull[INDEX_MAX_KEYS]
Definition: gist_private.h:245
Definition: dynahash.c:220
Definition: pg_list.h:54
gistxlogPage block
Definition: gist_private.h:193
struct SplitPageLayout * next
Definition: gist_private.h:200
IndexTuple itup
Definition: gist_private.h:196
IndexTupleData * list
Definition: gist_private.h:194
BlockNumber blkno
Definition: gist_private.h:186
Definition: type.h:95
Definition: c.h:687
static void callback(struct sockaddr *addr, struct sockaddr *mask, void *unused)
Definition: test_ifaddrs.c:46
uint64 XLogRecPtr
Definition: xlogdefs.h:21