PostgreSQL Source Code git master
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
pg_visibility.c File Reference
#include "postgres.h"
#include "access/heapam.h"
#include "access/htup_details.h"
#include "access/visibilitymap.h"
#include "access/xloginsert.h"
#include "catalog/pg_type.h"
#include "catalog/storage_xlog.h"
#include "funcapi.h"
#include "miscadmin.h"
#include "storage/bufmgr.h"
#include "storage/proc.h"
#include "storage/procarray.h"
#include "storage/read_stream.h"
#include "storage/smgr.h"
#include "utils/rel.h"
Include dependency graph for pg_visibility.c:

Go to the source code of this file.

Data Structures

struct  vbits
 
struct  corrupt_items
 
struct  collect_corrupt_items_read_stream_private
 

Typedefs

typedef struct vbits vbits
 
typedef struct corrupt_items corrupt_items
 

Functions

 PG_FUNCTION_INFO_V1 (pg_visibility_map)
 
 PG_FUNCTION_INFO_V1 (pg_visibility_map_rel)
 
 PG_FUNCTION_INFO_V1 (pg_visibility)
 
 PG_FUNCTION_INFO_V1 (pg_visibility_rel)
 
 PG_FUNCTION_INFO_V1 (pg_visibility_map_summary)
 
 PG_FUNCTION_INFO_V1 (pg_check_frozen)
 
 PG_FUNCTION_INFO_V1 (pg_check_visible)
 
 PG_FUNCTION_INFO_V1 (pg_truncate_visibility_map)
 
static TupleDesc pg_visibility_tupdesc (bool include_blkno, bool include_pd)
 
static vbitscollect_visibility_data (Oid relid, bool include_pd)
 
static corrupt_itemscollect_corrupt_items (Oid relid, bool all_visible, bool all_frozen)
 
static void record_corrupt_item (corrupt_items *items, ItemPointer tid)
 
static bool tuple_all_visible (HeapTuple tup, TransactionId OldestXmin, Buffer buffer)
 
static void check_relation_relkind (Relation rel)
 
Datum pg_visibility_map (PG_FUNCTION_ARGS)
 
Datum pg_visibility (PG_FUNCTION_ARGS)
 
Datum pg_visibility_map_rel (PG_FUNCTION_ARGS)
 
Datum pg_visibility_rel (PG_FUNCTION_ARGS)
 
Datum pg_visibility_map_summary (PG_FUNCTION_ARGS)
 
Datum pg_check_frozen (PG_FUNCTION_ARGS)
 
Datum pg_check_visible (PG_FUNCTION_ARGS)
 
Datum pg_truncate_visibility_map (PG_FUNCTION_ARGS)
 
static TransactionId GetStrictOldestNonRemovableTransactionId (Relation rel)
 
static BlockNumber collect_corrupt_items_read_stream_next_block (ReadStream *stream, void *callback_private_data, void *per_buffer_data)
 

Variables

 PG_MODULE_MAGIC
 

Typedef Documentation

◆ corrupt_items

typedef struct corrupt_items corrupt_items

◆ vbits

typedef struct vbits vbits

Function Documentation

◆ check_relation_relkind()

static void check_relation_relkind ( Relation  rel)
static

Definition at line 935 of file pg_visibility.c.

