PostgreSQL Source Code
git master
|
#include "postgres.h"
#include "access/detoast.h"
#include "access/genam.h"
#include "access/heaptoast.h"
#include "access/multixact.h"
#include "access/relation.h"
#include "access/table.h"
#include "access/toast_internals.h"
#include "access/visibilitymap.h"
#include "access/xact.h"
#include "catalog/pg_am.h"
#include "catalog/pg_class.h"
#include "funcapi.h"
#include "miscadmin.h"
#include "storage/bufmgr.h"
#include "storage/procarray.h"
#include "utils/builtins.h"
#include "utils/fmgroids.h"
#include "utils/rel.h"
Go to the source code of this file.
Data Structures | |
struct | ToastedAttribute |
struct | HeapCheckContext |
Macros | |
#define | HEAPCHECK_RELATION_COLS 4 |
#define | VARLENA_SIZE_LIMIT 0x3FFFFFFF |
Typedefs | |
typedef enum XidBoundsViolation | XidBoundsViolation |
typedef enum XidCommitStatus | XidCommitStatus |
typedef enum SkipPages | SkipPages |
typedef struct ToastedAttribute | ToastedAttribute |
typedef struct HeapCheckContext | HeapCheckContext |
Enumerations | |
enum | XidBoundsViolation { XID_INVALID , XID_IN_FUTURE , XID_PRECEDES_CLUSTERMIN , XID_PRECEDES_RELMIN , XID_BOUNDS_OK } |
enum | XidCommitStatus { XID_COMMITTED , XID_IS_CURRENT_XID , XID_IN_PROGRESS , XID_ABORTED } |
enum | SkipPages { SKIP_PAGES_ALL_FROZEN , SKIP_PAGES_ALL_VISIBLE , SKIP_PAGES_NONE } |
#define HEAPCHECK_RELATION_COLS 4 |
Definition at line 35 of file verify_heapam.c.
#define VARLENA_SIZE_LIMIT 0x3FFFFFFF |
Definition at line 38 of file verify_heapam.c.
typedef struct HeapCheckContext HeapCheckContext |
typedef struct ToastedAttribute ToastedAttribute |
typedef enum XidBoundsViolation XidBoundsViolation |
typedef enum XidCommitStatus XidCommitStatus |
enum SkipPages |
Enumerator | |
---|---|
SKIP_PAGES_ALL_FROZEN | |
SKIP_PAGES_ALL_VISIBLE | |
SKIP_PAGES_NONE |
Definition at line 61 of file verify_heapam.c.
enum XidBoundsViolation |
Enumerator | |
---|---|
XID_INVALID | |
XID_IN_FUTURE | |
XID_PRECEDES_CLUSTERMIN | |
XID_PRECEDES_RELMIN | |
XID_BOUNDS_OK |
Definition at line 44 of file verify_heapam.c.
enum XidCommitStatus |
Enumerator | |
---|---|
XID_COMMITTED | |
XID_IS_CURRENT_XID | |
XID_IN_PROGRESS | |
XID_ABORTED |
Definition at line 53 of file verify_heapam.c.
|
static |
Definition at line 1965 of file verify_heapam.c.
References MultiXactIdPrecedes(), MultiXactIdPrecedesOrEquals(), HeapCheckContext::next_mxact, HeapCheckContext::oldest_mxact, HeapCheckContext::relminmxid, TransactionIdIsValid, XID_BOUNDS_OK, XID_IN_FUTURE, XID_INVALID, XID_PRECEDES_CLUSTERMIN, and XID_PRECEDES_RELMIN.
Referenced by check_mxid_valid_in_rel().
|
static |
Definition at line 1987 of file verify_heapam.c.
References check_mxid_in_range(), update_cached_mxid_range(), and XID_BOUNDS_OK.
Referenced by check_tuple_visibility().
|
static |
Definition at line 1462 of file verify_heapam.c.
References chunk, DatumGetInt32(), DatumGetPointer(), fastgetattr(), psprintf(), RelationData::rd_att, report_toast_corruption(), TOAST_MAX_CHUNK_SIZE, ToastedAttribute::toast_pointer, HeapCheckContext::toast_rel, varatt_external::va_valueid, VARATT_IS_EXTENDED, VARATT_IS_SHORT, VARHDRSZ, VARHDRSZ_SHORT, VARSIZE, and VARSIZE_SHORT.
Referenced by check_toasted_attribute().
|
static |
Definition at line 1768 of file verify_heapam.c.
References BTEqualStrategyNumber, check_toast_tuple(), ForwardScanDirection, init_toast_snapshot(), ObjectIdGetDatum(), psprintf(), report_toast_corruption(), ScanKeyInit(), systable_beginscan_ordered(), systable_endscan_ordered(), systable_getnext_ordered(), TOAST_MAX_CHUNK_SIZE, ToastedAttribute::toast_pointer, HeapCheckContext::toast_rel, varatt_external::va_valueid, HeapCheckContext::valid_toast_index, and VARATT_EXTERNAL_GET_EXTSIZE.
Referenced by verify_heapam().
|
static |
Definition at line 1828 of file verify_heapam.c.
References HeapCheckContext::attnum, check_tuple_attribute(), check_tuple_header(), check_tuple_visibility(), HeapCheckContext::natts, HeapCheckContext::offset, psprintf(), HeapCheckContext::rel, RelationGetDescr, and report_corruption().
Referenced by verify_heapam().
|
static |
Definition at line 1568 of file verify_heapam.c.
References att_addlength_pointer, att_align_nominal, att_align_pointer, att_isnull(), ToastedAttribute::attnum, HeapCheckContext::attnum, ToastedAttribute::blkno, HeapCheckContext::blkno, DatumGetPointer(), fetchatt, HEAP_HASEXTERNAL, HEAP_HASNULL, if(), lappend(), HeapCheckContext::lp_len, ToastedAttribute::offnum, HeapCheckContext::offnum, HeapCheckContext::offset, palloc0(), psprintf(), RelationData::rd_rel, HeapCheckContext::rel, RelationGetDescr, report_corruption(), HeapTupleHeaderData::t_bits, HeapTupleHeaderData::t_hoff, HeapTupleHeaderData::t_infomask, TOAST_COMPRESS_METHOD, TOAST_INVALID_COMPRESSION_ID, TOAST_LZ4_COMPRESSION_ID, TOAST_PGLZ_COMPRESSION_ID, ToastedAttribute::toast_pointer, HeapCheckContext::toast_rel, HeapCheckContext::toasted_attributes, HeapCheckContext::tuphdr, HeapCheckContext::tuple_could_be_pruned, TupleDescAttr, varatt_external::va_rawsize, varatt_external::va_valueid, VARATT_EXTERNAL_GET_POINTER, VARATT_EXTERNAL_IS_COMPRESSED, VARATT_IS_EXTERNAL, VARLENA_SIZE_LIMIT, VARTAG_EXTERNAL, and VARTAG_ONDISK.
Referenced by check_tuple().
|
static |
Definition at line 907 of file verify_heapam.c.
References BITMAPLEN, HEAP_HASNULL, HEAP_UPDATED, HEAP_XMAX_COMMITTED, HEAP_XMAX_IS_MULTI, HeapTupleHeaderGetUpdateXid, HeapTupleHeaderIsHeapOnly, HeapTupleHeaderIsHotUpdated, HeapCheckContext::lp_len, MAXALIGN, HeapCheckContext::natts, psprintf(), pstrdup(), report_corruption(), SizeofHeapTupleHeader, HeapTupleHeaderData::t_hoff, HeapTupleHeaderData::t_infomask, TransactionIdIsValid, and HeapCheckContext::tuphdr.
Referenced by check_tuple().
|
static |
Definition at line 1020 of file verify_heapam.c.
References check_mxid_valid_in_rel(), EpochFromFullTransactionId, get_xid_status(), HEAP_MOVED_IN, HEAP_MOVED_OFF, HEAP_XMAX_INVALID, HEAP_XMAX_IS_LOCKED_ONLY, HEAP_XMAX_IS_MULTI, HeapTupleGetUpdateXid(), HeapTupleHeaderGetRawXmax, HeapTupleHeaderGetXmin, HeapTupleHeaderGetXvac, HeapTupleHeaderXminCommitted, HeapTupleHeaderXminInvalid, HeapCheckContext::next_fxid, HeapCheckContext::next_mxact, HeapCheckContext::oldest_fxid, HeapCheckContext::oldest_mxact, psprintf(), pstrdup(), HeapCheckContext::relfrozenfxid, HeapCheckContext::relminmxid, report_corruption(), HeapCheckContext::safe_xmin, HeapTupleHeaderData::t_infomask, TransactionIdPrecedes(), HeapCheckContext::tuphdr, HeapCheckContext::tuple_could_be_pruned, XID_ABORTED, XID_BOUNDS_OK, XID_COMMITTED, XID_IN_FUTURE, XID_IN_PROGRESS, XID_INVALID, XID_IS_CURRENT_XID, XID_PRECEDES_CLUSTERMIN, XID_PRECEDES_RELMIN, and XidFromFullTransactionId.
Referenced by check_tuple().
|
static |
Definition at line 1885 of file verify_heapam.c.
References Assert, EpochFromFullTransactionId, FirstNormalFullTransactionId, FirstNormalTransactionId, FullTransactionIdFromEpochAndXid(), FullTransactionIdFromU64(), FullTransactionIdIsNormal, HeapCheckContext::next_fxid, HeapCheckContext::next_xid, TransactionIdIsNormal, U64FromFullTransactionId, and XidFromFullTransactionId.
Referenced by update_cached_xid_range(), and verify_heapam().
|
inlinestatic |
Definition at line 1954 of file verify_heapam.c.
References FullTransactionIdPrecedes, FullTransactionIdPrecedesOrEquals, HeapCheckContext::next_fxid, and HeapCheckContext::oldest_fxid.
|
static |
Definition at line 2019 of file verify_heapam.c.
Referenced by check_tuple_visibility().
PG_FUNCTION_INFO_V1 | ( | verify_heapam | ) |
|
static |
Definition at line 859 of file verify_heapam.c.
References HeapCheckContext::attnum, HeapCheckContext::blkno, HeapCheckContext::is_corrupt, HeapCheckContext::offnum, report_corruption_internal(), HeapCheckContext::tupdesc, and HeapCheckContext::tupstore.
Referenced by check_tuple(), check_tuple_attribute(), check_tuple_header(), check_tuple_visibility(), and verify_heapam().
|
static |
Definition at line 823 of file verify_heapam.c.
References attnum, CStringGetTextDatum, heap_form_tuple(), HEAPCHECK_RELATION_COLS, Int32GetDatum(), Int64GetDatum(), pfree(), tuplestore_puttuple(), and values.
Referenced by report_corruption(), and report_toast_corruption().
|
static |
Definition at line 875 of file verify_heapam.c.
References ToastedAttribute::attnum, ToastedAttribute::blkno, HeapCheckContext::is_corrupt, ToastedAttribute::offnum, report_corruption_internal(), HeapCheckContext::tupdesc, and HeapCheckContext::tupstore.
Referenced by check_toast_tuple(), and check_toasted_attribute().
|
static |
Definition at line 1944 of file verify_heapam.c.
References HeapCheckContext::next_mxact, HeapCheckContext::oldest_mxact, and ReadMultiXactIdRange().
Referenced by check_mxid_valid_in_rel(), and verify_heapam().
|
static |
Definition at line 1927 of file verify_heapam.c.
References FullTransactionIdFromXidAndCtx(), LW_SHARED, LWLockAcquire(), LWLockRelease(), HeapCheckContext::next_fxid, HeapCheckContext::next_xid, TransamVariablesData::nextXid, HeapCheckContext::oldest_fxid, HeapCheckContext::oldest_xid, TransamVariablesData::oldestXid, TransamVariables, and XidFromFullTransactionId.
Referenced by verify_heapam().
Datum verify_heapam | ( | PG_FUNCTION_ARGS | ) |
Definition at line 221 of file verify_heapam.c.
References AccessShareLock, Assert, BAS_BULKREAD, BUFFER_LOCK_SHARE, BufferGetPage(), CHECK_FOR_INTERRUPTS, check_toasted_attribute(), check_tuple(), DEBUG1, ereport, errcode(), errdetail_relkind_not_supported(), errhint(), errmsg(), ERROR, fb(), FirstOffsetNumber, FullTransactionIdFromXidAndCtx(), GetAccessStrategy(), GetTransactionSnapshot(), HEAP_HOT_UPDATED, HeapTupleHeaderGetNatts, HeapTupleHeaderGetUpdateXid, HeapTupleHeaderGetXmin, HeapTupleHeaderIsHeapOnly, if(), InitMaterializedSRF(), InvalidBuffer, InvalidOffsetNumber, InvalidTransactionId, ItemIdGetLength, ItemIdGetOffset, ItemIdGetRedirect, ItemIdIsDead, ItemIdIsNormal, ItemIdIsRedirected, ItemIdIsUsed, ItemPointerGetBlockNumber(), ItemPointerGetOffsetNumber(), lfirst, list_free_deep(), LockBuffer(), MAIN_FORKNUM, MAXALIGN, MaxOffsetNumber, NIL, OffsetNumberNext, PageGetItem(), PageGetItemId(), PageGetMaxOffsetNumber(), PG_ARGISNULL, PG_GETARG_BOOL, PG_GETARG_INT64, PG_GETARG_OID, PG_GETARG_TEXT_PP, PG_RETURN_NULL, pg_strcasecmp(), psprintf(), RBM_NORMAL, ReadBufferExtended(), RecoveryInProgress(), relation_close(), relation_open(), RelationGetNumberOfBlocks, RelationGetRelationName, ReleaseBuffer(), report_corruption(), ReturnSetInfo::setDesc, ReturnSetInfo::setResult, SizeofHeapTupleHeader, skip, SKIP_PAGES_ALL_FROZEN, SKIP_PAGES_ALL_VISIBLE, SKIP_PAGES_NONE, HeapTupleHeaderData::t_infomask2, table_close(), table_open(), text_to_cstring(), toast_close_indexes(), toast_open_indexes(), TransactionIdEquals, TransactionIdIsInProgress(), TransactionIdIsNormal, TransactionIdIsValid, UnlockReleaseBuffer(), update_cached_mxid_range(), update_cached_xid_range(), VISIBILITYMAP_ALL_FROZEN, VISIBILITYMAP_ALL_VISIBLE, visibilitymap_get_status(), XID_ABORTED, XID_COMMITTED, XID_IN_PROGRESS, and SnapshotData::xmin.