PostgreSQL Source Code  git master
nbtree.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * nbtree.h
4  * header file for postgres btree access method implementation.
5  *
6  *
7  * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
8  * Portions Copyright (c) 1994, Regents of the University of California
9  *
10  * src/include/access/nbtree.h
11  *
12  *-------------------------------------------------------------------------
13  */
14 #ifndef NBTREE_H
15 #define NBTREE_H
16 
17 #include "access/amapi.h"
18 #include "access/itup.h"
19 #include "access/sdir.h"
20 #include "access/tableam.h"
21 #include "access/xlogreader.h"
22 #include "catalog/pg_am_d.h"
23 #include "catalog/pg_index.h"
24 #include "lib/stringinfo.h"
25 #include "storage/bufmgr.h"
26 #include "storage/shm_toc.h"
27 
28 /* There's room for a 16-bit vacuum cycle ID in BTPageOpaqueData */
29 typedef uint16 BTCycleId;
30 
31 /*
32  * BTPageOpaqueData -- At the end of every page, we store a pointer
33  * to both siblings in the tree. This is used to do forward/backward
34  * index scans. The next-page link is also critical for recovery when
35  * a search has navigated to the wrong page due to concurrent page splits
36  * or deletions; see src/backend/access/nbtree/README for more info.
37  *
38  * In addition, we store the page's btree level (counting upwards from
39  * zero at a leaf page) as well as some flag bits indicating the page type
40  * and status. If the page is deleted, a BTDeletedPageData struct is stored
41  * in the page's tuple area, while a standard BTPageOpaqueData struct is
42  * stored in the page special area.
43  *
44  * We also store a "vacuum cycle ID". When a page is split while VACUUM is
45  * processing the index, a nonzero value associated with the VACUUM run is
46  * stored into both halves of the split page. (If VACUUM is not running,
47  * both pages receive zero cycleids.) This allows VACUUM to detect whether
48  * a page was split since it started, with a small probability of false match
49  * if the page was last split some exact multiple of MAX_BT_CYCLE_ID VACUUMs
50  * ago. Also, during a split, the BTP_SPLIT_END flag is cleared in the left
51  * (original) page, and set in the right page, but only if the next page
52  * to its right has a different cycleid.
53  *
54  * NOTE: the BTP_LEAF flag bit is redundant since level==0 could be tested
55  * instead.
56  *
57  * NOTE: the btpo_level field used to be a union type in order to allow
58  * deleted pages to store a 32-bit safexid in the same field. We now store
59  * 64-bit/full safexid values using BTDeletedPageData instead.
60  */
61 
62 typedef struct BTPageOpaqueData
63 {
64  BlockNumber btpo_prev; /* left sibling, or P_NONE if leftmost */
65  BlockNumber btpo_next; /* right sibling, or P_NONE if rightmost */
66  uint32 btpo_level; /* tree level --- zero for leaf pages */
67  uint16 btpo_flags; /* flag bits, see below */
68  BTCycleId btpo_cycleid; /* vacuum cycle ID of latest split */
70 
72 
73 #define BTPageGetOpaque(page) ((BTPageOpaque) PageGetSpecialPointer(page))
74 
75 /* Bits defined in btpo_flags */
76 #define BTP_LEAF (1 << 0) /* leaf page, i.e. not internal page */
77 #define BTP_ROOT (1 << 1) /* root page (has no parent) */
78 #define BTP_DELETED (1 << 2) /* page has been deleted from tree */
79 #define BTP_META (1 << 3) /* meta-page */
80 #define BTP_HALF_DEAD (1 << 4) /* empty, but still in tree */
81 #define BTP_SPLIT_END (1 << 5) /* rightmost page of split group */
82 #define BTP_HAS_GARBAGE (1 << 6) /* page has LP_DEAD tuples (deprecated) */
83 #define BTP_INCOMPLETE_SPLIT (1 << 7) /* right sibling's downlink is missing */
84 #define BTP_HAS_FULLXID (1 << 8) /* contains BTDeletedPageData */
85 
86 /*
87  * The max allowed value of a cycle ID is a bit less than 64K. This is
88  * for convenience of pg_filedump and similar utilities: we want to use
89  * the last 2 bytes of special space as an index type indicator, and
90  * restricting cycle ID lets btree use that space for vacuum cycle IDs
91  * while still allowing index type to be identified.
92  */
93 #define MAX_BT_CYCLE_ID 0xFF7F
94 
95 
96 /*
97  * The Meta page is always the first page in the btree index.
98  * Its primary purpose is to point to the location of the btree root page.
99  * We also point to the "fast" root, which is the current effective root;
100  * see README for discussion.
101  */
102 
103 typedef struct BTMetaPageData
104 {
105  uint32 btm_magic; /* should contain BTREE_MAGIC */
106  uint32 btm_version; /* nbtree version (always <= BTREE_VERSION) */
107  BlockNumber btm_root; /* current root location */
108  uint32 btm_level; /* tree level of the root page */
109  BlockNumber btm_fastroot; /* current "fast" root location */
110  uint32 btm_fastlevel; /* tree level of the "fast" root page */
111  /* remaining fields only valid when btm_version >= BTREE_NOVAC_VERSION */
112 
113  /* number of deleted, non-recyclable pages during last cleanup */
115  /* number of heap tuples during last cleanup (deprecated) */
117 
118  bool btm_allequalimage; /* are all columns "equalimage"? */
120 
121 #define BTPageGetMeta(p) \
122  ((BTMetaPageData *) PageGetContents(p))
123 
124 /*
125  * The current Btree version is 4. That's what you'll get when you create
126  * a new index.
127  *
128  * Btree version 3 was used in PostgreSQL v11. It is mostly the same as
129  * version 4, but heap TIDs were not part of the keyspace. Index tuples
130  * with duplicate keys could be stored in any order. We continue to
131  * support reading and writing Btree versions 2 and 3, so that they don't
132  * need to be immediately re-indexed at pg_upgrade. In order to get the
133  * new heapkeyspace semantics, however, a REINDEX is needed.
134  *
135  * Deduplication is safe to use when the btm_allequalimage field is set to
136  * true. It's safe to read the btm_allequalimage field on version 3, but
137  * only version 4 indexes make use of deduplication. Even version 4
138  * indexes created on PostgreSQL v12 will need a REINDEX to make use of
139  * deduplication, though, since there is no other way to set
140  * btm_allequalimage to true (pg_upgrade hasn't been taught to set the
141  * metapage field).
142  *
143  * Btree version 2 is mostly the same as version 3. There are two new
144  * fields in the metapage that were introduced in version 3. A version 2
145  * metapage will be automatically upgraded to version 3 on the first
146  * insert to it. INCLUDE indexes cannot use version 2.
147  */
148 #define BTREE_METAPAGE 0 /* first page is meta */
149 #define BTREE_MAGIC 0x053162 /* magic number in metapage */
150 #define BTREE_VERSION 4 /* current version number */
151 #define BTREE_MIN_VERSION 2 /* minimum supported version */
152 #define BTREE_NOVAC_VERSION 3 /* version with all meta fields set */
153 
154 /*
155  * Maximum size of a btree index entry, including its tuple header.
156  *
157  * We actually need to be able to fit three items on every page,
158  * so restrict any one item to 1/3 the per-page available space.
159  *
160  * There are rare cases where _bt_truncate() will need to enlarge
161  * a heap index tuple to make space for a tiebreaker heap TID
162  * attribute, which we account for here.
163  */
164 #define BTMaxItemSize(page) \
165  MAXALIGN_DOWN((PageGetPageSize(page) - \
166  MAXALIGN(SizeOfPageHeaderData + \
167  3*sizeof(ItemIdData) + \
168  3*sizeof(ItemPointerData)) - \
169  MAXALIGN(sizeof(BTPageOpaqueData))) / 3)
170 #define BTMaxItemSizeNoHeapTid(page) \
171  MAXALIGN_DOWN((PageGetPageSize(page) - \
172  MAXALIGN(SizeOfPageHeaderData + 3*sizeof(ItemIdData)) - \
173  MAXALIGN(sizeof(BTPageOpaqueData))) / 3)
174 
175 /*
176  * MaxTIDsPerBTreePage is an upper bound on the number of heap TIDs tuples
177  * that may be stored on a btree leaf page. It is used to size the
178  * per-page temporary buffers.
179  *
180  * Note: we don't bother considering per-tuple overheads here to keep
181  * things simple (value is based on how many elements a single array of
182  * heap TIDs must have to fill the space between the page header and
183  * special area). The value is slightly higher (i.e. more conservative)
184  * than necessary as a result, which is considered acceptable.
185  */
186 #define MaxTIDsPerBTreePage \
187  (int) ((BLCKSZ - SizeOfPageHeaderData - sizeof(BTPageOpaqueData)) / \
188  sizeof(ItemPointerData))
189 
190 /*
191  * The leaf-page fillfactor defaults to 90% but is user-adjustable.
192  * For pages above the leaf level, we use a fixed 70% fillfactor.
193  * The fillfactor is applied during index build and when splitting
194  * a rightmost page; when splitting non-rightmost pages we try to
195  * divide the data equally. When splitting a page that's entirely
196  * filled with a single value (duplicates), the effective leaf-page
197  * fillfactor is 96%, regardless of whether the page is a rightmost
198  * page.
199  */
200 #define BTREE_MIN_FILLFACTOR 10
201 #define BTREE_DEFAULT_FILLFACTOR 90
202 #define BTREE_NONLEAF_FILLFACTOR 70
203 #define BTREE_SINGLEVAL_FILLFACTOR 96
204 
205 /*
206  * In general, the btree code tries to localize its knowledge about
207  * page layout to a couple of routines. However, we need a special
208  * value to indicate "no page number" in those places where we expect
209  * page numbers. We can use zero for this because we never need to
210  * make a pointer to the metadata page.
211  */
212 
213 #define P_NONE 0
214 
215 /*
216  * Macros to test whether a page is leftmost or rightmost on its tree level,
217  * as well as other state info kept in the opaque data.
218  */
219 #define P_LEFTMOST(opaque) ((opaque)->btpo_prev == P_NONE)
220 #define P_RIGHTMOST(opaque) ((opaque)->btpo_next == P_NONE)
221 #define P_ISLEAF(opaque) (((opaque)->btpo_flags & BTP_LEAF) != 0)
222 #define P_ISROOT(opaque) (((opaque)->btpo_flags & BTP_ROOT) != 0)
223 #define P_ISDELETED(opaque) (((opaque)->btpo_flags & BTP_DELETED) != 0)
224 #define P_ISMETA(opaque) (((opaque)->btpo_flags & BTP_META) != 0)
225 #define P_ISHALFDEAD(opaque) (((opaque)->btpo_flags & BTP_HALF_DEAD) != 0)
226 #define P_IGNORE(opaque) (((opaque)->btpo_flags & (BTP_DELETED|BTP_HALF_DEAD)) != 0)
227 #define P_HAS_GARBAGE(opaque) (((opaque)->btpo_flags & BTP_HAS_GARBAGE) != 0)
228 #define P_INCOMPLETE_SPLIT(opaque) (((opaque)->btpo_flags & BTP_INCOMPLETE_SPLIT) != 0)
229 #define P_HAS_FULLXID(opaque) (((opaque)->btpo_flags & BTP_HAS_FULLXID) != 0)
230 
231 /*
232  * BTDeletedPageData is the page contents of a deleted page
233  */
234 typedef struct BTDeletedPageData
235 {
236  FullTransactionId safexid; /* See BTPageIsRecyclable() */
238 
239 static inline void
241 {
242  BTPageOpaque opaque;
244  BTDeletedPageData *contents;
245 
246  opaque = BTPageGetOpaque(page);
247  header = ((PageHeader) page);
248 
249  opaque->btpo_flags &= ~BTP_HALF_DEAD;
251  header->pd_lower = MAXALIGN(SizeOfPageHeaderData) +
252  sizeof(BTDeletedPageData);
253  header->pd_upper = header->pd_special;
254 
255  /* Set safexid in deleted page */
256  contents = ((BTDeletedPageData *) PageGetContents(page));
257  contents->safexid = safexid;
258 }
259 
260 static inline FullTransactionId
262 {
263  BTPageOpaque opaque;
264  BTDeletedPageData *contents;
265 
266  /* We only expect to be called with a deleted page */
267  Assert(!PageIsNew(page));
268  opaque = BTPageGetOpaque(page);
269  Assert(P_ISDELETED(opaque));
270 
271  /* pg_upgrade'd deleted page -- must be safe to delete now */
272  if (!P_HAS_FULLXID(opaque))
274 
275  /* Get safexid from deleted page */
276  contents = ((BTDeletedPageData *) PageGetContents(page));
277  return contents->safexid;
278 }
279 
280 /*
281  * Is an existing page recyclable?
282  *
283  * This exists to centralize the policy on which deleted pages are now safe to
284  * re-use. However, _bt_pendingfsm_finalize() duplicates some of the same
285  * logic because it doesn't work directly with pages -- keep the two in sync.
286  *
287  * Note: PageIsNew() pages are always safe to recycle, but we can't deal with
288  * them here (caller is responsible for that case themselves). Caller might
289  * well need special handling for new pages anyway.
290  */
291 static inline bool
293 {
294  BTPageOpaque opaque;
295 
296  Assert(!PageIsNew(page));
297 
298  /* Recycling okay iff page is deleted and safexid is old enough */
299  opaque = BTPageGetOpaque(page);
300  if (P_ISDELETED(opaque))
301  {
302  /*
303  * The page was deleted, but when? If it was just deleted, a scan
304  * might have seen the downlink to it, and will read the page later.
305  * As long as that can happen, we must keep the deleted page around as
306  * a tombstone.
307  *
308  * For that check if the deletion XID could still be visible to
309  * anyone. If not, then no scan that's still in progress could have
310  * seen its downlink, and we can recycle it.
311  *
312  * XXX: If we had the heap relation we could be more aggressive about
313  * recycling deleted pages in non-catalog relations. For now we just
314  * pass NULL. That is at least simple and consistent.
315  */
317  }
318 
319  return false;
320 }
321 
322 /*
323  * BTVacState and BTPendingFSM are private nbtree.c state used during VACUUM.
324  * They are exported for use by page deletion related code in nbtpage.c.
325  */
326 typedef struct BTPendingFSM
327 {
328  BlockNumber target; /* Page deleted by current VACUUM */
329  FullTransactionId safexid; /* Page's BTDeletedPageData.safexid */
331 
332 typedef struct BTVacState
333 {
340 
341  /*
342  * _bt_pendingfsm_finalize() state
343  */
344  int bufsize; /* pendingpages space (in # elements) */
345  int maxbufsize; /* max bufsize that respects work_mem */
346  BTPendingFSM *pendingpages; /* One entry per newly deleted page */
347  int npendingpages; /* current # valid pendingpages */
349 
350 /*
351  * Lehman and Yao's algorithm requires a ``high key'' on every non-rightmost
352  * page. The high key is not a tuple that is used to visit the heap. It is
353  * a pivot tuple (see "Notes on B-Tree tuple format" below for definition).
354  * The high key on a page is required to be greater than or equal to any
355  * other key that appears on the page. If we find ourselves trying to
356  * insert a key that is strictly > high key, we know we need to move right
357  * (this should only happen if the page was split since we examined the
358  * parent page).
359  *
360  * Our insertion algorithm guarantees that we can use the initial least key
361  * on our right sibling as the high key. Once a page is created, its high
362  * key changes only if the page is split.
363  *
364  * On a non-rightmost page, the high key lives in item 1 and data items
365  * start in item 2. Rightmost pages have no high key, so we store data
366  * items beginning in item 1.
367  */
368 
369 #define P_HIKEY ((OffsetNumber) 1)
370 #define P_FIRSTKEY ((OffsetNumber) 2)
371 #define P_FIRSTDATAKEY(opaque) (P_RIGHTMOST(opaque) ? P_HIKEY : P_FIRSTKEY)
372 
373 /*
374  * Notes on B-Tree tuple format, and key and non-key attributes:
375  *
376  * INCLUDE B-Tree indexes have non-key attributes. These are extra
377  * attributes that may be returned by index-only scans, but do not influence
378  * the order of items in the index (formally, non-key attributes are not
379  * considered to be part of the key space). Non-key attributes are only
380  * present in leaf index tuples whose item pointers actually point to heap
381  * tuples (non-pivot tuples). _bt_check_natts() enforces the rules
382  * described here.
383  *
384  * Non-pivot tuple format (plain/non-posting variant):
385  *
386  * t_tid | t_info | key values | INCLUDE columns, if any
387  *
388  * t_tid points to the heap TID, which is a tiebreaker key column as of
389  * BTREE_VERSION 4.
390  *
391  * Non-pivot tuples complement pivot tuples, which only have key columns.
392  * The sole purpose of pivot tuples is to represent how the key space is
393  * separated. In general, any B-Tree index that has more than one level
394  * (i.e. any index that does not just consist of a metapage and a single
395  * leaf root page) must have some number of pivot tuples, since pivot
396  * tuples are used for traversing the tree. Suffix truncation can omit
397  * trailing key columns when a new pivot is formed, which makes minus
398  * infinity their logical value. Since BTREE_VERSION 4 indexes treat heap
399  * TID as a trailing key column that ensures that all index tuples are
400  * physically unique, it is necessary to represent heap TID as a trailing
401  * key column in pivot tuples, though very often this can be truncated
402  * away, just like any other key column. (Actually, the heap TID is
403  * omitted rather than truncated, since its representation is different to
404  * the non-pivot representation.)
405  *
406  * Pivot tuple format:
407  *
408  * t_tid | t_info | key values | [heap TID]
409  *
410  * We store the number of columns present inside pivot tuples by abusing
411  * their t_tid offset field, since pivot tuples never need to store a real
412  * offset (pivot tuples generally store a downlink in t_tid, though). The
413  * offset field only stores the number of columns/attributes when the
414  * INDEX_ALT_TID_MASK bit is set, which doesn't count the trailing heap
415  * TID column sometimes stored in pivot tuples -- that's represented by
416  * the presence of BT_PIVOT_HEAP_TID_ATTR. The INDEX_ALT_TID_MASK bit in
417  * t_info is always set on BTREE_VERSION 4 pivot tuples, since
418  * BTreeTupleIsPivot() must work reliably on heapkeyspace versions.
419  *
420  * In version 2 or version 3 (!heapkeyspace) indexes, INDEX_ALT_TID_MASK
421  * might not be set in pivot tuples. BTreeTupleIsPivot() won't work
422  * reliably as a result. The number of columns stored is implicitly the
423  * same as the number of columns in the index, just like any non-pivot
424  * tuple. (The number of columns stored should not vary, since suffix
425  * truncation of key columns is unsafe within any !heapkeyspace index.)
426  *
427  * The 12 least significant bits from t_tid's offset number are used to
428  * represent the number of key columns within a pivot tuple. This leaves 4
429  * status bits (BT_STATUS_OFFSET_MASK bits), which are shared by all tuples
430  * that have the INDEX_ALT_TID_MASK bit set (set in t_info) to store basic
431  * tuple metadata. BTreeTupleIsPivot() and BTreeTupleIsPosting() use the
432  * BT_STATUS_OFFSET_MASK bits.
433  *
434  * Sometimes non-pivot tuples also use a representation that repurposes
435  * t_tid to store metadata rather than a TID. PostgreSQL v13 introduced a
436  * new non-pivot tuple format to support deduplication: posting list
437  * tuples. Deduplication merges together multiple equal non-pivot tuples
438  * into a logically equivalent, space efficient representation. A posting
439  * list is an array of ItemPointerData elements. Non-pivot tuples are
440  * merged together to form posting list tuples lazily, at the point where
441  * we'd otherwise have to split a leaf page.
442  *
443  * Posting tuple format (alternative non-pivot tuple representation):
444  *
445  * t_tid | t_info | key values | posting list (TID array)
446  *
447  * Posting list tuples are recognized as such by having the
448  * INDEX_ALT_TID_MASK status bit set in t_info and the BT_IS_POSTING status
449  * bit set in t_tid's offset number. These flags redefine the content of
450  * the posting tuple's t_tid to store the location of the posting list
451  * (instead of a block number), as well as the total number of heap TIDs
452  * present in the tuple (instead of a real offset number).
453  *
454  * The 12 least significant bits from t_tid's offset number are used to
455  * represent the number of heap TIDs present in the tuple, leaving 4 status
456  * bits (the BT_STATUS_OFFSET_MASK bits). Like any non-pivot tuple, the
457  * number of columns stored is always implicitly the total number in the
458  * index (in practice there can never be non-key columns stored, since
459  * deduplication is not supported with INCLUDE indexes).
460  */
461 #define INDEX_ALT_TID_MASK INDEX_AM_RESERVED_BIT
462 
463 /* Item pointer offset bit masks */
464 #define BT_OFFSET_MASK 0x0FFF
465 #define BT_STATUS_OFFSET_MASK 0xF000
466 /* BT_STATUS_OFFSET_MASK status bits */
467 #define BT_PIVOT_HEAP_TID_ATTR 0x1000
468 #define BT_IS_POSTING 0x2000
469 
470 /*
471  * Note: BTreeTupleIsPivot() can have false negatives (but not false
472  * positives) when used with !heapkeyspace indexes
473  */
474 static inline bool
476 {
477  if ((itup->t_info & INDEX_ALT_TID_MASK) == 0)
478  return false;
479  /* absence of BT_IS_POSTING in offset number indicates pivot tuple */
481  return false;
482 
483  return true;
484 }
485 
486 static inline bool
488 {
489  if ((itup->t_info & INDEX_ALT_TID_MASK) == 0)
490  return false;
491  /* presence of BT_IS_POSTING in offset number indicates posting tuple */
493  return false;
494 
495  return true;
496 }
497 
498 static inline void
499 BTreeTupleSetPosting(IndexTuple itup, uint16 nhtids, int postingoffset)
500 {
501  Assert(nhtids > 1);
502  Assert((nhtids & BT_STATUS_OFFSET_MASK) == 0);
503  Assert((size_t) postingoffset == MAXALIGN(postingoffset));
504  Assert(postingoffset < INDEX_SIZE_MASK);
505  Assert(!BTreeTupleIsPivot(itup));
506 
507  itup->t_info |= INDEX_ALT_TID_MASK;
508  ItemPointerSetOffsetNumber(&itup->t_tid, (nhtids | BT_IS_POSTING));
509  ItemPointerSetBlockNumber(&itup->t_tid, postingoffset);
510 }
511 
512 static inline uint16
514 {
515  OffsetNumber existing;
516 
517  Assert(BTreeTupleIsPosting(posting));
518 
519  existing = ItemPointerGetOffsetNumberNoCheck(&posting->t_tid);
520  return (existing & BT_OFFSET_MASK);
521 }
522 
523 static inline uint32
525 {
526  Assert(BTreeTupleIsPosting(posting));
527 
528  return ItemPointerGetBlockNumberNoCheck(&posting->t_tid);
529 }
530 
531 static inline ItemPointer
533 {
534  return (ItemPointer) ((char *) posting +
535  BTreeTupleGetPostingOffset(posting));
536 }
537 
538 static inline ItemPointer
540 {
541  return BTreeTupleGetPosting(posting) + n;
542 }
543 
544 /*
545  * Get/set downlink block number in pivot tuple.
546  *
547  * Note: Cannot assert that tuple is a pivot tuple. If we did so then
548  * !heapkeyspace indexes would exhibit false positive assertion failures.
549  */
550 static inline BlockNumber
552 {
553  return ItemPointerGetBlockNumberNoCheck(&pivot->t_tid);
554 }
555 
556 static inline void
558 {
559  ItemPointerSetBlockNumber(&pivot->t_tid, blkno);
560 }
561 
562 /*
563  * Get number of attributes within tuple.
564  *
565  * Note that this does not include an implicit tiebreaker heap TID
566  * attribute, if any. Note also that the number of key attributes must be
567  * explicitly represented in all heapkeyspace pivot tuples.
568  *
569  * Note: This is defined as a macro rather than an inline function to
570  * avoid including rel.h.
571  */
572 #define BTreeTupleGetNAtts(itup, rel) \
573  ( \
574  (BTreeTupleIsPivot(itup)) ? \
575  ( \
576  ItemPointerGetOffsetNumberNoCheck(&(itup)->t_tid) & BT_OFFSET_MASK \
577  ) \
578  : \
579  IndexRelationGetNumberOfAttributes(rel) \
580  )
581 
582 /*
583  * Set number of key attributes in tuple.
584  *
585  * The heap TID tiebreaker attribute bit may also be set here, indicating that
586  * a heap TID value will be stored at the end of the tuple (i.e. using the
587  * special pivot tuple representation).
588  */
589 static inline void
590 BTreeTupleSetNAtts(IndexTuple itup, uint16 nkeyatts, bool heaptid)
591 {
592  Assert(nkeyatts <= INDEX_MAX_KEYS);
593  Assert((nkeyatts & BT_STATUS_OFFSET_MASK) == 0);
594  Assert(!heaptid || nkeyatts > 0);
595  Assert(!BTreeTupleIsPivot(itup) || nkeyatts == 0);
596 
597  itup->t_info |= INDEX_ALT_TID_MASK;
598 
599  if (heaptid)
600  nkeyatts |= BT_PIVOT_HEAP_TID_ATTR;
601 
602  /* BT_IS_POSTING bit is deliberately unset here */
603  ItemPointerSetOffsetNumber(&itup->t_tid, nkeyatts);
604  Assert(BTreeTupleIsPivot(itup));
605 }
606 
607 /*
608  * Get/set leaf page's "top parent" link from its high key. Used during page
609  * deletion.
610  *
611  * Note: Cannot assert that tuple is a pivot tuple. If we did so then
612  * !heapkeyspace indexes would exhibit false positive assertion failures.
613  */
614 static inline BlockNumber
616 {
617  return ItemPointerGetBlockNumberNoCheck(&leafhikey->t_tid);
618 }
619 
620 static inline void
622 {
623  ItemPointerSetBlockNumber(&leafhikey->t_tid, blkno);
624  BTreeTupleSetNAtts(leafhikey, 0, false);
625 }
626 
627 /*
628  * Get tiebreaker heap TID attribute, if any.
629  *
630  * This returns the first/lowest heap TID in the case of a posting list tuple.
631  */
632 static inline ItemPointer
634 {
635  if (BTreeTupleIsPivot(itup))
636  {
637  /* Pivot tuple heap TID representation? */
640  return (ItemPointer) ((char *) itup + IndexTupleSize(itup) -
641  sizeof(ItemPointerData));
642 
643  /* Heap TID attribute was truncated */
644  return NULL;
645  }
646  else if (BTreeTupleIsPosting(itup))
647  return BTreeTupleGetPosting(itup);
648 
649  return &itup->t_tid;
650 }
651 
652 /*
653  * Get maximum heap TID attribute, which could be the only TID in the case of
654  * a non-pivot tuple that does not have a posting list tuple.
655  *
656  * Works with non-pivot tuples only.
657  */
658 static inline ItemPointer
660 {
661  Assert(!BTreeTupleIsPivot(itup));
662 
663  if (BTreeTupleIsPosting(itup))
664  {
665  uint16 nposting = BTreeTupleGetNPosting(itup);
666 
667  return BTreeTupleGetPostingN(itup, nposting - 1);
668  }
669 
670  return &itup->t_tid;
671 }
672 
673 /*
674  * Operator strategy numbers for B-tree have been moved to access/stratnum.h,
675  * because many places need to use them in ScanKeyInit() calls.
676  *
677  * The strategy numbers are chosen so that we can commute them by
678  * subtraction, thus:
679  */
680 #define BTCommuteStrategyNumber(strat) (BTMaxStrategyNumber + 1 - (strat))
681 
682 /*
683  * When a new operator class is declared, we require that the user
684  * supply us with an amproc procedure (BTORDER_PROC) for determining
685  * whether, for two keys a and b, a < b, a = b, or a > b. This routine
686  * must return < 0, 0, > 0, respectively, in these three cases.
687  *
688  * To facilitate accelerated sorting, an operator class may choose to
689  * offer a second procedure (BTSORTSUPPORT_PROC). For full details, see
690  * src/include/utils/sortsupport.h.
691  *
692  * To support window frames defined by "RANGE offset PRECEDING/FOLLOWING",
693  * an operator class may choose to offer a third amproc procedure
694  * (BTINRANGE_PROC), independently of whether it offers sortsupport.
695  * For full details, see doc/src/sgml/btree.sgml.
696  *
697  * To facilitate B-Tree deduplication, an operator class may choose to
698  * offer a forth amproc procedure (BTEQUALIMAGE_PROC). For full details,
699  * see doc/src/sgml/btree.sgml.
700  */
701 
702 #define BTORDER_PROC 1
703 #define BTSORTSUPPORT_PROC 2
704 #define BTINRANGE_PROC 3
705 #define BTEQUALIMAGE_PROC 4
706 #define BTOPTIONS_PROC 5
707 #define BTNProcs 5
708 
709 /*
710  * We need to be able to tell the difference between read and write
711  * requests for pages, in order to do locking correctly.
712  */
713 
714 #define BT_READ BUFFER_LOCK_SHARE
715 #define BT_WRITE BUFFER_LOCK_EXCLUSIVE
716 
717 /*
718  * BTStackData -- As we descend a tree, we push the location of pivot
719  * tuples whose downlink we are about to follow onto a private stack. If
720  * we split a leaf, we use this stack to walk back up the tree and insert
721  * data into its parent page at the correct location. We also have to
722  * recursively insert into the grandparent page if and when the parent page
723  * splits. Our private stack can become stale due to concurrent page
724  * splits and page deletions, but it should never give us an irredeemably
725  * bad picture.
726  */
727 typedef struct BTStackData
728 {
733 
735 
736 /*
737  * BTScanInsertData is the btree-private state needed to find an initial
738  * position for an indexscan, or to insert new tuples -- an "insertion
739  * scankey" (not to be confused with a search scankey). It's used to descend
740  * a B-Tree using _bt_search.
741  *
742  * heapkeyspace indicates if we expect all keys in the index to be physically
743  * unique because heap TID is used as a tiebreaker attribute, and if index may
744  * have truncated key attributes in pivot tuples. This is actually a property
745  * of the index relation itself (not an indexscan). heapkeyspace indexes are
746  * indexes whose version is >= version 4. It's convenient to keep this close
747  * by, rather than accessing the metapage repeatedly.
748  *
749  * allequalimage is set to indicate that deduplication is safe for the index.
750  * This is also a property of the index relation rather than an indexscan.
751  *
752  * anynullkeys indicates if any of the keys had NULL value when scankey was
753  * built from index tuple (note that already-truncated tuple key attributes
754  * set NULL as a placeholder key value, which also affects value of
755  * anynullkeys). This is a convenience for unique index non-pivot tuple
756  * insertion, which usually temporarily unsets scantid, but shouldn't iff
757  * anynullkeys is true. Value generally matches non-pivot tuple's HasNulls
758  * bit, but may not when inserting into an INCLUDE index (tuple header value
759  * is affected by the NULL-ness of both key and non-key attributes).
760  *
761  * When nextkey is false (the usual case), _bt_search and _bt_binsrch will
762  * locate the first item >= scankey. When nextkey is true, they will locate
763  * the first item > scan key.
764  *
765  * pivotsearch is set to true by callers that want to re-find a leaf page
766  * using a scankey built from a leaf page's high key. Most callers set this
767  * to false.
768  *
769  * scantid is the heap TID that is used as a final tiebreaker attribute. It
770  * is set to NULL when index scan doesn't need to find a position for a
771  * specific physical tuple. Must be set when inserting new tuples into
772  * heapkeyspace indexes, since every tuple in the tree unambiguously belongs
773  * in one exact position (it's never set with !heapkeyspace indexes, though).
774  * Despite the representational difference, nbtree search code considers
775  * scantid to be just another insertion scankey attribute.
776  *
777  * scankeys is an array of scan key entries for attributes that are compared
778  * before scantid (user-visible attributes). keysz is the size of the array.
779  * During insertion, there must be a scan key for every attribute, but when
780  * starting a regular index scan some can be omitted. The array is used as a
781  * flexible array member, though it's sized in a way that makes it possible to
782  * use stack allocations. See nbtree/README for full details.
783  */
784 typedef struct BTScanInsertData
785 {
789  bool nextkey;
791  ItemPointer scantid; /* tiebreaker for scankeys */
792  int keysz; /* Size of scankeys array */
793  ScanKeyData scankeys[INDEX_MAX_KEYS]; /* Must appear last */
795 
797 
798 /*
799  * BTInsertStateData is a working area used during insertion.
800  *
801  * This is filled in after descending the tree to the first leaf page the new
802  * tuple might belong on. Tracks the current position while performing
803  * uniqueness check, before we have determined which exact page to insert
804  * to.
805  *
806  * (This should be private to nbtinsert.c, but it's also used by
807  * _bt_binsrch_insert)
808  */
809 typedef struct BTInsertStateData
810 {
811  IndexTuple itup; /* Item we're inserting */
812  Size itemsz; /* Size of itup -- should be MAXALIGN()'d */
813  BTScanInsert itup_key; /* Insertion scankey */
814 
815  /* Buffer containing leaf page we're likely to insert itup on */
817 
818  /*
819  * Cache of bounds within the current buffer. Only used for insertions
820  * where _bt_check_unique is called. See _bt_binsrch_insert and
821  * _bt_findinsertloc for details.
822  */
826 
827  /*
828  * if _bt_binsrch_insert found the location inside existing posting list,
829  * save the position inside the list. -1 sentinel value indicates overlap
830  * with an existing posting list tuple that has its LP_DEAD bit set.
831  */
834 
836 
837 /*
838  * State used to representing an individual pending tuple during
839  * deduplication.
840  */
841 typedef struct BTDedupInterval
842 {
846 
847 /*
848  * BTDedupStateData is a working area used during deduplication.
849  *
850  * The status info fields track the state of a whole-page deduplication pass.
851  * State about the current pending posting list is also tracked.
852  *
853  * A pending posting list is comprised of a contiguous group of equal items
854  * from the page, starting from page offset number 'baseoff'. This is the
855  * offset number of the "base" tuple for new posting list. 'nitems' is the
856  * current total number of existing items from the page that will be merged to
857  * make a new posting list tuple, including the base tuple item. (Existing
858  * items may themselves be posting list tuples, or regular non-pivot tuples.)
859  *
860  * The total size of the existing tuples to be freed when pending posting list
861  * is processed gets tracked by 'phystupsize'. This information allows
862  * deduplication to calculate the space saving for each new posting list
863  * tuple, and for the entire pass over the page as a whole.
864  */
865 typedef struct BTDedupStateData
866 {
867  /* Deduplication status info for entire pass over page */
868  bool deduplicate; /* Still deduplicating page? */
869  int nmaxitems; /* Number of max-sized tuples so far */
870  Size maxpostingsize; /* Limit on size of final tuple */
871 
872  /* Metadata about base tuple of current pending posting list */
873  IndexTuple base; /* Use to form new posting list */
874  OffsetNumber baseoff; /* page offset of base */
875  Size basetupsize; /* base size without original posting list */
876 
877  /* Other metadata about pending posting list */
878  ItemPointer htids; /* Heap TIDs in pending posting list */
879  int nhtids; /* Number of heap TIDs in htids array */
880  int nitems; /* Number of existing tuples/line pointers */
881  Size phystupsize; /* Includes line pointer overhead */
882 
883  /*
884  * Array of tuples to go on new version of the page. Contains one entry
885  * for each group of consecutive items. Note that existing tuples that
886  * will not become posting list tuples do not appear in the array (they
887  * are implicitly unchanged by deduplication pass).
888  */
889  int nintervals; /* current number of intervals in array */
892 
894 
895 /*
896  * BTVacuumPostingData is state that represents how to VACUUM (or delete) a
897  * posting list tuple when some (though not all) of its TIDs are to be
898  * deleted.
899  *
900  * Convention is that itup field is the original posting list tuple on input,
901  * and palloc()'d final tuple used to overwrite existing tuple on output.
902  */
903 typedef struct BTVacuumPostingData
904 {
905  /* Tuple that will be/was updated */
908 
909  /* State needed to describe final itup in WAL */
913 
915 
916 /*
917  * BTScanOpaqueData is the btree-private state needed for an indexscan.
918  * This consists of preprocessed scan keys (see _bt_preprocess_keys() for
919  * details of the preprocessing), information about the current location
920  * of the scan, and information about the marked location, if any. (We use
921  * BTScanPosData to represent the data needed for each of current and marked
922  * locations.) In addition we can remember some known-killed index entries
923  * that must be marked before we can move off the current page.
924  *
925  * Index scans work a page at a time: we pin and read-lock the page, identify
926  * all the matching items on the page and save them in BTScanPosData, then
927  * release the read-lock while returning the items to the caller for
928  * processing. This approach minimizes lock/unlock traffic. Note that we
929  * keep the pin on the index page until the caller is done with all the items
930  * (this is needed for VACUUM synchronization, see nbtree/README). When we
931  * are ready to step to the next page, if the caller has told us any of the
932  * items were killed, we re-lock the page to mark them killed, then unlock.
933  * Finally we drop the pin and step to the next page in the appropriate
934  * direction.
935  *
936  * If we are doing an index-only scan, we save the entire IndexTuple for each
937  * matched item, otherwise only its heap TID and offset. The IndexTuples go
938  * into a separate workspace array; each BTScanPosItem stores its tuple's
939  * offset within that array. Posting list tuples store a "base" tuple once,
940  * allowing the same key to be returned for each TID in the posting list
941  * tuple.
942  */
943 
944 typedef struct BTScanPosItem /* what we remember about each match */
945 {
946  ItemPointerData heapTid; /* TID of referenced heap item */
947  OffsetNumber indexOffset; /* index item's location within page */
948  LocationIndex tupleOffset; /* IndexTuple's offset in workspace, if any */
950 
951 typedef struct BTScanPosData
952 {
953  Buffer buf; /* if valid, the buffer is pinned */
954 
955  XLogRecPtr lsn; /* pos in the WAL stream when page was read */
956  BlockNumber currPage; /* page referenced by items array */
957  BlockNumber nextPage; /* page's right link when we scanned it */
958 
959  /*
960  * moreLeft and moreRight track whether we think there may be matching
961  * index entries to the left and right of the current page, respectively.
962  * We can clear the appropriate one of these flags when _bt_checkkeys()
963  * returns continuescan = false.
964  */
965  bool moreLeft;
966  bool moreRight;
967 
968  /*
969  * If we are doing an index-only scan, nextTupleOffset is the first free
970  * location in the associated tuple storage workspace.
971  */
973 
974  /*
975  * The items array is always ordered in index order (ie, increasing
976  * indexoffset). When scanning backwards it is convenient to fill the
977  * array back-to-front, so we start at the last slot and fill downwards.
978  * Hence we need both a first-valid-entry and a last-valid-entry counter.
979  * itemIndex is a cursor showing which entry was last returned to caller.
980  */
981  int firstItem; /* first valid index in items[] */
982  int lastItem; /* last valid index in items[] */
983  int itemIndex; /* current index in items[] */
984 
987 
989 
990 #define BTScanPosIsPinned(scanpos) \
991 ( \
992  AssertMacro(BlockNumberIsValid((scanpos).currPage) || \
993  !BufferIsValid((scanpos).buf)), \
994  BufferIsValid((scanpos).buf) \
995 )
996 #define BTScanPosUnpin(scanpos) \
997  do { \
998  ReleaseBuffer((scanpos).buf); \
999  (scanpos).buf = InvalidBuffer; \
1000  } while (0)
1001 #define BTScanPosUnpinIfPinned(scanpos) \
1002  do { \
1003  if (BTScanPosIsPinned(scanpos)) \
1004  BTScanPosUnpin(scanpos); \
1005  } while (0)
1006 
1007 #define BTScanPosIsValid(scanpos) \
1008 ( \
1009  AssertMacro(BlockNumberIsValid((scanpos).currPage) || \
1010  !BufferIsValid((scanpos).buf)), \
1011  BlockNumberIsValid((scanpos).currPage) \
1012 )
1013 #define BTScanPosInvalidate(scanpos) \
1014  do { \
1015  (scanpos).currPage = InvalidBlockNumber; \
1016  (scanpos).nextPage = InvalidBlockNumber; \
1017  (scanpos).buf = InvalidBuffer; \
1018  (scanpos).lsn = InvalidXLogRecPtr; \
1019  (scanpos).nextTupleOffset = 0; \
1020  } while (0)
1021 
1022 /* We need one of these for each equality-type SK_SEARCHARRAY scan key */
1023 typedef struct BTArrayKeyInfo
1024 {
1025  int scan_key; /* index of associated key in arrayKeyData */
1026  int cur_elem; /* index of current element in elem_values */
1027  int mark_elem; /* index of marked element in elem_values */
1028  int num_elems; /* number of elems in current array value */
1029  Datum *elem_values; /* array of num_elems Datums */
1031 
1032 typedef struct BTScanOpaqueData
1033 {
1034  /* these fields are set by _bt_preprocess_keys(): */
1035  bool qual_ok; /* false if qual can never be satisfied */
1036  int numberOfKeys; /* number of preprocessed scan keys */
1037  ScanKey keyData; /* array of preprocessed scan keys */
1038 
1039  /* workspace for SK_SEARCHARRAY support */
1040  ScanKey arrayKeyData; /* modified copy of scan->keyData */
1041  int numArrayKeys; /* number of equality-type array keys (-1 if
1042  * there are any unsatisfiable array keys) */
1043  int arrayKeyCount; /* count indicating number of array scan keys
1044  * processed */
1045  BTArrayKeyInfo *arrayKeys; /* info about each equality-type array key */
1046  MemoryContext arrayContext; /* scan-lifespan context for array data */
1047 
1048  /* info about killed items if any (killedItems is NULL if never used) */
1049  int *killedItems; /* currPos.items indexes of killed items */
1050  int numKilled; /* number of currently stored items */
1051 
1052  /*
1053  * If we are doing an index-only scan, these are the tuple storage
1054  * workspaces for the currPos and markPos respectively. Each is of size
1055  * BLCKSZ, so it can hold as much as a full page's worth of tuples.
1056  */
1057  char *currTuples; /* tuple storage for currPos */
1058  char *markTuples; /* tuple storage for markPos */
1059 
1060  /*
1061  * If the marked position is on the same page as current position, we
1062  * don't use markPos, but just keep the marked itemIndex in markItemIndex
1063  * (all the rest of currPos is valid for the mark position). Hence, to
1064  * determine if there is a mark, first look at markItemIndex, then at
1065  * markPos.
1066  */
1067  int markItemIndex; /* itemIndex, or -1 if not valid */
1068 
1069  /* keep these last in struct for efficiency */
1070  BTScanPosData currPos; /* current position data */
1071  BTScanPosData markPos; /* marked position, if any */
1073 
1075 
1076 /*
1077  * We use some private sk_flags bits in preprocessed scan keys. We're allowed
1078  * to use bits 16-31 (see skey.h). The uppermost bits are copied from the
1079  * index's indoption[] array entry for the index attribute.
1080  */
1081 #define SK_BT_REQFWD 0x00010000 /* required to continue forward scan */
1082 #define SK_BT_REQBKWD 0x00020000 /* required to continue backward scan */
1083 #define SK_BT_INDOPTION_SHIFT 24 /* must clear the above bits */
1084 #define SK_BT_DESC (INDOPTION_DESC << SK_BT_INDOPTION_SHIFT)
1085 #define SK_BT_NULLS_FIRST (INDOPTION_NULLS_FIRST << SK_BT_INDOPTION_SHIFT)
1086 
1087 typedef struct BTOptions
1088 {
1089  int32 varlena_header_; /* varlena header (do not touch directly!) */
1090  int fillfactor; /* page fill factor in percent (0..100) */
1092  bool deduplicate_items; /* Try to deduplicate items? */
1094 
1095 #define BTGetFillFactor(relation) \
1096  (AssertMacro(relation->rd_rel->relkind == RELKIND_INDEX && \
1097  relation->rd_rel->relam == BTREE_AM_OID), \
1098  (relation)->rd_options ? \
1099  ((BTOptions *) (relation)->rd_options)->fillfactor : \
1100  BTREE_DEFAULT_FILLFACTOR)
1101 #define BTGetTargetPageFreeSpace(relation) \
1102  (BLCKSZ * (100 - BTGetFillFactor(relation)) / 100)
1103 #define BTGetDeduplicateItems(relation) \
1104  (AssertMacro(relation->rd_rel->relkind == RELKIND_INDEX && \
1105  relation->rd_rel->relam == BTREE_AM_OID), \
1106  ((relation)->rd_options ? \
1107  ((BTOptions *) (relation)->rd_options)->deduplicate_items : true))
1108 
1109 /*
1110  * Constant definition for progress reporting. Phase numbers must match
1111  * btbuildphasename.
1112  */
1113 /* PROGRESS_CREATEIDX_SUBPHASE_INITIALIZE is 1 (see progress.h) */
1114 #define PROGRESS_BTREE_PHASE_INDEXBUILD_TABLESCAN 2
1115 #define PROGRESS_BTREE_PHASE_PERFORMSORT_1 3
1116 #define PROGRESS_BTREE_PHASE_PERFORMSORT_2 4
1117 #define PROGRESS_BTREE_PHASE_LEAF_LOAD 5
1118 
1119 /*
1120  * external entry points for btree, in nbtree.c
1121  */
1122 extern void btbuildempty(Relation index);
1123 extern bool btinsert(Relation rel, Datum *values, bool *isnull,
1124  ItemPointer ht_ctid, Relation heapRel,
1125  IndexUniqueCheck checkUnique,
1126  bool indexUnchanged,
1127  struct IndexInfo *indexInfo);
1128 extern IndexScanDesc btbeginscan(Relation rel, int nkeys, int norderbys);
1129 extern Size btestimateparallelscan(void);
1130 extern void btinitparallelscan(void *target);
1131 extern bool btgettuple(IndexScanDesc scan, ScanDirection dir);
1132 extern int64 btgetbitmap(IndexScanDesc scan, TIDBitmap *tbm);
1133 extern void btrescan(IndexScanDesc scan, ScanKey scankey, int nscankeys,
1134  ScanKey orderbys, int norderbys);
1135 extern void btparallelrescan(IndexScanDesc scan);
1136 extern void btendscan(IndexScanDesc scan);
1137 extern void btmarkpos(IndexScanDesc scan);
1138 extern void btrestrpos(IndexScanDesc scan);
1140  IndexBulkDeleteResult *stats,
1142  void *callback_state);
1144  IndexBulkDeleteResult *stats);
1145 extern bool btcanreturn(Relation index, int attno);
1146 
1147 /*
1148  * prototypes for internal functions in nbtree.c
1149  */
1150 extern bool _bt_parallel_seize(IndexScanDesc scan, BlockNumber *pageno);
1151 extern void _bt_parallel_release(IndexScanDesc scan, BlockNumber scan_page);
1152 extern void _bt_parallel_done(IndexScanDesc scan);
1154 
1155 /*
1156  * prototypes for functions in nbtdedup.c
1157  */
1158 extern void _bt_dedup_pass(Relation rel, Buffer buf, Relation heapRel,
1159  IndexTuple newitem, Size newitemsz,
1160  bool bottomupdedup);
1161 extern bool _bt_bottomupdel_pass(Relation rel, Buffer buf, Relation heapRel,
1162  Size newitemsz);
1164  OffsetNumber baseoff);
1168  int nhtids);
1169 extern void _bt_update_posting(BTVacuumPosting vacposting);
1170 extern IndexTuple _bt_swap_posting(IndexTuple newitem, IndexTuple oposting,
1171  int postingoff);
1172 
1173 /*
1174  * prototypes for functions in nbtinsert.c
1175  */
1176 extern bool _bt_doinsert(Relation rel, IndexTuple itup,
1177  IndexUniqueCheck checkUnique, bool indexUnchanged,
1178  Relation heapRel);
1179 extern void _bt_finish_split(Relation rel, Buffer lbuf, BTStack stack);
1180 extern Buffer _bt_getstackbuf(Relation rel, BTStack stack, BlockNumber child);
1181 
1182 /*
1183  * prototypes for functions in nbtsplitloc.c
1184  */
1185 extern OffsetNumber _bt_findsplitloc(Relation rel, Page origpage,
1186  OffsetNumber newitemoff, Size newitemsz, IndexTuple newitem,
1187  bool *newitemonleft);
1188 
1189 /*
1190  * prototypes for functions in nbtpage.c
1191  */
1192 extern void _bt_initmetapage(Page page, BlockNumber rootbknum, uint32 level,
1193  bool allequalimage);
1194 extern bool _bt_vacuum_needs_cleanup(Relation rel);
1195 extern void _bt_set_cleanup_info(Relation rel, BlockNumber num_delpages);
1196 extern void _bt_upgrademetapage(Page page);
1197 extern Buffer _bt_getroot(Relation rel, int access);
1198 extern Buffer _bt_gettrueroot(Relation rel);
1199 extern int _bt_getrootheight(Relation rel);
1200 extern void _bt_metaversion(Relation rel, bool *heapkeyspace,
1201  bool *allequalimage);
1202 extern void _bt_checkpage(Relation rel, Buffer buf);
1203 extern Buffer _bt_getbuf(Relation rel, BlockNumber blkno, int access);
1204 extern Buffer _bt_relandgetbuf(Relation rel, Buffer obuf,
1205  BlockNumber blkno, int access);
1206 extern void _bt_relbuf(Relation rel, Buffer buf);
1207 extern void _bt_lockbuf(Relation rel, Buffer buf, int access);
1208 extern void _bt_unlockbuf(Relation rel, Buffer buf);
1209 extern bool _bt_conditionallockbuf(Relation rel, Buffer buf);
1210 extern void _bt_upgradelockbufcleanup(Relation rel, Buffer buf);
1211 extern void _bt_pageinit(Page page, Size size);
1212 extern void _bt_delitems_vacuum(Relation rel, Buffer buf,
1213  OffsetNumber *deletable, int ndeletable,
1214  BTVacuumPosting *updatable, int nupdatable);
1215 extern void _bt_delitems_delete_check(Relation rel, Buffer buf,
1216  Relation heapRel,
1217  TM_IndexDeleteOp *delstate);
1218 extern void _bt_pagedel(Relation rel, Buffer leafbuf, BTVacState *vstate);
1219 extern void _bt_pendingfsm_init(Relation rel, BTVacState *vstate,
1220  bool cleanuponly);
1221 extern void _bt_pendingfsm_finalize(Relation rel, BTVacState *vstate);
1222 
1223 /*
1224  * prototypes for functions in nbtsearch.c
1225  */
1226 extern BTStack _bt_search(Relation rel, BTScanInsert key, Buffer *bufP,
1227  int access, Snapshot snapshot);
1229  bool forupdate, BTStack stack, int access, Snapshot snapshot);
1230 extern OffsetNumber _bt_binsrch_insert(Relation rel, BTInsertState insertstate);
1231 extern int32 _bt_compare(Relation rel, BTScanInsert key, Page page, OffsetNumber offnum);
1232 extern bool _bt_first(IndexScanDesc scan, ScanDirection dir);
1233 extern bool _bt_next(IndexScanDesc scan, ScanDirection dir);
1234 extern Buffer _bt_get_endpoint(Relation rel, uint32 level, bool rightmost,
1235  Snapshot snapshot);
1236 
1237 /*
1238  * prototypes for functions in nbtutils.c
1239  */
1240 extern BTScanInsert _bt_mkscankey(Relation rel, IndexTuple itup);
1241 extern void _bt_freestack(BTStack stack);
1242 extern void _bt_preprocess_array_keys(IndexScanDesc scan);
1243 extern void _bt_start_array_keys(IndexScanDesc scan, ScanDirection dir);
1244 extern bool _bt_advance_array_keys(IndexScanDesc scan, ScanDirection dir);
1245 extern void _bt_mark_array_keys(IndexScanDesc scan);
1246 extern void _bt_restore_array_keys(IndexScanDesc scan);
1247 extern void _bt_preprocess_keys(IndexScanDesc scan);
1248 extern bool _bt_checkkeys(IndexScanDesc scan, IndexTuple tuple,
1249  int tupnatts, ScanDirection dir, bool *continuescan);
1250 extern void _bt_killitems(IndexScanDesc scan);
1252 extern BTCycleId _bt_start_vacuum(Relation rel);
1253 extern void _bt_end_vacuum(Relation rel);
1254 extern void _bt_end_vacuum_callback(int code, Datum arg);
1255 extern Size BTreeShmemSize(void);
1256 extern void BTreeShmemInit(void);
1257 extern bytea *btoptions(Datum reloptions, bool validate);
1258 extern bool btproperty(Oid index_oid, int attno,
1259  IndexAMProperty prop, const char *propname,
1260  bool *res, bool *isnull);
1261 extern char *btbuildphasename(int64 phasenum);
1262 extern IndexTuple _bt_truncate(Relation rel, IndexTuple lastleft,
1263  IndexTuple firstright, BTScanInsert itup_key);
1264 extern int _bt_keep_natts_fast(Relation rel, IndexTuple lastleft,
1265  IndexTuple firstright);
1266 extern bool _bt_check_natts(Relation rel, bool heapkeyspace, Page page,
1267  OffsetNumber offnum);
1268 extern void _bt_check_third_page(Relation rel, Relation heap,
1269  bool needheaptidspace, Page page, IndexTuple newtup);
1270 extern bool _bt_allequalimage(Relation rel, bool debugmessage);
1271 
1272 /*
1273  * prototypes for functions in nbtvalidate.c
1274  */
1275 extern bool btvalidate(Oid opclassoid);
1276 extern void btadjustmembers(Oid opfamilyoid,
1277  Oid opclassoid,
1278  List *operators,
1279  List *functions);
1280 
1281 /*
1282  * prototypes for functions in nbtsort.c
1283  */
1285  struct IndexInfo *indexInfo);
1286 extern void _bt_parallel_build_main(dsm_segment *seg, shm_toc *toc);
1287 
1288 #endif /* NBTREE_H */
IndexAMProperty
Definition: amapi.h:35
uint32 BlockNumber
Definition: block.h:31
static Datum values[MAXATTR]
Definition: bootstrap.c:156
int Buffer
Definition: buf.h:23
PageHeaderData * PageHeader
Definition: bufpage.h:166
Pointer Page
Definition: bufpage.h:78
#define SizeOfPageHeaderData
Definition: bufpage.h:215
#define PageIsNew(page)
Definition: bufpage.h:228
#define PageGetContents(page)
Definition: bufpage.h:245
uint16 LocationIndex
Definition: bufpage.h:87
unsigned short uint16
Definition: c.h:451
unsigned int uint32
Definition: c.h:452
#define MAXALIGN(LEN)
Definition: c.h:768
signed int int32
Definition: c.h:440
double float8
Definition: c.h:576
#define FLEXIBLE_ARRAY_MEMBER
Definition: c.h:361
size_t Size
Definition: c.h:551
bool(* IndexBulkDeleteCallback)(ItemPointer itemptr, void *state)
Definition: genam.h:86
IndexUniqueCheck
Definition: genam.h:115
#define ItemPointerGetBlockNumberNoCheck(pointer)
Definition: itemptr.h:89
#define ItemPointerSetOffsetNumber(pointer, offsetNumber)
Definition: itemptr.h:148
#define ItemPointerGetOffsetNumberNoCheck(pointer)
Definition: itemptr.h:108
struct ItemPointerData ItemPointerData
#define ItemPointerSetBlockNumber(pointer, blockNumber)
Definition: itemptr.h:138
#define IndexTupleSize(itup)
Definition: itup.h:70
#define MaxIndexTuplesPerPage
Definition: itup.h:144
#define INDEX_SIZE_MASK
Definition: itup.h:65
Assert(fmt[strlen(fmt) - 1] !='\n')
#define P_HAS_FULLXID(opaque)
Definition: nbtree.h:229
bool btinsert(Relation rel, Datum *values, bool *isnull, ItemPointer ht_ctid, Relation heapRel, IndexUniqueCheck checkUnique, bool indexUnchanged, struct IndexInfo *indexInfo)
Definition: nbtree.c:187
Buffer _bt_relandgetbuf(Relation rel, Buffer obuf, BlockNumber blkno, int access)
Definition: nbtpage.c:1015
void _bt_check_third_page(Relation rel, Relation heap, bool needheaptidspace, Page page, IndexTuple newtup)
Definition: nbtutils.c:2638
bool btcanreturn(Relation index, int attno)
Definition: nbtree.c:1418
void _bt_parallel_release(IndexScanDesc scan, BlockNumber scan_page)
Definition: nbtree.c:693
BTPageOpaqueData * BTPageOpaque
Definition: nbtree.h:71
#define BT_PIVOT_HEAP_TID_ATTR
Definition: nbtree.h:467
static uint16 BTreeTupleGetNPosting(IndexTuple posting)
Definition: nbtree.h:513
void _bt_upgrademetapage(Page page)
Definition: nbtpage.c:109
void _bt_relbuf(Relation rel, Buffer buf)
Definition: nbtpage.c:1035
IndexTuple _bt_swap_posting(IndexTuple newitem, IndexTuple oposting, int postingoff)
Definition: nbtdedup.c:1018
static bool BTreeTupleIsPivot(IndexTuple itup)
Definition: nbtree.h:475
Buffer _bt_gettrueroot(Relation rel)
Definition: nbtpage.c:577
int _bt_getrootheight(Relation rel)
Definition: nbtpage.c:672
BTStackData * BTStack
Definition: nbtree.h:734
void _bt_end_vacuum(Relation rel)
Definition: nbtutils.c:2033
bool btvalidate(Oid opclassoid)
Definition: nbtvalidate.c:41
void _bt_pageinit(Page page, Size size)
Definition: nbtpage.c:1141
bool _bt_first(IndexScanDesc scan, ScanDirection dir)
Definition: nbtsearch.c:860
OffsetNumber _bt_findsplitloc(Relation rel, Page origpage, OffsetNumber newitemoff, Size newitemsz, IndexTuple newitem, bool *newitemonleft)
Definition: nbtsplitloc.c:129
static FullTransactionId BTPageGetDeleteXid(Page page)
Definition: nbtree.h:261
#define BTP_HAS_FULLXID
Definition: nbtree.h:84
void _bt_update_posting(BTVacuumPosting vacposting)
Definition: nbtdedup.c:920
bool _bt_bottomupdel_pass(Relation rel, Buffer buf, Relation heapRel, Size newitemsz)
Definition: nbtdedup.c:306
char * btbuildphasename(int64 phasenum)
Definition: nbtutils.c:2157
#define BTP_HALF_DEAD
Definition: nbtree.h:80
static bool BTPageIsRecyclable(Page page)
Definition: nbtree.h:292
bool _bt_dedup_save_htid(BTDedupState state, IndexTuple itup)
Definition: nbtdedup.c:483
void _bt_end_vacuum_callback(int code, Datum arg)
Definition: nbtutils.c:2061
void _bt_pagedel(Relation rel, Buffer leafbuf, BTVacState *vstate)
Definition: nbtpage.c:1815
struct BTPageOpaqueData BTPageOpaqueData
IndexScanDesc btbeginscan(Relation rel, int nkeys, int norderbys)
Definition: nbtree.c:343
void _bt_delitems_vacuum(Relation rel, Buffer buf, OffsetNumber *deletable, int ndeletable, BTVacuumPosting *updatable, int nupdatable)
Definition: nbtpage.c:1166
static void BTreeTupleSetTopParent(IndexTuple leafhikey, BlockNumber blkno)
Definition: nbtree.h:621
Buffer _bt_getroot(Relation rel, int access)
Definition: nbtpage.c:343
void _bt_freestack(BTStack stack)
Definition: nbtutils.c:182
static void BTreeTupleSetPosting(IndexTuple itup, uint16 nhtids, int postingoffset)
Definition: nbtree.h:499
void BTreeShmemInit(void)
Definition: nbtutils.c:2083
void _bt_parallel_done(IndexScanDesc scan)
Definition: nbtree.c:716
IndexBulkDeleteResult * btbulkdelete(IndexVacuumInfo *info, IndexBulkDeleteResult *stats, IndexBulkDeleteCallback callback, void *callback_state)
Definition: nbtree.c:785
void _bt_dedup_start_pending(BTDedupState state, IndexTuple base, OffsetNumber baseoff)
Definition: nbtdedup.c:432
#define BTPageGetOpaque(page)
Definition: nbtree.h:73
#define P_ISDELETED(opaque)
Definition: nbtree.h:223
bytea * btoptions(Datum reloptions, bool validate)
Definition: nbtutils.c:2111
static ItemPointer BTreeTupleGetPosting(IndexTuple posting)
Definition: nbtree.h:532
void _bt_checkpage(Relation rel, Buffer buf)
Definition: nbtpage.c:794
bool _bt_advance_array_keys(IndexScanDesc scan, ScanDirection dir)
Definition: nbtutils.c:551
BTCycleId _bt_vacuum_cycleid(Relation rel)
Definition: nbtutils.c:1942
void _bt_metaversion(Relation rel, bool *heapkeyspace, bool *allequalimage)
Definition: nbtpage.c:736
static BlockNumber BTreeTupleGetTopParent(IndexTuple leafhikey)
Definition: nbtree.h:615
struct BTArrayKeyInfo BTArrayKeyInfo
void _bt_parallel_advance_array_keys(IndexScanDesc scan)
Definition: nbtree.c:757
void btadjustmembers(Oid opfamilyoid, Oid opclassoid, List *operators, List *functions)
Definition: nbtvalidate.c:293
BTScanInsert _bt_mkscankey(Relation rel, IndexTuple itup)
Definition: nbtutils.c:90
struct BTPendingFSM BTPendingFSM
void _bt_killitems(IndexScanDesc scan)
Definition: nbtutils.c:1725
#define BT_OFFSET_MASK
Definition: nbtree.h:464
IndexBulkDeleteResult * btvacuumcleanup(IndexVacuumInfo *info, IndexBulkDeleteResult *stats)
Definition: nbtree.c:815
IndexTuple _bt_form_posting(IndexTuple base, ItemPointer htids, int nhtids)
Definition: nbtdedup.c:860
bool _bt_doinsert(Relation rel, IndexTuple itup, IndexUniqueCheck checkUnique, bool indexUnchanged, Relation heapRel)
Definition: nbtinsert.c:100
#define MaxTIDsPerBTreePage
Definition: nbtree.h:186
void _bt_finish_split(Relation rel, Buffer lbuf, BTStack stack)
Definition: nbtinsert.c:2230
static void BTreeTupleSetDownLink(IndexTuple pivot, BlockNumber blkno)
Definition: nbtree.h:557
bool _bt_checkkeys(IndexScanDesc scan, IndexTuple tuple, int tupnatts, ScanDirection dir, bool *continuescan)
Definition: nbtutils.c:1362
bool btgettuple(IndexScanDesc scan, ScanDirection dir)
Definition: nbtree.c:211
void btparallelrescan(IndexScanDesc scan)
Definition: nbtree.c:594
struct BTVacState BTVacState
void _bt_preprocess_array_keys(IndexScanDesc scan)
Definition: nbtutils.c:210
bool _bt_check_natts(Relation rel, bool heapkeyspace, Page page, OffsetNumber offnum)
Definition: nbtutils.c:2471
IndexTuple _bt_truncate(Relation rel, IndexTuple lastleft, IndexTuple firstright, BTScanInsert itup_key)
Definition: nbtutils.c:2205
void _bt_set_cleanup_info(Relation rel, BlockNumber num_delpages)
Definition: nbtpage.c:234
#define BT_STATUS_OFFSET_MASK
Definition: nbtree.h:465
uint16 BTCycleId
Definition: nbtree.h:29
static uint32 BTreeTupleGetPostingOffset(IndexTuple posting)
Definition: nbtree.h:524
struct BTScanInsertData BTScanInsertData
void btbuildempty(Relation index)
Definition: nbtree.c:151
bool _bt_parallel_seize(IndexScanDesc scan, BlockNumber *pageno)
Definition: nbtree.c:635
struct BTMetaPageData BTMetaPageData
bool _bt_conditionallockbuf(Relation rel, Buffer buf)
Definition: nbtpage.c:1105
Buffer _bt_getbuf(Relation rel, BlockNumber blkno, int access)
Definition: nbtpage.c:871
BTScanInsertData * BTScanInsert
Definition: nbtree.h:796
Size btestimateparallelscan(void)
Definition: nbtree.c:570
int _bt_keep_natts_fast(Relation rel, IndexTuple lastleft, IndexTuple firstright)
Definition: nbtutils.c:2424
static ItemPointer BTreeTupleGetPostingN(IndexTuple posting, int n)
Definition: nbtree.h:539
IndexBuildResult * btbuild(Relation heap, Relation index, struct IndexInfo *indexInfo)
Definition: nbtsort.c:301
void btinitparallelscan(void *target)
Definition: nbtree.c:579
void _bt_parallel_build_main(dsm_segment *seg, shm_toc *toc)
Definition: nbtsort.c:1798
void _bt_unlockbuf(Relation rel, Buffer buf)
Definition: nbtpage.c:1082
static BlockNumber BTreeTupleGetDownLink(IndexTuple pivot)
Definition: nbtree.h:551
void _bt_restore_array_keys(IndexScanDesc scan)
Definition: nbtutils.c:629
#define INDEX_ALT_TID_MASK
Definition: nbtree.h:461
void _bt_upgradelockbufcleanup(Relation rel, Buffer buf)
Definition: nbtpage.c:1121
void _bt_initmetapage(Page page, BlockNumber rootbknum, uint32 level, bool allequalimage)
Definition: nbtpage.c:69
Buffer _bt_getstackbuf(Relation rel, BTStack stack, BlockNumber child)
Definition: nbtinsert.c:2307
BTVacuumPostingData * BTVacuumPosting
Definition: nbtree.h:914
void _bt_delitems_delete_check(Relation rel, Buffer buf, Relation heapRel, TM_IndexDeleteOp *delstate)
Definition: nbtpage.c:1528
struct BTDeletedPageData BTDeletedPageData
bool _bt_vacuum_needs_cleanup(Relation rel)
Definition: nbtpage.c:181
OffsetNumber _bt_binsrch_insert(Relation rel, BTInsertState insertstate)
Definition: nbtsearch.c:442
bool _bt_next(IndexScanDesc scan, ScanDirection dir)
Definition: nbtsearch.c:1466
struct BTDedupInterval BTDedupInterval
int32 _bt_compare(Relation rel, BTScanInsert key, Page page, OffsetNumber offnum)
Definition: nbtsearch.c:656
struct BTScanPosItem BTScanPosItem
static ItemPointer BTreeTupleGetMaxHeapTID(IndexTuple itup)
Definition: nbtree.h:659
void _bt_dedup_pass(Relation rel, Buffer buf, Relation heapRel, IndexTuple newitem, Size newitemsz, bool bottomupdedup)
Definition: nbtdedup.c:58
static bool BTreeTupleIsPosting(IndexTuple itup)
Definition: nbtree.h:487
Size BTreeShmemSize(void)
Definition: nbtutils.c:2070
Buffer _bt_get_endpoint(Relation rel, uint32 level, bool rightmost, Snapshot snapshot)
Definition: nbtsearch.c:2307
void _bt_mark_array_keys(IndexScanDesc scan)
Definition: nbtutils.c:610
static void BTPageSetDeleted(Page page, FullTransactionId safexid)
Definition: nbtree.h:240
int64 btgetbitmap(IndexScanDesc scan, TIDBitmap *tbm)
Definition: nbtree.c:285
void btmarkpos(IndexScanDesc scan)
Definition: nbtree.c:484
BTDedupStateData * BTDedupState
Definition: nbtree.h:893
void btendscan(IndexScanDesc scan)
Definition: nbtree.c:448
void _bt_pendingfsm_finalize(Relation rel, BTVacState *vstate)
Definition: nbtpage.c:2955
#define BT_IS_POSTING
Definition: nbtree.h:468
void _bt_lockbuf(Relation rel, Buffer buf, int access)
Definition: nbtpage.c:1051
struct BTOptions BTOptions
void btrescan(IndexScanDesc scan, ScanKey scankey, int nscankeys, ScanKey orderbys, int norderbys)
Definition: nbtree.c:389
bool btproperty(Oid index_oid, int attno, IndexAMProperty prop, const char *propname, bool *res, bool *isnull)
Definition: nbtutils.c:2134
struct BTScanPosData BTScanPosData
static ItemPointer BTreeTupleGetHeapTID(IndexTuple itup)
Definition: nbtree.h:633
void _bt_pendingfsm_init(Relation rel, BTVacState *vstate, bool cleanuponly)
Definition: nbtpage.c:2914
Size _bt_dedup_finish_pending(Page newpage, BTDedupState state)
Definition: nbtdedup.c:554
struct BTScanOpaqueData BTScanOpaqueData
BTStack _bt_search(Relation rel, BTScanInsert key, Buffer *bufP, int access, Snapshot snapshot)
Definition: nbtsearch.c:96
BTInsertStateData * BTInsertState
Definition: nbtree.h:835
static void BTreeTupleSetNAtts(IndexTuple itup, uint16 nkeyatts, bool heaptid)
Definition: nbtree.h:590
void btrestrpos(IndexScanDesc scan)
Definition: nbtree.c:514
bool _bt_allequalimage(Relation rel, bool debugmessage)
Definition: nbtutils.c:2696
struct BTDedupStateData BTDedupStateData
#define BTP_DELETED
Definition: nbtree.h:78
void _bt_start_array_keys(IndexScanDesc scan, ScanDirection dir)
Definition: nbtutils.c:525
void _bt_preprocess_keys(IndexScanDesc scan)
Definition: nbtutils.c:749
struct BTStackData BTStackData
BTCycleId _bt_start_vacuum(Relation rel)
Definition: nbtutils.c:1976
BTScanPosData * BTScanPos
Definition: nbtree.h:988
struct BTInsertStateData BTInsertStateData
struct BTVacuumPostingData BTVacuumPostingData
Buffer _bt_moveright(Relation rel, BTScanInsert key, Buffer buf, bool forupdate, BTStack stack, int access, Snapshot snapshot)
Definition: nbtsearch.c:236
BTScanOpaqueData * BTScanOpaque
Definition: nbtree.h:1074
uint16 OffsetNumber
Definition: off.h:24
void * arg
#define INDEX_MAX_KEYS
static void header(const char *fmt,...) pg_attribute_printf(1
Definition: pg_regress.c:212
static char * buf
Definition: pg_test_fsync.c:67
uintptr_t Datum
Definition: postgres.h:411
unsigned int Oid
Definition: postgres_ext.h:31
bool GlobalVisCheckRemovableFullXid(Relation rel, FullTransactionId fxid)
Definition: procarray.c:4260
static const struct fns functions
Definition: regcomp.c:313
ScanDirection
Definition: sdir.h:23
Datum * elem_values
Definition: nbtree.h:1029
uint16 nitems
Definition: nbtree.h:844
OffsetNumber baseoff
Definition: nbtree.h:843
Size maxpostingsize
Definition: nbtree.h:870
ItemPointer htids
Definition: nbtree.h:878
bool deduplicate
Definition: nbtree.h:868
OffsetNumber baseoff
Definition: nbtree.h:874
Size basetupsize
Definition: nbtree.h:875
BTDedupInterval intervals[MaxIndexTuplesPerPage]
Definition: nbtree.h:890
IndexTuple base
Definition: nbtree.h:873
Size phystupsize
Definition: nbtree.h:881
FullTransactionId safexid
Definition: nbtree.h:236
OffsetNumber stricthigh
Definition: nbtree.h:825
bool bounds_valid
Definition: nbtree.h:823
OffsetNumber low
Definition: nbtree.h:824
IndexTuple itup
Definition: nbtree.h:811
BTScanInsert itup_key
Definition: nbtree.h:813
uint32 btm_last_cleanup_num_delpages
Definition: nbtree.h:114
uint32 btm_level
Definition: nbtree.h:108
float8 btm_last_cleanup_num_heap_tuples
Definition: nbtree.h:116
BlockNumber btm_fastroot
Definition: nbtree.h:109
uint32 btm_version
Definition: nbtree.h:106
uint32 btm_magic
Definition: nbtree.h:105
BlockNumber btm_root
Definition: nbtree.h:107
bool btm_allequalimage
Definition: nbtree.h:118
uint32 btm_fastlevel
Definition: nbtree.h:110
int fillfactor
Definition: nbtree.h:1090
bool deduplicate_items
Definition: nbtree.h:1092
float8 vacuum_cleanup_index_scale_factor
Definition: nbtree.h:1091
int32 varlena_header_
Definition: nbtree.h:1089
BlockNumber btpo_next
Definition: nbtree.h:65
BlockNumber btpo_prev
Definition: nbtree.h:64
uint16 btpo_flags
Definition: nbtree.h:67
uint32 btpo_level
Definition: nbtree.h:66
BTCycleId btpo_cycleid
Definition: nbtree.h:68
FullTransactionId safexid
Definition: nbtree.h:329
BlockNumber target
Definition: nbtree.h:328
bool pivotsearch
Definition: nbtree.h:790
ItemPointer scantid
Definition: nbtree.h:791
bool allequalimage
Definition: nbtree.h:787
bool heapkeyspace
Definition: nbtree.h:786
bool anynullkeys
Definition: nbtree.h:788
ScanKeyData scankeys[INDEX_MAX_KEYS]
Definition: nbtree.h:793
BTArrayKeyInfo * arrayKeys
Definition: nbtree.h:1045
char * markTuples
Definition: nbtree.h:1058
BTScanPosData currPos
Definition: nbtree.h:1070
int * killedItems
Definition: nbtree.h:1049
char * currTuples
Definition: nbtree.h:1057
ScanKey arrayKeyData
Definition: nbtree.h:1040
BTScanPosData markPos
Definition: nbtree.h:1071
ScanKey keyData
Definition: nbtree.h:1037
MemoryContext arrayContext
Definition: nbtree.h:1046
bool moreRight
Definition: nbtree.h:966
Buffer buf
Definition: nbtree.h:953
BlockNumber currPage
Definition: nbtree.h:956
int firstItem
Definition: nbtree.h:981
int nextTupleOffset
Definition: nbtree.h:972
BlockNumber nextPage
Definition: nbtree.h:957
bool moreLeft
Definition: nbtree.h:965
int lastItem
Definition: nbtree.h:982
BTScanPosItem items[MaxTIDsPerBTreePage]
Definition: nbtree.h:985
int itemIndex
Definition: nbtree.h:983
XLogRecPtr lsn
Definition: nbtree.h:955
ItemPointerData heapTid
Definition: nbtree.h:946
LocationIndex tupleOffset
Definition: nbtree.h:948
OffsetNumber indexOffset
Definition: nbtree.h:947
BlockNumber bts_blkno
Definition: nbtree.h:729
struct BTStackData * bts_parent
Definition: nbtree.h:731
OffsetNumber bts_offset
Definition: nbtree.h:730
IndexBulkDeleteResult * stats
Definition: nbtree.h:335
BTCycleId cycleid
Definition: nbtree.h:338
BTPendingFSM * pendingpages
Definition: nbtree.h:346
int npendingpages
Definition: nbtree.h:347
IndexBulkDeleteCallback callback
Definition: nbtree.h:336
MemoryContext pagedelcontext
Definition: nbtree.h:339
IndexVacuumInfo * info
Definition: nbtree.h:334
int bufsize
Definition: nbtree.h:344
int maxbufsize
Definition: nbtree.h:345
void * callback_state
Definition: nbtree.h:337
uint16 deletetids[FLEXIBLE_ARRAY_MEMBER]
Definition: nbtree.h:911
uint16 ndeletedtids
Definition: nbtree.h:910
IndexTuple itup
Definition: nbtree.h:906
OffsetNumber updatedoffset
Definition: nbtree.h:907
ItemPointerData t_tid
Definition: itup.h:37
unsigned short t_info
Definition: itup.h:49
Definition: pg_list.h:52
Definition: type.h:90
Definition: regguts.h:318
Definition: c.h:633
static void callback(struct sockaddr *addr, struct sockaddr *mask, void *unused)
Definition: test_ifaddrs.c:48
#define FirstNormalFullTransactionId
Definition: transam.h:57
uint64 XLogRecPtr
Definition: xlogdefs.h:21