936{
937 if (!RELKIND_HAS_TABLE_AM(rel->rd_rel->relkind))
939 (errcode(ERRCODE_WRONG_OBJECT_TYPE),
940 errmsg("relation \"%s\" is of wrong relation kind",
943}
int errcode(int sqlerrcode)
Definition: elog.c:853
int errmsg(const char *fmt,...)
Definition: elog.c:1070
#define ERROR
Definition: elog.h:39
#define ereport(elevel,...)
Definition: elog.h:149
int errdetail_relkind_not_supported(char relkind)
Definition: pg_class.c:24
#define RelationGetRelationName(relation)
Definition: rel.h:539
Form_pg_class rd_rel
Definition: rel.h:111

References ereport, errcode(), errdetail_relkind_not_supported(), errmsg(), ERROR, RelationData::rd_rel, collect_corrupt_items_read_stream_private::rel, and RelationGetRelationName.

Referenced by collect_corrupt_items(), collect_visibility_data(), pg_truncate_visibility_map(), pg_visibility(), pg_visibility_map(), and pg_visibility_map_summary().

◆ collect_corrupt_items()

static corrupt_items * collect_corrupt_items ( Oid  relid,
bool  all_visible,
bool  all_frozen 
)
static

Definition at line 708 of file pg_visibility.c.

709{
710 Relation rel;
712 Buffer vmbuffer = InvalidBuffer;
716 ReadStream *stream;
717 Buffer buffer;
718
720
721 /* Only some relkinds have a visibility map */
723
724 if (all_visible)
726
727 /*
728 * Guess an initial array size. We don't expect many corrupted tuples, so
729 * start with a small array. This function uses the "next" field to track
730 * the next offset where we can store an item (which is the same thing as
731 * the number of items found so far) and the "count" field to track the
732 * number of entries allocated. We'll repurpose these fields before
733 * returning.
734 */
735 items = palloc0(sizeof(corrupt_items));
736 items->next = 0;
737 items->count = 64;
738 items->tids = palloc(items->count * sizeof(ItemPointerData));
739
740 p.current_blocknum = 0;
741 p.last_exclusive = RelationGetNumberOfBlocks(rel);
742 p.rel = rel;
743 p.vmbuffer = InvalidBuffer;
744 p.all_frozen = all_frozen;
745 p.all_visible = all_visible;
747 bstrategy,
748 rel,
751 &p,
752 0);
753
754 /* Loop over every block in the relation. */
755 while ((buffer = read_stream_next_buffer(stream, NULL)) != InvalidBuffer)
756 {
757 bool check_frozen = all_frozen;
758 bool check_visible = all_visible;
759 Page page;
760 OffsetNumber offnum,
761 maxoff;
762 BlockNumber blkno;
763
764 /* Make sure we are interruptible. */
766
768
769 page = BufferGetPage(buffer);
770 maxoff = PageGetMaxOffsetNumber(page);
771 blkno = BufferGetBlockNumber(buffer);
772
773 /*
774 * The visibility map bits might have changed while we were acquiring
775 * the page lock. Recheck to avoid returning spurious results.
776 */
777 if (check_frozen && !VM_ALL_FROZEN(rel, blkno, &vmbuffer))
778 check_frozen = false;
779 if (check_visible && !VM_ALL_VISIBLE(rel, blkno, &vmbuffer))
780 check_visible = false;
781 if (!check_visible && !check_frozen)
782 {
783 UnlockReleaseBuffer(buffer);
784 continue;
785 }
786
787 /* Iterate over each tuple on the page. */
788 for (offnum = FirstOffsetNumber;
789 offnum <= maxoff;
790 offnum = OffsetNumberNext(offnum))
791 {
792 HeapTupleData tuple;
793 ItemId itemid;
794
795 itemid = PageGetItemId(page, offnum);
796
797 /* Unused or redirect line pointers are of no interest. */
798 if (!ItemIdIsUsed(itemid) || ItemIdIsRedirected(itemid))
799 continue;
800
801 /* Dead line pointers are neither all-visible nor frozen. */
802 if (ItemIdIsDead(itemid))
803 {
804 ItemPointerSet(&(tuple.t_self), blkno, offnum);
806 continue;
807 }
808
809 /* Initialize a HeapTupleData structure for checks below. */
810 ItemPointerSet(&(tuple.t_self), blkno, offnum);
811 tuple.t_data = (HeapTupleHeader) PageGetItem(page, itemid);
812 tuple.t_len = ItemIdGetLength(itemid);
813 tuple.t_tableOid = relid;
814
815 /*
816 * If we're checking whether the page is all-visible, we expect
817 * the tuple to be all-visible.
818 */
819 if (check_visible &&
820 !tuple_all_visible(&tuple, OldestXmin, buffer))
821 {
822 TransactionId RecomputedOldestXmin;
823
824 /*
825 * Time has passed since we computed OldestXmin, so it's
826 * possible that this tuple is all-visible in reality even
827 * though it doesn't appear so based on our
828 * previously-computed value. Let's compute a new value so we
829 * can be certain whether there is a problem.
830 *
831 * From a concurrency point of view, it sort of sucks to
832 * retake ProcArrayLock here while we're holding the buffer
833 * exclusively locked, but it should be safe against
834 * deadlocks, because surely
835 * GetStrictOldestNonRemovableTransactionId() should never
836 * take a buffer lock. And this shouldn't happen often, so
837 * it's worth being careful so as to avoid false positives.
838 */
839 RecomputedOldestXmin = GetStrictOldestNonRemovableTransactionId(rel);
840
841 if (!TransactionIdPrecedes(OldestXmin, RecomputedOldestXmin))
843 else
844 {
845 OldestXmin = RecomputedOldestXmin;
846 if (!tuple_all_visible(&tuple, OldestXmin, buffer))
848 }
849 }
850
851 /*
852 * If we're checking whether the page is all-frozen, we expect the
853 * tuple to be in a state where it will never need freezing.
854 */
855 if (check_frozen)
856 {
859 }
860 }
861
862 UnlockReleaseBuffer(buffer);
863 }
864 read_stream_end(stream);
865
866 /* Clean up. */
867 if (vmbuffer != InvalidBuffer)
869 if (p.vmbuffer != InvalidBuffer)
870 ReleaseBuffer(p.vmbuffer);
872
873 /*
874 * Before returning, repurpose the fields to match caller's expectations.
875 * next is now the next item that should be read (rather than written) and
876 * count is now the number of items we wrote (rather than the number we
877 * allocated).
878 */
879 items->count = items->next;
880 items->next = 0;
881
882 return items;
883}
uint32 BlockNumber
Definition: block.h:31
int Buffer
Definition: buf.h:23
#define InvalidBuffer
Definition: buf.h:25
BlockNumber BufferGetBlockNumber(Buffer buffer)
Definition: bufmgr.c:3724
void ReleaseBuffer(Buffer buffer)
Definition: bufmgr.c:4924
void UnlockReleaseBuffer(Buffer buffer)
Definition: bufmgr.c:4941
void LockBuffer(Buffer buffer, int mode)
Definition: bufmgr.c:5158
@ BAS_BULKREAD
Definition: bufmgr.h:36
#define BUFFER_LOCK_SHARE
Definition: bufmgr.h:190
#define RelationGetNumberOfBlocks(reln)
Definition: bufmgr.h:273
static Page BufferGetPage(Buffer buffer)
Definition: bufmgr.h:400
Pointer Page
Definition: bufpage.h:81
static Item PageGetItem(Page page, ItemId itemId)
Definition: bufpage.h:354
static ItemId PageGetItemId(Page page, OffsetNumber offsetNumber)
Definition: bufpage.h:243
static OffsetNumber PageGetMaxOffsetNumber(Page page)
Definition: bufpage.h:372
uint32 TransactionId
Definition: c.h:606
BufferAccessStrategy GetAccessStrategy(BufferAccessStrategyType btype)
Definition: freelist.c:541
bool heap_tuple_needs_eventual_freeze(HeapTupleHeader tuple)
Definition: heapam.c:7651
HeapTupleHeaderData * HeapTupleHeader
Definition: htup.h:23
#define ItemIdGetLength(itemId)
Definition: itemid.h:59
#define ItemIdIsDead(itemId)
Definition: itemid.h:113
#define ItemIdIsUsed(itemId)
Definition: itemid.h:92
#define ItemIdIsRedirected(itemId)
Definition: itemid.h:106
static void ItemPointerSet(ItemPointerData *pointer, BlockNumber blockNumber, OffsetNumber offNum)
Definition: itemptr.h:135
#define AccessShareLock
Definition: lockdefs.h:36
void * palloc0(Size size)
Definition: mcxt.c:1347
void * palloc(Size size)
Definition: mcxt.c:1317
#define CHECK_FOR_INTERRUPTS()
Definition: miscadmin.h:122
#define OffsetNumberNext(offsetNumber)
Definition: off.h:52
uint16 OffsetNumber
Definition: off.h:24
#define FirstOffsetNumber
Definition: off.h:27
static BlockNumber collect_corrupt_items_read_stream_next_block(ReadStream *stream, void *callback_private_data, void *per_buffer_data)
static void check_relation_relkind(Relation rel)
static void record_corrupt_item(corrupt_items *items, ItemPointer tid)
static TransactionId GetStrictOldestNonRemovableTransactionId(Relation rel)
static bool tuple_all_visible(HeapTuple tup, TransactionId OldestXmin, Buffer buffer)
Buffer read_stream_next_buffer(ReadStream *stream, void **per_buffer_data)
Definition: read_stream.c:605
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)
Definition: read_stream.c:551
void read_stream_end(ReadStream *stream)
Definition: read_stream.c:846
#define READ_STREAM_FULL
Definition: read_stream.h:43
@ MAIN_FORKNUM
Definition: relpath.h:58
void relation_close(Relation relation, LOCKMODE lockmode)
Definition: relation.c:205
Relation relation_open(Oid relationId, LOCKMODE lockmode)
Definition: relation.c:47
ItemPointerData t_self
Definition: htup.h:65
uint32 t_len
Definition: htup.h:64
HeapTupleHeader t_data
Definition: htup.h:68
Oid t_tableOid
Definition: htup.h:66
static ItemArray items
Definition: test_tidstore.c:48
bool TransactionIdPrecedes(TransactionId id1, TransactionId id2)
Definition: transam.c:280
#define InvalidTransactionId
Definition: transam.h:31
#define VM_ALL_VISIBLE(r, b, v)
Definition: visibilitymap.h:24
#define VM_ALL_FROZEN(r, b, v)
Definition: visibilitymap.h:26

