36#include "catalog/pg_opfamily_d.h"
55#define InvalidBtreeLevel ((uint32) InvalidBlockNumber)
56#define BTreeTupleGetNKeyAtts(itup, rel) \
57 Min(IndexRelationGetNumberOfKeyAttributes(rel), BTreeTupleGetNAtts(itup, rel))
180 void *
state,
bool readonly);
182 bool heapkeyspace,
bool readonly,
bool heapallindexed,
183 bool rootdescend,
bool checkunique);
214 bool tupleIsAlive,
void *checkstate);
257 args.heapallindexed =
false;
258 args.rootdescend =
false;
259 args.parentcheck =
false;
260 args.checkunique =
false;
289 args.heapallindexed =
false;
290 args.rootdescend =
false;
291 args.parentcheck =
true;
292 args.checkunique =
false;
320 (
errcode(ERRCODE_INDEX_CORRUPTED),
321 errmsg(
"index \"%s\" lacks a main relation fork",
326 if (allequalimage && !heapkeyspace)
328 (
errcode(ERRCODE_INDEX_CORRUPTED),
329 errmsg(
"index \"%s\" metapage has equalimage field set on unsupported nbtree version",
333 bool has_interval_ops =
false;
338 has_interval_ops =
true;
340 (
errcode(ERRCODE_INDEX_CORRUPTED),
341 errmsg(
"index \"%s\" metapage incorrectly indicates that deduplication is safe",
344 ?
errhint(
"This is known of \"interval\" indexes last built on a version predating 2023-11.")
351 args->heapallindexed, args->rootdescend, args->checkunique);
379 bool readonly,
bool heapallindexed,
bool rootdescend,
389 elog(
DEBUG1,
"verifying consistency of tree structure for index \"%s\"",
392 elog(
DEBUG1,
"verifying consistency of tree structure for index \"%s\" with cross-level checks",
406 state->heaprel = heaprel;
407 state->heapkeyspace = heapkeyspace;
408 state->readonly = readonly;
409 state->heapallindexed = heapallindexed;
410 state->rootdescend = rootdescend;
411 state->checkunique = checkunique;
414 if (
state->heapallindexed)
434 state->heaptuplespresent = 0;
459 state->snapshot->xmin))
462 errmsg(
"index \"%s\" cannot be verified using transaction snapshot",
471 if (
state->checkunique)
480 if (
state->rootdescend && !
state->heapkeyspace)
482 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
483 errmsg(
"cannot verify that tuples from index \"%s\" can each be found by an independent index search",
485 errhint(
"Only B-Tree version 4 indexes support rootdescend verification.")));
510 errdetail_internal(
"Fast root block %u (level %u) differs from true root block %u (level %u).",
533 (
errcode(ERRCODE_INDEX_CORRUPTED),
534 errmsg(
"index \"%s\" has no valid pages on level below %u or first level",
537 previouslevel = current.
level;
543 if (
state->heapallindexed)
584 elog(
DEBUG1,
"verifying that tuples from index \"%s\" are present in \"%s\"",
645 " (true root level)" : level.
level == 0 ?
" (leaf level)" :
"");
648 state->previncompletesplit =
false;
656 state->targetblock = current;
677 (
errcode(ERRCODE_INDEX_CORRUPTED),
678 errmsg(
"downlink or sibling link points to deleted block in index \"%s\"",
681 current, leftcurrent, opaque->
btpo_prev)));
685 (
errcode(ERRCODE_INDEX_CORRUPTED),
686 errmsg(
"block %u fell off the end of index \"%s\"",
708 (
errcode(ERRCODE_INDEX_CORRUPTED),
709 errmsg(
"block %u is not leftmost in index \"%s\"",
714 (
errcode(ERRCODE_INDEX_CORRUPTED),
715 errmsg(
"block %u is not true root in index \"%s\"",
775 (
errcode(ERRCODE_INDEX_CORRUPTED),
776 errmsg(
"leftmost down link for level points to block in index \"%s\" whose level is not one level down",
778 errdetail_internal(
"Block pointed to=%u expected level=%u level in pointed to block=%u.",
787 if (current == leftcurrent || current == opaque->
btpo_prev)
789 (
errcode(ERRCODE_INDEX_CORRUPTED),
790 errmsg(
"circular link chain found in block %u of index \"%s\"",
793 leftcurrent = current;
800 state->lowkey = NULL;
835 while (current !=
P_NONE);
841 state->lowkey = NULL;
847 return nextleveldown;
859 tid,
state->snapshot, slot);
891 if (nblock != lVis->
blkno || noffset != lVis->
offset)
892 nitid =
psprintf(
" tid=(%u,%u)", nblock, noffset);
898 pnposting =
psprintf(
" posting %u", nposting);
901 (
errcode(ERRCODE_INDEX_CORRUPTED),
902 errmsg(
"index uniqueness is violated for index \"%s\"",
904 errdetail(
"Index %s%s and%s%s (point to heap %s and %s) page lsn=%X/%08X.",
905 itid, pposting, nitid, pnposting, htid, nhtid,
916 bool has_visible_entry =
false;
931 has_visible_entry =
true;
948 lVis->
blkno = targetblock;
966 has_visible_entry =
true;
975 lVis->
blkno = targetblock;
982 if (!has_visible_entry &&
984 lVis->
blkno != targetblock)
992 errmsg(
"index uniqueness can not be checked for index tid=(%u,%u) in index \"%s\"",
995 errdetail(
"It doesn't have visible heap tids and key is equal to the tid=(%u,%u)%s (points to heap tid=(%u,%u)).",
999 errhint(
"VACUUM the table and repeat the check.")));
1015 reached_from =
start;
1016 bool all_half_dead =
true;
1024 while (reached !=
P_NONE && all_half_dead)
1038 reached != reached_from &&
1039 reached_opaque->
btpo_next == reached_from;
1047 errmsg_internal(
"harmless interrupted page deletion detected in index \"%s\"",
1050 reached, reached_from,
1053 reached_from = reached;
1060 return all_half_dead;
1106 if (!
state->readonly)
1136 if (newtargetblock != leftcurrent)
1140 state->checkstrategy);
1146 btpo_prev_from_target = opaque->
btpo_prev;
1168 if (btpo_prev_from_target == leftcurrent)
1172 (
errcode(ERRCODE_INTERNAL_ERROR),
1173 errmsg_internal(
"harmless concurrent page split detected in index \"%s\"",
1176 leftcurrent, newtargetblock,
1177 state->targetblock)));
1188 state->targetblock = newtargetblock;
1192 (
errcode(ERRCODE_INDEX_CORRUPTED),
1193 errmsg(
"left link/right link pair in index \"%s\" not in agreement",
1196 state->targetblock, leftcurrent,
1197 btpo_prev_from_target)));
1251 elog(
DEBUG2,
"verifying %u items on %s block %u", max,
1252 P_ISLEAF(topaque) ?
"leaf" :
"internal",
state->targetblock);
1271 (
errcode(ERRCODE_INDEX_CORRUPTED),
1272 errmsg(
"wrong number of high key index tuple attributes in index \"%s\"",
1277 P_ISLEAF(topaque) ?
"heap" :
"index",
1295 bool lowersizelimit;
1303 bool unique_checked =
false;
1308 state->target, offset);
1320 (
errcode(ERRCODE_INDEX_CORRUPTED),
1321 errmsg(
"index tuple size does not equal lp_len in index \"%s\"",
1324 state->targetblock, offset,
1327 errhint(
"This could be a torn page problem.")));
1344 (
errcode(ERRCODE_INDEX_CORRUPTED),
1345 errmsg(
"wrong number of index tuple attributes in index \"%s\"",
1350 P_ISLEAF(topaque) ?
"heap" :
"index",
1394 (
errcode(ERRCODE_INDEX_CORRUPTED),
1395 errmsg(
"could not find tuple using search from root page in index \"%s\"",
1420 char *itid =
psprintf(
"(%u,%u)",
state->targetblock, offset);
1423 (
errcode(ERRCODE_INDEX_CORRUPTED),
1424 errmsg_internal(
"posting list contains misplaced TID in index \"%s\"",
1476 (
errcode(ERRCODE_INDEX_CORRUPTED),
1477 errmsg(
"index row size %zu exceeds maximum for index \"%s\"",
1481 P_ISLEAF(topaque) ?
"heap" :
"index",
1503 if (norm != logtuple)
1583 (
errcode(ERRCODE_INDEX_CORRUPTED),
1584 errmsg(
"high key invariant violated for index \"%s\"",
1588 P_ISLEAF(topaque) ?
"heap" :
"index",
1629 (
errcode(ERRCODE_INDEX_CORRUPTED),
1630 errmsg(
"item order invariant violated for index \"%s\"",
1632 errdetail_internal(
"Lower index tid=%s (points to %s tid=%s) higher index tid=%s (points to %s tid=%s) page lsn=%X/%08X.",
1634 P_ISLEAF(topaque) ?
"heap" :
"index",
1637 P_ISLEAF(topaque) ?
"heap" :
"index",
1648 if (
state->checkunique &&
state->indexinfo->ii_Unique &&
1654 unique_checked =
true;
1657 if (
state->checkunique &&
state->indexinfo->ii_Unique &&
1686 else if (!unique_checked)
1731 if (!
state->readonly)
1746 (
errcode(ERRCODE_INDEX_CORRUPTED),
1747 errmsg(
"cross page item order invariant violated for index \"%s\"",
1750 state->targetblock, offset,
1758 if (
state->checkunique &&
state->indexinfo->ii_Unique &&
1763 elog(
DEBUG2,
"check cross page unique condition");
1782 if (!unique_checked)
1799 (
errcode(ERRCODE_INDEX_CORRUPTED),
1800 errmsg(
"right block of leaf block is non-leaf for index \"%s\"",
1922 errmsg_internal(
"level %u sibling page in block %u of index \"%s\" was found deleted or half dead",
1924 errdetail_internal(
"Deleted page found when building scankey from right sibling.")));
2054 P_ISLEAF(opaque) ?
"leaf" :
"internal", targetnext,
2153 bool rightsplit =
state->previncompletesplit;
2162 state->target, target_downlinkoffnum);
2199 state->previncompletesplit =
false;
2206 (
errcode(ERRCODE_INDEX_CORRUPTED),
2207 errmsg(
"can't traverse from downlink %u to downlink %u of index \"%s\"",
2208 state->prevrightlink, downlink,
2212 if (blkno == downlink && loaded_child)
2213 page = loaded_child;
2223 (
errcode(ERRCODE_INDEX_CORRUPTED),
2224 errmsg(
"the first child of leftmost target page is not leftmost of its level in index \"%s\"",
2227 state->targetblock, blkno,
2234 (
errcode(ERRCODE_INDEX_CORRUPTED),
2235 errmsg(
"block found while following rightlinks from child of index \"%s\" has invalid level",
2237 errdetail_internal(
"Block pointed to=%u expected level=%u level in pointed to block=%u.",
2238 blkno, target_level - 1, opaque->
btpo_level)));
2241 if ((!first && blkno ==
state->prevrightlink) || blkno == opaque->
btpo_prev)
2243 (
errcode(ERRCODE_INDEX_CORRUPTED),
2244 errmsg(
"circular link chain found in block %u of index \"%s\"",
2247 if (blkno != downlink && !
P_IGNORE(opaque))
2291 if (blkno == downlink)
2294 pivotkey_offset = target_downlinkoffnum;
2309 (
errcode(ERRCODE_INDEX_CORRUPTED),
2310 errmsg(
"child high key is greater than rightmost pivot key on target level in index \"%s\"",
2313 state->targetblock, blkno,
2318 state->target, pivotkey_offset);
2339 (
errcode(ERRCODE_INDEX_CORRUPTED),
2340 errmsg(
"can't find left sibling high key in index \"%s\"",
2343 state->targetblock, blkno,
2345 itup =
state->lowkey;
2351 (
errcode(ERRCODE_INDEX_CORRUPTED),
2352 errmsg(
"mismatch between parent key and child high key in index \"%s\"",
2355 state->targetblock, blkno,
2361 if (blkno == downlink)
2364 state->previncompletesplit = rightsplit;
2372 if (page != loaded_child)
2405 state->target, downlinkoffnum);
2491 (
errcode(ERRCODE_INDEX_CORRUPTED),
2492 errmsg(
"downlink to deleted page found in index \"%s\"",
2495 state->targetblock, childblock,
2499 offset <= maxoffset;
2532 (
errcode(ERRCODE_INDEX_CORRUPTED),
2533 errmsg(
"down-link lower bound invariant violated for index \"%s\"",
2535 errdetail_internal(
"Parent block=%u child index tid=(%u,%u) parent page lsn=%X/%08X.",
2536 state->targetblock, childblock, offset,
2603 errmsg_internal(
"harmless interrupted page split detected in index \"%s\"",
2624 (
errcode(ERRCODE_INDEX_CORRUPTED),
2625 errmsg(
"leaf index block lacks downlink in index \"%s\"",
2632 elog(
DEBUG1,
"checking for interrupted multi-level deletion due to missing downlink in index \"%s\"",
2652 (
errcode(ERRCODE_INDEX_CORRUPTED),
2653 errmsg_internal(
"downlink points to block in index \"%s\" whose level is not one level down",
2655 errdetail_internal(
"Top parent/under check block=%u block pointed to=%u expected level=%u level in pointed to block=%u.",
2690 (
errcode(ERRCODE_INDEX_CORRUPTED),
2691 errmsg_internal(
"downlink to deleted leaf page found in index \"%s\"",
2693 errdetail_internal(
"Top parent/target block=%u leaf block=%u top parent/under check lsn=%X/%08X.",
2716 (
errcode(ERRCODE_INDEX_CORRUPTED),
2717 errmsg(
"internal index block lacks downlink in index \"%s\"",
2781 bool *isnull,
bool tupleIsAlive,
void *checkstate)
2799 errmsg(
"heap tuple (%u,%u) from table \"%s\" lacks matching index tuple within index \"%s\"",
2805 ?
errhint(
"Retrying verification using the function bt_index_parent_check() might provide a more specific error.")
2808 state->heaptuplespresent++;
2854 bool formnewtup =
false;
2865 for (
i = 0;
i < tupleDescriptor->
natts;
i++)
2872 need_free[
i] =
false;
2876 if (att->attbyval || att->attlen != -1 || isnull[
i])
2886 (
errcode(ERRCODE_INDEX_CORRUPTED),
2887 errmsg(
"external varlena datum in tuple that references heap row (%u,%u) in index \"%s\"",
2893 (att->attstorage == TYPSTORAGE_EXTENDED ||
2894 att->attstorage == TYPSTORAGE_MAIN))
2907 need_free[
i] =
true;
2925 need_free[
i] =
true;
2954 for (
i = 0;
i < tupleDescriptor->
natts;
i++)
3016 Assert(key->heapkeyspace && key->scantid != NULL);
3036 insertstate.
itup = itup;
3041 insertstate.
buf = lbuf;
3112 Assert(!key->nextkey && key->backward);
3118 if (!key->heapkeyspace)
3149 if (key->keysz == uppnkeyatts)
3150 return key->scantid == NULL && rheaptid != NULL;
3152 return key->keysz < uppnkeyatts;
3174 Assert(!key->nextkey && key->backward);
3197 Assert(!key->nextkey && key->backward);
3202 if (!key->heapkeyspace)
3235 Assert(!key->nextkey && key->backward);
3243 if (!key->heapkeyspace)
3264 if (key->keysz == uppnkeyatts)
3265 return key->scantid == NULL && childheaptid != NULL;
3267 return key->keysz < uppnkeyatts;
3302 state->checkstrategy);
3319 (
errcode(ERRCODE_INDEX_CORRUPTED),
3320 errmsg(
"invalid meta page found at block %u in index \"%s\"",
3331 (
errcode(ERRCODE_INDEX_CORRUPTED),
3332 errmsg(
"index \"%s\" meta page is corrupt",
3338 (
errcode(ERRCODE_INDEX_CORRUPTED),
3339 errmsg(
"version mismatch in index \"%s\": file version %d, "
3340 "current version %d, minimum supported version %d",
3360 (
errcode(ERRCODE_INDEX_CORRUPTED),
3361 errmsg_internal(
"invalid leaf page level %u for block %u in index \"%s\"",
3367 (
errcode(ERRCODE_INDEX_CORRUPTED),
3368 errmsg_internal(
"invalid internal page level 0 for block %u in index \"%s\"",
3395 (
errcode(ERRCODE_INDEX_CORRUPTED),
3396 errmsg(
"Number of items on block %u of index \"%s\" exceeds MaxIndexTuplesPerPage (%u)",
3402 (
errcode(ERRCODE_INDEX_CORRUPTED),
3403 errmsg(
"internal block %u in index \"%s\" lacks high key and/or at least one downlink",
3408 (
errcode(ERRCODE_INDEX_CORRUPTED),
3409 errmsg(
"non-rightmost leaf block %u in index \"%s\" lacks high key item",
3421 (
errcode(ERRCODE_INDEX_CORRUPTED),
3422 errmsg(
"internal page block %u in index \"%s\" is half-dead",
3424 errhint(
"This can be caused by an interrupted VACUUM in version 9.3 or older, before upgrade. Please REINDEX it.")));
3432 (
errcode(ERRCODE_INDEX_CORRUPTED),
3433 errmsg_internal(
"internal page block %u in index \"%s\" has garbage items",
3438 (
errcode(ERRCODE_INDEX_CORRUPTED),
3439 errmsg_internal(
"full transaction id page flag appears in non-deleted block %u in index \"%s\"",
3444 (
errcode(ERRCODE_INDEX_CORRUPTED),
3498 (
errcode(ERRCODE_INDEX_CORRUPTED),
3499 errmsg(
"line pointer points past end of tuple space in index \"%s\"",
3514 (
errcode(ERRCODE_INDEX_CORRUPTED),
3515 errmsg(
"invalid line pointer storage in index \"%s\"",
3543 (
errcode(ERRCODE_INDEX_CORRUPTED),
3544 errmsg_internal(
"block %u or its right sibling block or child block in index \"%s\" has unexpected pivot tuple",
3550 (
errcode(ERRCODE_INDEX_CORRUPTED),
3551 errmsg_internal(
"block %u or its right sibling block or child block in index \"%s\" has unexpected non-pivot tuple",
3558 (
errcode(ERRCODE_INDEX_CORRUPTED),
3559 errmsg(
"block %u or its right sibling block or child block in index \"%s\" contains non-pivot tuple that lacks a heap TID",
3590 return &itup->
t_tid;
#define InvalidBlockNumber
static bool BlockNumberIsValid(BlockNumber blockNumber)
void bloom_free(bloom_filter *filter)
bloom_filter * bloom_create(int64 total_elems, int bloom_work_mem, uint64 seed)
double bloom_prop_bits_set(bloom_filter *filter)
bool bloom_lacks_element(bloom_filter *filter, unsigned char *elem, size_t len)
void bloom_add_element(bloom_filter *filter, unsigned char *elem, size_t len)
static Datum values[MAXATTR]
void UnlockReleaseBuffer(Buffer buffer)
Buffer ReadBufferExtended(Relation reln, ForkNumber forkNum, BlockNumber blockNum, ReadBufferMode mode, BufferAccessStrategy strategy)
#define RelationGetNumberOfBlocks(reln)
static Page BufferGetPage(Buffer buffer)
static void LockBuffer(Buffer buffer, BufferLockMode mode)
static bool BufferIsValid(Buffer bufnum)
static ItemId PageGetItemId(Page page, OffsetNumber offsetNumber)
static void * PageGetItem(PageData *page, const ItemIdData *itemId)
static XLogRecPtr PageGetLSN(const PageData *page)
static OffsetNumber PageGetMaxOffsetNumber(const PageData *page)
#define Assert(condition)
memcpy(sums, checksumBaseOffsets, sizeof(checksumBaseOffsets))
int errcode(int sqlerrcode)
int int errdetail_internal(const char *fmt,...) pg_attribute_printf(1
int errhint(const char *fmt,...) pg_attribute_printf(1
int errdetail(const char *fmt,...) pg_attribute_printf(1
int int errmsg_internal(const char *fmt,...) pg_attribute_printf(1
#define ereport(elevel,...)
void ExecDropSingleTupleTableSlot(TupleTableSlot *slot)
#define palloc0_object(type)
#define PG_MODULE_MAGIC_EXT(...)
#define PG_FUNCTION_INFO_V1(funcname)
#define PG_DETOAST_DATUM(datum)
#define PG_GETARG_BOOL(n)
BufferAccessStrategy GetAccessStrategy(BufferAccessStrategyType btype)
#define TOAST_INDEX_TARGET
static TransactionId HeapTupleHeaderGetXmin(const HeapTupleHeaderData *tup)
IndexInfo * BuildIndexInfo(Relation index)
IndexTuple index_form_tuple(TupleDesc tupleDescriptor, const Datum *values, const bool *isnull)
#define ItemIdGetLength(itemId)
#define ItemIdGetOffset(itemId)
#define ItemIdIsDead(itemId)
#define ItemIdIsUsed(itemId)
#define ItemIdIsRedirected(itemId)
#define ItemIdGetFlags(itemId)
int32 ItemPointerCompare(const ItemPointerData *arg1, const ItemPointerData *arg2)
static OffsetNumber ItemPointerGetOffsetNumber(const ItemPointerData *pointer)
static OffsetNumber ItemPointerGetOffsetNumberNoCheck(const ItemPointerData *pointer)
static BlockNumber ItemPointerGetBlockNumber(const ItemPointerData *pointer)
static BlockNumber ItemPointerGetBlockNumberNoCheck(const ItemPointerData *pointer)
static void ItemPointerCopy(const ItemPointerData *fromPointer, ItemPointerData *toPointer)
static bool ItemPointerIsValid(const ItemPointerData *pointer)
static bool IndexTupleHasVarwidths(const IndexTupleData *itup)
IndexTupleData * IndexTuple
static Datum index_getattr(IndexTuple tup, int attnum, TupleDesc tupleDesc, bool *isnull)
static Size IndexTupleSize(const IndexTupleData *itup)
#define MaxIndexTuplesPerPage
void * MemoryContextAlloc(MemoryContext context, Size size)
void MemoryContextReset(MemoryContext context)
void pfree(void *pointer)
MemoryContext CurrentMemoryContext
void MemoryContextDelete(MemoryContext context)
#define AllocSetContextCreate
#define ALLOCSET_DEFAULT_SIZES
#define CHECK_FOR_INTERRUPTS()
IndexTuple _bt_form_posting(IndexTuple base, const ItemPointerData *htids, int nhtids)
void _bt_relbuf(Relation rel, Buffer buf)
void _bt_checkpage(Relation rel, Buffer buf)
void _bt_metaversion(Relation rel, bool *heapkeyspace, bool *allequalimage)
#define P_HAS_FULLXID(opaque)
#define P_ISHALFDEAD(opaque)
static uint16 BTreeTupleGetNPosting(IndexTuple posting)
static bool BTreeTupleIsPivot(IndexTuple itup)
#define BTREE_MIN_VERSION
#define P_HAS_GARBAGE(opaque)
#define BTPageGetOpaque(page)
#define P_ISDELETED(opaque)
static BlockNumber BTreeTupleGetTopParent(IndexTuple leafhikey)
#define MaxTIDsPerBTreePage
#define P_FIRSTDATAKEY(opaque)
#define P_RIGHTMOST(opaque)
#define P_INCOMPLETE_SPLIT(opaque)
static ItemPointer BTreeTupleGetPostingN(IndexTuple posting, int n)
static BlockNumber BTreeTupleGetDownLink(IndexTuple pivot)
static ItemPointer BTreeTupleGetMaxHeapTID(IndexTuple itup)
static bool BTreeTupleIsPosting(IndexTuple itup)
#define BTMaxItemSizeNoHeapTid
static ItemPointer BTreeTupleGetHeapTID(IndexTuple itup)
#define BTreeTupleGetNAtts(itup, rel)
OffsetNumber _bt_binsrch_insert(Relation rel, BTInsertState insertstate)
int32 _bt_compare(Relation rel, BTScanInsert key, Page page, OffsetNumber offnum)
BTStack _bt_search(Relation rel, Relation heaprel, BTScanInsert key, Buffer *bufP, int access, bool returnstack)
BTScanInsert _bt_mkscankey(Relation rel, IndexTuple itup)
bool _bt_check_natts(Relation rel, bool heapkeyspace, Page page, OffsetNumber offnum)
bool _bt_allequalimage(Relation rel, bool debugmessage)
#define InvalidOffsetNumber
#define OffsetNumberIsValid(offsetNumber)
#define OffsetNumberNext(offsetNumber)
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
FormData_pg_attribute * Form_pg_attribute
#define ERRCODE_DATA_CORRUPTED
uint64 pg_prng_uint64(pg_prng_state *state)
pg_prng_state pg_global_prng_state
#define ERRCODE_T_R_SERIALIZATION_FAILURE
static Datum PointerGetDatum(const void *X)
static Pointer DatumGetPointer(Datum X)
char * psprintf(const char *fmt,...)
static int cmp(const chr *x, const chr *y, size_t len)
static SMgrRelation RelationGetSmgr(Relation rel)
#define RelationGetDescr(relation)
#define RelationGetRelationName(relation)
#define IndexRelationGetNumberOfKeyAttributes(relation)
bool smgrexists(SMgrRelation reln, ForkNumber forknum)
Snapshot GetTransactionSnapshot(void)
void UnregisterSnapshot(Snapshot snapshot)
Snapshot RegisterSnapshot(Snapshot snapshot)
BufferAccessStrategy checkstrategy
BlockNumber prevrightlink
MemoryContext targetcontext
uint16 * ii_ExclusionStrats
struct HeapTupleData * rd_indextuple
TupleTableSlot * table_slot_create(Relation relation, List **reglist)
static double table_index_build_scan(Relation table_rel, Relation index_rel, IndexInfo *index_info, bool allow_sync, bool progress, IndexBuildCallback callback, void *callback_state, TableScanDesc scan)
static TableScanDesc table_beginscan_strat(Relation rel, Snapshot snapshot, int nkeys, ScanKeyData *key, bool allow_strat, bool allow_sync)
static bool table_tuple_fetch_row_version(Relation rel, ItemPointer tid, Snapshot snapshot, TupleTableSlot *slot)
#define TransactionIdIsValid(xid)
static bool TransactionIdPrecedes(TransactionId id1, TransactionId id2)
static FormData_pg_attribute * TupleDescAttr(TupleDesc tupdesc, int i)
static bool VARATT_CAN_MAKE_SHORT(const void *PTR)
static bool VARATT_IS_EXTERNAL(const void *PTR)
static Size VARSIZE(const void *PTR)
static char * VARDATA(const void *PTR)
static Size VARATT_CONVERTED_SHORT_SIZE(const void *PTR)
static bool VARATT_IS_COMPRESSED(const void *PTR)
static void SET_VARSIZE_SHORT(void *PTR, Size len)
void amcheck_lock_relation_and_check(Oid indrelid, Oid am_id, IndexDoCheckCallback check, LOCKMODE lockmode, void *state)
static bool offset_is_negative_infinity(BTPageOpaque opaque, OffsetNumber offset)
static bool bt_leftmost_ignoring_half_dead(BtreeCheckState *state, BlockNumber start, BTPageOpaque start_opaque)
static bool invariant_l_offset(BtreeCheckState *state, BTScanInsert key, OffsetNumber upperbound)
static ItemPointer BTreeTupleGetPointsToTID(IndexTuple itup)
static IndexTuple bt_posting_plain_tuple(IndexTuple itup, int n)
static void bt_target_page_check(BtreeCheckState *state)
static void bt_check_every_level(Relation rel, Relation heaprel, bool heapkeyspace, bool readonly, bool heapallindexed, bool rootdescend, bool checkunique)
static void bt_report_duplicate(BtreeCheckState *state, BtreeLastVisibleEntry *lVis, ItemPointer nexttid, BlockNumber nblock, OffsetNumber noffset, int nposting)
static bool bt_pivot_tuple_identical(bool heapkeyspace, IndexTuple itup1, IndexTuple itup2)
static bool invariant_leq_offset(BtreeCheckState *state, BTScanInsert key, OffsetNumber upperbound)
Datum bt_index_parent_check(PG_FUNCTION_ARGS)
static void bt_child_highkey_check(BtreeCheckState *state, OffsetNumber target_downlinkoffnum, Page loaded_child, uint32 target_level)
static bool heap_entry_is_visible(BtreeCheckState *state, ItemPointer tid)
static BTScanInsert bt_mkscankey_pivotsearch(Relation rel, IndexTuple itup)
Datum bt_index_check(PG_FUNCTION_ARGS)
static BtreeLevel bt_check_level_from_leftmost(BtreeCheckState *state, BtreeLevel level)
static void bt_downlink_missing_check(BtreeCheckState *state, bool rightsplit, BlockNumber blkno, Page page)
static ItemId PageGetItemIdCareful(BtreeCheckState *state, BlockNumber block, Page page, OffsetNumber offset)
static void bt_tuple_present_callback(Relation index, ItemPointer tid, Datum *values, bool *isnull, bool tupleIsAlive, void *checkstate)
static void bt_index_check_callback(Relation indrel, Relation heaprel, void *state, bool readonly)
static bool bt_rootdescend(BtreeCheckState *state, IndexTuple itup)
static BTScanInsert bt_right_page_check_scankey(BtreeCheckState *state, OffsetNumber *rightfirstoffset)
static bool invariant_g_offset(BtreeCheckState *state, BTScanInsert key, OffsetNumber lowerbound)
#define InvalidBtreeLevel
static Page palloc_btree_page(BtreeCheckState *state, BlockNumber blocknum)
static IndexTuple bt_normalize_tuple(BtreeCheckState *state, IndexTuple itup)
static void bt_recheck_sibling_links(BtreeCheckState *state, BlockNumber btpo_prev_from_target, BlockNumber leftcurrent)
static ItemPointer BTreeTupleGetHeapTIDCareful(BtreeCheckState *state, IndexTuple itup, bool nonpivot)
#define BTreeTupleGetNKeyAtts(itup, rel)
static void bt_child_check(BtreeCheckState *state, BTScanInsert targetkey, OffsetNumber downlinkoffnum)
static void bt_entry_unique_check(BtreeCheckState *state, IndexTuple itup, BlockNumber targetblock, OffsetNumber offset, BtreeLastVisibleEntry *lVis)
static bool invariant_l_nontarget_offset(BtreeCheckState *state, BTScanInsert key, BlockNumber nontargetblock, Page nontarget, OffsetNumber upperbound)
#define IsolationUsesXactSnapshot()
#define LSN_FORMAT_ARGS(lsn)