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