References AccessShareLock, collect_corrupt_items_read_stream_private::all_frozen, collect_corrupt_items_read_stream_private::all_visible, BAS_BULKREAD, BUFFER_LOCK_SHARE, BufferGetBlockNumber(), BufferGetPage(), CHECK_FOR_INTERRUPTS, check_relation_relkind(), collect_corrupt_items_read_stream_next_block(), collect_corrupt_items_read_stream_private::current_blocknum, FirstOffsetNumber, GetAccessStrategy(), GetStrictOldestNonRemovableTransactionId(), heap_tuple_needs_eventual_freeze(), InvalidBuffer, InvalidTransactionId, ItemIdGetLength, ItemIdIsDead, ItemIdIsRedirected, ItemIdIsUsed, ItemPointerSet(), items, collect_corrupt_items_read_stream_private::last_exclusive, LockBuffer(), MAIN_FORKNUM, OffsetNumberNext, PageGetItem(), PageGetItemId(), PageGetMaxOffsetNumber(), palloc(), palloc0(), read_stream_begin_relation(), read_stream_end(), READ_STREAM_FULL, read_stream_next_buffer(), record_corrupt_item(), collect_corrupt_items_read_stream_private::rel, relation_close(), relation_open(), RelationGetNumberOfBlocks, ReleaseBuffer(), HeapTupleData::t_data, HeapTupleData::t_len, HeapTupleData::t_self, HeapTupleData::t_tableOid, TransactionIdPrecedes(), tuple_all_visible(), UnlockReleaseBuffer(), VM_ALL_FROZEN, VM_ALL_VISIBLE, and collect_corrupt_items_read_stream_private::vmbuffer.

Referenced by pg_check_frozen(), and pg_check_visible().

◆ collect_corrupt_items_read_stream_next_block()

static BlockNumber collect_corrupt_items_read_stream_next_block ( ReadStream stream,
void *  callback_private_data,
void *  per_buffer_data 
)
static

Definition at line 666 of file pg_visibility.c.

669{
670 struct collect_corrupt_items_read_stream_private *p = callback_private_data;
671
673 {
674 bool check_frozen = false;
675 bool check_visible = false;
676
677 /* Make sure we are interruptible. */
679
681 check_frozen = true;
683 check_visible = true;
684 if (!check_visible && !check_frozen)
685 continue;
686
687 return p->current_blocknum++;
688 }
689
690 return InvalidBlockNumber;
691}
#define InvalidBlockNumber
Definition: block.h:33

References collect_corrupt_items_read_stream_private::all_frozen, collect_corrupt_items_read_stream_private::all_visible, CHECK_FOR_INTERRUPTS, collect_corrupt_items_read_stream_private::current_blocknum, InvalidBlockNumber, collect_corrupt_items_read_stream_private::last_exclusive, collect_corrupt_items_read_stream_private::rel, VM_ALL_FROZEN, VM_ALL_VISIBLE, and collect_corrupt_items_read_stream_private::vmbuffer.

Referenced by collect_corrupt_items().

◆ collect_visibility_data()

static vbits * collect_visibility_data ( Oid  relid,
bool  include_pd 
)
static

Definition at line 500 of file pg_visibility.c.

501{
502 Relation rel;
503 BlockNumber nblocks;
504 vbits *info;
505 BlockNumber blkno;
506 Buffer vmbuffer = InvalidBuffer;
509 ReadStream *stream = NULL;
510
511 rel = relation_open(relid, AccessShareLock);
512
513 /* Only some relkinds have a visibility map */
515
516 nblocks = RelationGetNumberOfBlocks(rel);
517 info = palloc0(offsetof(vbits, bits) + nblocks);
518 info->next = 0;
519 info->count = nblocks;
520
521 /* Create a stream if reading main fork. */
522 if (include_pd)
523 {
524 p.current_blocknum = 0;
525 p.last_exclusive = nblocks;
527 bstrategy,
528 rel,
531 &p,
532 0);
533 }
534
535 for (blkno = 0; blkno < nblocks; ++blkno)
536 {
537 int32 mapbits;
538
539 /* Make sure we are interruptible. */
541
542 /* Get map info. */
543 mapbits = (int32) visibilitymap_get_status(rel, blkno, &vmbuffer);
544 if ((mapbits & VISIBILITYMAP_ALL_VISIBLE) != 0)
545 info->bits[blkno] |= (1 << 0);
546 if ((mapbits & VISIBILITYMAP_ALL_FROZEN) != 0)
547 info->bits[blkno] |= (1 << 1);
548
549 /*
550 * Page-level data requires reading every block, so only get it if the
551 * caller needs it. Use a buffer access strategy, too, to prevent
552 * cache-trashing.
553 */
554 if (include_pd)
555 {
556 Buffer buffer;
557 Page page;
558
559 buffer = read_stream_next_buffer(stream, NULL);
561
562 page = BufferGetPage(buffer);
563 if (PageIsAllVisible(page))
564 info->bits[blkno] |= (1 << 2);
565
566 UnlockReleaseBuffer(buffer);
567 }
568 }
569
570 if (include_pd)
571 {
573 read_stream_end(stream);
574 }
575
576 /* Clean up. */
577 if (vmbuffer != InvalidBuffer)
578 ReleaseBuffer(vmbuffer);
580
581 return info;
582}
static bool PageIsAllVisible(Page page)
Definition: bufpage.h:429
#define Assert(condition)
Definition: c.h:812
int32_t int32
Definition: c.h:481
BlockNumber block_range_read_stream_cb(ReadStream *stream, void *callback_private_data, void *per_buffer_data)
Definition: read_stream.c:171
BlockNumber next
Definition: pg_visibility.c:32
uint8 bits[FLEXIBLE_ARRAY_MEMBER]
Definition: pg_visibility.c:34
BlockNumber count
Definition: pg_visibility.c:33
uint8 visibilitymap_get_status(Relation rel, BlockNumber heapBlk, Buffer *vmbuf)
#define VISIBILITYMAP_ALL_FROZEN
#define VISIBILITYMAP_ALL_VISIBLE

