PostgreSQL Source Code git master
Loading...
Searching...
No Matches
nbtutils.c
Go to the documentation of this file.
1/*-------------------------------------------------------------------------
2 *
3 * nbtutils.c
4 * Utility code for Postgres btree implementation.
5 *
6 * Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group
7 * Portions Copyright (c) 1994, Regents of the University of California
8 *
9 *
10 * IDENTIFICATION
11 * src/backend/access/nbtree/nbtutils.c
12 *
13 *-------------------------------------------------------------------------
14 */
15
16#include "postgres.h"
17
18#include <time.h>
19
20#include "access/nbtree.h"
21#include "access/reloptions.h"
22#include "access/relscan.h"
23#include "commands/progress.h"
24#include "common/int.h"
25#include "lib/qunique.h"
26#include "miscadmin.h"
27#include "utils/datum.h"
28#include "utils/lsyscache.h"
29#include "utils/rel.h"
30
31
32static int _bt_compare_int(const void *va, const void *vb);
33static int _bt_keep_natts(Relation rel, IndexTuple lastleft,
35
36
37/*
38 * _bt_mkscankey
39 * Build an insertion scan key that contains comparison data from itup
40 * as well as comparator routines appropriate to the key datatypes.
41 *
42 * The result is intended for use with _bt_compare() and _bt_truncate().
43 * Callers that don't need to fill out the insertion scankey arguments
44 * (e.g. they use an ad-hoc comparison routine, or only need a scankey
45 * for _bt_truncate()) can pass a NULL index tuple. The scankey will
46 * be initialized as if an "all truncated" pivot tuple was passed
47 * instead.
48 *
49 * Note that we may occasionally have to share lock the metapage to
50 * determine whether or not the keys in the index are expected to be
51 * unique (i.e. if this is a "heapkeyspace" index). We assume a
52 * heapkeyspace index when caller passes a NULL tuple, allowing index
53 * build callers to avoid accessing the non-existent metapage. We
54 * also assume that the index is _not_ allequalimage when a NULL tuple
55 * is passed; CREATE INDEX callers call _bt_allequalimage() to set the
56 * field themselves.
57 */
60{
61 BTScanInsert key;
64 int indnkeyatts;
66 int tupnatts;
67 int i;
68
72 tupnatts = itup ? BTreeTupleGetNAtts(itup, rel) : 0;
73
75
76 /*
77 * We'll execute search using scan key constructed on key columns.
78 * Truncated attributes and non-key attributes are omitted from the final
79 * scan key.
80 */
81 key = palloc(offsetof(BTScanInsertData, scankeys) +
82 sizeof(ScanKeyData) * indnkeyatts);
83 if (itup)
84 _bt_metaversion(rel, &key->heapkeyspace, &key->allequalimage);
85 else
86 {
87 /* Utility statement callers can set these fields themselves */
88 key->heapkeyspace = true;
89 key->allequalimage = false;
90 }
91 key->anynullkeys = false; /* initial assumption */
92 key->nextkey = false; /* usual case, required by btinsert */
93 key->backward = false; /* usual case, required by btinsert */
94 key->keysz = Min(indnkeyatts, tupnatts);
95 key->scantid = key->heapkeyspace && itup ?
97 skey = key->scankeys;
98 for (i = 0; i < indnkeyatts; i++)
99 {
101 Datum arg;
102 bool null;
103 int flags;
104
105 /*
106 * We can use the cached (default) support procs since no cross-type
107 * comparison can be needed.
108 */
110
111 /*
112 * Key arguments built from truncated attributes (or when caller
113 * provides no tuple) are defensively represented as NULL values. They
114 * should never be used.
115 */
116 if (i < tupnatts)
117 arg = index_getattr(itup, i + 1, itupdesc, &null);
118 else
119 {
120 arg = (Datum) 0;
121 null = true;
122 }
123 flags = (null ? SK_ISNULL : 0) | (indoption[i] << SK_BT_INDOPTION_SHIFT);
125 flags,
126 (AttrNumber) (i + 1),
129 rel->rd_indcollation[i],
130 procinfo,
131 arg);
132 /* Record if any key attribute is NULL (or truncated) */
133 if (null)
134 key->anynullkeys = true;
135 }
136
137 /*
138 * In NULLS NOT DISTINCT mode, we pretend that there are no null keys, so
139 * that full uniqueness check is done.
140 */
141 if (rel->rd_index->indnullsnotdistinct)
142 key->anynullkeys = false;
143
144 return key;
145}
146
147/*
148 * qsort comparison function for int arrays
149 */
150static int
151_bt_compare_int(const void *va, const void *vb)
152{
153 int a = *((const int *) va);
154 int b = *((const int *) vb);
155
156 return pg_cmp_s32(a, b);
157}
158
159/*
160 * _bt_killitems - set LP_DEAD state for items an indexscan caller has
161 * told us were killed
162 *
163 * scan->opaque, referenced locally through so, contains information about the
164 * current page and killed tuples thereon (generally, this should only be
165 * called if so->numKilled > 0).
166 *
167 * Caller should not have a lock on the so->currPos page, but must hold a
168 * buffer pin when !so->dropPin. When we return, it still won't be locked.
169 * It'll continue to hold whatever pins were held before calling here.
170 *
171 * We match items by heap TID before assuming they are the right ones to set
172 * LP_DEAD. If the scan is one that holds a buffer pin on the target page
173 * continuously from initially reading the items until applying this function
174 * (if it is a !so->dropPin scan), VACUUM cannot have deleted any items on the
175 * page, so the page's TIDs can't have been recycled by now. There's no risk
176 * that we'll confuse a new index tuple that happens to use a recycled TID
177 * with a now-removed tuple with the same TID (that used to be on this same
178 * page). We can't rely on that during scans that drop buffer pins eagerly
179 * (so->dropPin scans), though, so we must condition setting LP_DEAD bits on
180 * the page LSN having not changed since back when _bt_readpage saw the page.
181 * We totally give up on setting LP_DEAD bits when the page LSN changed.
182 *
183 * We give up much less often during !so->dropPin scans, but it still happens.
184 * We cope with cases where items have moved right due to insertions. If an
185 * item has moved off the current page due to a split, we'll fail to find it
186 * and just give up on it.
187 */
188void
190{
191 Relation rel = scan->indexRelation;
193 Page page;
194 BTPageOpaque opaque;
195 OffsetNumber minoff;
196 OffsetNumber maxoff;
197 int numKilled = so->numKilled;
198 bool killedsomething = false;
199 Buffer buf;
200
201 Assert(numKilled > 0);
202 Assert(BTScanPosIsValid(so->currPos));
203 Assert(scan->heapRelation != NULL); /* can't be a bitmap index scan */
204
205 /* Always invalidate so->killedItems[] before leaving so->currPos */
206 so->numKilled = 0;
207
208 /*
209 * We need to iterate through so->killedItems[] in leaf page order; the
210 * loop below expects this (when marking posting list tuples, at least).
211 * so->killedItems[] is now in whatever order the scan returned items in.
212 * Scrollable cursor scans might have even saved the same item/TID twice.
213 *
214 * Sort and unique-ify so->killedItems[] to deal with all this.
215 */
216 if (numKilled > 1)
217 {
218 qsort(so->killedItems, numKilled, sizeof(int), _bt_compare_int);
219 numKilled = qunique(so->killedItems, numKilled, sizeof(int),
221 }
222
223 if (!so->dropPin)
224 {
225 /*
226 * We have held the pin on this page since we read the index tuples,
227 * so all we need to do is lock it. The pin will have prevented
228 * concurrent VACUUMs from recycling any of the TIDs on the page.
229 */
230 Assert(BTScanPosIsPinned(so->currPos));
231 buf = so->currPos.buf;
232 _bt_lockbuf(rel, buf, BT_READ);
233 }
234 else
235 {
237
238 Assert(!BTScanPosIsPinned(so->currPos));
239 buf = _bt_getbuf(rel, so->currPos.currPage, BT_READ);
240
242 Assert(so->currPos.lsn <= latestlsn);
243 if (so->currPos.lsn != latestlsn)
244 {
245 /* Modified, give up on hinting */
246 _bt_relbuf(rel, buf);
247 return;
248 }
249
250 /* Unmodified, hinting is safe */
251 }
252
253 page = BufferGetPage(buf);
254 opaque = BTPageGetOpaque(page);
255 minoff = P_FIRSTDATAKEY(opaque);
256 maxoff = PageGetMaxOffsetNumber(page);
257
258 /* Iterate through so->killedItems[] in leaf page order */
259 for (int i = 0; i < numKilled; i++)
260 {
261 int itemIndex = so->killedItems[i];
262 BTScanPosItem *kitem = &so->currPos.items[itemIndex];
264
265 Assert(itemIndex >= so->currPos.firstItem &&
266 itemIndex <= so->currPos.lastItem);
267 Assert(i == 0 ||
268 offnum >= so->currPos.items[so->killedItems[i - 1]].indexOffset);
269
270 if (offnum < minoff)
271 continue; /* pure paranoia */
272 while (offnum <= maxoff)
273 {
274 ItemId iid = PageGetItemId(page, offnum);
276 bool killtuple = false;
277
279 {
280 int pi = i + 1;
282 int j;
283
284 /*
285 * Note that the page may have been modified in almost any way
286 * since we first read it (in the !so->dropPin case), so it's
287 * possible that this posting list tuple wasn't a posting list
288 * tuple when we first encountered its heap TIDs.
289 */
290 for (j = 0; j < nposting; j++)
291 {
293
294 if (!ItemPointerEquals(item, &kitem->heapTid))
295 break; /* out of posting list loop */
296
297 /*
298 * kitem must have matching offnum when heap TIDs match,
299 * though only in the common case where the page can't
300 * have been concurrently modified
301 */
302 Assert(kitem->indexOffset == offnum || !so->dropPin);
303
304 /*
305 * Read-ahead to later kitems here.
306 *
307 * We rely on the assumption that not advancing kitem here
308 * will prevent us from considering the posting list tuple
309 * fully dead by not matching its next heap TID in next
310 * loop iteration.
311 *
312 * If, on the other hand, this is the final heap TID in
313 * the posting list tuple, then tuple gets killed
314 * regardless (i.e. we handle the case where the last
315 * kitem is also the last heap TID in the last index tuple
316 * correctly -- posting tuple still gets killed).
317 */
318 if (pi < numKilled)
319 kitem = &so->currPos.items[so->killedItems[pi++]];
320 }
321
322 /*
323 * Don't bother advancing the outermost loop's int iterator to
324 * avoid processing killed items that relate to the same
325 * offnum/posting list tuple. This micro-optimization hardly
326 * seems worth it. (Further iterations of the outermost loop
327 * will fail to match on this same posting list's first heap
328 * TID instead, so we'll advance to the next offnum/index
329 * tuple pretty quickly.)
330 */
331 if (j == nposting)
332 killtuple = true;
333 }
334 else if (ItemPointerEquals(&ituple->t_tid, &kitem->heapTid))
335 killtuple = true;
336
337 /*
338 * Mark index item as dead, if it isn't already. Since this
339 * happens while holding a buffer lock possibly in shared mode,
340 * it's possible that multiple processes attempt to do this
341 * simultaneously, leading to multiple full-page images being sent
342 * to WAL (if wal_log_hints or data checksums are enabled), which
343 * is undesirable.
344 */
345 if (killtuple && !ItemIdIsDead(iid))
346 {
347 if (!killedsomething)
348 {
349 /*
350 * Use the hint bit infrastructure to check if we can
351 * update the page while just holding a share lock. If we
352 * are not allowed, there's no point continuing.
353 */
355 goto unlock_page;
356 }
357
358 /* found the item/all posting list items */
360 killedsomething = true;
361 break; /* out of inner search loop */
362 }
363 offnum = OffsetNumberNext(offnum);
364 }
365 }
366
367 /*
368 * Since this can be redone later if needed, mark as dirty hint.
369 *
370 * Whenever we mark anything LP_DEAD, we also set the page's
371 * BTP_HAS_GARBAGE flag, which is likewise just a hint. (Note that we
372 * only rely on the page-level flag in !heapkeyspace indexes.)
373 */
374 if (killedsomething)
375 {
376 opaque->btpo_flags |= BTP_HAS_GARBAGE;
377 BufferFinishSetHintBits(buf, true, true);
378 }
379
381 if (!so->dropPin)
382 _bt_unlockbuf(rel, buf);
383 else
384 _bt_relbuf(rel, buf);
385}
386
387
388/*
389 * The following routines manage a shared-memory area in which we track
390 * assignment of "vacuum cycle IDs" to currently-active btree vacuuming
391 * operations. There is a single counter which increments each time we
392 * start a vacuum to assign it a cycle ID. Since multiple vacuums could
393 * be active concurrently, we have to track the cycle ID for each active
394 * vacuum; this requires at most MaxBackends entries (usually far fewer).
395 * We assume at most one vacuum can be active for a given index.
396 *
397 * Access to the shared memory area is controlled by BtreeVacuumLock.
398 * In principle we could use a separate lmgr locktag for each index,
399 * but a single LWLock is much cheaper, and given the short time that
400 * the lock is ever held, the concurrency hit should be minimal.
401 */
402
403typedef struct BTOneVacInfo
404{
405 LockRelId relid; /* global identifier of an index */
406 BTCycleId cycleid; /* cycle ID for its active VACUUM */
408
409typedef struct BTVacInfo
410{
411 BTCycleId cycle_ctr; /* cycle ID most recently assigned */
412 int num_vacuums; /* number of currently active VACUUMs */
413 int max_vacuums; /* allocated length of vacuums[] array */
416
418
419
420/*
421 * _bt_vacuum_cycleid --- get the active vacuum cycle ID for an index,
422 * or zero if there is no active VACUUM
423 *
424 * Note: for correct interlocking, the caller must already hold pin and
425 * exclusive lock on each buffer it will store the cycle ID into. This
426 * ensures that even if a VACUUM starts immediately afterwards, it cannot
427 * process those pages until the page split is complete.
428 */
431{
432 BTCycleId result = 0;
433 int i;
434
435 /* Share lock is enough since this is a read-only operation */
437
438 for (i = 0; i < btvacinfo->num_vacuums; i++)
439 {
441
442 if (vac->relid.relId == rel->rd_lockInfo.lockRelId.relId &&
443 vac->relid.dbId == rel->rd_lockInfo.lockRelId.dbId)
444 {
445 result = vac->cycleid;
446 break;
447 }
448 }
449
451 return result;
452}
453
454/*
455 * _bt_start_vacuum --- assign a cycle ID to a just-starting VACUUM operation
456 *
457 * Note: the caller must guarantee that it will eventually call
458 * _bt_end_vacuum, else we'll permanently leak an array slot. To ensure
459 * that this happens even in elog(FATAL) scenarios, the appropriate coding
460 * is not just a PG_TRY, but
461 * PG_ENSURE_ERROR_CLEANUP(_bt_end_vacuum_callback, PointerGetDatum(rel))
462 */
465{
466 BTCycleId result;
467 int i;
469
471
472 /*
473 * Assign the next cycle ID, being careful to avoid zero as well as the
474 * reserved high values.
475 */
476 result = ++(btvacinfo->cycle_ctr);
477 if (result == 0 || result > MAX_BT_CYCLE_ID)
478 result = btvacinfo->cycle_ctr = 1;
479
480 /* Let's just make sure there's no entry already for this index */
481 for (i = 0; i < btvacinfo->num_vacuums; i++)
482 {
483 vac = &btvacinfo->vacuums[i];
484 if (vac->relid.relId == rel->rd_lockInfo.lockRelId.relId &&
485 vac->relid.dbId == rel->rd_lockInfo.lockRelId.dbId)
486 {
487 /*
488 * Unlike most places in the backend, we have to explicitly
489 * release our LWLock before throwing an error. This is because
490 * we expect _bt_end_vacuum() to be called before transaction
491 * abort cleanup can run to release LWLocks.
492 */
494 elog(ERROR, "multiple active vacuums for index \"%s\"",
496 }
497 }
498
499 /* OK, add an entry */
501 {
503 elog(ERROR, "out of btvacinfo slots");
504 }
507 vac->cycleid = result;
509
511 return result;
512}
513
514/*
515 * _bt_end_vacuum --- mark a btree VACUUM operation as done
516 *
517 * Note: this is deliberately coded not to complain if no entry is found;
518 * this allows the caller to put PG_TRY around the start_vacuum operation.
519 */
520void
522{
523 int i;
524
526
527 /* Find the array entry */
528 for (i = 0; i < btvacinfo->num_vacuums; i++)
529 {
531
532 if (vac->relid.relId == rel->rd_lockInfo.lockRelId.relId &&
533 vac->relid.dbId == rel->rd_lockInfo.lockRelId.dbId)
534 {
535 /* Remove it by shifting down the last entry */
538 break;
539 }
540 }
541
543}
544
545/*
546 * _bt_end_vacuum wrapped as an on_shmem_exit callback function
547 */
548void
553
554/*
555 * BTreeShmemSize --- report amount of shared memory space needed
556 */
557Size
559{
560 Size size;
561
562 size = offsetof(BTVacInfo, vacuums);
563 size = add_size(size, mul_size(MaxBackends, sizeof(BTOneVacInfo)));
564 return size;
565}
566
567/*
568 * BTreeShmemInit --- initialize this module's shared memory
569 */
570void
572{
573 bool found;
574
575 btvacinfo = (BTVacInfo *) ShmemInitStruct("BTree Vacuum State",
577 &found);
578
580 {
581 /* Initialize shared memory area */
582 Assert(!found);
583
584 /*
585 * It doesn't really matter what the cycle counter starts at, but
586 * having it always start the same doesn't seem good. Seed with
587 * low-order bits of time() instead.
588 */
590
593 }
594 else
595 Assert(found);
596}
597
598bytea *
599btoptions(Datum reloptions, bool validate)
600{
601 static const relopt_parse_elt tab[] = {
602 {"fillfactor", RELOPT_TYPE_INT, offsetof(BTOptions, fillfactor)},
603 {"vacuum_cleanup_index_scale_factor", RELOPT_TYPE_REAL,
604 offsetof(BTOptions, vacuum_cleanup_index_scale_factor)},
605 {"deduplicate_items", RELOPT_TYPE_BOOL,
606 offsetof(BTOptions, deduplicate_items)}
607 };
608
609 return (bytea *) build_reloptions(reloptions, validate,
611 sizeof(BTOptions),
612 tab, lengthof(tab));
613}
614
615/*
616 * btproperty() -- Check boolean properties of indexes.
617 *
618 * This is optional, but handling AMPROP_RETURNABLE here saves opening the rel
619 * to call btcanreturn.
620 */
621bool
623 IndexAMProperty prop, const char *propname,
624 bool *res, bool *isnull)
625{
626 switch (prop)
627 {
629 /* answer only for columns, not AM or whole index */
630 if (attno == 0)
631 return false;
632 /* otherwise, btree can always return data */
633 *res = true;
634 return true;
635
636 default:
637 return false; /* punt to generic code */
638 }
639}
640
641/*
642 * btbuildphasename() -- Return name of index build phase.
643 */
644char *
646{
647 switch (phasenum)
648 {
650 return "initializing";
652 return "scanning table";
654 return "sorting live tuples";
656 return "sorting dead tuples";
658 return "loading tuples in tree";
659 default:
660 return NULL;
661 }
662}
663
664/*
665 * _bt_truncate() -- create tuple without unneeded suffix attributes.
666 *
667 * Returns truncated pivot index tuple allocated in caller's memory context,
668 * with key attributes copied from caller's firstright argument. If rel is
669 * an INCLUDE index, non-key attributes will definitely be truncated away,
670 * since they're not part of the key space. More aggressive suffix
671 * truncation can take place when it's clear that the returned tuple does not
672 * need one or more suffix key attributes. We only need to keep firstright
673 * attributes up to and including the first non-lastleft-equal attribute.
674 * Caller's insertion scankey is used to compare the tuples; the scankey's
675 * argument values are not considered here.
676 *
677 * Note that returned tuple's t_tid offset will hold the number of attributes
678 * present, so the original item pointer offset is not represented. Caller
679 * should only change truncated tuple's downlink. Note also that truncated
680 * key attributes are treated as containing "minus infinity" values by
681 * _bt_compare().
682 *
683 * In the worst case (when a heap TID must be appended to distinguish lastleft
684 * from firstright), the size of the returned tuple is the size of firstright
685 * plus the size of an additional MAXALIGN()'d item pointer. This guarantee
686 * is important, since callers need to stay under the 1/3 of a page
687 * restriction on tuple size. If this routine is ever taught to truncate
688 * within an attribute/datum, it will need to avoid returning an enlarged
689 * tuple to caller when truncation + TOAST compression ends up enlarging the
690 * final datum.
691 */
694 BTScanInsert itup_key)
695{
698 int keepnatts;
703
704 /*
705 * We should only ever truncate non-pivot tuples from leaf pages. It's
706 * never okay to truncate when splitting an internal page.
707 */
709
710 /* Determine how many attributes must be kept in truncated tuple */
711 keepnatts = _bt_keep_natts(rel, lastleft, firstright, itup_key);
712
713#ifdef DEBUG_NO_TRUNCATE
714 /* Force truncation to be ineffective for testing purposes */
715 keepnatts = nkeyatts + 1;
716#endif
717
720
722 {
723 /*
724 * index_truncate_tuple() just returns a straight copy of firstright
725 * when it has no attributes to truncate. When that happens, we may
726 * need to truncate away a posting list here instead.
727 */
730 pivot->t_info &= ~INDEX_SIZE_MASK;
732 }
733
734 /*
735 * If there is a distinguishing key attribute within pivot tuple, we're
736 * done
737 */
738 if (keepnatts <= nkeyatts)
739 {
741 return pivot;
742 }
743
744 /*
745 * We have to store a heap TID in the new pivot tuple, since no non-TID
746 * key attribute value in firstright distinguishes the right side of the
747 * split from the left side. nbtree conceptualizes this case as an
748 * inability to truncate away any key attributes, since heap TID is
749 * treated as just another key attribute (despite lacking a pg_attribute
750 * entry).
751 *
752 * Use enlarged space that holds a copy of pivot. We need the extra space
753 * to store a heap TID at the end (using the special pivot tuple
754 * representation). Note that the original pivot already has firstright's
755 * possible posting list/non-key attribute values removed at this point.
756 */
760 /* Cannot leak memory here */
761 pfree(pivot);
762
763 /*
764 * Store all of firstright's key attribute values plus a tiebreaker heap
765 * TID value in enlarged pivot tuple
766 */
767 tidpivot->t_info &= ~INDEX_SIZE_MASK;
768 tidpivot->t_info |= newsize;
771
772 /*
773 * Lehman & Yao use lastleft as the leaf high key in all cases, but don't
774 * consider suffix truncation. It seems like a good idea to follow that
775 * example in cases where no truncation takes place -- use lastleft's heap
776 * TID. (This is also the closest value to negative infinity that's
777 * legally usable.)
778 */
780
781 /*
782 * We're done. Assert() that heap TID invariants hold before returning.
783 *
784 * Lehman and Yao require that the downlink to the right page, which is to
785 * be inserted into the parent page in the second phase of a page split be
786 * a strict lower bound on items on the right page, and a non-strict upper
787 * bound for items on the left page. Assert that heap TIDs follow these
788 * invariants, since a heap TID value is apparently needed as a
789 * tiebreaker.
790 */
791#ifndef DEBUG_NO_TRUNCATE
795 BTreeTupleGetHeapTID(lastleft)) >= 0);
798#else
799
800 /*
801 * Those invariants aren't guaranteed to hold for lastleft + firstright
802 * heap TID attribute values when they're considered here only because
803 * DEBUG_NO_TRUNCATE is defined (a heap TID is probably not actually
804 * needed as a tiebreaker). DEBUG_NO_TRUNCATE must therefore use a heap
805 * TID value that always works as a strict lower bound for items to the
806 * right. In particular, it must avoid using firstright's leading key
807 * attribute values along with lastleft's heap TID value when lastleft's
808 * TID happens to be greater than firstright's TID.
809 */
811
812 /*
813 * Pivot heap TID should never be fully equal to firstright. Note that
814 * the pivot heap TID will still end up equal to lastleft's heap TID when
815 * that's the only usable value.
816 */
821#endif
822
823 return tidpivot;
824}
825
826/*
827 * _bt_keep_natts - how many key attributes to keep when truncating.
828 *
829 * Caller provides two tuples that enclose a split point. Caller's insertion
830 * scankey is used to compare the tuples; the scankey's argument values are
831 * not considered here.
832 *
833 * This can return a number of attributes that is one greater than the
834 * number of key attributes for the index relation. This indicates that the
835 * caller must use a heap TID as a unique-ifier in new pivot tuple.
836 */
837static int
839 BTScanInsert itup_key)
840{
843 int keepnatts;
845
846 /*
847 * _bt_compare() treats truncated key attributes as having the value minus
848 * infinity, which would break searches within !heapkeyspace indexes. We
849 * must still truncate away non-key attribute values, though.
850 */
851 if (!itup_key->heapkeyspace)
852 return nkeyatts;
853
854 scankey = itup_key->scankeys;
855 keepnatts = 1;
856 for (int attnum = 1; attnum <= nkeyatts; attnum++, scankey++)
857 {
858 Datum datum1,
859 datum2;
860 bool isNull1,
861 isNull2;
862
863 datum1 = index_getattr(lastleft, attnum, itupdesc, &isNull1);
865
866 if (isNull1 != isNull2)
867 break;
868
869 if (!isNull1 &&
871 scankey->sk_collation,
872 datum1,
873 datum2)) != 0)
874 break;
875
876 keepnatts++;
877 }
878
879 /*
880 * Assert that _bt_keep_natts_fast() agrees with us in passing. This is
881 * expected in an allequalimage index.
882 */
883 Assert(!itup_key->allequalimage ||
884 keepnatts == _bt_keep_natts_fast(rel, lastleft, firstright));
885
886 return keepnatts;
887}
888
889/*
890 * _bt_keep_natts_fast - fast bitwise variant of _bt_keep_natts.
891 *
892 * This is exported so that a candidate split point can have its effect on
893 * suffix truncation inexpensively evaluated ahead of time when finding a
894 * split location. A naive bitwise approach to datum comparisons is used to
895 * save cycles.
896 *
897 * The approach taken here usually provides the same answer as _bt_keep_natts
898 * will (for the same pair of tuples from a heapkeyspace index), since the
899 * majority of btree opclasses can never indicate that two datums are equal
900 * unless they're bitwise equal after detoasting. When an index only has
901 * "equal image" columns, routine is guaranteed to give the same result as
902 * _bt_keep_natts would.
903 *
904 * Callers can rely on the fact that attributes considered equal here are
905 * definitely also equal according to _bt_keep_natts, even when the index uses
906 * an opclass or collation that is not "allequalimage"/deduplication-safe.
907 * This weaker guarantee is good enough for nbtsplitloc.c caller, since false
908 * negatives generally only have the effect of making leaf page splits use a
909 * more balanced split point.
910 */
911int
913{
916 int keepnatts;
917
918 keepnatts = 1;
919 for (int attnum = 1; attnum <= keysz; attnum++)
920 {
921 Datum datum1,
922 datum2;
923 bool isNull1,
924 isNull2;
926
927 datum1 = index_getattr(lastleft, attnum, itupdesc, &isNull1);
930
931 if (isNull1 != isNull2)
932 break;
933
934 if (!isNull1 &&
935 !datum_image_eq(datum1, datum2, att->attbyval, att->attlen))
936 break;
937
938 keepnatts++;
939 }
940
941 return keepnatts;
942}
943
944/*
945 * _bt_check_natts() -- Verify tuple has expected number of attributes.
946 *
947 * Returns value indicating if the expected number of attributes were found
948 * for a particular offset on page. This can be used as a general purpose
949 * sanity check.
950 *
951 * Testing a tuple directly with BTreeTupleGetNAtts() should generally be
952 * preferred to calling here. That's usually more convenient, and is always
953 * more explicit. Call here instead when offnum's tuple may be a negative
954 * infinity tuple that uses the pre-v11 on-disk representation, or when a low
955 * context check is appropriate. This routine is as strict as possible about
956 * what is expected on each version of btree.
957 */
958bool
959_bt_check_natts(Relation rel, bool heapkeyspace, Page page, OffsetNumber offnum)
960{
963 BTPageOpaque opaque = BTPageGetOpaque(page);
964 IndexTuple itup;
965 int tupnatts;
966
967 /*
968 * We cannot reliably test a deleted or half-dead page, since they have
969 * dummy high keys
970 */
971 if (P_IGNORE(opaque))
972 return true;
973
974 Assert(offnum >= FirstOffsetNumber &&
975 offnum <= PageGetMaxOffsetNumber(page));
976
977 itup = (IndexTuple) PageGetItem(page, PageGetItemId(page, offnum));
978 tupnatts = BTreeTupleGetNAtts(itup, rel);
979
980 /* !heapkeyspace indexes do not support deduplication */
981 if (!heapkeyspace && BTreeTupleIsPosting(itup))
982 return false;
983
984 /* Posting list tuples should never have "pivot heap TID" bit set */
985 if (BTreeTupleIsPosting(itup) &&
988 return false;
989
990 /* INCLUDE indexes do not support deduplication */
991 if (natts != nkeyatts && BTreeTupleIsPosting(itup))
992 return false;
993
994 if (P_ISLEAF(opaque))
995 {
996 if (offnum >= P_FIRSTDATAKEY(opaque))
997 {
998 /*
999 * Non-pivot tuple should never be explicitly marked as a pivot
1000 * tuple
1001 */
1002 if (BTreeTupleIsPivot(itup))
1003 return false;
1004
1005 /*
1006 * Leaf tuples that are not the page high key (non-pivot tuples)
1007 * should never be truncated. (Note that tupnatts must have been
1008 * inferred, even with a posting list tuple, because only pivot
1009 * tuples store tupnatts directly.)
1010 */
1011 return tupnatts == natts;
1012 }
1013 else
1014 {
1015 /*
1016 * Rightmost page doesn't contain a page high key, so tuple was
1017 * checked above as ordinary leaf tuple
1018 */
1019 Assert(!P_RIGHTMOST(opaque));
1020
1021 /*
1022 * !heapkeyspace high key tuple contains only key attributes. Note
1023 * that tupnatts will only have been explicitly represented in
1024 * !heapkeyspace indexes that happen to have non-key attributes.
1025 */
1026 if (!heapkeyspace)
1027 return tupnatts == nkeyatts;
1028
1029 /* Use generic heapkeyspace pivot tuple handling */
1030 }
1031 }
1032 else /* !P_ISLEAF(opaque) */
1033 {
1034 if (offnum == P_FIRSTDATAKEY(opaque))
1035 {
1036 /*
1037 * The first tuple on any internal page (possibly the first after
1038 * its high key) is its negative infinity tuple. Negative
1039 * infinity tuples are always truncated to zero attributes. They
1040 * are a particular kind of pivot tuple.
1041 */
1042 if (heapkeyspace)
1043 return tupnatts == 0;
1044
1045 /*
1046 * The number of attributes won't be explicitly represented if the
1047 * negative infinity tuple was generated during a page split that
1048 * occurred with a version of Postgres before v11. There must be
1049 * a problem when there is an explicit representation that is
1050 * non-zero, or when there is no explicit representation and the
1051 * tuple is evidently not a pre-pg_upgrade tuple.
1052 *
1053 * Prior to v11, downlinks always had P_HIKEY as their offset.
1054 * Accept that as an alternative indication of a valid
1055 * !heapkeyspace negative infinity tuple.
1056 */
1057 return tupnatts == 0 ||
1059 }
1060 else
1061 {
1062 /*
1063 * !heapkeyspace downlink tuple with separator key contains only
1064 * key attributes. Note that tupnatts will only have been
1065 * explicitly represented in !heapkeyspace indexes that happen to
1066 * have non-key attributes.
1067 */
1068 if (!heapkeyspace)
1069 return tupnatts == nkeyatts;
1070
1071 /* Use generic heapkeyspace pivot tuple handling */
1072 }
1073 }
1074
1075 /* Handle heapkeyspace pivot tuples (excluding minus infinity items) */
1076 Assert(heapkeyspace);
1077
1078 /*
1079 * Explicit representation of the number of attributes is mandatory with
1080 * heapkeyspace index pivot tuples, regardless of whether or not there are
1081 * non-key attributes.
1082 */
1083 if (!BTreeTupleIsPivot(itup))
1084 return false;
1085
1086 /* Pivot tuple should not use posting list representation (redundant) */
1087 if (BTreeTupleIsPosting(itup))
1088 return false;
1089
1090 /*
1091 * Heap TID is a tiebreaker key attribute, so it cannot be untruncated
1092 * when any other key attribute is truncated
1093 */
1094 if (BTreeTupleGetHeapTID(itup) != NULL && tupnatts != nkeyatts)
1095 return false;
1096
1097 /*
1098 * Pivot tuple must have at least one untruncated key attribute (minus
1099 * infinity pivot tuples are the only exception). Pivot tuples can never
1100 * represent that there is a value present for a key attribute that
1101 * exceeds pg_index.indnkeyatts for the index.
1102 */
1103 return tupnatts > 0 && tupnatts <= nkeyatts;
1104}
1105
1106/*
1107 *
1108 * _bt_check_third_page() -- check whether tuple fits on a btree page at all.
1109 *
1110 * We actually need to be able to fit three items on every page, so restrict
1111 * any one item to 1/3 the per-page available space. Note that itemsz should
1112 * not include the ItemId overhead.
1113 *
1114 * It might be useful to apply TOAST methods rather than throw an error here.
1115 * Using out of line storage would break assumptions made by suffix truncation
1116 * and by contrib/amcheck, though.
1117 */
1118void
1120 Page page, IndexTuple newtup)
1121{
1122 Size itemsz;
1123 BTPageOpaque opaque;
1124
1125 itemsz = MAXALIGN(IndexTupleSize(newtup));
1126
1127 /* Double check item size against limit */
1128 if (itemsz <= BTMaxItemSize)
1129 return;
1130
1131 /*
1132 * Tuple is probably too large to fit on page, but it's possible that the
1133 * index uses version 2 or version 3, or that page is an internal page, in
1134 * which case a slightly higher limit applies.
1135 */
1136 if (!needheaptidspace && itemsz <= BTMaxItemSizeNoHeapTid)
1137 return;
1138
1139 /*
1140 * Internal page insertions cannot fail here, because that would mean that
1141 * an earlier leaf level insertion that should have failed didn't
1142 */
1143 opaque = BTPageGetOpaque(page);
1144 if (!P_ISLEAF(opaque))
1145 elog(ERROR, "cannot insert oversized tuple of size %zu on internal page of index \"%s\"",
1146 itemsz, RelationGetRelationName(rel));
1147
1148 ereport(ERROR,
1150 errmsg("index row size %zu exceeds btree version %u maximum %zu for index \"%s\"",
1151 itemsz,
1155 errdetail("Index row references tuple (%u,%u) in relation \"%s\".",
1159 errhint("Values larger than 1/3 of a buffer page cannot be indexed.\n"
1160 "Consider a function index of an MD5 hash of the value, "
1161 "or use full text indexing."),
1163}
1164
1165/*
1166 * Are all attributes in rel "equality is image equality" attributes?
1167 *
1168 * We use each attribute's BTEQUALIMAGE_PROC opclass procedure. If any
1169 * opclass either lacks a BTEQUALIMAGE_PROC procedure or returns false, we
1170 * return false; otherwise we return true.
1171 *
1172 * Returned boolean value is stored in index metapage during index builds.
1173 * Deduplication can only be used when we return true.
1174 */
1175bool
1177{
1178 bool allequalimage = true;
1179
1180 /* INCLUDE indexes can never support deduplication */
1183 return false;
1184
1185 for (int i = 0; i < IndexRelationGetNumberOfKeyAttributes(rel); i++)
1186 {
1187 Oid opfamily = rel->rd_opfamily[i];
1188 Oid opcintype = rel->rd_opcintype[i];
1189 Oid collation = rel->rd_indcollation[i];
1191
1192 equalimageproc = get_opfamily_proc(opfamily, opcintype, opcintype,
1194
1195 /*
1196 * If there is no BTEQUALIMAGE_PROC then deduplication is assumed to
1197 * be unsafe. Otherwise, actually call proc and see what it says.
1198 */
1199 if (!OidIsValid(equalimageproc) ||
1201 ObjectIdGetDatum(opcintype))))
1202 {
1203 allequalimage = false;
1204 break;
1205 }
1206 }
1207
1208 if (debugmessage)
1209 {
1210 if (allequalimage)
1211 elog(DEBUG1, "index \"%s\" can safely use deduplication",
1213 else
1214 elog(DEBUG1, "index \"%s\" cannot use deduplication",
1216 }
1217
1218 return allequalimage;
1219}
IndexAMProperty
Definition amapi.h:39
@ AMPROP_RETURNABLE
Definition amapi.h:47
int16 AttrNumber
Definition attnum.h:21
static bool validate(Port *port, const char *auth)
Definition auth-oauth.c:638
int Buffer
Definition buf.h:23
void BufferFinishSetHintBits(Buffer buffer, bool mark_dirty, bool buffer_std)
Definition bufmgr.c:6937
XLogRecPtr BufferGetLSNAtomic(Buffer buffer)
Definition bufmgr.c:4632
bool BufferBeginSetHintBits(Buffer buffer)
Definition bufmgr.c:6909
static Page BufferGetPage(Buffer buffer)
Definition bufmgr.h:470
static ItemId PageGetItemId(Page page, OffsetNumber offsetNumber)
Definition bufpage.h:269
static void * PageGetItem(PageData *page, const ItemIdData *itemId)
Definition bufpage.h:379
PageData * Page
Definition bufpage.h:81
static OffsetNumber PageGetMaxOffsetNumber(const PageData *page)
Definition bufpage.h:397
#define Min(x, y)
Definition c.h:1093
#define MAXALIGN(LEN)
Definition c.h:898
#define Assert(condition)
Definition c.h:945
int64_t int64
Definition c.h:615
#define FLEXIBLE_ARRAY_MEMBER
Definition c.h:552
int16_t int16
Definition c.h:613
#define lengthof(array)
Definition c.h:875
#define OidIsValid(objectId)
Definition c.h:860
size_t Size
Definition c.h:691
bool datum_image_eq(Datum value1, Datum value2, bool typByVal, int typLen)
Definition datum.c:266
Datum arg
Definition elog.c:1322
int errcode(int sqlerrcode)
Definition elog.c:874
int errhint(const char *fmt,...) pg_attribute_printf(1
int errdetail(const char *fmt,...) pg_attribute_printf(1
#define DEBUG1
Definition elog.h:30
#define ERROR
Definition elog.h:39
#define elog(elevel,...)
Definition elog.h:226
#define ereport(elevel,...)
Definition elog.h:150
Datum FunctionCall2Coll(FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2)
Definition fmgr.c:1151
Datum OidFunctionCall1Coll(Oid functionId, Oid collation, Datum arg1)
Definition fmgr.c:1413
bool IsUnderPostmaster
Definition globals.c:120
int MaxBackends
Definition globals.c:146
FmgrInfo * index_getprocinfo(Relation irel, AttrNumber attnum, uint16 procnum)
Definition indexam.c:917
IndexTuple index_truncate_tuple(TupleDesc sourceDescriptor, IndexTuple source, int leavenatts)
Definition indextuple.c:508
static int pg_cmp_s32(int32 a, int32 b)
Definition int.h:713
int b
Definition isn.c:74
int a
Definition isn.c:73
int j
Definition isn.c:78
int i
Definition isn.c:77
#define ItemIdMarkDead(itemId)
Definition itemid.h:179
#define ItemIdIsDead(itemId)
Definition itemid.h:113
int32 ItemPointerCompare(const ItemPointerData *arg1, const ItemPointerData *arg2)
Definition itemptr.c:51
bool ItemPointerEquals(const ItemPointerData *pointer1, const ItemPointerData *pointer2)
Definition itemptr.c:35
static void ItemPointerSetOffsetNumber(ItemPointerData *pointer, OffsetNumber offsetNumber)
Definition itemptr.h:158
static OffsetNumber ItemPointerGetOffsetNumber(const ItemPointerData *pointer)
Definition itemptr.h:124
static OffsetNumber ItemPointerGetOffsetNumberNoCheck(const ItemPointerData *pointer)
Definition itemptr.h:114
static BlockNumber ItemPointerGetBlockNumber(const ItemPointerData *pointer)
Definition itemptr.h:103
static void ItemPointerCopy(const ItemPointerData *fromPointer, ItemPointerData *toPointer)
Definition itemptr.h:172
IndexTupleData * IndexTuple
Definition itup.h:53
static Datum index_getattr(IndexTuple tup, int attnum, TupleDesc tupleDesc, bool *isnull)
Definition itup.h:131
static Size IndexTupleSize(const IndexTupleData *itup)
Definition itup.h:71
Oid get_opfamily_proc(Oid opfamily, Oid lefttype, Oid righttype, int16 procnum)
Definition lsyscache.c:915
bool LWLockAcquire(LWLock *lock, LWLockMode mode)
Definition lwlock.c:1177
void LWLockRelease(LWLock *lock)
Definition lwlock.c:1794
@ LW_SHARED
Definition lwlock.h:113
@ LW_EXCLUSIVE
Definition lwlock.h:112
void pfree(void *pointer)
Definition mcxt.c:1616
void * palloc0(Size size)
Definition mcxt.c:1417
void * palloc(Size size)
Definition mcxt.c:1387
void _bt_relbuf(Relation rel, Buffer buf)
Definition nbtpage.c:1028
void _bt_metaversion(Relation rel, bool *heapkeyspace, bool *allequalimage)
Definition nbtpage.c:744
Buffer _bt_getbuf(Relation rel, BlockNumber blkno, int access)
Definition nbtpage.c:850
void _bt_unlockbuf(Relation rel, Buffer buf)
Definition nbtpage.c:1075
void _bt_lockbuf(Relation rel, Buffer buf, int access)
Definition nbtpage.c:1044
#define BTScanPosIsPinned(scanpos)
Definition nbtree.h:1004
#define BT_PIVOT_HEAP_TID_ATTR
Definition nbtree.h:466
static uint16 BTreeTupleGetNPosting(IndexTuple posting)
Definition nbtree.h:519
static bool BTreeTupleIsPivot(IndexTuple itup)
Definition nbtree.h:481
#define P_ISLEAF(opaque)
Definition nbtree.h:221
#define P_HIKEY
Definition nbtree.h:368
#define PROGRESS_BTREE_PHASE_PERFORMSORT_2
Definition nbtree.h:1148
#define PROGRESS_BTREE_PHASE_LEAF_LOAD
Definition nbtree.h:1149
#define BTP_HAS_GARBAGE
Definition nbtree.h:83
#define BTEQUALIMAGE_PROC
Definition nbtree.h:720
#define BTORDER_PROC
Definition nbtree.h:717
#define BTPageGetOpaque(page)
Definition nbtree.h:74
#define BTREE_VERSION
Definition nbtree.h:151
#define BTScanPosIsValid(scanpos)
Definition nbtree.h:1021
#define PROGRESS_BTREE_PHASE_INDEXBUILD_TABLESCAN
Definition nbtree.h:1146
#define SK_BT_INDOPTION_SHIFT
Definition nbtree.h:1115
#define P_FIRSTDATAKEY(opaque)
Definition nbtree.h:370
#define MAX_BT_CYCLE_ID
Definition nbtree.h:94
#define PROGRESS_BTREE_PHASE_PERFORMSORT_1
Definition nbtree.h:1147
uint16 BTCycleId
Definition nbtree.h:30
static uint32 BTreeTupleGetPostingOffset(IndexTuple posting)
Definition nbtree.h:530
#define P_RIGHTMOST(opaque)
Definition nbtree.h:220
static ItemPointer BTreeTupleGetPostingN(IndexTuple posting, int n)
Definition nbtree.h:545
#define BT_READ
Definition nbtree.h:730
#define P_IGNORE(opaque)
Definition nbtree.h:226
static ItemPointer BTreeTupleGetMaxHeapTID(IndexTuple itup)
Definition nbtree.h:665
static bool BTreeTupleIsPosting(IndexTuple itup)
Definition nbtree.h:493
#define BTREE_NOVAC_VERSION
Definition nbtree.h:153
#define BTMaxItemSizeNoHeapTid
Definition nbtree.h:170
static ItemPointer BTreeTupleGetHeapTID(IndexTuple itup)
Definition nbtree.h:639
static void BTreeTupleSetNAtts(IndexTuple itup, uint16 nkeyatts, bool heaptid)
Definition nbtree.h:596
#define BTMaxItemSize
Definition nbtree.h:165
#define BTreeTupleGetNAtts(itup, rel)
Definition nbtree.h:578
BTScanOpaqueData * BTScanOpaque
Definition nbtree.h:1097
void _bt_check_third_page(Relation rel, Relation heap, bool needheaptidspace, Page page, IndexTuple newtup)
Definition nbtutils.c:1119
void _bt_end_vacuum(Relation rel)
Definition nbtutils.c:521
void _bt_end_vacuum_callback(int code, Datum arg)
Definition nbtutils.c:549
void BTreeShmemInit(void)
Definition nbtutils.c:571
BTCycleId _bt_vacuum_cycleid(Relation rel)
Definition nbtutils.c:430
BTScanInsert _bt_mkscankey(Relation rel, IndexTuple itup)
Definition nbtutils.c:59
void _bt_killitems(IndexScanDesc scan)
Definition nbtutils.c:189
bool _bt_check_natts(Relation rel, bool heapkeyspace, Page page, OffsetNumber offnum)
Definition nbtutils.c:959
IndexTuple _bt_truncate(Relation rel, IndexTuple lastleft, IndexTuple firstright, BTScanInsert itup_key)
Definition nbtutils.c:693
int _bt_keep_natts_fast(Relation rel, IndexTuple lastleft, IndexTuple firstright)
Definition nbtutils.c:912
static BTVacInfo * btvacinfo
Definition nbtutils.c:417
char * btbuildphasename(int64 phasenum)
Definition nbtutils.c:645
bytea * btoptions(Datum reloptions, bool validate)
Definition nbtutils.c:599
Size BTreeShmemSize(void)
Definition nbtutils.c:558
static int _bt_keep_natts(Relation rel, IndexTuple lastleft, IndexTuple firstright, BTScanInsert itup_key)
Definition nbtutils.c:838
bool btproperty(Oid index_oid, int attno, IndexAMProperty prop, const char *propname, bool *res, bool *isnull)
Definition nbtutils.c:622
bool _bt_allequalimage(Relation rel, bool debugmessage)
Definition nbtutils.c:1176
static int _bt_compare_int(const void *va, const void *vb)
Definition nbtutils.c:151
BTCycleId _bt_start_vacuum(Relation rel)
Definition nbtutils.c:464
static char * errmsg
#define OffsetNumberNext(offsetNumber)
Definition off.h:52
uint16 OffsetNumber
Definition off.h:24
#define FirstOffsetNumber
Definition off.h:27
#define OffsetNumberPrev(offsetNumber)
Definition off.h:54
int16 attnum
static char buf[DEFAULT_XLOG_SEG_SIZE]
static int fillfactor
Definition pgbench.c:188
#define qsort(a, b, c, d)
Definition port.h:495
static bool DatumGetBool(Datum X)
Definition postgres.h:100
static Datum ObjectIdGetDatum(Oid X)
Definition postgres.h:252
uint64_t Datum
Definition postgres.h:70
static Pointer DatumGetPointer(Datum X)
Definition postgres.h:332
static int32 DatumGetInt32(Datum X)
Definition postgres.h:202
#define InvalidOid
unsigned int Oid
static int fb(int x)
#define PROGRESS_CREATEIDX_SUBPHASE_INITIALIZE
Definition progress.h:132
static size_t qunique(void *array, size_t elements, size_t width, int(*compare)(const void *, const void *))
Definition qunique.h:21
#define RelationGetDescr(relation)
Definition rel.h:540
#define RelationGetRelationName(relation)
Definition rel.h:548
#define IndexRelationGetNumberOfAttributes(relation)
Definition rel.h:526
#define IndexRelationGetNumberOfKeyAttributes(relation)
Definition rel.h:533
int errtableconstraint(Relation rel, const char *conname)
Definition relcache.c:6116
void * build_reloptions(Datum reloptions, bool validate, relopt_kind kind, Size relopt_struct_size, const relopt_parse_elt *relopt_elems, int num_relopt_elems)
@ RELOPT_KIND_BTREE
Definition reloptions.h:45
@ RELOPT_TYPE_INT
Definition reloptions.h:33
@ RELOPT_TYPE_BOOL
Definition reloptions.h:31
@ RELOPT_TYPE_REAL
Definition reloptions.h:34
void ScanKeyEntryInitializeWithInfo(ScanKey entry, int flags, AttrNumber attributeNumber, StrategyNumber strategy, Oid subtype, Oid collation, FmgrInfo *finfo, Datum argument)
Definition scankey.c:101
Size add_size(Size s1, Size s2)
Definition shmem.c:485
Size mul_size(Size s1, Size s2)
Definition shmem.c:500
void * ShmemInitStruct(const char *name, Size size, bool *foundPtr)
Definition shmem.c:381
#define SK_ISNULL
Definition skey.h:115
#define InvalidStrategy
Definition stratnum.h:24
BTCycleId cycleid
Definition nbtutils.c:406
LockRelId relid
Definition nbtutils.c:405
uint16 btpo_flags
Definition nbtree.h:68
bool allequalimage
Definition nbtree.h:798
bool heapkeyspace
Definition nbtree.h:797
ScanKeyData scankeys[INDEX_MAX_KEYS]
Definition nbtree.h:804
OffsetNumber indexOffset
Definition nbtree.h:958
BTCycleId cycle_ctr
Definition nbtutils.c:411
int num_vacuums
Definition nbtutils.c:412
BTOneVacInfo vacuums[FLEXIBLE_ARRAY_MEMBER]
Definition nbtutils.c:414
int max_vacuums
Definition nbtutils.c:413
Relation indexRelation
Definition relscan.h:138
Relation heapRelation
Definition relscan.h:137
ItemPointerData t_tid
Definition itup.h:37
LockRelId lockRelId
Definition rel.h:46
Oid relId
Definition rel.h:40
Oid dbId
Definition rel.h:41
LockInfoData rd_lockInfo
Definition rel.h:114
Oid * rd_opcintype
Definition rel.h:208
int16 * rd_indoption
Definition rel.h:211
Form_pg_index rd_index
Definition rel.h:192
Oid * rd_opfamily
Definition rel.h:207
Oid * rd_indcollation
Definition rel.h:217
Definition c.h:778
static CompactAttribute * TupleDescCompactAttr(TupleDesc tupdesc, int i)
Definition tupdesc.h:193
uint64 XLogRecPtr
Definition xlogdefs.h:21