PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
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-2016, 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 "access/xlogreader.h"
21 #include "fmgr.h"
22 #include "lib/pairingheap.h"
23 #include "storage/bufmgr.h"
24 #include "storage/buffile.h"
25 #include "utils/hsearch.h"
26 #include "access/genam.h"
27 
28 /*
29  * Maximum number of "halves" a page can be split into in one operation.
30  * Typically a split produces 2 halves, but can be more if keys have very
31  * different lengths, or when inserting multiple keys in one operation (as
32  * when inserting downlinks to an internal node). There is no theoretical
33  * limit on this, but in practice if you get more than a handful page halves
34  * in one split, there's something wrong with the opclass implementation.
35  * GIST_MAX_SPLIT_PAGES is an arbitrary limit on that, used to size some
36  * local arrays used during split. Note that there is also a limit on the
37  * number of buffers that can be held locked at a time, MAX_SIMUL_LWLOCKS,
38  * so if you raise this higher than that limit, you'll just get a different
39  * error.
40  */
41 #define GIST_MAX_SPLIT_PAGES 75
42 
43 /* Buffer lock modes */
44 #define GIST_SHARE BUFFER_LOCK_SHARE
45 #define GIST_EXCLUSIVE BUFFER_LOCK_EXCLUSIVE
46 #define GIST_UNLOCK BUFFER_LOCK_UNLOCK
47 
48 typedef struct
49 {
52  char tupledata[FLEXIBLE_ARRAY_MEMBER];
54 
55 #define BUFFER_PAGE_DATA_OFFSET MAXALIGN(offsetof(GISTNodeBufferPage, tupledata))
56 /* Returns free space in node buffer page */
57 #define PAGE_FREE_SPACE(nbp) (nbp->freespace)
58 /* Checks if node buffer page is empty */
59 #define PAGE_IS_EMPTY(nbp) (nbp->freespace == BLCKSZ - BUFFER_PAGE_DATA_OFFSET)
60 /* Checks if node buffers page don't contain sufficient space for index tuple */
61 #define PAGE_NO_SPACE(nbp, itup) (PAGE_FREE_SPACE(nbp) < \
62  MAXALIGN(IndexTupleSize(itup)))
63 
64 /*
65  * GISTSTATE: information needed for any GiST index operation
66  *
67  * This struct retains call info for the index's opclass-specific support
68  * functions (per index column), plus the index's tuple descriptor.
69  *
70  * scanCxt holds the GISTSTATE itself as well as any data that lives for the
71  * lifetime of the index operation. We pass this to the support functions
72  * via fn_mcxt, so that they can store scan-lifespan data in it. The
73  * functions are invoked in tempCxt, which is typically short-lifespan
74  * (that is, it's reset after each tuple). However, tempCxt can be the same
75  * as scanCxt if we're not bothering with per-tuple context resets.
76  */
77 typedef struct GISTSTATE
78 {
79  MemoryContext scanCxt; /* context for scan-lifespan data */
80  MemoryContext tempCxt; /* short-term context for calling functions */
81 
82  TupleDesc tupdesc; /* index's tuple descriptor */
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 an RBTree to manage the distance-order
111  * queue. Each GISTSearchTreeItem stores all unvisited items of the same
112  * distance; they are GISTSearchItems chained together via their next fields.
113  *
114  * In a non-ordered search (no order-by operators), the RBTree degenerates
115  * to a single item, which we use as a queue of unvisited index pages only.
116  * In this case matched heap items from the current index leaf page are
117  * remembered in GISTScanOpaqueData.pageData[] and returned directly from
118  * there, instead of building a separate GISTSearchItem for each one.
119  */
120 
121 /* Individual heap tuple to be visited */
122 typedef struct GISTSearchHeapItem
123 {
125  bool recheck; /* T if quals must be rechecked */
126  bool recheckDistances; /* T if distances must be rechecked */
127  IndexTuple ftup; /* data fetched back from the index, used in
128  * index-only scans */
129  OffsetNumber offnum; /* track offset in page to mark tuple as
130  * LP_DEAD */
132 
133 /* Unvisited item, either index page or heap tuple */
134 typedef struct GISTSearchItem
135 {
137  BlockNumber blkno; /* index page number, or InvalidBlockNumber */
138  union
139  {
140  GistNSN parentlsn; /* parent page's LSN, if index page */
141  /* we must store parentlsn to detect whether a split occurred */
142  GISTSearchHeapItem heap; /* heap info, if heap tuple */
143  } data;
144  double distances[FLEXIBLE_ARRAY_MEMBER]; /* numberOfOrderBys
145  * entries */
147 
148 #define GISTSearchItemIsHeap(item) ((item).blkno == InvalidBlockNumber)
149 
150 #define SizeOfGISTSearchItem(n_distances) (offsetof(GISTSearchItem, distances) + sizeof(double) * (n_distances))
151 
152 /*
153  * GISTScanOpaqueData: private state for a scan of a GiST index
154  */
155 typedef struct GISTScanOpaqueData
156 {
157  GISTSTATE *giststate; /* index information, see above */
158  Oid *orderByTypes; /* datatypes of ORDER BY expressions */
159 
160  pairingheap *queue; /* queue of unvisited items */
161  MemoryContext queueCxt; /* context holding the queue */
162  bool qual_ok; /* false if qual can never be satisfied */
163  bool firstCall; /* true until first gistgettuple call */
164 
165  /* pre-allocated workspace arrays */
166  double *distances; /* output area for gistindex_keytest */
167 
168  /* info about killed items if any (killedItems is NULL if never used) */
169  OffsetNumber *killedItems; /* offset numbers of killed items */
170  int numKilled; /* number of currently stored items */
171  BlockNumber curBlkno; /* current number of block */
172  GistNSN curPageLSN; /* pos in the WAL stream when page was read */
173 
174  /* In a non-ordered search, returnable heap items are stored here: */
176  OffsetNumber nPageData; /* number of valid items in array */
177  OffsetNumber curPageData; /* next item to return */
178  MemoryContext pageDataCxt; /* context holding the fetched tuples, for
179  * index-only scans */
181 
183 
184 
185 /* XLog stuff */
186 
187 #define XLOG_GIST_PAGE_UPDATE 0x00
188  /* #define XLOG_GIST_NEW_ROOT 0x20 */ /* not used anymore */
189 #define XLOG_GIST_PAGE_SPLIT 0x30
190  /* #define XLOG_GIST_INSERT_COMPLETE 0x40 */ /* not used anymore */
191 #define XLOG_GIST_CREATE_INDEX 0x50
192  /* #define XLOG_GIST_PAGE_DELETE 0x60 */ /* not used anymore */
193 
194 /*
195  * Backup Blk 0: updated page.
196  * Backup Blk 1: If this operation completes a page split, by inserting a
197  * downlink for the split page, the left half of the split
198  */
199 typedef struct gistxlogPageUpdate
200 {
201  /* number of deleted offsets */
204 
205  /*
206  * In payload of blk 0 : 1. todelete OffsetNumbers 2. tuples to insert
207  */
209 
210 /*
211  * Backup Blk 0: If this operation completes a page split, by inserting a
212  * downlink for the split page, the left half of the split
213  * Backup Blk 1 - npage: split pages (1 is the original page)
214  */
215 typedef struct gistxlogPageSplit
216 {
217  BlockNumber origrlink; /* rightlink of the page before split */
218  GistNSN orignsn; /* NSN of the page before split */
219  bool origleaf; /* was splitted page a leaf page? */
220 
221  uint16 npage; /* # of pages in the split */
222  bool markfollowright; /* set F_FOLLOW_RIGHT flags */
223 
224  /*
225  * follow: 1. gistxlogPage and array of IndexTupleData per page
226  */
228 
229 typedef struct gistxlogPage
230 {
232  int num; /* number of index tuples following */
233 } gistxlogPage;
234 
235 /* SplitedPageLayout - gistSplit function result */
236 typedef struct SplitedPageLayout
237 {
240  int lenlist;
241  IndexTuple itup; /* union key for page */
242  Page page; /* to operate */
243  Buffer buffer; /* to write after all proceed */
244 
247 
248 /*
249  * GISTInsertStack used for locking buffers and transfer arguments during
250  * insertion
251  */
252 typedef struct GISTInsertStack
253 {
254  /* current page */
258 
259  /*
260  * log sequence number from page->lsn to recognize page update and compare
261  * it with page's nsn to recognize page split
262  */
264 
265  /* offset of the downlink in the parent page, that points to this page */
267 
268  /* pointer to parent */
271 
272 /* Working state and results for multi-column split logic in gistsplit.c */
273 typedef struct GistSplitVector
274 {
275  GIST_SPLITVEC splitVector; /* passed to/from user PickSplit method */
276 
277  Datum spl_lattr[INDEX_MAX_KEYS]; /* Union of subkeys in
278  * splitVector.spl_left */
280 
281  Datum spl_rattr[INDEX_MAX_KEYS]; /* Union of subkeys in
282  * splitVector.spl_right */
284 
285  bool *spl_dontcare; /* flags tuples which could go to either side
286  * of the split for zero penalty */
288 
289 typedef struct
290 {
292  Size freespace; /* free space to be left */
293 
296 
297 /* root page of a gist index */
298 #define GIST_ROOT_BLKNO 0
299 
300 /*
301  * Before PostgreSQL 9.1, we used rely on so-called "invalid tuples" on inner
302  * pages to finish crash recovery of incomplete page splits. If a crash
303  * happened in the middle of a page split, so that the downlink pointers were
304  * not yet inserted, crash recovery inserted a special downlink pointer. The
305  * semantics of an invalid tuple was that it if you encounter one in a scan,
306  * it must always be followed, because we don't know if the tuples on the
307  * child page match or not.
308  *
309  * We no longer create such invalid tuples, we now mark the left-half of such
310  * an incomplete split with the F_FOLLOW_RIGHT flag instead, and finish the
311  * split properly the next time we need to insert on that page. To retain
312  * on-disk compatibility for the sake of pg_upgrade, we still store 0xffff as
313  * the offset number of all inner tuples. If we encounter any invalid tuples
314  * with 0xfffe during insertion, we throw an error, though scans still handle
315  * them. You should only encounter invalid tuples if you pg_upgrade a pre-9.1
316  * gist index which already has invalid tuples in it because of a crash. That
317  * should be rare, and you are recommended to REINDEX anyway if you have any
318  * invalid tuples in an index, so throwing an error is as far as we go with
319  * supporting that.
320  */
321 #define TUPLE_IS_VALID 0xffff
322 #define TUPLE_IS_INVALID 0xfffe
323 
324 #define GistTupleIsInvalid(itup) ( ItemPointerGetOffsetNumber( &((itup)->t_tid) ) == TUPLE_IS_INVALID )
325 #define GistTupleSetValid(itup) ItemPointerSetOffsetNumber( &((itup)->t_tid), TUPLE_IS_VALID )
326 
327 
328 
329 
330 /*
331  * A buffer attached to an internal node, used when building an index in
332  * buffering mode.
333  */
334 typedef struct
335 {
336  BlockNumber nodeBlocknum; /* index block # this buffer is for */
337  int32 blocksCount; /* current # of blocks occupied by buffer */
338 
339  BlockNumber pageBlocknum; /* temporary file block # */
340  GISTNodeBufferPage *pageBuffer; /* in-memory buffer page */
341 
342  /* is this buffer queued for emptying? */
344 
345  /* is this a temporary copy, not in the hash table? */
346  bool isTemp;
347 
348  int level; /* 0 == leaf */
350 
351 /*
352  * Does specified level have buffers? (Beware of multiple evaluation of
353  * arguments.)
354  */
355 #define LEVEL_HAS_BUFFERS(nlevel, gfbb) \
356  ((nlevel) != 0 && (nlevel) % (gfbb)->levelStep == 0 && \
357  (nlevel) != (gfbb)->rootlevel)
358 
359 /* Is specified buffer at least half-filled (should be queued for emptying)? */
360 #define BUFFER_HALF_FILLED(nodeBuffer, gfbb) \
361  ((nodeBuffer)->blocksCount > (gfbb)->pagesPerBuffer / 2)
362 
363 /*
364  * Is specified buffer full? Our buffers can actually grow indefinitely,
365  * beyond the "maximum" size, so this just means whether the buffer has grown
366  * beyond the nominal maximum size.
367  */
368 #define BUFFER_OVERFLOWED(nodeBuffer, gfbb) \
369  ((nodeBuffer)->blocksCount > (gfbb)->pagesPerBuffer)
370 
371 /*
372  * Data structure with general information about build buffers.
373  */
374 typedef struct GISTBuildBuffers
375 {
376  /* Persistent memory context for the buffers and metadata. */
378 
379  BufFile *pfile; /* Temporary file to store buffers in */
380  long nFileBlocks; /* Current size of the temporary file */
381 
382  /*
383  * resizable array of free blocks.
384  */
385  long *freeBlocks;
386  int nFreeBlocks; /* # of currently free blocks in the array */
387  int freeBlocksLen; /* current allocated length of the array */
388 
389  /* Hash for buffers by block number */
391 
392  /* List of buffers scheduled for emptying */
394 
395  /*
396  * Parameters to the buffering build algorithm. levelStep determines which
397  * levels in the tree have buffers, and pagesPerBuffer determines how
398  * large each buffer is.
399  */
402 
403  /* Array of lists of buffers on each level, for final emptying */
406 
407  /*
408  * Dynamically-sized array of buffers that currently have their last page
409  * loaded in main memory.
410  */
412  int loadedBuffersCount; /* # of entries in loadedBuffers */
413  int loadedBuffersLen; /* allocated size of loadedBuffers */
414 
415  /* Level of the current root node (= height of the index tree - 1) */
418 
419 /*
420  * Storage type for GiST's reloptions
421  */
422 typedef struct GiSTOptions
423 {
424  int32 vl_len_; /* varlena header (do not touch directly!) */
425  int fillfactor; /* page fill factor in percent (0..100) */
426  int bufferingModeOffset; /* use buffering build? */
427 } GiSTOptions;
428 
429 /* gist.c */
431 extern void gistbuildempty(Relation index);
432 extern bool gistinsert(Relation r, Datum *values, bool *isnull,
433  ItemPointer ht_ctid, Relation heapRel,
434  IndexUniqueCheck checkUnique);
437 extern void freeGISTstate(GISTSTATE *giststate);
438 extern void gistdoinsert(Relation r,
439  IndexTuple itup,
440  Size freespace,
441  GISTSTATE *GISTstate);
442 
443 /* A List of these is returned from gistplacetopage() in *splitinfo */
444 typedef struct
445 {
446  Buffer buf; /* the split page "half" */
447  IndexTuple downlink; /* downlink for this half. */
449 
450 extern bool gistplacetopage(Relation rel, Size freespace, GISTSTATE *giststate,
451  Buffer buffer,
452  IndexTuple *itup, int ntup,
453  OffsetNumber oldoffnum, BlockNumber *newblkno,
454  Buffer leftchildbuf,
455  List **splitinfo,
456  bool markleftchild);
457 
458 extern SplitedPageLayout *gistSplit(Relation r, Page page, IndexTuple *itup,
459  int len, GISTSTATE *giststate);
460 
461 /* gistxlog.c */
462 extern void gist_redo(XLogReaderState *record);
463 extern void gist_desc(StringInfo buf, XLogReaderState *record);
464 extern const char *gist_identify(uint8 info);
465 extern void gist_xlog_startup(void);
466 extern void gist_xlog_cleanup(void);
467 
468 extern XLogRecPtr gistXLogUpdate(RelFileNode node, Buffer buffer,
469  OffsetNumber *todelete, int ntodelete,
470  IndexTuple *itup, int ntup,
471  Buffer leftchild);
472 
474  BlockNumber blkno, bool page_is_leaf,
475  SplitedPageLayout *dist,
476  BlockNumber origrlink, GistNSN oldnsn,
477  Buffer leftchild, bool markfollowright);
478 
479 /* gistget.c */
480 extern bool gistgettuple(IndexScanDesc scan, ScanDirection dir);
481 extern int64 gistgetbitmap(IndexScanDesc scan, TIDBitmap *tbm);
482 extern bool gistcanreturn(Relation index, int attno);
483 
484 /* gistvalidate.c */
485 extern bool gistvalidate(Oid opclassoid);
486 
487 /* gistutil.c */
488 
489 #define GiSTPageSize \
490  ( BLCKSZ - SizeOfPageHeaderData - MAXALIGN(sizeof(GISTPageOpaqueData)) )
491 
492 #define GIST_MIN_FILLFACTOR 10
493 #define GIST_DEFAULT_FILLFACTOR 90
494 
495 extern bytea *gistoptions(Datum reloptions, bool validate);
496 extern bool gistfitpage(IndexTuple *itvec, int len);
497 extern bool gistnospace(Page page, IndexTuple *itvec, int len, OffsetNumber todelete, Size freespace);
498 extern void gistcheckpage(Relation rel, Buffer buf);
499 extern Buffer gistNewBuffer(Relation r);
500 extern void gistfillbuffer(Page page, IndexTuple *itup, int len,
501  OffsetNumber off);
502 extern IndexTuple *gistextractpage(Page page, int *len /* out */ );
503 extern IndexTuple *gistjoinvector(
504  IndexTuple *itvec, int *len,
505  IndexTuple *additvec, int addlen);
506 extern IndexTupleData *gistfillitupvec(IndexTuple *vec, int veclen, int *memlen);
507 
508 extern IndexTuple gistunion(Relation r, IndexTuple *itvec,
509  int len, GISTSTATE *giststate);
511  IndexTuple oldtup,
512  IndexTuple addtup,
513  GISTSTATE *giststate);
514 extern IndexTuple gistFormTuple(GISTSTATE *giststate,
515  Relation r, Datum *attdata, bool *isnull, bool isleaf);
516 
518  IndexTuple it,
519  GISTSTATE *giststate);
520 
521 extern void GISTInitBuffer(Buffer b, uint32 f);
522 extern void gistdentryinit(GISTSTATE *giststate, int nkey, GISTENTRY *e,
523  Datum k, Relation r, Page pg, OffsetNumber o,
524  bool l, bool isNull);
525 
526 extern float gistpenalty(GISTSTATE *giststate, int attno,
527  GISTENTRY *key1, bool isNull1,
528  GISTENTRY *key2, bool isNull2);
529 extern void gistMakeUnionItVec(GISTSTATE *giststate, IndexTuple *itvec, int len,
530  Datum *attr, bool *isnull);
531 extern bool gistKeyIsEQ(GISTSTATE *giststate, int attno, Datum a, Datum b);
532 extern void gistDeCompressAtt(GISTSTATE *giststate, Relation r, IndexTuple tuple, Page p,
533  OffsetNumber o, GISTENTRY *attdata, bool *isnull);
534 extern IndexTuple gistFetchTuple(GISTSTATE *giststate, Relation r,
535  IndexTuple tuple);
536 extern void gistMakeUnionKey(GISTSTATE *giststate, int attno,
537  GISTENTRY *entry1, bool isnull1,
538  GISTENTRY *entry2, bool isnull2,
539  Datum *dst, bool *dstisnull);
540 
542 
543 /* gistvacuum.c */
545  IndexBulkDeleteResult *stats,
547  void *callback_state);
549  IndexBulkDeleteResult *stats);
550 
551 /* gistsplit.c */
552 extern void gistSplitByKey(Relation r, Page page, IndexTuple *itup,
553  int len, GISTSTATE *giststate,
554  GistSplitVector *v,
555  int attno);
556 
557 /* gistbuild.c */
559  struct IndexInfo *indexInfo);
560 extern void gistValidateBufferingOption(char *value);
561 
562 /* gistbuildbuffers.c */
563 extern GISTBuildBuffers *gistInitBuildBuffers(int pagesPerBuffer, int levelStep,
564  int maxLevel);
566  GISTSTATE *giststate,
567  BlockNumber blkno, int level);
569  GISTNodeBuffer *nodeBuffer, IndexTuple item);
571  GISTNodeBuffer *nodeBuffer, IndexTuple *item);
572 extern void gistFreeBuildBuffers(GISTBuildBuffers *gfbb);
574  GISTSTATE *giststate, Relation r,
575  int level, Buffer buffer,
576  List *splitinfo);
577 extern void gistUnloadNodeBuffers(GISTBuildBuffers *gfbb);
578 
579 #endif /* GIST_PRIVATE_H */
void gistFreeBuildBuffers(GISTBuildBuffers *gfbb)
struct gistxlogPage gistxlogPage
TupleDesc tupdesc
Definition: gist_private.h:82
BlockNumber blkno
Definition: gist_private.h:255
Definition: fmgr.h:53
static struct @76 value
BlockNumber pageBlocknum
Definition: gist_private.h:339
void gistbuildempty(Relation index)
Definition: gist.c:116
Buffer gistNewBuffer(Relation r)
Definition: gistutil.c:758
BlockNumber blkno
Definition: gist_private.h:137
Datum spl_lattr[INDEX_MAX_KEYS]
Definition: gist_private.h:277
struct GISTSTATE GISTSTATE
struct GISTSearchItem GISTSearchItem
OffsetNumber * killedItems
Definition: gist_private.h:169
BlockNumber blkno
Definition: gist_private.h:231
FmgrInfo fetchFn[INDEX_MAX_KEYS]
Definition: gist_private.h:94
GISTNodeBuffer * gistGetNodeBuffer(GISTBuildBuffers *gfbb, GISTSTATE *giststate, BlockNumber blkno, int level)
Datum gisthandler(PG_FUNCTION_ARGS)
Definition: gist.c:55
IndexTuple gistunion(Relation r, IndexTuple *itvec, int len, GISTSTATE *giststate)
Definition: gistutil.c:213
int bufferingModeOffset
Definition: gist_private.h:426
struct gistxlogPageSplit gistxlogPageSplit
Oid supportCollation[INDEX_MAX_KEYS]
Definition: gist_private.h:97
pairingheap * queue
Definition: gist_private.h:160
FmgrInfo compressFn[INDEX_MAX_KEYS]
Definition: gist_private.h:88
MemoryContext context
Definition: gist_private.h:377
void gistMakeUnionItVec(GISTSTATE *giststate, IndexTuple *itvec, int len, Datum *attr, bool *isnull)
Definition: gistutil.c:150
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:161
MemoryContext createTempGistContext(void)
Definition: gist.c:103
BlockNumber curBlkno
Definition: gist_private.h:171
List ** buffersOnLevels
Definition: gist_private.h:404
BlockNumber nodeBlocknum
Definition: gist_private.h:336
unsigned char uint8
Definition: c.h:263
struct gistxlogPageUpdate gistxlogPageUpdate
GIST_SPLITVEC splitVector
Definition: gist_private.h:275
uint32 BlockNumber
Definition: block.h:31
void gist_xlog_cleanup(void)
Definition: gistxlog.c:317
IndexBulkDeleteResult * gistbulkdelete(IndexVacuumInfo *info, IndexBulkDeleteResult *stats, IndexBulkDeleteCallback callback, void *callback_state)
Definition: gistvacuum.c:139
unsigned int Oid
Definition: postgres_ext.h:31
MemoryContext pageDataCxt
Definition: gist_private.h:178
IndexTupleData * list
Definition: gist_private.h:239
struct GiSTOptions GiSTOptions
bool gistvalidate(Oid opclassoid)
Definition: gistvalidate.c:33
Datum spl_rattr[INDEX_MAX_KEYS]
Definition: gist_private.h:281
struct GISTScanOpaqueData GISTScanOpaqueData
signed int int32
Definition: c.h:253
uint16 OffsetNumber
Definition: off.h:24
Definition: type.h:90
GISTSTATE * giststate
Definition: gist_private.h:157
gistxlogPage block
Definition: gist_private.h:238
IndexUniqueCheck
Definition: genam.h:106
double distances[FLEXIBLE_ARRAY_MEMBER]
Definition: gist_private.h:144
Definition: dynahash.c:193
GISTNodeBufferPage * pageBuffer
Definition: gist_private.h:340
struct GistSplitVector GistSplitVector
unsigned short uint16
Definition: c.h:264
FmgrInfo consistentFn[INDEX_MAX_KEYS]
Definition: gist_private.h:86
void gistValidateBufferingOption(char *value)
Definition: gistbuild.c:240
List * bufferEmptyingQueue
Definition: gist_private.h:393
void gistfillbuffer(Page page, IndexTuple *itup, int len, OffsetNumber off)
Definition: gistutil.c:29
static void callback(struct sockaddr *addr, struct sockaddr *mask, void *unused)
Definition: test_ifaddrs.c:49
GISTScanOpaqueData * GISTScanOpaque
Definition: gist_private.h:182
void GISTInitBuffer(Buffer b, uint32 f)
Definition: gistutil.c:697
MemoryContext tempCxt
Definition: gist_private.h:80
void gistPushItupToNodeBuffer(GISTBuildBuffers *gfbb, GISTNodeBuffer *nodeBuffer, IndexTuple item)
IndexTuple downlink
Definition: gist_private.h:447
float gistpenalty(GISTSTATE *giststate, int attno, GISTENTRY *key1, bool isNull1, GISTENTRY *key2, bool isNull2)
Definition: gistutil.c:664
GISTInsertStack * stack
Definition: gist_private.h:294
static char * buf
Definition: pg_test_fsync.c:65
bool gistPopItupFromNodeBuffer(GISTBuildBuffers *gfbb, GISTNodeBuffer *nodeBuffer, IndexTuple *item)
XLogRecPtr gistGetFakeLSN(Relation rel)
Definition: gistutil.c:845
FmgrInfo picksplitFn[INDEX_MAX_KEYS]
Definition: gist_private.h:91
ScanDirection
Definition: sdir.h:22
IndexTuple gistgetadjusted(Relation r, IndexTuple oldtup, IndexTuple addtup, GISTSTATE *giststate)
Definition: gistutil.c:310
FmgrInfo penaltyFn[INDEX_MAX_KEYS]
Definition: gist_private.h:90
BlockNumber origrlink
Definition: gist_private.h:217
unsigned int uint32
Definition: c.h:265
OffsetNumber nPageData
Definition: gist_private.h:176
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:290
IndexBuildResult * gistbuild(Relation heap, Relation index, struct IndexInfo *indexInfo)
Definition: gistbuild.c:113
bool gistfitpage(IndexTuple *itvec, int len)
Definition: gistutil.c:74
struct SplitedPageLayout * next
Definition: gist_private.h:245
GISTSTATE * initGISTstate(Relation index)
Definition: gist.c:1398
FmgrInfo decompressFn[INDEX_MAX_KEYS]
Definition: gist_private.h:89
bool gistcanreturn(Relation index, int attno)
Definition: gistget.c:800
void gistdentryinit(GISTSTATE *giststate, int nkey, GISTENTRY *e, Datum k, Relation r, Page pg, OffsetNumber o, bool l, bool isNull)
Definition: gistutil.c:540
bool gistKeyIsEQ(GISTSTATE *giststate, int attno, Datum a, Datum b)
Definition: gistutil.c:275
XLogRecPtr gistXLogSplit(RelFileNode node, BlockNumber blkno, bool page_is_leaf, SplitedPageLayout *dist, BlockNumber origrlink, GistNSN oldnsn, Buffer leftchild, bool markfollowright)
Definition: gistxlog.c:326
OffsetNumber downlinkoffnum
Definition: gist_private.h:266
GISTSearchHeapItem heap
Definition: gist_private.h:142
bool queuedForEmptying
Definition: gist_private.h:343
IndexTuple * gistjoinvector(IndexTuple *itvec, int *len, IndexTuple *additvec, int addlen)
Definition: gistutil.c:109
bool gistgettuple(IndexScanDesc scan, ScanDirection dir)
Definition: gistget.c:623
uintptr_t Datum
Definition: postgres.h:374
struct IndexTupleData IndexTupleData
bool gistnospace(Page page, IndexTuple *itvec, int len, OffsetNumber todelete, Size freespace)
Definition: gistutil.c:54
GISTBuildBuffers * gistInitBuildBuffers(int pagesPerBuffer, int levelStep, int maxLevel)
IndexTuple gistFetchTuple(GISTSTATE *giststate, Relation r, IndexTuple tuple)
Definition: gistutil.c:627
SplitedPageLayout * gistSplit(Relation r, Page page, IndexTuple *itup, int len, GISTSTATE *giststate)
Definition: gist.c:1313
XLogRecPtr gistXLogUpdate(RelFileNode node, Buffer buffer, OffsetNumber *todelete, int ntodelete, IndexTuple *itup, int ntup, Buffer leftchild)
Definition: gistxlog.c:390
void freeGISTstate(GISTSTATE *giststate)
Definition: gist.c:1487
const char * gist_identify(uint8 info)
Definition: gistdesc.c:53
struct SplitedPageLayout SplitedPageLayout
BlockNumber prev
Definition: gist_private.h:50
ItemPointerData heapPtr
Definition: gist_private.h:124
pairingheap_node phNode
Definition: gist_private.h:136
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:227
bytea * gistoptions(Datum reloptions, bool validate)
Definition: gistutil.c:812
TupleDesc fetchTupdesc
Definition: gist_private.h:83
GISTSearchHeapItem pageData[BLCKSZ/sizeof(IndexTupleData)]
Definition: gist_private.h:175
#define INDEX_MAX_KEYS
size_t Size
Definition: c.h:352
int64 gistgetbitmap(IndexScanDesc scan, TIDBitmap *tbm)
Definition: gistget.c:753
#define leftchild(x)
Definition: fsmpage.c:29
OffsetNumber curPageData
Definition: gist_private.h:177
FmgrInfo distanceFn[INDEX_MAX_KEYS]
Definition: gist_private.h:93
XLogRecPtr GistNSN
Definition: gist.h:50
GISTNodeBuffer ** loadedBuffers
Definition: gist_private.h:411
static Datum values[MAXATTR]
Definition: bootstrap.c:160
bool gistplacetopage(Relation rel, Size freespace, GISTSTATE *giststate, Buffer buffer, IndexTuple *itup, int ntup, OffsetNumber oldoffnum, BlockNumber *newblkno, Buffer leftchildbuf, List **splitinfo, bool markleftchild)
Definition: gist.c:205
bool spl_risnull[INDEX_MAX_KEYS]
Definition: gist_private.h:283
e
Definition: preproc-init.c:82
IndexTuple * gistextractpage(Page page, int *len)
Definition: gistutil.c:90
union GISTSearchItem::@38 data
struct GISTSearchHeapItem GISTSearchHeapItem
OffsetNumber offnum
Definition: gist_private.h:129
struct GISTBuildBuffers GISTBuildBuffers
MemoryContext scanCxt
Definition: gist_private.h:79
void gistdoinsert(Relation r, IndexTuple itup, Size freespace, GISTSTATE *GISTstate)
Definition: gist.c:576
Definition: c.h:434
#define PG_FUNCTION_ARGS
Definition: fmgr.h:150
bool gistinsert(Relation r, Datum *values, bool *isnull, ItemPointer ht_ctid, Relation heapRel, IndexUniqueCheck checkUnique)
Definition: gist.c:142
OffsetNumber gistchoose(Relation r, Page p, IndexTuple it, GISTSTATE *giststate)
Definition: gistutil.c:368
IndexTupleData * gistfillitupvec(IndexTuple *vec, int veclen, int *memlen)
Definition: gistutil.c:122
bool spl_lisnull[INDEX_MAX_KEYS]
Definition: gist_private.h:279
FmgrInfo unionFn[INDEX_MAX_KEYS]
Definition: gist_private.h:87
Definition: pg_list.h:45
GistNSN parentlsn
Definition: gist_private.h:140
int Buffer
Definition: buf.h:23
struct GISTInsertStack * parent
Definition: gist_private.h:269
void gist_redo(XLogReaderState *record)
Definition: gistxlog.c:279
bool(* IndexBulkDeleteCallback)(ItemPointer itemptr, void *state)
Definition: genam.h:80
struct GISTInsertStack GISTInsertStack
Pointer Page
Definition: bufpage.h:74
void gistcheckpage(Relation rel, Buffer buf)
Definition: gistutil.c:719
void gistUnloadNodeBuffers(GISTBuildBuffers *gfbb)
IndexBulkDeleteResult * gistvacuumcleanup(IndexVacuumInfo *info, IndexBulkDeleteResult *stats)
Definition: gistvacuum.c:29
IndexTuple gistFormTuple(GISTSTATE *giststate, Relation r, Datum *attdata, bool *isnull, bool isleaf)
void gist_desc(StringInfo buf, XLogReaderState *record)
Definition: gistdesc.c:34
void gist_xlog_startup(void)
Definition: gistxlog.c:311