36#include "catalog/pg_opfamily_d.h"
55#define InvalidBtreeLevel ((uint32) InvalidBlockNumber)
56#define BTreeTupleGetNKeyAtts(itup, rel) \
57 Min(IndexRelationGetNumberOfKeyAttributes(rel), BTreeTupleGetNAtts(itup, rel))
178 void *
state,
bool readonly);
180 bool heapkeyspace,
bool readonly,
bool heapallindexed,
181 bool rootdescend,
bool checkunique);
212 bool tupleIsAlive,
void *checkstate);
255 args.heapallindexed =
false;
256 args.rootdescend =
false;
257 args.parentcheck =
false;
258 args.checkunique =
false;
287 args.heapallindexed =
false;
288 args.rootdescend =
false;
289 args.parentcheck =
true;
290 args.checkunique =
false;
318 (
errcode(ERRCODE_INDEX_CORRUPTED),
319 errmsg(
"index \"%s\" lacks a main relation fork",
324 if (allequalimage && !heapkeyspace)
326 (
errcode(ERRCODE_INDEX_CORRUPTED),
327 errmsg(
"index \"%s\" metapage has equalimage field set on unsupported nbtree version",
331 bool has_interval_ops =
false;
336 has_interval_ops =
true;
338 (
errcode(ERRCODE_INDEX_CORRUPTED),
339 errmsg(
"index \"%s\" metapage incorrectly indicates that deduplication is safe",
342 ?
errhint(
"This is known of \"interval\" indexes last built on a version predating 2023-11.")
349 args->heapallindexed,
args->rootdescend,
args->checkunique);
377 bool readonly,
bool heapallindexed,
bool rootdescend,
387 elog(
DEBUG1,
"verifying consistency of tree structure for index \"%s\"",
390 elog(
DEBUG1,
"verifying consistency of tree structure for index \"%s\" with cross-level checks",
404 state->heaprel = heaprel;
405 state->heapkeyspace = heapkeyspace;
406 state->readonly = readonly;
407 state->heapallindexed = heapallindexed;
408 state->rootdescend = rootdescend;
409 state->checkunique = checkunique;
412 if (
state->heapallindexed)
432 state->heaptuplespresent = 0;
457 state->snapshot->xmin))
460 errmsg(
"index \"%s\" cannot be verified using transaction snapshot",
469 if (
state->checkunique)
478 if (
state->rootdescend && !
state->heapkeyspace)
480 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
481 errmsg(
"cannot verify that tuples from index \"%s\" can each be found by an independent index search",
483 errhint(
"Only B-Tree version 4 indexes support rootdescend verification.")));
508 errdetail_internal(
"Fast root block %u (level %u) differs from true root block %u (level %u).",
531 (
errcode(ERRCODE_INDEX_CORRUPTED),
532 errmsg(
"index \"%s\" has no valid pages on level below %u or first level",
535 previouslevel = current.
level;
541 if (
state->heapallindexed)
582 elog(
DEBUG1,
"verifying that tuples from index \"%s\" are present in \"%s\"",
643 " (true root level)" : level.
level == 0 ?
" (leaf level)" :
"");
646 state->previncompletesplit =
false;
654 state->targetblock = current;
675 (
errcode(ERRCODE_INDEX_CORRUPTED),
676 errmsg(
"downlink or sibling link points to deleted block in index \"%s\"",
679 current, leftcurrent, opaque->
btpo_prev)));
683 (
errcode(ERRCODE_INDEX_CORRUPTED),
684 errmsg(
"block %u fell off the end of index \"%s\"",
706 (
errcode(ERRCODE_INDEX_CORRUPTED),
707 errmsg(
"block %u is not leftmost in index \"%s\"",
712 (
errcode(ERRCODE_INDEX_CORRUPTED),
713 errmsg(
"block %u is not true root in index \"%s\"",
773 (
errcode(ERRCODE_INDEX_CORRUPTED),
774 errmsg(
"leftmost down link for level points to block in index \"%s\" whose level is not one level down",
776 errdetail_internal(
"Block pointed to=%u expected level=%u level in pointed to block=%u.",
785 if (current == leftcurrent || current == opaque->
btpo_prev)
787 (
errcode(ERRCODE_INDEX_CORRUPTED),
788 errmsg(
"circular link chain found in block %u of index \"%s\"",
791 leftcurrent = current;
798 state->lowkey = NULL;
833 while (current !=
P_NONE);
839 state->lowkey = NULL;
845 return nextleveldown;
857 tid,
state->snapshot, slot);
889 if (nblock != lVis->
blkno || noffset != lVis->
offset)
890 nitid =
psprintf(
" tid=(%u,%u)", nblock, noffset);
896 pnposting =
psprintf(
" posting %u", nposting);
899 (
errcode(ERRCODE_INDEX_CORRUPTED),
900 errmsg(
"index uniqueness is violated for index \"%s\"",
902 errdetail(
"Index %s%s and%s%s (point to heap %s and %s) page lsn=%X/%08X.",
903 itid, pposting, nitid, pnposting, htid, nhtid,
914 bool has_visible_entry =
false;
929 has_visible_entry =
true;
946 lVis->
blkno = targetblock;
964 has_visible_entry =
true;
973 lVis->
blkno = targetblock;
980 if (!has_visible_entry &&
982 lVis->
blkno != targetblock)
990 errmsg(
"index uniqueness can not be checked for index tid=(%u,%u) in index \"%s\"",
993 errdetail(
"It doesn't have visible heap tids and key is equal to the tid=(%u,%u)%s (points to heap tid=(%u,%u)).",
997 errhint(
"VACUUM the table and repeat the check.")));
1013 reached_from =
start;
1014 bool all_half_dead =
true;
1022 while (reached !=
P_NONE && all_half_dead)
1036 reached != reached_from &&
1037 reached_opaque->
btpo_next == reached_from;
1045 errmsg_internal(
"harmless interrupted page deletion detected in index \"%s\"",
1048 reached, reached_from,
1051 reached_from = reached;
1058 return all_half_dead;
1104 if (!
state->readonly)
1134 if (newtargetblock != leftcurrent)
1138 state->checkstrategy);
1144 btpo_prev_from_target = opaque->
btpo_prev;
1166 if (btpo_prev_from_target == leftcurrent)
1170 (
errcode(ERRCODE_INTERNAL_ERROR),
1171 errmsg_internal(
"harmless concurrent page split detected in index \"%s\"",
1174 leftcurrent, newtargetblock,
1175 state->targetblock)));
1186 state->targetblock = newtargetblock;
1190 (
errcode(ERRCODE_INDEX_CORRUPTED),
1191 errmsg(
"left link/right link pair in index \"%s\" not in agreement",
1194 state->targetblock, leftcurrent,
1195 btpo_prev_from_target)));
1249 elog(
DEBUG2,
"verifying %u items on %s block %u", max,
1250 P_ISLEAF(topaque) ?
"leaf" :
"internal",
state->targetblock);
1269 (
errcode(ERRCODE_INDEX_CORRUPTED),
1270 errmsg(
"wrong number of high key index tuple attributes in index \"%s\"",
1275 P_ISLEAF(topaque) ?
"heap" :
"index",
1293 bool lowersizelimit;
1301 bool unique_checked =
false;
1306 state->target, offset);
1318 (
errcode(ERRCODE_INDEX_CORRUPTED),
1319 errmsg(
"index tuple size does not equal lp_len in index \"%s\"",
1322 state->targetblock, offset,
1325 errhint(
"This could be a torn page problem.")));
1342 (
errcode(ERRCODE_INDEX_CORRUPTED),
1343 errmsg(
"wrong number of index tuple attributes in index \"%s\"",
1348 P_ISLEAF(topaque) ?
"heap" :
"index",
1392 (
errcode(ERRCODE_INDEX_CORRUPTED),
1393 errmsg(
"could not find tuple using search from root page in index \"%s\"",
1418 char *itid =
psprintf(
"(%u,%u)",
state->targetblock, offset);
1421 (
errcode(ERRCODE_INDEX_CORRUPTED),
1422 errmsg_internal(
"posting list contains misplaced TID in index \"%s\"",
1474 (
errcode(ERRCODE_INDEX_CORRUPTED),
1475 errmsg(
"index row size %zu exceeds maximum for index \"%s\"",
1479 P_ISLEAF(topaque) ?
"heap" :
"index",
1501 if (norm != logtuple)
1581 (
errcode(ERRCODE_INDEX_CORRUPTED),
1582 errmsg(
"high key invariant violated for index \"%s\"",
1586 P_ISLEAF(topaque) ?
"heap" :
"index",
1627 (
errcode(ERRCODE_INDEX_CORRUPTED),
1628 errmsg(
"item order invariant violated for index \"%s\"",
1630 errdetail_internal(
"Lower index tid=%s (points to %s tid=%s) higher index tid=%s (points to %s tid=%s) page lsn=%X/%08X.",
1632 P_ISLEAF(topaque) ?
"heap" :
"index",
1635 P_ISLEAF(topaque) ?
"heap" :
"index",
1646 if (
state->checkunique &&
state->indexinfo->ii_Unique &&
1652 unique_checked =
true;
1655 if (
state->checkunique &&
state->indexinfo->ii_Unique &&
1684 else if (!unique_checked)
1729 if (!
state->readonly)
1744 (
errcode(ERRCODE_INDEX_CORRUPTED),
1745 errmsg(
"cross page item order invariant violated for index \"%s\"",
1748 state->targetblock, offset,
1756 if (
state->checkunique &&
state->indexinfo->ii_Unique &&
1761 elog(
DEBUG2,
"check cross page unique condition");
1780 if (!unique_checked)
1797 (
errcode(ERRCODE_INDEX_CORRUPTED),
1798 errmsg(
"right block of leaf block is non-leaf for index \"%s\"",
1920 errmsg_internal(
"level %u sibling page in block %u of index \"%s\" was found deleted or half dead",
1922 errdetail_internal(
"Deleted page found when building scankey from right sibling.")));
2052 P_ISLEAF(opaque) ?
"leaf" :
"internal", targetnext,
2151 bool rightsplit =
state->previncompletesplit;
2160 state->target, target_downlinkoffnum);
2197 state->previncompletesplit =
false;
2204 (
errcode(ERRCODE_INDEX_CORRUPTED),
2205 errmsg(
"can't traverse from downlink %u to downlink %u of index \"%s\"",
2206 state->prevrightlink, downlink,
2210 if (blkno == downlink && loaded_child)
2211 page = loaded_child;
2221 (
errcode(ERRCODE_INDEX_CORRUPTED),
2222 errmsg(
"the first child of leftmost target page is not leftmost of its level in index \"%s\"",
2225 state->targetblock, blkno,
2232 (
errcode(ERRCODE_INDEX_CORRUPTED),
2233 errmsg(
"block found while following rightlinks from child of index \"%s\" has invalid level",
2235 errdetail_internal(
"Block pointed to=%u expected level=%u level in pointed to block=%u.",
2236 blkno, target_level - 1, opaque->
btpo_level)));
2239 if ((!first && blkno ==
state->prevrightlink) || blkno == opaque->
btpo_prev)
2241 (
errcode(ERRCODE_INDEX_CORRUPTED),
2242 errmsg(
"circular link chain found in block %u of index \"%s\"",
2245 if (blkno != downlink && !
P_IGNORE(opaque))
2289 if (blkno == downlink)
2292 pivotkey_offset = target_downlinkoffnum;
2307 (
errcode(ERRCODE_INDEX_CORRUPTED),
2308 errmsg(
"child high key is greater than rightmost pivot key on target level in index \"%s\"",
2311 state->targetblock, blkno,
2316 state->target, pivotkey_offset);
2337 (
errcode(ERRCODE_INDEX_CORRUPTED),
2338 errmsg(
"can't find left sibling high key in index \"%s\"",
2341 state->targetblock, blkno,
2343 itup =
state->lowkey;
2349 (
errcode(ERRCODE_INDEX_CORRUPTED),
2350 errmsg(
"mismatch between parent key and child high key in index \"%s\"",
2353 state->targetblock, blkno,
2359 if (blkno == downlink)
2362 state->previncompletesplit = rightsplit;
2370 if (page != loaded_child)
2403 state->target, downlinkoffnum);
2489 (
errcode(ERRCODE_INDEX_CORRUPTED),
2490 errmsg(
"downlink to deleted page found in index \"%s\"",
2493 state->targetblock, childblock,
2497 offset <= maxoffset;
2530 (
errcode(ERRCODE_INDEX_CORRUPTED),
2531 errmsg(
"down-link lower bound invariant violated for index \"%s\"",
2533 errdetail_internal(
"Parent block=%u child index tid=(%u,%u) parent page lsn=%X/%08X.",
2534 state->targetblock, childblock, offset,
2601 errmsg_internal(
"harmless interrupted page split detected in index \"%s\"",
2622 (
errcode(ERRCODE_INDEX_CORRUPTED),
2623 errmsg(
"leaf index block lacks downlink in index \"%s\"",
2630 elog(
DEBUG1,
"checking for interrupted multi-level deletion due to missing downlink in index \"%s\"",
2650 (
errcode(ERRCODE_INDEX_CORRUPTED),
2651 errmsg_internal(
"downlink points to block in index \"%s\" whose level is not one level down",
2653 errdetail_internal(
"Top parent/under check block=%u block pointed to=%u expected level=%u level in pointed to block=%u.",
2688 (
errcode(ERRCODE_INDEX_CORRUPTED),
2689 errmsg_internal(
"downlink to deleted leaf page found in index \"%s\"",
2691 errdetail_internal(
"Top parent/target block=%u leaf block=%u top parent/under check lsn=%X/%08X.",
2714 (
errcode(ERRCODE_INDEX_CORRUPTED),
2715 errmsg(
"internal index block lacks downlink in index \"%s\"",
2779 bool *isnull,
bool tupleIsAlive,
void *checkstate)
2797 errmsg(
"heap tuple (%u,%u) from table \"%s\" lacks matching index tuple within index \"%s\"",
2803 ?
errhint(
"Retrying verification using the function bt_index_parent_check() might provide a more specific error.")
2806 state->heaptuplespresent++;
2852 bool formnewtup =
false;
2863 for (
i = 0;
i < tupleDescriptor->
natts;
i++)
2870 need_free[
i] =
false;
2874 if (att->attbyval || att->attlen != -1 || isnull[
i])
2884 (
errcode(ERRCODE_INDEX_CORRUPTED),
2885 errmsg(
"external varlena datum in tuple that references heap row (%u,%u) in index \"%s\"",
2891 (att->attstorage == TYPSTORAGE_EXTENDED ||
2892 att->attstorage == TYPSTORAGE_MAIN))
2905 need_free[
i] =
true;
2923 need_free[
i] =
true;
2952 for (
i = 0;
i < tupleDescriptor->
natts;
i++)
3035 insertstate.
itup = itup;
3040 insertstate.
buf = lbuf;
3118 if (!
key->heapkeyspace)
3149 if (
key->keysz == uppnkeyatts)
3150 return key->scantid == NULL && rheaptid != NULL;
3152 return key->keysz < uppnkeyatts;
3202 if (!
key->heapkeyspace)
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 LockBuffer(Buffer buffer, BufferLockMode mode)
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 bool BufferIsValid(Buffer bufnum)
static void * PageGetItem(const PageData *page, const ItemIdData *itemId)
static ItemId PageGetItemId(Page page, OffsetNumber offsetNumber)
static XLogRecPtr PageGetLSN(const PageData *page)
static OffsetNumber PageGetMaxOffsetNumber(const PageData *page)
int errmsg_internal(const char *fmt,...)
int errdetail_internal(const char *fmt,...)
int errdetail(const char *fmt,...)
int errhint(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
void ExecDropSingleTupleTableSlot(TupleTableSlot *slot)
#define PG_DETOAST_DATUM(datum)
#define PG_GETARG_BOOL(n)
BufferAccessStrategy GetAccessStrategy(BufferAccessStrategyType btype)
Assert(PointerIsAligned(start, uint64))
#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)
void * palloc0(Size size)
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)
BTStack _bt_search(Relation rel, Relation heaprel, BTScanInsert key, Buffer *bufP, int access)
OffsetNumber _bt_binsrch_insert(Relation rel, BTInsertState insertstate)
int32 _bt_compare(Relation rel, BTScanInsert key, Page page, OffsetNumber offnum)
void _bt_freestack(BTStack stack)
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)
struct BtreeCheckState BtreeCheckState
PG_MODULE_MAGIC_EXT(.name="amcheck",.version=PG_VERSION)
static IndexTuple bt_posting_plain_tuple(IndexTuple itup, int n)
struct BTCallbackState BTCallbackState
struct BtreeLastVisibleEntry BtreeLastVisibleEntry
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)
PG_FUNCTION_INFO_V1(bt_index_check)
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)
struct BtreeLevel BtreeLevel
#define IsolationUsesXactSnapshot()
#define LSN_FORMAT_ARGS(lsn)