References AccessShareLock, Assert, BAS_BULKREAD, vbits::bits, block_range_read_stream_cb(), BUFFER_LOCK_SHARE, BufferGetPage(), CHECK_FOR_INTERRUPTS, check_relation_relkind(), vbits::count, BlockRangeReadStreamPrivate::current_blocknum, GetAccessStrategy(), InvalidBuffer, BlockRangeReadStreamPrivate::last_exclusive, LockBuffer(), MAIN_FORKNUM, vbits::next, PageIsAllVisible(), palloc0(), read_stream_begin_relation(), read_stream_end(), READ_STREAM_FULL, read_stream_next_buffer(), relation_close(), relation_open(), RelationGetNumberOfBlocks, ReleaseBuffer(), UnlockReleaseBuffer(), VISIBILITYMAP_ALL_FROZEN, VISIBILITYMAP_ALL_VISIBLE, and visibilitymap_get_status().

Referenced by pg_visibility_map_rel(), and pg_visibility_rel().

◆ GetStrictOldestNonRemovableTransactionId()

static TransactionId GetStrictOldestNonRemovableTransactionId ( Relation  rel)
static

Definition at line 617 of file pg_visibility.c.

618{
619 RunningTransactions runningTransactions;
620
621 if (RecoveryInProgress())
622 {
623 TransactionId result;
624
625 /* As we ignore KnownAssignedXids on standby, just pick nextXid */
626 LWLockAcquire(XidGenLock, LW_SHARED);
628 LWLockRelease(XidGenLock);
629 return result;
630 }
631 else if (rel == NULL || rel->rd_rel->relisshared)
632 {
633 /* Shared relation: take into account all running xids */
634 runningTransactions = GetRunningTransactionData();
635 LWLockRelease(ProcArrayLock);
636 LWLockRelease(XidGenLock);
637 return runningTransactions->oldestRunningXid;
638 }
639 else if (!RELATION_IS_LOCAL(rel))
640 {
641 /*
642 * Normal relation: take into account xids running within the current
643 * database
644 */
645 runningTransactions = GetRunningTransactionData();
646 LWLockRelease(ProcArrayLock);
647 LWLockRelease(XidGenLock);
648 return runningTransactions->oldestDatabaseRunningXid;
649 }
650 else
651 {
652 /*
653 * For temporary relations, ComputeXidHorizons() uses only
654 * TransamVariables->latestCompletedXid and MyProc->xid. These two
655 * shouldn't go backwards. So we're fine with this horizon.
656 */
658 }
659}
bool LWLockAcquire(LWLock *lock, LWLockMode mode)
Definition: lwlock.c:1168
void LWLockRelease(LWLock *lock)
Definition: lwlock.c:1781
@ LW_SHARED
Definition: lwlock.h:115
TransactionId GetOldestNonRemovableTransactionId(Relation rel)
Definition: procarray.c:2005
RunningTransactions GetRunningTransactionData(void)
Definition: procarray.c:2689
#define RELATION_IS_LOCAL(relation)
Definition: rel.h:648
TransactionId oldestRunningXid
Definition: standby.h:92
TransactionId oldestDatabaseRunningXid
Definition: standby.h:93
FullTransactionId nextXid
Definition: transam.h:220
#define XidFromFullTransactionId(x)
Definition: transam.h:48
TransamVariablesData * TransamVariables
Definition: varsup.c:34
bool RecoveryInProgress(void)
Definition: xlog.c:6334

References GetOldestNonRemovableTransactionId(), GetRunningTransactionData(), LW_SHARED, LWLockAcquire(), LWLockRelease(), TransamVariablesData::nextXid, RunningTransactionsData::oldestDatabaseRunningXid, RunningTransactionsData::oldestRunningXid, RelationData::rd_rel, RecoveryInProgress(), RELATION_IS_LOCAL, TransamVariables, and XidFromFullTransactionId.

Referenced by collect_corrupt_items().

◆ pg_check_frozen()

Datum pg_check_frozen ( PG_FUNCTION_ARGS  )

Definition at line 321 of file pg_visibility.c.

322{
323 FuncCallContext *funcctx;
325
326 if (SRF_IS_FIRSTCALL())
327 {
328 Oid relid = PG_GETARG_OID(0);
329 MemoryContext oldcontext;
330
331 funcctx = SRF_FIRSTCALL_INIT();
332 oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
333 /* collect_corrupt_items will verify the relkind */
334 funcctx->user_fctx = collect_corrupt_items(relid, false, true);
335 MemoryContextSwitchTo(oldcontext);
336 }
337
338 funcctx = SRF_PERCALL_SETUP();
339 items = (corrupt_items *) funcctx->user_fctx;
340
341 if (items->next < items->count)
342 SRF_RETURN_NEXT(funcctx, PointerGetDatum(&items->tids[items->next++]));
343
344 SRF_RETURN_DONE(funcctx);
345}
#define PG_GETARG_OID(n)
Definition: fmgr.h:275
#define SRF_IS_FIRSTCALL()
Definition: funcapi.h:304
#define SRF_PERCALL_SETUP()
Definition: funcapi.h:308
#define SRF_RETURN_NEXT(_funcctx, _result)
Definition: funcapi.h:310
#define SRF_FIRSTCALL_INIT()
Definition: funcapi.h:306
#define SRF_RETURN_DONE(_funcctx)
Definition: funcapi.h:328
if(TABLE==NULL||TABLE_index==NULL)
Definition: isn.c:76
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition: palloc.h:124
static corrupt_items * collect_corrupt_items(Oid relid, bool all_visible, bool all_frozen)
static Datum PointerGetDatum(const void *X)
Definition: postgres.h:322
unsigned int Oid
Definition: postgres_ext.h:31
void * user_fctx
Definition: funcapi.h:82
MemoryContext multi_call_memory_ctx
Definition: funcapi.h:101

