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-2019, 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 */
98 } GISTSTATE;
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 */
142  IndexOrderByDistance distances[FLEXIBLE_ARRAY_MEMBER];
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: */
174  GISTSearchHeapItem pageData[BLCKSZ / sizeof(IndexTupleData)];
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 */
188 } gistxlogPage;
189 
190 /* SplitedPageLayout - gistSplit function result */
191 typedef struct SplitedPageLayout
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 */
241  bool spl_lisnull[INDEX_MAX_KEYS];
242 
243  Datum spl_rattr[INDEX_MAX_KEYS]; /* Union of subkeys in
244  * splitVector.spl_right */
245  bool spl_risnull[INDEX_MAX_KEYS];
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 */
399 } GiSTOptions;
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  struct IndexInfo *indexInfo);
409 extern void freeGISTstate(GISTSTATE *giststate);
410 extern void gistdoinsert(Relation r,
411  IndexTuple itup,
412  Size freespace,
413  GISTSTATE *giststate,
414  Relation heapRel,
415  bool is_build);
416 
417 /* A List of these is returned from gistplacetopage() in *splitinfo */
418 typedef struct
419 {
420  Buffer buf; /* the split page "half" */
421  IndexTuple downlink; /* downlink for this half. */
423 
424 extern bool gistplacetopage(Relation rel, Size freespace, GISTSTATE *giststate,
425  Buffer buffer,
426  IndexTuple *itup, int ntup,
427  OffsetNumber oldoffnum, BlockNumber *newblkno,
428  Buffer leftchildbuf,
429  List **splitinfo,
430  bool markfollowright,
431  Relation heapRel,
432  bool is_build);
433 
434 extern SplitedPageLayout *gistSplit(Relation r, Page page, IndexTuple *itup,
435  int len, GISTSTATE *giststate);
436 
437 /* gistxlog.c */
438 extern XLogRecPtr gistXLogPageDelete(Buffer buffer,
439  FullTransactionId xid, Buffer parentBuffer,
440  OffsetNumber downlinkOffset);
441 
442 extern void gistXLogPageReuse(Relation rel, BlockNumber blkno,
443  FullTransactionId latestRemovedXid);
444 
445 extern XLogRecPtr gistXLogUpdate(Buffer buffer,
446  OffsetNumber *todelete, int ntodelete,
447  IndexTuple *itup, int ntup,
448  Buffer leftchild);
449 
450 extern XLogRecPtr gistXLogDelete(Buffer buffer, OffsetNumber *todelete,
451  int ntodelete, TransactionId latestRemovedXid);
452 
453 extern XLogRecPtr gistXLogSplit(bool page_is_leaf,
454  SplitedPageLayout *dist,
455  BlockNumber origrlink, GistNSN oldnsn,
456  Buffer leftchild, bool markfollowright);
457 
458 /* gistget.c */
459 extern bool gistgettuple(IndexScanDesc scan, ScanDirection dir);
460 extern int64 gistgetbitmap(IndexScanDesc scan, TIDBitmap *tbm);
461 extern bool gistcanreturn(Relation index, int attno);
462 
463 /* gistvalidate.c */
464 extern bool gistvalidate(Oid opclassoid);
465 
466 /* gistutil.c */
467 
468 #define GiSTPageSize \
469  ( BLCKSZ - SizeOfPageHeaderData - MAXALIGN(sizeof(GISTPageOpaqueData)) )
470 
471 #define GIST_MIN_FILLFACTOR 10
472 #define GIST_DEFAULT_FILLFACTOR 90
473 
474 extern bytea *gistoptions(Datum reloptions, bool validate);
475 extern bool gistproperty(Oid index_oid, int attno,
476  IndexAMProperty prop, const char *propname,
477  bool *res, bool *isnull);
478 extern bool gistfitpage(IndexTuple *itvec, int len);
479 extern bool gistnospace(Page page, IndexTuple *itvec, int len, OffsetNumber todelete, Size freespace);
480 extern void gistcheckpage(Relation rel, Buffer buf);
481 extern Buffer gistNewBuffer(Relation r);
482 extern bool gistPageRecyclable(Page page);
483 extern void gistfillbuffer(Page page, IndexTuple *itup, int len,
484  OffsetNumber off);
485 extern IndexTuple *gistextractpage(Page page, int *len /* out */ );
486 extern IndexTuple *gistjoinvector(IndexTuple *itvec, int *len,
487  IndexTuple *additvec, int addlen);
488 extern IndexTupleData *gistfillitupvec(IndexTuple *vec, int veclen, int *memlen);
489 
490 extern IndexTuple gistunion(Relation r, IndexTuple *itvec,
491  int len, GISTSTATE *giststate);
493  IndexTuple oldtup,
494  IndexTuple addtup,
495  GISTSTATE *giststate);
496 extern IndexTuple gistFormTuple(GISTSTATE *giststate,
497  Relation r, Datum *attdata, bool *isnull, bool isleaf);
498 
500  IndexTuple it,
501  GISTSTATE *giststate);
502 
503 extern void GISTInitBuffer(Buffer b, uint32 f);
504 extern void gistdentryinit(GISTSTATE *giststate, int nkey, GISTENTRY *e,
505  Datum k, Relation r, Page pg, OffsetNumber o,
506  bool l, bool isNull);
507 
508 extern float gistpenalty(GISTSTATE *giststate, int attno,
509  GISTENTRY *key1, bool isNull1,
510  GISTENTRY *key2, bool isNull2);
511 extern void gistMakeUnionItVec(GISTSTATE *giststate, IndexTuple *itvec, int len,
512  Datum *attr, bool *isnull);
513 extern bool gistKeyIsEQ(GISTSTATE *giststate, int attno, Datum a, Datum b);
514 extern void gistDeCompressAtt(GISTSTATE *giststate, Relation r, IndexTuple tuple, Page p,
515  OffsetNumber o, GISTENTRY *attdata, bool *isnull);
516 extern HeapTuple gistFetchTuple(GISTSTATE *giststate, Relation r,
517  IndexTuple tuple);
518 extern void gistMakeUnionKey(GISTSTATE *giststate, int attno,
519  GISTENTRY *entry1, bool isnull1,
520  GISTENTRY *entry2, bool isnull2,
521  Datum *dst, bool *dstisnull);
522 
524 
525 /* gistvacuum.c */
527  IndexBulkDeleteResult *stats,
529  void *callback_state);
531  IndexBulkDeleteResult *stats);
532 
533 /* gistsplit.c */
534 extern void gistSplitByKey(Relation r, Page page, IndexTuple *itup,
535  int len, GISTSTATE *giststate,
536  GistSplitVector *v,
537  int attno);
538 
539 /* gistbuild.c */
541  struct IndexInfo *indexInfo);
542 extern void gistValidateBufferingOption(const char *value);
543 
544 /* gistbuildbuffers.c */
545 extern GISTBuildBuffers *gistInitBuildBuffers(int pagesPerBuffer, int levelStep,
546  int maxLevel);
548  GISTSTATE *giststate,
549  BlockNumber blkno, int level);
551  GISTNodeBuffer *nodeBuffer, IndexTuple item);
553  GISTNodeBuffer *nodeBuffer, IndexTuple *item);
554 extern void gistFreeBuildBuffers(GISTBuildBuffers *gfbb);
556  GISTSTATE *giststate, Relation r,
557  int level, Buffer buffer,
558  List *splitinfo);
559 extern void gistUnloadNodeBuffers(GISTBuildBuffers *gfbb);
560 
561 #endif /* GIST_PRIVATE_H */
void gistFreeBuildBuffers(GISTBuildBuffers *gfbb)
struct gistxlogPage gistxlogPage
void gistdoinsert(Relation r, IndexTuple itup, Size freespace, GISTSTATE *giststate, Relation heapRel, bool is_build)
Definition: gist.c:623
BlockNumber blkno
Definition: gist_private.h:210
bool gistPageRecyclable(Page page)
Definition: gistutil.c:883
Definition: fmgr.h:56
BlockNumber pageBlocknum
Definition: gist_private.h:303
void gistbuildempty(Relation index)
Definition: gist.c:125
Buffer gistNewBuffer(Relation r)
Definition: gistutil.c:810
IndexOrderByDistance * distances
Definition: gist_private.h:165
BlockNumber blkno
Definition: gist_private.h:133
GistOptBufferingMode buffering_mode
Definition: gist_private.h:398
HeapTuple gistFetchTuple(GISTSTATE *giststate, Relation r, IndexTuple tuple)
Definition: gistutil.c:659
IndexAMProperty
Definition: amapi.h:34
XLogRecPtr gistXLogSplit(bool page_is_leaf, SplitedPageLayout *dist, BlockNumber origrlink, GistNSN oldnsn, Buffer leftchild, bool markfollowright)
Definition: gistxlog.c:518
struct GISTSTATE GISTSTATE
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:216
struct GISTSearchItem GISTSearchItem
uint32 TransactionId
Definition: c.h:507
OffsetNumber * killedItems
Definition: gist_private.h:168
BlockNumber blkno
Definition: gist_private.h:186
FmgrInfo fetchFn[INDEX_MAX_KEYS]
Definition: gist_private.h:94
GISTNodeBuffer * gistGetNodeBuffer(GISTBuildBuffers *gfbb, GISTSTATE *giststate, BlockNumber blkno, int level)
IndexTuple gistunion(Relation r, IndexTuple *itvec, int len, GISTSTATE *giststate)
Definition: gistutil.c:219
Oid supportCollation[INDEX_MAX_KEYS]
Definition: gist_private.h:97
pairingheap * queue
Definition: gist_private.h:159
FmgrInfo compressFn[INDEX_MAX_KEYS]
Definition: gist_private.h:88
MemoryContext context
Definition: gist_private.h:341
Relation heapRel
Definition: gist_private.h:254
void gistMakeUnionItVec(GISTSTATE *giststate, IndexTuple *itvec, int len, Datum *attr, bool *isnull)
Definition: gistutil.c:155
void gistSplitByKey(Relation r, Page page, IndexTuple *itup, int len, GISTSTATE *giststate, GistSplitVector *v, int attno)
Definition: gistsplit.c:623
FmgrInfo equalFn[INDEX_MAX_KEYS]
Definition: gist_private.h:92
MemoryContext queueCxt
Definition: gist_private.h:160
MemoryContext createTempGistContext(void)
Definition: gist.c:114
BlockNumber curBlkno
Definition: gist_private.h:170
List ** buffersOnLevels
Definition: gist_private.h:368
BlockNumber nodeBlocknum
Definition: gist_private.h:300
GIST_SPLITVEC splitVector
Definition: gist_private.h:237
static struct @145 value
uint32 BlockNumber
Definition: block.h:31
IndexBulkDeleteResult * gistbulkdelete(IndexVacuumInfo *info, IndexBulkDeleteResult *stats, IndexBulkDeleteCallback callback, void *callback_state)
Definition: gistvacuum.c:83
unsigned int Oid
Definition: postgres_ext.h:31
MemoryContext pageDataCxt
Definition: gist_private.h:177
IndexTupleData * list
Definition: gist_private.h:194
struct GiSTOptions GiSTOptions
bool gistvalidate(Oid opclassoid)
Definition: gistvalidate.c:34
struct GISTScanOpaqueData GISTScanOpaqueData
signed int int32
Definition: c.h:346
uint16 OffsetNumber
Definition: off.h:24
Definition: type.h:89
GISTSTATE * giststate
Definition: gist_private.h:156
gistxlogPage block
Definition: gist_private.h:193
IndexUniqueCheck
Definition: genam.h:112
XLogRecPtr gistXLogPageDelete(Buffer buffer, FullTransactionId xid, Buffer parentBuffer, OffsetNumber downlinkOffset)
Definition: gistxlog.c:575
Definition: dynahash.c:208
GISTNodeBufferPage * pageBuffer
Definition: gist_private.h:304
struct GistSplitVector GistSplitVector
FmgrInfo consistentFn[INDEX_MAX_KEYS]
Definition: gist_private.h:86
List * bufferEmptyingQueue
Definition: gist_private.h:357
void gistfillbuffer(Page page, IndexTuple *itup, int len, OffsetNumber off)
Definition: gistutil.c:34
static void callback(struct sockaddr *addr, struct sockaddr *mask, void *unused)
Definition: test_ifaddrs.c:48
GISTScanOpaqueData * GISTScanOpaque
Definition: gist_private.h:181
void GISTInitBuffer(Buffer b, uint32 f)
Definition: gistutil.c:749
MemoryContext tempCxt
Definition: gist_private.h:78
void gistPushItupToNodeBuffer(GISTBuildBuffers *gfbb, GISTNodeBuffer *nodeBuffer, IndexTuple item)
IndexTuple downlink
Definition: gist_private.h:421
float gistpenalty(GISTSTATE *giststate, int attno, GISTENTRY *key1, bool isNull1, GISTENTRY *key2, bool isNull2)
Definition: gistutil.c:716
GISTInsertStack * stack
Definition: gist_private.h:258
static char * buf
Definition: pg_test_fsync.c:68
bool gistPopItupFromNodeBuffer(GISTBuildBuffers *gfbb, GISTNodeBuffer *nodeBuffer, IndexTuple *item)
XLogRecPtr gistGetFakeLSN(Relation rel)
Definition: gistutil.c:1027
FmgrInfo picksplitFn[INDEX_MAX_KEYS]
Definition: gist_private.h:91
ScanDirection
Definition: sdir.h:22
GistOptBufferingMode
Definition: gist_private.h:384
IndexTuple gistgetadjusted(Relation r, IndexTuple oldtup, IndexTuple addtup, GISTSTATE *giststate)
Definition: gistutil.c:316
FmgrInfo penaltyFn[INDEX_MAX_KEYS]
Definition: gist_private.h:90
unsigned int uint32
Definition: c.h:358
OffsetNumber nPageData
Definition: gist_private.h:175
void gistRelocateBuildBuffersOnSplit(GISTBuildBuffers *gfbb, GISTSTATE *giststate, Relation r, int level, Buffer buffer, List *splitinfo)
void gistDeCompressAtt(GISTSTATE *giststate, Relation r, IndexTuple tuple, Page p, OffsetNumber o, GISTENTRY *attdata, bool *isnull)
Definition: gistutil.c:296
IndexBuildResult * gistbuild(Relation heap, Relation index, struct IndexInfo *indexInfo)
Definition: gistbuild.c:116
bool gistfitpage(IndexTuple *itvec, int len)
Definition: gistutil.c:79
struct SplitedPageLayout * next
Definition: gist_private.h:200
void gistXLogPageReuse(Relation rel, BlockNumber blkno, FullTransactionId latestRemovedXid)
Definition: gistxlog.c:599
GISTSTATE * initGISTstate(Relation index)
Definition: gist.c:1486
FmgrInfo decompressFn[INDEX_MAX_KEYS]
Definition: gist_private.h:89
bool gistcanreturn(Relation index, int attno)
Definition: gistget.c:795
void gistdentryinit(GISTSTATE *giststate, int nkey, GISTENTRY *e, Datum k, Relation r, Page pg, OffsetNumber o, bool l, bool isNull)
Definition: gistutil.c:547
bool gistKeyIsEQ(GISTSTATE *giststate, int attno, Datum a, Datum b)
Definition: gistutil.c:281
TupleDesc leafTupdesc
Definition: gist_private.h:80
OffsetNumber downlinkoffnum
Definition: gist_private.h:228
GISTSearchHeapItem heap
Definition: gist_private.h:138
bool queuedForEmptying
Definition: gist_private.h:307
IndexTuple * gistjoinvector(IndexTuple *itvec, int *len, IndexTuple *additvec, int addlen)
Definition: gistutil.c:114
bool gistproperty(Oid index_oid, int attno, IndexAMProperty prop, const char *propname, bool *res, bool *isnull)
Definition: gistutil.c:944
bool gistgettuple(IndexScanDesc scan, ScanDirection dir)
Definition: gistget.c:614
bool gistinsert(Relation r, Datum *values, bool *isnull, ItemPointer ht_ctid, Relation heapRel, IndexUniqueCheck checkUnique, struct IndexInfo *indexInfo)
Definition: gist.c:151
uintptr_t Datum
Definition: postgres.h:367
struct IndexTupleData IndexTupleData
bool gistnospace(Page page, IndexTuple *itvec, int len, OffsetNumber todelete, Size freespace)
Definition: gistutil.c:59
GISTBuildBuffers * gistInitBuildBuffers(int pagesPerBuffer, int levelStep, int maxLevel)
SplitedPageLayout * gistSplit(Relation r, Page page, IndexTuple *itup, int len, GISTSTATE *giststate)
Definition: gist.c:1399
void freeGISTstate(GISTSTATE *giststate)
Definition: gist.c:1614
TupleDesc nonLeafTupdesc
Definition: gist_private.h:81
struct SplitedPageLayout SplitedPageLayout
BlockNumber prev
Definition: gist_private.h:48
ItemPointerData heapPtr
Definition: gist_private.h:120
pairingheap_node phNode
Definition: gist_private.h:132
uint64 XLogRecPtr
Definition: xlogdefs.h:21
void gistMakeUnionKey(GISTSTATE *giststate, int attno, GISTENTRY *entry1, bool isnull1, GISTENTRY *entry2, bool isnull2, Datum *dst, bool *dstisnull)
Definition: gistutil.c:233
bytea * gistoptions(Datum reloptions, bool validate)
Definition: gistutil.c:909
TupleDesc fetchTupdesc
Definition: gist_private.h:83
#define INDEX_MAX_KEYS
size_t Size
Definition: c.h:466
int64 gistgetbitmap(IndexScanDesc scan, TIDBitmap *tbm)
Definition: gistget.c:745
#define leftchild(x)
Definition: fsmpage.c:29
OffsetNumber curPageData
Definition: gist_private.h:176
FmgrInfo distanceFn[INDEX_MAX_KEYS]
Definition: gist_private.h:93
void gistValidateBufferingOption(const char *value)
XLogRecPtr GistNSN
Definition: gist.h:51
GISTNodeBuffer ** loadedBuffers
Definition: gist_private.h:375
static Datum values[MAXATTR]
Definition: bootstrap.c:167
e
Definition: preproc-init.c:82
IndexTuple * gistextractpage(Page page, int *len)
Definition: gistutil.c:95
struct GISTSearchHeapItem GISTSearchHeapItem
OffsetNumber offnum
Definition: gist_private.h:125
struct GISTBuildBuffers GISTBuildBuffers
MemoryContext scanCxt
Definition: gist_private.h:77
Definition: c.h:549
XLogRecPtr gistXLogDelete(Buffer buffer, OffsetNumber *todelete, int ntodelete, TransactionId latestRemovedXid)
Definition: gistxlog.c:673
OffsetNumber gistchoose(Relation r, Page p, IndexTuple it, GISTSTATE *giststate)
Definition: gistutil.c:374
IndexTupleData * gistfillitupvec(IndexTuple *vec, int veclen, int *memlen)
Definition: gistutil.c:127
FmgrInfo unionFn[INDEX_MAX_KEYS]
Definition: gist_private.h:87
Definition: pg_list.h:50
GistNSN parentlsn
Definition: gist_private.h:136
int Buffer
Definition: buf.h:23
struct GISTInsertStack * parent
Definition: gist_private.h:231
struct GISTInsertStack GISTInsertStack
Pointer Page
Definition: bufpage.h:78
void gistcheckpage(Relation rel, Buffer buf)
Definition: gistutil.c:771
bool(* IndexBulkDeleteCallback)(ItemPointer itemptr, void *state)
Definition: genam.h:84
void gistUnloadNodeBuffers(GISTBuildBuffers *gfbb)
IndexBulkDeleteResult * gistvacuumcleanup(IndexVacuumInfo *info, IndexBulkDeleteResult *stats)
Definition: gistvacuum.c:101
XLogRecPtr gistXLogUpdate(Buffer buffer, OffsetNumber *todelete, int ntodelete, IndexTuple *itup, int ntup, Buffer leftchild)
Definition: gistxlog.c:632
IndexTuple gistFormTuple(GISTSTATE *giststate, Relation r, Datum *attdata, bool *isnull, bool isleaf)