88 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
89 errmsg(
"invalid block number")));
129 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
130 errmsg(
"invalid block number")));
262 int64 all_visible = 0;
263 int64 all_frozen = 0;
275 for (blkno = 0; blkno < nblocks; ++blkno)
296 elog(
ERROR,
"return type must be a row type");
490 info->
count = nblocks;
492 for (blkno = 0; blkno < nblocks; ++blkno)
502 info->
bits[blkno] |= (1 << 0);
504 info->
bits[blkno] |= (1 << 1);
522 info->
bits[blkno] |= (1 << 2);
642 for (blkno = 0; blkno < nblocks; ++blkno)
644 bool check_frozen =
false;
645 bool check_visible =
false;
658 check_visible =
true;
659 if (!check_visible && !check_frozen)
675 check_frozen =
false;
677 check_visible =
false;
678 if (!check_visible && !check_frozen)
742 OldestXmin = RecomputedOldestXmin;
831 if (!RELKIND_HAS_TABLE_AM(rel->
rd_rel->relkind))
833 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
834 errmsg(
"relation \"%s\" is of wrong relation kind",
#define InvalidBlockNumber
static bool BlockNumberIsValid(BlockNumber blockNumber)
static Datum values[MAXATTR]
void ReleaseBuffer(Buffer buffer)
void UnlockReleaseBuffer(Buffer buffer)
void LockBuffer(Buffer buffer, int mode)
Buffer ReadBufferExtended(Relation reln, ForkNumber forkNum, BlockNumber blockNum, ReadBufferMode mode, BufferAccessStrategy strategy)
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 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)
Assert(fmt[strlen(fmt) - 1] !='\n')
#define AccessExclusiveLock
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 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)
#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
MemoryContext multi_call_memory_ctx
RelFileLocator rd_locator
TransactionId oldestRunningXid
TransactionId oldestDatabaseRunningXid
BlockNumber smgr_cached_nblocks[MAX_FORKNUM+1]
uint8 bits[FLEXIBLE_ARRAY_MEMBER]
bool TransactionIdPrecedes(TransactionId id1, TransactionId id2)
#define InvalidTransactionId
TupleDesc CreateTemplateTupleDesc(int natts)
void TupleDescInitEntry(TupleDesc desc, AttrNumber attributeNumber, const char *attributeName, Oid oidtypeid, int32 typmod, int attdim)
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)
void XLogRegisterData(char *data, uint32 len)
XLogRecPtr XLogInsert(RmgrId rmid, uint8 info)
void XLogBeginInsert(void)
#define XLR_SPECIAL_REL_UPDATE