PostgreSQL Source Code git master
|
#include "postgres.h"
#include "access/heaptoast.h"
#include "access/htup_details.h"
#include "access/nbtree.h"
#include "access/table.h"
#include "access/tableam.h"
#include "access/transam.h"
#include "access/xact.h"
#include "catalog/index.h"
#include "catalog/pg_am.h"
#include "catalog/pg_opfamily_d.h"
#include "common/pg_prng.h"
#include "lib/bloomfilter.h"
#include "miscadmin.h"
#include "storage/smgr.h"
#include "utils/guc.h"
#include "utils/memutils.h"
#include "utils/snapmgr.h"
Go to the source code of this file.
Data Structures | |
struct | BtreeCheckState |
struct | BtreeLevel |
struct | BtreeLastVisibleEntry |
Macros | |
#define | InvalidBtreeLevel ((uint32) InvalidBlockNumber) |
#define | BTreeTupleGetNKeyAtts(itup, rel) Min(IndexRelationGetNumberOfKeyAttributes(rel), BTreeTupleGetNAtts(itup, rel)) |
Typedefs | |
typedef struct BtreeCheckState | BtreeCheckState |
typedef struct BtreeLevel | BtreeLevel |
typedef struct BtreeLastVisibleEntry | BtreeLastVisibleEntry |
Variables | |
PG_MODULE_MAGIC | |
#define BTreeTupleGetNKeyAtts | ( | itup, | |
rel | |||
) | Min(IndexRelationGetNumberOfKeyAttributes(rel), BTreeTupleGetNAtts(itup, rel)) |
Definition at line 52 of file verify_nbtree.c.
#define InvalidBtreeLevel ((uint32) InvalidBlockNumber) |
Definition at line 51 of file verify_nbtree.c.
typedef struct BtreeCheckState BtreeCheckState |
typedef struct BtreeLastVisibleEntry BtreeLastVisibleEntry |
typedef struct BtreeLevel BtreeLevel |
|
static |
Definition at line 500 of file verify_nbtree.c.
References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, Assert, BAS_BULKREAD, bloom_create(), bloom_free(), bloom_prop_bits_set(), bt_check_level_from_leftmost(), bt_tuple_present_callback(), BTMetaPageData::btm_fastlevel, BTMetaPageData::btm_fastroot, BTMetaPageData::btm_level, BTMetaPageData::btm_root, BTPageGetMeta, BTREE_METAPAGE, BuildIndexInfo(), CurrentMemoryContext, DEBUG1, elog, ereport, errcode(), ERRCODE_T_R_SERIALIZATION_FAILURE, errdetail_internal(), errhint(), errmsg(), errmsg_internal(), ERROR, GetAccessStrategy(), GetTransactionSnapshot(), HeapTupleHeaderGetXmin(), IndexInfo::ii_Concurrent, IndexInfo::ii_ExclusionOps, IndexInfo::ii_ExclusionProcs, IndexInfo::ii_ExclusionStrats, IndexInfo::ii_Unique, INT64_FORMAT, InvalidBlockNumber, InvalidBtreeLevel, InvalidSnapshot, IsolationUsesXactSnapshot, BtreeLevel::istruerootlevel, BtreeLevel::leftmost, BtreeLevel::level, maintenance_work_mem, Max, MaxTIDsPerBTreePage, MemoryContextDelete(), P_NONE, palloc0(), palloc_btree_page(), pg_global_prng_state, pg_prng_uint64(), RelationData::rd_index, RelationData::rd_indextuple, RecentXmin, RegisterSnapshot(), RelationGetNumberOfBlocks, RelationGetRelationName, SnapshotAny, HeapTupleData::t_data, table_beginscan_strat(), table_index_build_scan(), TransactionIdIsValid, TransactionIdPrecedes(), UnregisterSnapshot(), and SnapshotData::xmin.
Referenced by bt_index_check_internal().
|
static |
Definition at line 760 of file verify_nbtree.c.
References Assert, bt_leftmost_ignoring_half_dead(), bt_recheck_sibling_links(), bt_target_page_check(), BTPageGetOpaque, BTPageOpaqueData::btpo_level, BTPageOpaqueData::btpo_next, BTPageOpaqueData::btpo_prev, BTreeTupleGetDownLink(), CHECK_FOR_INTERRUPTS, DEBUG1, elog, ereport, errcode(), errdetail_internal(), errmsg(), errmsg_internal(), ERROR, IndexTupleSize(), InvalidBlockNumber, InvalidBtreeLevel, BtreeLevel::istruerootlevel, BtreeLevel::leftmost, BtreeLevel::level, MemoryContextAlloc(), MemoryContextReset(), MemoryContextSwitchTo(), P_FIRSTDATAKEY, P_HIKEY, P_IGNORE, P_ISDELETED, P_ISLEAF, P_ISROOT, P_NONE, P_RIGHTMOST, PageGetItem(), PageGetItemIdCareful(), PageGetLSN(), palloc_btree_page(), pfree(), and RelationGetRelationName.
Referenced by bt_check_every_level().
|
static |
Definition at line 2531 of file verify_nbtree.c.
References Assert, bt_child_highkey_check(), BTPageGetOpaque, BTPageOpaqueData::btpo_level, BTreeTupleGetDownLink(), ereport, errcode(), errdetail_internal(), errmsg(), ERROR, invariant_l_nontarget_offset(), LSN_FORMAT_ARGS, offset_is_negative_infinity(), OffsetNumberNext, P_FIRSTDATAKEY, P_ISDELETED, PageGetItem(), PageGetItemIdCareful(), PageGetMaxOffsetNumber(), palloc_btree_page(), pfree(), and RelationGetRelationName.
Referenced by bt_target_page_check().
|
static |
Definition at line 2284 of file verify_nbtree.c.
References BlockNumberIsValid(), bt_downlink_missing_check(), bt_leftmost_ignoring_half_dead(), bt_pivot_tuple_identical(), BTPageGetOpaque, BTPageOpaqueData::btpo_level, BTPageOpaqueData::btpo_next, BTPageOpaqueData::btpo_prev, BTreeTupleGetDownLink(), ereport, errcode(), errdetail_internal(), errmsg(), ERROR, InvalidBlockNumber, LSN_FORMAT_ARGS, offset_is_negative_infinity(), OffsetNumberIsValid, OffsetNumberNext, P_HAS_FULLXID, P_HIKEY, P_IGNORE, P_INCOMPLETE_SPLIT, P_ISDELETED, P_NONE, P_RIGHTMOST, PageGetItem(), PageGetItemIdCareful(), PageGetMaxOffsetNumber(), palloc_btree_page(), pfree(), and RelationGetRelationName.
Referenced by bt_child_check(), and bt_target_page_check().
|
static |
Definition at line 2696 of file verify_nbtree.c.
References Assert, BTPageGetOpaque, BTPageOpaqueData::btpo_level, BTPageOpaqueData::btpo_prev, BTreeTupleGetDownLink(), BTreeTupleGetTopParent(), CHECK_FOR_INTERRUPTS, DEBUG1, elog, ereport, errcode(), errdetail_internal(), errmsg(), errmsg_internal(), ERROR, LSN_FORMAT_ARGS, P_FIRSTDATAKEY, P_HIKEY, P_IGNORE, P_ISDELETED, P_ISHALFDEAD, P_ISLEAF, P_ISROOT, P_RIGHTMOST, PageGetItem(), PageGetItemIdCareful(), PageGetLSN(), palloc_btree_page(), pfree(), and RelationGetRelationName.
Referenced by bt_child_highkey_check().
|
static |
Definition at line 1047 of file verify_nbtree.c.
References Assert, BtreeLastVisibleEntry::blkno, bt_report_duplicate(), BTreeTupleGetHeapTID(), BTreeTupleGetNPosting(), BTreeTupleGetPostingN(), BTreeTupleIsPosting(), DEBUG1, ereport, errcode(), errdetail(), errhint(), errmsg(), heap_entry_is_visible(), i, InvalidBlockNumber, ItemPointerGetBlockNumberNoCheck(), ItemPointerGetOffsetNumberNoCheck(), ItemPointerIsValid(), BtreeLastVisibleEntry::offset, P_NONE, BtreeLastVisibleEntry::postingIndex, psprintf(), RelationGetRelationName, and BtreeLastVisibleEntry::tid.
Referenced by bt_target_page_check().
Datum bt_index_check | ( | PG_FUNCTION_ARGS | ) |
Definition at line 238 of file verify_nbtree.c.
References bt_index_check_internal(), PG_GETARG_BOOL, PG_GETARG_OID, PG_NARGS, and PG_RETURN_VOID.
|
static |
Definition at line 287 of file verify_nbtree.c.
References _bt_allequalimage(), _bt_metaversion(), AccessShareLock, AtEOXact_GUC(), bt_check_every_level(), btree_index_checkable(), btree_index_mainfork_expected(), ereport, errcode(), ERRCODE_UNDEFINED_TABLE, errhint(), errmsg(), ERROR, GetUserIdAndSecContext(), i, index_close(), index_open(), IndexGetRelation(), IndexRelationGetNumberOfKeyAttributes, InvalidOid, MAIN_FORKNUM, NewGUCNestLevel(), OidIsValid, RelationData::rd_opfamily, RelationData::rd_rel, RelationGetRelationName, RelationGetSmgr(), RestrictSearchPath(), SECURITY_RESTRICTED_OPERATION, SetUserIdAndSecContext(), ShareLock, smgrexists(), table_close(), and table_open().
Referenced by bt_index_check(), and bt_index_parent_check().
Datum bt_index_parent_check | ( | PG_FUNCTION_ARGS | ) |
Definition at line 264 of file verify_nbtree.c.
References bt_index_check_internal(), PG_GETARG_BOOL, PG_GETARG_OID, PG_NARGS, and PG_RETURN_VOID.
|
static |
Definition at line 1146 of file verify_nbtree.c.
References Assert, BTPageGetOpaque, BTPageOpaqueData::btpo_next, BTPageOpaqueData::btpo_prev, CHECK_FOR_INTERRUPTS, DEBUG1, ereport, errcode(), errdetail_internal(), errmsg_internal(), LSN_FORMAT_ARGS, P_ISHALFDEAD, P_NONE, PageGetLSN(), palloc_btree_page(), pfree(), RelationGetRelationName, and start.
Referenced by bt_check_level_from_leftmost(), and bt_child_highkey_check().
|
inlinestatic |
Definition at line 3607 of file verify_nbtree.c.
References _bt_mkscankey(), and BTScanInsertData::backward.
Referenced by bt_right_page_check_scankey(), and bt_target_page_check().
|
static |
Definition at line 2987 of file verify_nbtree.c.
References Assert, BTreeTupleIsPivot(), BTreeTupleIsPosting(), data, DatumGetPointer(), ereport, errcode(), errmsg(), ERROR, i, index_form_tuple(), index_getattr(), INDEX_MAX_KEYS, IndexTupleHasVarwidths(), ItemPointerGetBlockNumber(), ItemPointerGetOffsetNumber(), len, TupleDescData::natts, palloc(), pfree(), PG_DETOAST_DATUM, PointerGetDatum(), RelationGetDescr, RelationGetRelationName, SET_VARSIZE_SHORT, IndexTupleData::t_tid, TOAST_INDEX_TARGET, TupleDescAttr(), VARATT_CAN_MAKE_SHORT, VARATT_CONVERTED_SHORT_SIZE, VARATT_IS_COMPRESSED, VARATT_IS_EXTERNAL, VARDATA, and VARSIZE.
Referenced by bt_target_page_check(), and bt_tuple_present_callback().
|
static |
Definition at line 2211 of file verify_nbtree.c.
References IndexTupleSize(), ItemPointerData::ip_posid, IndexTupleData::t_info, and IndexTupleData::t_tid.
Referenced by bt_child_highkey_check().
|
inlinestatic |
Definition at line 3115 of file verify_nbtree.c.
References _bt_form_posting(), Assert, BTreeTupleGetPostingN(), and BTreeTupleIsPosting().
Referenced by bt_target_page_check().
|
static |
Definition at line 1235 of file verify_nbtree.c.
References _bt_checkpage(), Assert, BT_READ, BTPageGetOpaque, BTPageOpaqueData::btpo_next, BTPageOpaqueData::btpo_prev, BufferGetPage(), BufferIsValid(), DEBUG1, ereport, errcode(), errdetail_internal(), errmsg(), errmsg_internal(), ERROR, InvalidBlockNumber, InvalidBuffer, LockBuffer(), MAIN_FORKNUM, P_ISDELETED, P_NONE, RBM_NORMAL, ReadBufferExtended(), RelationGetRelationName, and UnlockReleaseBuffer().
Referenced by bt_check_level_from_leftmost().
|
static |
Definition at line 1007 of file verify_nbtree.c.
References BtreeLastVisibleEntry::blkno, ereport, errcode(), errdetail(), errmsg(), ERROR, ItemPointerGetBlockNumberNoCheck(), ItemPointerGetOffsetNumberNoCheck(), LSN_FORMAT_ARGS, BtreeLastVisibleEntry::offset, BtreeLastVisibleEntry::postingIndex, psprintf(), RelationGetRelationName, and BtreeLastVisibleEntry::tid.
Referenced by bt_entry_unique_check().
|
static |
Definition at line 2004 of file verify_nbtree.c.
References bt_mkscankey_pivotsearch(), BTPageGetOpaque, BTPageOpaqueData::btpo_level, BTPageOpaqueData::btpo_next, CHECK_FOR_INTERRUPTS, DEBUG2, ereport, errcode(), errdetail_internal(), errmsg_internal(), OffsetNumberNext, P_FIRSTDATAKEY, P_IGNORE, P_ISLEAF, P_RIGHTMOST, PageGetItem(), PageGetItemIdCareful(), PageGetMaxOffsetNumber(), palloc_btree_page(), pfree(), and RelationGetRelationName.
Referenced by bt_target_page_check().
|
static |
Definition at line 3148 of file verify_nbtree.c.
References _bt_binsrch_insert(), _bt_compare(), _bt_freestack(), _bt_mkscankey(), _bt_relbuf(), _bt_search(), Assert, BTInsertStateData::bounds_valid, BT_READ, BTInsertStateData::buf, BufferGetPage(), BufferIsValid(), IndexTupleSize(), BTInsertStateData::itemsz, BTInsertStateData::itup, BTInsertStateData::itup_key, sort-test::key, MAXALIGN, PageGetMaxOffsetNumber(), pfree(), and BTInsertStateData::postingoff.
Referenced by bt_target_page_check().
|
static |
Definition at line 1375 of file verify_nbtree.c.
References _bt_check_natts(), _bt_compare(), BTScanInsertData::anynullkeys, BtreeLastVisibleEntry::blkno, bloom_add_element(), bt_child_check(), bt_child_highkey_check(), bt_entry_unique_check(), bt_mkscankey_pivotsearch(), bt_normalize_tuple(), bt_posting_plain_tuple(), bt_right_page_check_scankey(), bt_rootdescend(), BTMaxItemSize, BTMaxItemSizeNoHeapTid, BTPageGetOpaque, BTPageOpaqueData::btpo_level, BTPageOpaqueData::btpo_next, BTreeTupleGetHeapTID(), BTreeTupleGetMaxHeapTID(), BTreeTupleGetNAtts, BTreeTupleGetNPosting(), BTreeTupleGetPointsToTID(), BTreeTupleGetPostingN(), BTreeTupleIsPosting(), CHECK_FOR_INTERRUPTS, DEBUG2, elog, ereport, errcode(), errdetail_internal(), errhint(), errmsg(), errmsg_internal(), ERROR, BTScanInsertData::heapkeyspace, i, IndexTupleSize(), InvalidBlockNumber, InvalidOffsetNumber, invariant_g_offset(), invariant_l_offset(), invariant_leq_offset(), ItemIdGetLength, ItemIdIsDead, ItemPointerCompare(), ItemPointerCopy(), ItemPointerGetBlockNumber(), ItemPointerGetBlockNumberNoCheck(), ItemPointerGetOffsetNumber(), ItemPointerGetOffsetNumberNoCheck(), ItemPointerIsValid(), LSN_FORMAT_ARGS, BtreeLastVisibleEntry::offset, offset_is_negative_infinity(), OffsetNumberNext, P_FIRSTDATAKEY, P_HIKEY, P_IGNORE, P_ISLEAF, P_RIGHTMOST, PageGetItem(), PageGetItemIdCareful(), PageGetMaxOffsetNumber(), palloc_btree_page(), pfree(), BtreeLastVisibleEntry::postingIndex, psprintf(), RelationGetRelationName, BTScanInsertData::scantid, BtreeLastVisibleEntry::tid, and unlikely.
Referenced by bt_check_level_from_leftmost().
|
static |
Definition at line 2919 of file verify_nbtree.c.
References Assert, bloom_lacks_element(), bt_normalize_tuple(), ereport, errcode(), ERRCODE_DATA_CORRUPTED, errhint(), errmsg(), ERROR, index_form_tuple(), IndexTupleSize(), ItemPointerGetBlockNumber(), ItemPointerGetOffsetNumber(), pfree(), RelationGetDescr, RelationGetRelationName, IndexTupleData::t_tid, and values.
Referenced by bt_check_every_level().
|
inlinestatic |
Definition at line 428 of file verify_nbtree.c.
References ereport, errcode(), errdetail(), errmsg(), ERROR, RelationData::rd_index, RelationData::rd_rel, RELATION_IS_OTHER_TEMP, and RelationGetRelationName.
Referenced by bt_index_check_internal().
|
inlinestatic |
Definition at line 462 of file verify_nbtree.c.
References DEBUG1, ereport, errcode(), errmsg(), RelationData::rd_rel, RecoveryInProgress(), and RelationGetRelationName.
Referenced by bt_index_check_internal().
|
inlinestatic |
Definition at line 3671 of file verify_nbtree.c.
References Assert, BTreeTupleGetHeapTID(), BTreeTupleIsPivot(), ereport, errcode(), errmsg(), errmsg_internal(), ERROR, ItemPointerIsValid(), and RelationGetRelationName.
Referenced by invariant_l_nontarget_offset(), and invariant_l_offset().
|
inlinestatic |
Definition at line 3719 of file verify_nbtree.c.
References BTreeTupleGetHeapTID(), BTreeTupleIsPivot(), and IndexTupleData::t_tid.
Referenced by bt_target_page_check().
|
static |
Definition at line 988 of file verify_nbtree.c.
References ExecDropSingleTupleTableSlot(), table_slot_create(), and table_tuple_fetch_row_version().
Referenced by bt_entry_unique_check().
|
inlinestatic |
Definition at line 3333 of file verify_nbtree.c.
References _bt_compare(), Assert, cmp(), and sort-test::key.
Referenced by bt_target_page_check().
|
inlinestatic |
Definition at line 3369 of file verify_nbtree.c.
References _bt_compare(), Assert, BTPageGetOpaque, BTreeTupleGetHeapTIDCareful(), BTreeTupleGetNKeyAtts, cmp(), sort-test::key, P_FIRSTDATAKEY, P_ISLEAF, PageGetItem(), and PageGetItemIdCareful().
Referenced by bt_child_check().
|
inlinestatic |
Definition at line 3247 of file verify_nbtree.c.
References _bt_compare(), Assert, BTPageGetOpaque, BTreeTupleGetHeapTIDCareful(), BTreeTupleGetNKeyAtts, cmp(), invariant_leq_offset(), sort-test::key, P_FIRSTDATAKEY, P_ISLEAF, PageGetItem(), and PageGetItemIdCareful().
Referenced by bt_target_page_check().
|
inlinestatic |
Definition at line 3310 of file verify_nbtree.c.
References _bt_compare(), Assert, cmp(), and sort-test::key.
Referenced by bt_target_page_check(), and invariant_l_offset().
|
inlinestatic |
Definition at line 3212 of file verify_nbtree.c.
References P_FIRSTDATAKEY, and P_ISLEAF.
Referenced by bt_child_check(), bt_child_highkey_check(), and bt_target_page_check().
|
static |
Definition at line 3631 of file verify_nbtree.c.
References ereport, errcode(), errdetail_internal(), errmsg(), ERROR, ItemIdGetFlags, ItemIdGetLength, ItemIdGetOffset, ItemIdIsRedirected, ItemIdIsUsed, MAXALIGN, PageGetItemId(), and RelationGetRelationName.
Referenced by bt_check_level_from_leftmost(), bt_child_check(), bt_child_highkey_check(), bt_downlink_missing_check(), bt_right_page_check_scankey(), bt_target_page_check(), invariant_l_nontarget_offset(), and invariant_l_offset().
|
static |
Definition at line 3429 of file verify_nbtree.c.
References _bt_checkpage(), BT_READ, BTMetaPageData::btm_magic, BTMetaPageData::btm_version, BTPageGetMeta, BTPageGetOpaque, BTPageOpaqueData::btpo_level, BTREE_MAGIC, BTREE_METAPAGE, BTREE_MIN_VERSION, BTREE_VERSION, BufferGetPage(), ereport, errcode(), errhint(), errmsg(), errmsg_internal(), ERROR, LockBuffer(), MAIN_FORKNUM, MaxIndexTuplesPerPage, P_FIRSTDATAKEY, P_HAS_FULLXID, P_HAS_GARBAGE, P_HIKEY, P_ISDELETED, P_ISHALFDEAD, P_ISLEAF, P_ISMETA, P_RIGHTMOST, PageGetMaxOffsetNumber(), palloc(), RBM_NORMAL, ReadBufferExtended(), RelationGetRelationName, and UnlockReleaseBuffer().
Referenced by bt_check_every_level(), bt_check_level_from_leftmost(), bt_child_check(), bt_child_highkey_check(), bt_downlink_missing_check(), bt_leftmost_ignoring_half_dead(), bt_right_page_check_scankey(), and bt_target_page_check().
PG_FUNCTION_INFO_V1 | ( | bt_index_check | ) |
PG_FUNCTION_INFO_V1 | ( | bt_index_parent_check | ) |
PG_MODULE_MAGIC |
Definition at line 45 of file verify_nbtree.c.