References collect_corrupt_items(), if(), items, MemoryContextSwitchTo(), FuncCallContext::multi_call_memory_ctx, PG_GETARG_OID, PointerGetDatum(), SRF_FIRSTCALL_INIT, SRF_IS_FIRSTCALL, SRF_PERCALL_SETUP, SRF_RETURN_DONE, SRF_RETURN_NEXT, and FuncCallContext::user_fctx.

◆ pg_check_visible()

Datum pg_check_visible ( PG_FUNCTION_ARGS  )

Definition at line 353 of file pg_visibility.c.

354{
355 FuncCallContext *funcctx;
357
358 if (SRF_IS_FIRSTCALL())
359 {
360 Oid relid = PG_GETARG_OID(0);
361 MemoryContext oldcontext;
362
363 funcctx = SRF_FIRSTCALL_INIT();
364 oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
365 /* collect_corrupt_items will verify the relkind */
366 funcctx->user_fctx = collect_corrupt_items(relid, true, false);
367 MemoryContextSwitchTo(oldcontext);
368 }
369
370 funcctx = SRF_PERCALL_SETUP();
371 items = (corrupt_items *) funcctx->user_fctx;
372
373 if (items->next < items->count)
374 SRF_RETURN_NEXT(funcctx, PointerGetDatum(&items->tids[items->next++]));
375
376 SRF_RETURN_DONE(funcctx);
377}

References collect_corrupt_items(), if(), items, MemoryContextSwitchTo(), FuncCallContext::multi_call_memory_ctx, PG_GETARG_OID, PointerGetDatum(), SRF_FIRSTCALL_INIT, SRF_IS_FIRSTCALL, SRF_PERCALL_SETUP, SRF_RETURN_DONE, SRF_RETURN_NEXT, and FuncCallContext::user_fctx.

◆ PG_FUNCTION_INFO_V1() [1/8]

PG_FUNCTION_INFO_V1 ( pg_check_frozen  )

◆ PG_FUNCTION_INFO_V1() [2/8]

PG_FUNCTION_INFO_V1 ( pg_check_visible  )

◆ PG_FUNCTION_INFO_V1() [3/8]

PG_FUNCTION_INFO_V1 ( pg_truncate_visibility_map  )

◆ PG_FUNCTION_INFO_V1() [4/8]

PG_FUNCTION_INFO_V1 ( pg_visibility  )

◆ PG_FUNCTION_INFO_V1() [5/8]

PG_FUNCTION_INFO_V1 ( pg_visibility_map  )

◆ PG_FUNCTION_INFO_V1() [6/8]

PG_FUNCTION_INFO_V1 ( pg_visibility_map_rel  )

◆ PG_FUNCTION_INFO_V1() [7/8]

PG_FUNCTION_INFO_V1 ( pg_visibility_map_summary  )

◆ PG_FUNCTION_INFO_V1() [8/8]

PG_FUNCTION_INFO_V1 ( pg_visibility_rel  )

◆ pg_truncate_visibility_map()

Datum pg_truncate_visibility_map ( PG_FUNCTION_ARGS  )

Definition at line 388 of file pg_visibility.c.

