100 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
101 errmsg(
"invalid block number")));
141 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
142 errmsg(
"invalid block number")));
274 int64 all_visible = 0;
275 int64 all_frozen = 0;
287 for (blkno = 0; blkno < nblocks; ++blkno)
308 elog(
ERROR,
"return type must be a row type");
504 info->
count = nblocks;
520 for (blkno = 0; blkno < nblocks; ++blkno)
530 info->
bits[blkno] |= (1 << 0);
532 info->
bits[blkno] |= (1 << 1);
549 info->
bits[blkno] |= (1 << 2);
616 else if (rel == NULL || rel->
rd_rel->relisshared)
652 void *callback_private_data,
653 void *per_buffer_data)
659 bool check_frozen =
false;
660 bool check_visible =
false;
668 check_visible =
true;
669 if (!check_visible && !check_frozen)
763 check_frozen =
false;
765 check_visible =
false;
766 if (!check_visible && !check_frozen)
830 OldestXmin = RecomputedOldestXmin;
922 if (!RELKIND_HAS_TABLE_AM(
rel->
rd_rel->relkind))
924 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
925 errmsg(
"relation \"%s\" is of wrong relation kind",
#define InvalidBlockNumber
static bool BlockNumberIsValid(BlockNumber blockNumber)
static Datum values[MAXATTR]
BlockNumber BufferGetBlockNumber(Buffer buffer)
void ReleaseBuffer(Buffer buffer)
void UnlockReleaseBuffer(Buffer buffer)
void LockBuffer(Buffer buffer, int mode)
Buffer ReadBuffer(Relation reln, BlockNumber blockNum)
#define BUFFER_LOCK_SHARE
#define RelationGetNumberOfBlocks(reln)
static Page BufferGetPage(Buffer buffer)
static Item PageGetItem(Page page, ItemId itemId)
static ItemId PageGetItemId(Page page, OffsetNumber offsetNumber)
static bool PageIsAllVisible(Page page)
static OffsetNumber PageGetMaxOffsetNumber(Page page)
#define Assert(condition)
#define FLEXIBLE_ARRAY_MEMBER
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
TupleDesc BlessTupleDesc(TupleDesc tupdesc)
Datum Int64GetDatum(int64 X)
#define PG_GETARG_INT64(n)
#define PG_RETURN_DATUM(x)
BufferAccessStrategy GetAccessStrategy(BufferAccessStrategyType btype)
TypeFuncClass get_call_result_type(FunctionCallInfo fcinfo, Oid *resultTypeId, TupleDesc *resultTupleDesc)
#define SRF_IS_FIRSTCALL()
#define SRF_PERCALL_SETUP()
#define SRF_RETURN_NEXT(_funcctx, _result)
#define SRF_FIRSTCALL_INIT()
static Datum HeapTupleGetDatum(const HeapTupleData *tuple)
#define SRF_RETURN_DONE(_funcctx)
bool heap_tuple_needs_eventual_freeze(HeapTupleHeader tuple)
HTSV_Result HeapTupleSatisfiesVacuum(HeapTuple htup, TransactionId OldestXmin, Buffer buffer)
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, const Datum *values, const bool *isnull)
HeapTupleHeaderData * HeapTupleHeader
#define HeapTupleHeaderGetXmin(tup)
if(TABLE==NULL||TABLE_index==NULL)
#define ItemIdGetLength(itemId)
#define ItemIdIsDead(itemId)
#define ItemIdIsUsed(itemId)
#define ItemIdIsRedirected(itemId)
static void ItemPointerSet(ItemPointerData *pointer, BlockNumber blockNumber, OffsetNumber offNum)
#define AccessExclusiveLock
bool LWLockAcquire(LWLock *lock, LWLockMode mode)
void LWLockRelease(LWLock *lock)
void * palloc0(Size size)
void * repalloc(void *pointer, Size size)
#define CHECK_FOR_INTERRUPTS()
#define OffsetNumberNext(offsetNumber)
#define FirstOffsetNumber
int errdetail_relkind_not_supported(char relkind)
static BlockNumber collect_corrupt_items_read_stream_next_block(ReadStream *stream, void *callback_private_data, void *per_buffer_data)
static corrupt_items * collect_corrupt_items(Oid relid, bool all_visible, bool all_frozen)
Datum pg_visibility_map_summary(PG_FUNCTION_ARGS)
Datum pg_visibility_rel(PG_FUNCTION_ARGS)
PG_FUNCTION_INFO_V1(pg_visibility_map)
struct corrupt_items corrupt_items
static TupleDesc pg_visibility_tupdesc(bool include_blkno, bool include_pd)
static void check_relation_relkind(Relation rel)
static void record_corrupt_item(corrupt_items *items, ItemPointer tid)
static TransactionId GetStrictOldestNonRemovableTransactionId(Relation rel)
Datum pg_visibility_map(PG_FUNCTION_ARGS)
static vbits * collect_visibility_data(Oid relid, bool include_pd)
Datum pg_visibility_map_rel(PG_FUNCTION_ARGS)
Datum pg_check_visible(PG_FUNCTION_ARGS)
Datum pg_check_frozen(PG_FUNCTION_ARGS)
Datum pg_visibility(PG_FUNCTION_ARGS)
static bool tuple_all_visible(HeapTuple tup, TransactionId OldestXmin, Buffer buffer)
Datum pg_truncate_visibility_map(PG_FUNCTION_ARGS)
static Datum PointerGetDatum(const void *X)
static Datum BoolGetDatum(bool X)
TransactionId GetOldestNonRemovableTransactionId(Relation rel)
RunningTransactions GetRunningTransactionData(void)
MemoryContextSwitchTo(old_ctx)
ReadStream * read_stream_begin_relation(int flags, BufferAccessStrategy strategy, Relation rel, ForkNumber forknum, ReadStreamBlockNumberCB callback, void *callback_private_data, size_t per_buffer_data_size)
Buffer read_stream_next_buffer(ReadStream *stream, void **per_buffer_data)
void read_stream_end(ReadStream *stream)
BlockNumber block_range_read_stream_cb(ReadStream *stream, void *callback_private_data, void *per_buffer_data)
#define RELATION_IS_LOCAL(relation)
static SMgrRelation RelationGetSmgr(Relation rel)
#define RelationGetRelationName(relation)
#define RelationNeedsWAL(relation)
void smgrtruncate(SMgrRelation reln, ForkNumber *forknum, int nforks, BlockNumber *nblocks)
void relation_close(Relation relation, LOCKMODE lockmode)
Relation relation_open(Oid relationId, LOCKMODE lockmode)
#define XLOG_SMGR_TRUNCATE
BlockNumber last_exclusive
BlockNumber current_blocknum
MemoryContext multi_call_memory_ctx
RelFileLocator rd_locator
TransactionId oldestRunningXid
TransactionId oldestDatabaseRunningXid
BlockNumber smgr_cached_nblocks[MAX_FORKNUM+1]
FullTransactionId nextXid
BlockNumber last_exclusive
BlockNumber current_blocknum
uint8 bits[FLEXIBLE_ARRAY_MEMBER]
bool TransactionIdPrecedes(TransactionId id1, TransactionId id2)
#define InvalidTransactionId
#define XidFromFullTransactionId(x)
TupleDesc CreateTemplateTupleDesc(int natts)
void TupleDescInitEntry(TupleDesc desc, AttrNumber attributeNumber, const char *attributeName, Oid oidtypeid, int32 typmod, int attdim)
TransamVariablesData * TransamVariables
uint8 visibilitymap_get_status(Relation rel, BlockNumber heapBlk, Buffer *vmbuf)
BlockNumber visibilitymap_prepare_truncate(Relation rel, BlockNumber nheapblocks)
#define VM_ALL_VISIBLE(r, b, v)
#define VM_ALL_FROZEN(r, b, v)
#define VISIBILITYMAP_ALL_FROZEN
#define VISIBILITYMAP_ALL_VISIBLE
bool RecoveryInProgress(void)
XLogRecPtr XLogInsert(RmgrId rmid, uint8 info)
void XLogRegisterData(const char *data, uint32 len)
void XLogBeginInsert(void)
#define XLR_SPECIAL_REL_UPDATE