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-2017, 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 "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 a pairing heap to manage the
110  * distance-order queue. In a non-ordered search (no order-by operators),
111  * we use it to return heap tuples before unvisited index pages, to
112  * ensure depth-first order, but all entries are otherwise considered
113  * equal.
114  */
115 
116 /* Individual heap tuple to be visited */
117 typedef struct GISTSearchHeapItem
118 {
120  bool recheck; /* T if quals must be rechecked */
121  bool recheckDistances; /* T if distances must be rechecked */
122  HeapTuple recontup; /* data reconstructed from the index, used in
123  * index-only scans */
124  OffsetNumber offnum; /* track offset in page to mark tuple as
125  * LP_DEAD */
127 
128 /* Unvisited item, either index page or heap tuple */
129 typedef struct GISTSearchItem
130 {
132  BlockNumber blkno; /* index page number, or InvalidBlockNumber */
133  union
134  {
135  GistNSN parentlsn; /* parent page's LSN, if index page */
136  /* we must store parentlsn to detect whether a split occurred */
137  GISTSearchHeapItem heap; /* heap info, if heap tuple */
138  } data;
139  double distances[FLEXIBLE_ARRAY_MEMBER]; /* numberOfOrderBys
140  * entries */
142 
143 #define GISTSearchItemIsHeap(item) ((item).blkno == InvalidBlockNumber)
144 
145 #define SizeOfGISTSearchItem(n_distances) (offsetof(GISTSearchItem, distances) + sizeof(double) * (n_distances))
146 
147 /*
148  * GISTScanOpaqueData: private state for a scan of a GiST index
149  */
150 typedef struct GISTScanOpaqueData
151 {
152  GISTSTATE *giststate; /* index information, see above */
153  Oid *orderByTypes; /* datatypes of ORDER BY expressions */
154 
155  pairingheap *queue; /* queue of unvisited items */
156  MemoryContext queueCxt; /* context holding the queue */
157  bool qual_ok; /* false if qual can never be satisfied */
158  bool firstCall; /* true until first gistgettuple call */
159 
160  /* pre-allocated workspace arrays */
161  double *distances; /* output area for gistindex_keytest */
162 
163  /* info about killed items if any (killedItems is NULL if never used) */
164  OffsetNumber *killedItems; /* offset numbers of killed items */
165  int numKilled; /* number of currently stored items */
166  BlockNumber curBlkno; /* current number of block */
167  GistNSN curPageLSN; /* pos in the WAL stream when page was read */
168 
169  /* In a non-ordered search, returnable heap items are stored here: */
171  OffsetNumber nPageData; /* number of valid items in array */
172  OffsetNumber curPageData; /* next item to return */
173  MemoryContext pageDataCxt; /* context holding the fetched tuples, for
174  * index-only scans */
176 
178 
179 /* despite the name, gistxlogPage is not part of any xlog record */
180 typedef struct gistxlogPage
181 {
183  int num; /* number of index tuples following */
184 } gistxlogPage;
185 
186 /* SplitedPageLayout - gistSplit function result */
187 typedef struct SplitedPageLayout
188 {
191  int lenlist;
192  IndexTuple itup; /* union key for page */
193  Page page; /* to operate */
194  Buffer buffer; /* to write after all proceed */
195 
198 
199 /*
200  * GISTInsertStack used for locking buffers and transfer arguments during
201  * insertion
202  */
203 typedef struct GISTInsertStack
204 {
205  /* current page */
209 
210  /*
211  * log sequence number from page->lsn to recognize page update and compare
212  * it with page's nsn to recognize page split
213  */
215 
216  /* offset of the downlink in the parent page, that points to this page */
218 
219  /* pointer to parent */
222 
223 /* Working state and results for multi-column split logic in gistsplit.c */
224 typedef struct GistSplitVector
225 {
226  GIST_SPLITVEC splitVector; /* passed to/from user PickSplit method */
227 
228  Datum spl_lattr[INDEX_MAX_KEYS]; /* Union of subkeys in
229  * splitVector.spl_left */
231 
232  Datum spl_rattr[INDEX_MAX_KEYS]; /* Union of subkeys in
233  * splitVector.spl_right */
235 
236  bool *spl_dontcare; /* flags tuples which could go to either side
237  * of the split for zero penalty */
239 
240 typedef struct
241 {
243  Size freespace; /* free space to be left */
244 
247 
248 /* root page of a gist index */
249 #define GIST_ROOT_BLKNO 0
250 
251 /*
252  * Before PostgreSQL 9.1, we used to rely on so-called "invalid tuples" on
253  * inner pages to finish crash recovery of incomplete page splits. If a crash
254  * happened in the middle of a page split, so that the downlink pointers were
255  * not yet inserted, crash recovery inserted a special downlink pointer. The
256  * semantics of an invalid tuple was that it if you encounter one in a scan,
257  * it must always be followed, because we don't know if the tuples on the
258  * child page match or not.
259  *
260  * We no longer create such invalid tuples, we now mark the left-half of such
261  * an incomplete split with the F_FOLLOW_RIGHT flag instead, and finish the
262  * split properly the next time we need to insert on that page. To retain
263  * on-disk compatibility for the sake of pg_upgrade, we still store 0xffff as
264  * the offset number of all inner tuples. If we encounter any invalid tuples
265  * with 0xfffe during insertion, we throw an error, though scans still handle
266  * them. You should only encounter invalid tuples if you pg_upgrade a pre-9.1
267  * gist index which already has invalid tuples in it because of a crash. That
268  * should be rare, and you are recommended to REINDEX anyway if you have any
269  * invalid tuples in an index, so throwing an error is as far as we go with
270  * supporting that.
271  */
272 #define TUPLE_IS_VALID 0xffff
273 #define TUPLE_IS_INVALID 0xfffe
274 
275 #define GistTupleIsInvalid(itup) ( ItemPointerGetOffsetNumber( &((itup)->t_tid) ) == TUPLE_IS_INVALID )
276 #define GistTupleSetValid(itup) ItemPointerSetOffsetNumber( &((itup)->t_tid), TUPLE_IS_VALID )
277 
278 
279 
280 
281 /*
282  * A buffer attached to an internal node, used when building an index in
283  * buffering mode.
284  */
285 typedef struct
286 {
287  BlockNumber nodeBlocknum; /* index block # this buffer is for */
288  int32 blocksCount; /* current # of blocks occupied by buffer */
289 
290  BlockNumber pageBlocknum; /* temporary file block # */
291  GISTNodeBufferPage *pageBuffer; /* in-memory buffer page */
292 
293  /* is this buffer queued for emptying? */
295 
296  /* is this a temporary copy, not in the hash table? */
297  bool isTemp;
298 
299  int level; /* 0 == leaf */
301 
302 /*
303  * Does specified level have buffers? (Beware of multiple evaluation of
304  * arguments.)
305  */
306 #define LEVEL_HAS_BUFFERS(nlevel, gfbb) \
307  ((nlevel) != 0 && (nlevel) % (gfbb)->levelStep == 0 && \
308  (nlevel) != (gfbb)->rootlevel)
309 
310 /* Is specified buffer at least half-filled (should be queued for emptying)? */
311 #define BUFFER_HALF_FILLED(nodeBuffer, gfbb) \
312  ((nodeBuffer)->blocksCount > (gfbb)->pagesPerBuffer / 2)
313 
314 /*
315  * Is specified buffer full? Our buffers can actually grow indefinitely,
316  * beyond the "maximum" size, so this just means whether the buffer has grown
317  * beyond the nominal maximum size.
318  */
319 #define BUFFER_OVERFLOWED(nodeBuffer, gfbb) \
320  ((nodeBuffer)->blocksCount > (gfbb)->pagesPerBuffer)
321 
322 /*
323  * Data structure with general information about build buffers.
324  */
325 typedef struct GISTBuildBuffers
326 {
327  /* Persistent memory context for the buffers and metadata. */
329 
330  BufFile *pfile; /* Temporary file to store buffers in */
331  long nFileBlocks; /* Current size of the temporary file */
332 
333  /*
334  * resizable array of free blocks.
335  */
336  long *freeBlocks;
337  int nFreeBlocks; /* # of currently free blocks in the array */
338  int freeBlocksLen; /* current allocated length of the array */
339 
340  /* Hash for buffers by block number */
342 
343  /* List of buffers scheduled for emptying */
345 
346  /*
347  * Parameters to the buffering build algorithm. levelStep determines which
348  * levels in the tree have buffers, and pagesPerBuffer determines how
349  * large each buffer is.
350  */
353 
354  /* Array of lists of buffers on each level, for final emptying */
357 
358  /*
359  * Dynamically-sized array of buffers that currently have their last page
360  * loaded in main memory.
361  */
363  int loadedBuffersCount; /* # of entries in loadedBuffers */
364  int loadedBuffersLen; /* allocated size of loadedBuffers */
365 
366  /* Level of the current root node (= height of the index tree - 1) */
369 
370 /*
371  * Storage type for GiST's reloptions
372  */
373 typedef struct GiSTOptions
374 {
375  int32 vl_len_; /* varlena header (do not touch directly!) */
376  int fillfactor; /* page fill factor in percent (0..100) */
377  int bufferingModeOffset; /* use buffering build? */
378 } GiSTOptions;
379 
380 /* gist.c */
381 extern void gistbuildempty(Relation index);
382 extern bool gistinsert(Relation r, Datum *values, bool *isnull,
383  ItemPointer ht_ctid, Relation heapRel,
384  IndexUniqueCheck checkUnique,
385  struct IndexInfo *indexInfo);
388 extern void freeGISTstate(GISTSTATE *giststate);
389 extern void gistdoinsert(Relation r,
390  IndexTuple itup,
391  Size freespace,
392  GISTSTATE *GISTstate);
393 
394 /* A List of these is returned from gistplacetopage() in *splitinfo */
395 typedef struct
396 {
397  Buffer buf; /* the split page "half" */
398  IndexTuple downlink; /* downlink for this half. */
400 
401 extern bool gistplacetopage(Relation rel, Size freespace, GISTSTATE *giststate,
402  Buffer buffer,
403  IndexTuple *itup, int ntup,
404  OffsetNumber oldoffnum, BlockNumber *newblkno,
405  Buffer leftchildbuf,
406  List **splitinfo,
407  bool markleftchild);
408 
409 extern SplitedPageLayout *gistSplit(Relation r, Page page, IndexTuple *itup,
410  int len, GISTSTATE *giststate);
411 
413  OffsetNumber *todelete, int ntodelete,
414  IndexTuple *itup, int ntup,
415  Buffer leftchild);
416 
417 extern XLogRecPtr gistXLogSplit(bool page_is_leaf,
418  SplitedPageLayout *dist,
419  BlockNumber origrlink, GistNSN oldnsn,
420  Buffer leftchild, bool markfollowright);
421 
422 /* gistget.c */
423 extern bool gistgettuple(IndexScanDesc scan, ScanDirection dir);
424 extern int64 gistgetbitmap(IndexScanDesc scan, TIDBitmap *tbm);
425 extern bool gistcanreturn(Relation index, int attno);
426 
427 /* gistvalidate.c */
428 extern bool gistvalidate(Oid opclassoid);
429 
430 /* gistutil.c */
431 
432 #define GiSTPageSize \
433  ( BLCKSZ - SizeOfPageHeaderData - MAXALIGN(sizeof(GISTPageOpaqueData)) )
434 
435 #define GIST_MIN_FILLFACTOR 10
436 #define GIST_DEFAULT_FILLFACTOR 90
437 
438 extern bytea *gistoptions(Datum reloptions, bool validate);
439 extern bool gistproperty(Oid index_oid, int attno,
440  IndexAMProperty prop, const char *propname,
441  bool *res, bool *isnull);
442 extern bool gistfitpage(IndexTuple *itvec, int len);
443 extern bool gistnospace(Page page, IndexTuple *itvec, int len, OffsetNumber todelete, Size freespace);
444 extern void gistcheckpage(Relation rel, Buffer buf);
445 extern Buffer gistNewBuffer(Relation r);
446 extern void gistfillbuffer(Page page, IndexTuple *itup, int len,
447  OffsetNumber off);
448 extern IndexTuple *gistextractpage(Page page, int *len /* out */ );
449 extern IndexTuple *gistjoinvector(
450  IndexTuple *itvec, int *len,
451  IndexTuple *additvec, int addlen);
452 extern IndexTupleData *gistfillitupvec(IndexTuple *vec, int veclen, int *memlen);
453 
454 extern IndexTuple gistunion(Relation r, IndexTuple *itvec,
455  int len, GISTSTATE *giststate);
457  IndexTuple oldtup,
458  IndexTuple addtup,
459  GISTSTATE *giststate);
460 extern IndexTuple gistFormTuple(GISTSTATE *giststate,
461  Relation r, Datum *attdata, bool *isnull, bool isleaf);
462 
464  IndexTuple it,
465  GISTSTATE *giststate);
466 
467 extern void GISTInitBuffer(Buffer b, uint32 f);
468 extern void gistdentryinit(GISTSTATE *giststate, int nkey, GISTENTRY *e,
469  Datum k, Relation r, Page pg, OffsetNumber o,
470  bool l, bool isNull);
471 
472 extern float gistpenalty(GISTSTATE *giststate, int attno,
473  GISTENTRY *key1, bool isNull1,
474  GISTENTRY *key2, bool isNull2);
475 extern void gistMakeUnionItVec(GISTSTATE *giststate, IndexTuple *itvec, int len,
476  Datum *attr, bool *isnull);
477 extern bool gistKeyIsEQ(GISTSTATE *giststate, int attno, Datum a, Datum b);
478 extern void gistDeCompressAtt(GISTSTATE *giststate, Relation r, IndexTuple tuple, Page p,
479  OffsetNumber o, GISTENTRY *attdata, bool *isnull);
480 extern HeapTuple gistFetchTuple(GISTSTATE *giststate, Relation r,
481  IndexTuple tuple);
482 extern void gistMakeUnionKey(GISTSTATE *giststate, int attno,
483  GISTENTRY *entry1, bool isnull1,
484  GISTENTRY *entry2, bool isnull2,
485  Datum *dst, bool *dstisnull);
486 
488 
489 /* gistvacuum.c */
491  IndexBulkDeleteResult *stats,
493  void *callback_state);
495  IndexBulkDeleteResult *stats);
496 
497 /* gistsplit.c */
498 extern void gistSplitByKey(Relation r, Page page, IndexTuple *itup,
499  int len, GISTSTATE *giststate,
500  GistSplitVector *v,
501  int attno);
502 
503 /* gistbuild.c */
505  struct IndexInfo *indexInfo);
506 extern void gistValidateBufferingOption(char *value);
507 
508 /* gistbuildbuffers.c */
509 extern GISTBuildBuffers *gistInitBuildBuffers(int pagesPerBuffer, int levelStep,
510  int maxLevel);
512  GISTSTATE *giststate,
513  BlockNumber blkno, int level);
515  GISTNodeBuffer *nodeBuffer, IndexTuple item);
517  GISTNodeBuffer *nodeBuffer, IndexTuple *item);
518 extern void gistFreeBuildBuffers(GISTBuildBuffers *gfbb);
520  GISTSTATE *giststate, Relation r,
521  int level, Buffer buffer,
522  List *splitinfo);
523 extern void gistUnloadNodeBuffers(GISTBuildBuffers *gfbb);
524 
525 #endif /* GIST_PRIVATE_H */
void gistFreeBuildBuffers(GISTBuildBuffers *gfbb)
struct gistxlogPage gistxlogPage
TupleDesc tupdesc
Definition: gist_private.h:81
BlockNumber blkno
Definition: gist_private.h:206
Definition: fmgr.h:56
BlockNumber pageBlocknum
Definition: gist_private.h:290
void gistbuildempty(Relation index)
Definition: gist.c:121
Buffer gistNewBuffer(Relation r)
Definition: gistutil.c:762
BlockNumber blkno
Definition: gist_private.h:132
HeapTuple gistFetchTuple(GISTSTATE *giststate, Relation r, IndexTuple tuple)
Definition: gistutil.c:631
IndexAMProperty
Definition: amapi.h:34
XLogRecPtr gistXLogSplit(bool page_is_leaf, SplitedPageLayout *dist, BlockNumber origrlink, GistNSN oldnsn, Buffer leftchild, bool markfollowright)
Definition: gistxlog.c:393
Datum spl_lattr[INDEX_MAX_KEYS]
Definition: gist_private.h:228
struct GISTSTATE GISTSTATE
struct GISTSearchItem GISTSearchItem
OffsetNumber * killedItems
Definition: gist_private.h:164
BlockNumber blkno
Definition: gist_private.h:182
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:217
int bufferingModeOffset
Definition: gist_private.h:377
Oid supportCollation[INDEX_MAX_KEYS]
Definition: gist_private.h:96
pairingheap * queue
Definition: gist_private.h:155
FmgrInfo compressFn[INDEX_MAX_KEYS]
Definition: gist_private.h:87
MemoryContext context
Definition: gist_private.h:328
void gistMakeUnionItVec(GISTSTATE *giststate, IndexTuple *itvec, int len, Datum *attr, bool *isnull)
Definition: gistutil.c:154
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:156
MemoryContext createTempGistContext(void)
Definition: gist.c:110
BlockNumber curBlkno
Definition: gist_private.h:166
List ** buffersOnLevels
Definition: gist_private.h:355
BlockNumber nodeBlocknum
Definition: gist_private.h:287
GIST_SPLITVEC splitVector
Definition: gist_private.h:226
uint32 BlockNumber
Definition: block.h:31
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:173
IndexTupleData * list
Definition: gist_private.h:190
struct GiSTOptions GiSTOptions
bool gistvalidate(Oid opclassoid)
Definition: gistvalidate.c:34
Datum spl_rattr[INDEX_MAX_KEYS]
Definition: gist_private.h:232
struct GISTScanOpaqueData GISTScanOpaqueData
signed int int32
Definition: c.h:256
uint16 OffsetNumber
Definition: off.h:24
Definition: type.h:89
GISTSTATE * giststate
Definition: gist_private.h:152
gistxlogPage block
Definition: gist_private.h:189
IndexUniqueCheck
Definition: genam.h:111
double distances[FLEXIBLE_ARRAY_MEMBER]
Definition: gist_private.h:139
Definition: dynahash.c:193
GISTNodeBufferPage * pageBuffer
Definition: gist_private.h:291
struct GistSplitVector GistSplitVector
FmgrInfo consistentFn[INDEX_MAX_KEYS]
Definition: gist_private.h:85
void gistValidateBufferingOption(char *value)
Definition: gistbuild.c:241
List * bufferEmptyingQueue
Definition: gist_private.h:344
void gistfillbuffer(Page page, IndexTuple *itup, int len, OffsetNumber off)
Definition: gistutil.c:33
static struct @121 value
static void callback(struct sockaddr *addr, struct sockaddr *mask, void *unused)
Definition: test_ifaddrs.c:48
GISTScanOpaqueData * GISTScanOpaque
Definition: gist_private.h:177
void GISTInitBuffer(Buffer b, uint32 f)
Definition: gistutil.c:701
MemoryContext tempCxt
Definition: gist_private.h:79
void gistPushItupToNodeBuffer(GISTBuildBuffers *gfbb, GISTNodeBuffer *nodeBuffer, IndexTuple item)
IndexTuple downlink
Definition: gist_private.h:398
float gistpenalty(GISTSTATE *giststate, int attno, GISTENTRY *key1, bool isNull1, GISTENTRY *key2, bool isNull2)
Definition: gistutil.c:668
GISTInsertStack * stack
Definition: gist_private.h:245
static char * buf
Definition: pg_test_fsync.c:66
bool gistPopItupFromNodeBuffer(GISTBuildBuffers *gfbb, GISTNodeBuffer *nodeBuffer, IndexTuple *item)
XLogRecPtr gistGetFakeLSN(Relation rel)
Definition: gistutil.c:946
FmgrInfo picksplitFn[INDEX_MAX_KEYS]
Definition: gist_private.h:90
ScanDirection
Definition: sdir.h:22
IndexTuple gistgetadjusted(Relation r, IndexTuple oldtup, IndexTuple addtup, GISTSTATE *giststate)
Definition: gistutil.c:314
FmgrInfo penaltyFn[INDEX_MAX_KEYS]
Definition: gist_private.h:89
unsigned int uint32
Definition: c.h:268
OffsetNumber nPageData
Definition: gist_private.h:171
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:294
IndexBuildResult * gistbuild(Relation heap, Relation index, struct IndexInfo *indexInfo)
Definition: gistbuild.c:114
bool gistfitpage(IndexTuple *itvec, int len)
Definition: gistutil.c:78
struct SplitedPageLayout * next
Definition: gist_private.h:196
GISTSTATE * initGISTstate(Relation index)
Definition: gist.c:1423
FmgrInfo decompressFn[INDEX_MAX_KEYS]
Definition: gist_private.h:88
bool gistcanreturn(Relation index, int attno)
Definition: gistget.c:806
void gistdentryinit(GISTSTATE *giststate, int nkey, GISTENTRY *e, Datum k, Relation r, Page pg, OffsetNumber o, bool l, bool isNull)
Definition: gistutil.c:544
bool gistKeyIsEQ(GISTSTATE *giststate, int attno, Datum a, Datum b)
Definition: gistutil.c:279
OffsetNumber downlinkoffnum
Definition: gist_private.h:217
GISTSearchHeapItem heap
Definition: gist_private.h:137
bool queuedForEmptying
Definition: gist_private.h:294
IndexTuple * gistjoinvector(IndexTuple *itvec, int *len, IndexTuple *additvec, int addlen)
Definition: gistutil.c:113
bool gistproperty(Oid index_oid, int attno, IndexAMProperty prop, const char *propname, bool *res, bool *isnull)
Definition: gistutil.c:851
bool gistgettuple(IndexScanDesc scan, ScanDirection dir)
Definition: gistget.c:627
bool gistinsert(Relation r, Datum *values, bool *isnull, ItemPointer ht_ctid, Relation heapRel, IndexUniqueCheck checkUnique, struct IndexInfo *indexInfo)
Definition: gist.c:147
uintptr_t Datum
Definition: postgres.h:372
struct IndexTupleData IndexTupleData
bool gistnospace(Page page, IndexTuple *itvec, int len, OffsetNumber todelete, Size freespace)
Definition: gistutil.c:58
GISTBuildBuffers * gistInitBuildBuffers(int pagesPerBuffer, int levelStep, int maxLevel)
SplitedPageLayout * gistSplit(Relation r, Page page, IndexTuple *itup, int len, GISTSTATE *giststate)
Definition: gist.c:1338
void freeGISTstate(GISTSTATE *giststate)
Definition: gist.c:1510
union GISTSearchItem::@43 data
struct SplitedPageLayout SplitedPageLayout
BlockNumber prev
Definition: gist_private.h:49
ItemPointerData heapPtr
Definition: gist_private.h:119
pairingheap_node phNode
Definition: gist_private.h:131
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:231
bytea * gistoptions(Datum reloptions, bool validate)
Definition: gistutil.c:816
TupleDesc fetchTupdesc
Definition: gist_private.h:82
WalTimeSample buffer[LAG_TRACKER_BUFFER_SIZE]
Definition: walsender.c:214
GISTSearchHeapItem pageData[BLCKSZ/sizeof(IndexTupleData)]
Definition: gist_private.h:170
#define INDEX_MAX_KEYS
size_t Size
Definition: c.h:356
int64 gistgetbitmap(IndexScanDesc scan, TIDBitmap *tbm)
Definition: gistget.c:758
#define leftchild(x)
Definition: fsmpage.c:29
OffsetNumber curPageData
Definition: gist_private.h:172
FmgrInfo distanceFn[INDEX_MAX_KEYS]
Definition: gist_private.h:92
XLogRecPtr GistNSN
Definition: gist.h:50
GISTNodeBuffer ** loadedBuffers
Definition: gist_private.h:362
static Datum values[MAXATTR]
Definition: bootstrap.c:163
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:212
bool spl_risnull[INDEX_MAX_KEYS]
Definition: gist_private.h:234
e
Definition: preproc-init.c:82
IndexTuple * gistextractpage(Page page, int *len)
Definition: gistutil.c:94
struct GISTSearchHeapItem GISTSearchHeapItem
OffsetNumber offnum
Definition: gist_private.h:124
struct GISTBuildBuffers GISTBuildBuffers
MemoryContext scanCxt
Definition: gist_private.h:78
void gistdoinsert(Relation r, IndexTuple itup, Size freespace, GISTSTATE *GISTstate)
Definition: gist.c:601
Definition: c.h:439
OffsetNumber gistchoose(Relation r, Page p, IndexTuple it, GISTSTATE *giststate)
Definition: gistutil.c:372
IndexTupleData * gistfillitupvec(IndexTuple *vec, int veclen, int *memlen)
Definition: gistutil.c:126
bool spl_lisnull[INDEX_MAX_KEYS]
Definition: gist_private.h:230
FmgrInfo unionFn[INDEX_MAX_KEYS]
Definition: gist_private.h:86
Definition: pg_list.h:45
GistNSN parentlsn
Definition: gist_private.h:135
int Buffer
Definition: buf.h:23
struct GISTInsertStack * parent
Definition: gist_private.h:220
bool(* IndexBulkDeleteCallback)(ItemPointer itemptr, void *state)
Definition: genam.h:83
struct GISTInsertStack GISTInsertStack
Pointer Page
Definition: bufpage.h:74
void gistcheckpage(Relation rel, Buffer buf)
Definition: gistutil.c:723
void gistUnloadNodeBuffers(GISTBuildBuffers *gfbb)
IndexBulkDeleteResult * gistvacuumcleanup(IndexVacuumInfo *info, IndexBulkDeleteResult *stats)
Definition: gistvacuum.c:29
XLogRecPtr gistXLogUpdate(Buffer buffer, OffsetNumber *todelete, int ntodelete, IndexTuple *itup, int ntup, Buffer leftchild)
Definition: gistxlog.c:457
IndexTuple gistFormTuple(GISTSTATE *giststate, Relation r, Datum *attdata, bool *isnull, bool isleaf)