389{
390 Oid relid = PG_GETARG_OID(0);
391 Relation rel;
392 ForkNumber fork;
393 BlockNumber block;
394 BlockNumber old_block;
395
397
398 /* Only some relkinds have a visibility map */
400
401 /* Forcibly reset cached file size */
403
404 /* Compute new and old size before entering critical section. */
406 block = visibilitymap_prepare_truncate(rel, 0);
407 old_block = BlockNumberIsValid(block) ? smgrnblocks(RelationGetSmgr(rel), fork) : 0;
408
409 /*
410 * WAL-logging, buffer dropping, file truncation must be atomic and all on
411 * one side of a checkpoint. See RelationTruncate() for discussion.
412 */
416
417 if (RelationNeedsWAL(rel))
418 {
419 XLogRecPtr lsn;
420 xl_smgr_truncate xlrec;
421
422 xlrec.blkno = 0;
423 xlrec.rlocator = rel->rd_locator;
424 xlrec.flags = SMGR_TRUNCATE_VM;
425
427 XLogRegisterData((char *) &xlrec, sizeof(xlrec));
428
429 lsn = XLogInsert(RM_SMGR_ID,
431 XLogFlush(lsn);
432 }
433
434 if (BlockNumberIsValid(block))
435 smgrtruncate(RelationGetSmgr(rel), &fork, 1, &old_block, &block);
436
439
440 /*
441 * Release the lock right away, not at commit time.
442 *
443 * It would be a problem to release the lock prior to commit if this
444 * truncate operation sends any transactional invalidation messages. Other
445 * backends would potentially be able to lock the relation without
446 * processing them in the window of time between when we release the lock
447 * here and when we sent the messages at our eventual commit. However,
448 * we're currently only sending a non-transactional smgr invalidation,
449 * which will have been posted to shared memory immediately from within
450 * smgr_truncate. Therefore, there should be no race here.
451 *
452 * The reason why it's desirable to release the lock early here is because
453 * of the possibility that someone will need to use this to blow away many
454 * visibility map forks at once. If we can't release the lock until
455 * commit time, the transaction doing this will accumulate
456 * AccessExclusiveLocks on all of those relations at the same time, which
457 * is undesirable. However, if this turns out to be unsafe we may have no
458 * choice...
459 */
461
462 /* Nothing to return. */
464}
static bool BlockNumberIsValid(BlockNumber blockNumber)
Definition: block.h:71
#define PG_RETURN_VOID()
Definition: fmgr.h:349
#define AccessExclusiveLock
Definition: lockdefs.h:43
#define START_CRIT_SECTION()
Definition: miscadmin.h:149
#define END_CRIT_SECTION()
Definition: miscadmin.h:151
#define DELAY_CHKPT_START
Definition: proc.h:119
#define DELAY_CHKPT_COMPLETE
Definition: proc.h:120
static SMgrRelation RelationGetSmgr(Relation rel)
Definition: rel.h:567
#define RelationNeedsWAL(relation)
Definition: rel.h:628
ForkNumber
Definition: relpath.h:56
@ VISIBILITYMAP_FORKNUM
Definition: relpath.h:60
BlockNumber smgrnblocks(SMgrRelation reln, ForkNumber forknum)
Definition: smgr.c:677
void smgrtruncate(SMgrRelation reln, ForkNumber *forknum, int nforks, BlockNumber *old_nblocks, BlockNumber *nblocks)
Definition: smgr.c:729
PGPROC * MyProc
Definition: proc.c:66
#define SMGR_TRUNCATE_VM
Definition: storage_xlog.h:41
#define XLOG_SMGR_TRUNCATE
Definition: storage_xlog.h:31
int delayChkptFlags
Definition: proc.h:240
RelFileLocator rd_locator
Definition: rel.h:57
BlockNumber smgr_cached_nblocks[MAX_FORKNUM+1]
Definition: smgr.h:46
RelFileLocator rlocator
Definition: storage_xlog.h:49
BlockNumber blkno
Definition: storage_xlog.h:48
BlockNumber visibilitymap_prepare_truncate(Relation rel, BlockNumber nheapblocks)
void XLogFlush(XLogRecPtr record)
Definition: xlog.c:2802
uint64 XLogRecPtr
Definition: xlogdefs.h:21
XLogRecPtr XLogInsert(RmgrId rmid, uint8 info)
Definition: xloginsert.c:474
void XLogRegisterData(const char *data, uint32 len)
Definition: xloginsert.c:364
void XLogBeginInsert(void)
Definition: xloginsert.c:149
#define XLR_SPECIAL_REL_UPDATE
Definition: xlogrecord.h:82

References AccessExclusiveLock, Assert, xl_smgr_truncate::blkno, BlockNumberIsValid(), check_relation_relkind(), DELAY_CHKPT_COMPLETE, DELAY_CHKPT_START, PGPROC::delayChkptFlags, END_CRIT_SECTION, xl_smgr_truncate::flags, InvalidBlockNumber, MyProc, PG_GETARG_OID, PG_RETURN_VOID, RelationData::rd_locator, relation_close(), relation_open(), RelationGetSmgr(), RelationNeedsWAL, xl_smgr_truncate::rlocator, SMgrRelationData::smgr_cached_nblocks, SMGR_TRUNCATE_VM, smgrnblocks(), smgrtruncate(), START_CRIT_SECTION, VISIBILITYMAP_FORKNUM, visibilitymap_prepare_truncate(), XLOG_SMGR_TRUNCATE, XLogBeginInsert(), XLogFlush(), XLogInsert(), XLogRegisterData(), and XLR_SPECIAL_REL_UPDATE.

◆ pg_visibility()

Datum pg_visibility ( PG_FUNCTION_ARGS  )

Definition at line 120 of file pg_visibility.c.

121{
122 Oid relid = PG_GETARG_OID(0);
123 int64 blkno = PG_GETARG_INT64(1);
124 int32 mapbits;
125 Relation rel;
126 Buffer vmbuffer = InvalidBuffer;
127 Buffer buffer;
128 Page page;
129 TupleDesc tupdesc;
130 Datum values[3];
131 bool nulls[3] = {0};
132
133 rel = relation_open(relid, AccessShareLock);
134
135 /* Only some relkinds have a visibility map */
137
138 if (blkno < 0 || blkno > MaxBlockNumber)
140 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
141 errmsg("invalid block number")));
142
143 tupdesc = pg_visibility_tupdesc(false, true);
144
145 mapbits = (int32) visibilitymap_get_status(rel, blkno, &vmbuffer);
146 if (vmbuffer != InvalidBuffer)
147 ReleaseBuffer(vmbuffer);
148 values[0] = BoolGetDatum((mapbits & VISIBILITYMAP_ALL_VISIBLE) != 0);
149 values[1] = BoolGetDatum((mapbits & VISIBILITYMAP_ALL_FROZEN) != 0);
150
151 /* Here we have to explicitly check rel size ... */
152 if (blkno < RelationGetNumberOfBlocks(rel))
153 {
154 buffer = ReadBuffer(rel, blkno);
156
157 page = BufferGetPage(buffer);
159
160 UnlockReleaseBuffer(buffer);
161 }
162 else
163 {
164 /* As with the vismap, silently return 0 for pages past EOF */
165 values[2] = BoolGetDatum(false);
166 }
167
169
171}
#define MaxBlockNumber
Definition: block.h:35
static Datum values[MAXATTR]
Definition: bootstrap.c:151
Buffer ReadBuffer(Relation reln, BlockNumber blockNum)
Definition: bufmgr.c:746
int64_t int64
Definition: c.h:482
#define PG_GETARG_INT64(n)
Definition: fmgr.h:283
#define PG_RETURN_DATUM(x)
Definition: fmgr.h:353
static Datum HeapTupleGetDatum(const HeapTupleData *tuple)
Definition: funcapi.h:230
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, const Datum *values, const bool *isnull)
Definition: heaptuple.c:1117
static TupleDesc pg_visibility_tupdesc(bool include_blkno, bool include_pd)
uintptr_t Datum
Definition: postgres.h:64
static Datum BoolGetDatum(bool X)
Definition: postgres.h:102

References AccessShareLock, BoolGetDatum(), BUFFER_LOCK_SHARE, BufferGetPage(), check_relation_relkind(), ereport, errcode(), errmsg(), ERROR, heap_form_tuple(), HeapTupleGetDatum(), InvalidBuffer, LockBuffer(), MaxBlockNumber, PageIsAllVisible(), PG_GETARG_INT64, PG_GETARG_OID, PG_RETURN_DATUM, pg_visibility_tupdesc(), ReadBuffer(), relation_close(), relation_open(), RelationGetNumberOfBlocks, ReleaseBuffer(), UnlockReleaseBuffer(), values, VISIBILITYMAP_ALL_FROZEN, VISIBILITYMAP_ALL_VISIBLE, and visibilitymap_get_status().

◆ pg_visibility_map()

Datum pg_visibility_map ( PG_FUNCTION_ARGS  )

Definition at line 81 of file pg_visibility.c.

