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