82{
83 Oid relid = PG_GETARG_OID(0);
84 int64 blkno = PG_GETARG_INT64(1);
85 int32 mapbits;
86 Relation rel;
87 Buffer vmbuffer = InvalidBuffer;
88 TupleDesc tupdesc;
89 Datum values[2];
90 bool nulls[2] = {0};
91
92 rel = relation_open(relid, AccessShareLock);
93
94 /* Only some relkinds have a visibility map */
96
97 if (blkno < 0 || blkno > MaxBlockNumber)
99 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
100 errmsg("invalid block number")));
101
102 tupdesc = pg_visibility_tupdesc(false, false);
103
104 mapbits = (int32) visibilitymap_get_status(rel, blkno, &vmbuffer);
105 if (vmbuffer != InvalidBuffer)
106 ReleaseBuffer(vmbuffer);
107 values[0] = BoolGetDatum((mapbits & VISIBILITYMAP_ALL_VISIBLE) != 0);
108 values[1] = BoolGetDatum((mapbits & VISIBILITYMAP_ALL_FROZEN) != 0);
109
111
113}

References AccessShareLock, BoolGetDatum(), check_relation_relkind(), ereport, errcode(), errmsg(), ERROR, heap_form_tuple(), HeapTupleGetDatum(), InvalidBuffer, MaxBlockNumber, PG_GETARG_INT64, PG_GETARG_OID, PG_RETURN_DATUM, pg_visibility_tupdesc(), relation_close(), relation_open(), ReleaseBuffer(), values, VISIBILITYMAP_ALL_FROZEN, VISIBILITYMAP_ALL_VISIBLE, and visibilitymap_get_status().

◆ pg_visibility_map_rel()

Datum pg_visibility_map_rel ( PG_FUNCTION_ARGS  )

Definition at line 177 of file pg_visibility.c.

178{
179 FuncCallContext *funcctx;
180 vbits *info;
181
182 if (SRF_IS_FIRSTCALL())
183 {
184 Oid relid = PG_GETARG_OID(0);
185 MemoryContext oldcontext;
186
187 funcctx = SRF_FIRSTCALL_INIT();
188 oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
189 funcctx->tuple_desc = pg_visibility_tupdesc(true, false);
190 /* collect_visibility_data will verify the relkind */
191 funcctx->user_fctx = collect_visibility_data(relid, false);
192 MemoryContextSwitchTo(oldcontext);
193 }
194
195 funcctx = SRF_PERCALL_SETUP();
196 info = (vbits *) funcctx->user_fctx;
197
198 if (info->next < info->count)
199 {
200 Datum values[3];
201 bool nulls[3] = {0};
202 HeapTuple tuple;
203
204 values[0] = Int64GetDatum(info->next);
205 values[1] = BoolGetDatum((info->bits[info->next] & (1 << 0)) != 0);
206 values[2] = BoolGetDatum((info->bits[info->next] & (1 << 1)) != 0);
207 info->next++;
208
209 tuple = heap_form_tuple(funcctx->tuple_desc, values, nulls);
210 SRF_RETURN_NEXT(funcctx, HeapTupleGetDatum(tuple));
211 }
212
213 SRF_RETURN_DONE(funcctx);
214}
Datum Int64GetDatum(int64 X)
Definition: fmgr.c:1807
static vbits * collect_visibility_data(Oid relid, bool include_pd)
TupleDesc tuple_desc
Definition: funcapi.h:112

References vbits::bits, BoolGetDatum(), collect_visibility_data(), vbits::count, heap_form_tuple(), HeapTupleGetDatum(), if(), Int64GetDatum(), MemoryContextSwitchTo(), FuncCallContext::multi_call_memory_ctx, vbits::next, PG_GETARG_OID, pg_visibility_tupdesc(), SRF_FIRSTCALL_INIT, SRF_IS_FIRSTCALL, SRF_PERCALL_SETUP, SRF_RETURN_DONE, SRF_RETURN_NEXT, FuncCallContext::tuple_desc, FuncCallContext::user_fctx, and values.

◆ pg_visibility_map_summary()

Datum pg_visibility_map_summary ( PG_FUNCTION_ARGS  )

Definition at line 266 of file pg_visibility.c.

267{
268 Oid relid = PG_GETARG_OID(0);
269 Relation rel;
270 BlockNumber nblocks;
271 BlockNumber blkno;
272 Buffer vmbuffer = InvalidBuffer;
273 int64 all_visible = 0;
274 int64 all_frozen = 0;
275 TupleDesc tupdesc;
276 Datum values[2];
277 bool nulls[2] = {0};
278
279 rel = relation_open(relid, AccessShareLock);
280
281 /* Only some relkinds have a visibility map */
283
284 nblocks = RelationGetNumberOfBlocks(rel);
285
286 for (blkno = 0; blkno < nblocks; ++blkno)
287 {
288 int32 mapbits;
289
290 /* Make sure we are interruptible. */
292
293 /* Get map info. */
294 mapbits = (int32) visibilitymap_get_status(rel, blkno, &vmbuffer);
295 if ((mapbits & VISIBILITYMAP_ALL_VISIBLE) != 0)
296 ++all_visible;
297 if ((mapbits & VISIBILITYMAP_ALL_FROZEN) != 0)
298 ++all_frozen;
299 }
300
301 /* Clean up. */
302 if (vmbuffer != InvalidBuffer)
303 ReleaseBuffer(vmbuffer);
305
306 if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
307 elog(ERROR, "return type must be a row type");
308
309 values[0] = Int64GetDatum(all_visible);
310 values[1] = Int64GetDatum(all_frozen);
311
313}
#define elog(elevel,...)
Definition: elog.h:225
TypeFuncClass get_call_result_type(FunctionCallInfo fcinfo, Oid *resultTypeId, TupleDesc *resultTupleDesc)
Definition: funcapi.c:276
@ TYPEFUNC_COMPOSITE
Definition: funcapi.h:149

References AccessShareLock, CHECK_FOR_INTERRUPTS, check_relation_relkind(), elog, ERROR, get_call_result_type(), heap_form_tuple(), HeapTupleGetDatum(), Int64GetDatum(), InvalidBuffer, PG_GETARG_OID, PG_RETURN_DATUM, relation_close(), relation_open(), RelationGetNumberOfBlocks, ReleaseBuffer(), TYPEFUNC_COMPOSITE, values, VISIBILITYMAP_ALL_FROZEN, VISIBILITYMAP_ALL_VISIBLE, and visibilitymap_get_status().

◆ pg_visibility_rel()

Datum pg_visibility_rel ( PG_FUNCTION_ARGS  )

Definition at line 221 of file pg_visibility.c.

222{
223 FuncCallContext *funcctx;
224 vbits *info;
225
226 if (SRF_IS_FIRSTCALL())
227 {
228 Oid relid = PG_GETARG_OID(0);
229 MemoryContext oldcontext;
230
231 funcctx = SRF_FIRSTCALL_INIT();
232 oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
233 funcctx->tuple_desc = pg_visibility_tupdesc(true, true);
234 /* collect_visibility_data will verify the relkind */
235 funcctx->user_fctx = collect_visibility_data(relid, true);
236 MemoryContextSwitchTo(oldcontext);
237 }
238
239 funcctx = SRF_PERCALL_SETUP();
240 info = (vbits *) funcctx->user_fctx;
241
242 if (info->next < info->count)
243 {
244 Datum values[4];
245 bool nulls[4] = {0};
246 HeapTuple tuple;
247
248 values[0] = Int64GetDatum(info->next);
249 values[1] = BoolGetDatum((info->bits[info->next] & (1 << 0)) != 0);
250 values[2] = BoolGetDatum((info->bits[info->next] & (1 << 1)) != 0);
251 values[3] = BoolGetDatum((info->bits[info->next] & (1 << 2)) != 0);
252 info->next++;
253
254 tuple = heap_form_tuple(funcctx->tuple_desc, values, nulls);
255 SRF_RETURN_NEXT(funcctx, HeapTupleGetDatum(tuple));
256 }
257
258 SRF_RETURN_DONE(funcctx);
259}

References vbits::bits, BoolGetDatum(), collect_visibility_data(), vbits::count, heap_form_tuple(), HeapTupleGetDatum(), if(), Int64GetDatum(), MemoryContextSwitchTo(), FuncCallContext::multi_call_memory_ctx, vbits::next, PG_GETARG_OID, pg_visibility_tupdesc(), SRF_FIRSTCALL_INIT, SRF_IS_FIRSTCALL, SRF_PERCALL_SETUP, SRF_RETURN_DONE, SRF_RETURN_NEXT, FuncCallContext::tuple_desc, FuncCallContext::user_fctx, and values.

◆ pg_visibility_tupdesc()

static TupleDesc pg_visibility_tupdesc ( bool  include_blkno,
bool  include_pd 
)
static

Definition at line 471 of file pg_visibility.c.

472{
473 TupleDesc tupdesc;
474 AttrNumber maxattr = 2;
475 AttrNumber a = 0;
476
477 if (include_blkno)
478 ++maxattr;
479 if (include_pd)
480 ++maxattr;
481 tupdesc = CreateTemplateTupleDesc(maxattr);
482 if (include_blkno)
483 TupleDescInitEntry(tupdesc, ++a, "blkno", INT8OID, -1, 0);
484 TupleDescInitEntry(tupdesc, ++a, "all_visible", BOOLOID, -1, 0);
485 TupleDescInitEntry(tupdesc, ++a, "all_frozen", BOOLOID, -1, 0);
486 if (include_pd)
487 TupleDescInitEntry(tupdesc, ++a, "pd_all_visible", BOOLOID, -1, 0);
488 Assert(a == maxattr);
489
490 return BlessTupleDesc(tupdesc);
491}
int16 AttrNumber
Definition: attnum.h:21
TupleDesc BlessTupleDesc(TupleDesc tupdesc)
Definition: execTuples.c:2258
int a
Definition: isn.c:68
TupleDesc CreateTemplateTupleDesc(int natts)
Definition: tupdesc.c:165
void TupleDescInitEntry(TupleDesc desc, AttrNumber attributeNumber, const char *attributeName, Oid oidtypeid, int32 typmod, int attdim)
Definition: tupdesc.c:797

References a, Assert, BlessTupleDesc(), CreateTemplateTupleDesc(), and TupleDescInitEntry().

Referenced by pg_visibility(), pg_visibility_map(), pg_visibility_map_rel(), and pg_visibility_rel().

◆ record_corrupt_item()

static void record_corrupt_item ( corrupt_items items,
ItemPointer  tid 
)
static

Definition at line 889 of file pg_visibility.c.

890{
891 /* enlarge output array if needed. */
892 if (items->next >= items->count)
893 {
894 items->count *= 2;
895 items->tids = repalloc(items->tids,
896 items->count * sizeof(ItemPointerData));
897 }
898 /* and add the new item */
899 items->tids[items->next++] = *tid;
900}
void * repalloc(void *pointer, Size size)
Definition: mcxt.c:1541

References items, and repalloc().

Referenced by collect_corrupt_items().

◆ tuple_all_visible()

static bool tuple_all_visible ( HeapTuple  tup,
TransactionId  OldestXmin,
Buffer  buffer 
)
static

Definition at line 907 of file pg_visibility.c.

908{
910 TransactionId xmin;
911
912 state = HeapTupleSatisfiesVacuum(tup, OldestXmin, buffer);
913 if (state != HEAPTUPLE_LIVE)
914 return false; /* all-visible implies live */
915
916 /*
917 * Neither lazy_scan_heap nor heap_page_is_all_visible will mark a page
918 * all-visible unless every tuple is hinted committed. However, those hint
919 * bits could be lost after a crash, so we can't be certain that they'll
920 * be set here. So just check the xmin.
921 */
922
923 xmin = HeapTupleHeaderGetXmin(tup->t_data);
924 if (!TransactionIdPrecedes(xmin, OldestXmin))
925 return false; /* xmin not old enough for all to see */
926
927 return true;
928}
HTSV_Result
Definition: heapam.h:125
@ HEAPTUPLE_LIVE
Definition: heapam.h:127
HTSV_Result HeapTupleSatisfiesVacuum(HeapTuple htup, TransactionId OldestXmin, Buffer buffer)
#define HeapTupleHeaderGetXmin(tup)
Definition: htup_details.h:309
Definition: regguts.h:323

References HEAPTUPLE_LIVE, HeapTupleHeaderGetXmin, HeapTupleSatisfiesVacuum(), HeapTupleData::t_data, and TransactionIdPrecedes().

Referenced by collect_corrupt_items().

Variable Documentation

◆ PG_MODULE_MAGIC

PG_MODULE_MAGIC

Definition at line 28 of file pg_visibility.c.