1/*-------------------------------------------------------------------------
4 * POSTGRES snapshot manager
6 * Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
7 * Portions Copyright (c) 1994, Regents of the University of California
9 * src/include/utils/snapmgr.h
11 *-------------------------------------------------------------------------
27/* Variables representing various special snapshot semantics */
32 #define SnapshotSelf (&SnapshotSelfData)
33 #define SnapshotAny (&SnapshotAnyData)
35/* Use get_toast_snapshot() for the TOAST snapshot */
38 * We don't provide a static SnapshotDirty variable because it would be
39 * non-reentrant. Instead, users of that snapshot type should declare a
40 * local variable of type SnapshotData, and initialize it with this macro.
42 #define InitDirtySnapshot(snapshotdata) \
43 ((snapshotdata).snapshot_type = SNAPSHOT_DIRTY)
46 * Similarly, some initialization is required for a NonVacuumable snapshot.
47 * The caller must supply the visibility cutoff state to use (c.f.
48 * GlobalVisTestFor()).
50 #define InitNonVacuumableSnapshot(snapshotdata, vistestp) \
51 ((snapshotdata).snapshot_type = SNAPSHOT_NON_VACUUMABLE, \
52 (snapshotdata).vistest = (vistestp))
54/* This macro encodes the knowledge of which snapshots are MVCC-safe */
55 #define IsMVCCSnapshot(snapshot) \
56 ((snapshot)->snapshot_type == SNAPSHOT_MVCC || \
57 (snapshot)->snapshot_type == SNAPSHOT_HISTORIC_MVCC)
59 #define IsHistoricMVCCSnapshot(snapshot) \
60 ((snapshot)->snapshot_type == SNAPSHOT_HISTORIC_MVCC)
98 * These live in procarray.c because they're intimately linked to the
99 * procarray contents, but thematically they better fit into snapmgr.h.
109 * Utility functions for implementing visibility routines in table AMs.
113/* Support for catalog timetravel for logical decoding */
125#endif /* SNAPMGR_H */
bool GlobalVisTestIsRemovableFullXid(GlobalVisState *state, FullTransactionId fxid)
void UnregisterSnapshotFromOwner(Snapshot snapshot, ResourceOwner owner)
struct HTAB * HistoricSnapshotGetTupleCids(void)
bool GlobalVisTestIsRemovableXid(GlobalVisState *state, TransactionId xid)
bool GlobalVisCheckRemovableFullXid(Relation rel, FullTransactionId fxid)
void AtSubAbort_Snapshot(int level)
void SerializeSnapshot(Snapshot snapshot, char *start_address)
void AtEOXact_Snapshot(bool isCommit, bool resetXmin)
bool XidInMVCCSnapshot(TransactionId xid, Snapshot snapshot)
Snapshot GetTransactionSnapshot(void)
Snapshot GetLatestSnapshot(void)
void TeardownHistoricSnapshot(bool is_error)
Snapshot GetCatalogSnapshot(Oid relid)
void UnregisterSnapshot(Snapshot snapshot)
void PushActiveSnapshot(Snapshot snapshot)
Snapshot RestoreSnapshot(char *start_address)
void AtSubCommit_Snapshot(int level)
PGDLLIMPORT SnapshotData SnapshotToastData
void UpdateActiveSnapshotCommandId(void)
PGDLLIMPORT TransactionId TransactionXmin
bool HistoricSnapshotActive(void)
void ImportSnapshot(const char *idstr)
bool ActiveSnapshotSet(void)
PGDLLIMPORT SnapshotData SnapshotAnyData
Snapshot RegisterSnapshot(Snapshot snapshot)
bool XactHasExportedSnapshots(void)
void DeleteAllExportedSnapshotFiles(void)
bool GlobalVisCheckRemovableXid(Relation rel, TransactionId xid)
bool HaveRegisteredOrActiveSnapshot(void)
void InvalidateCatalogSnapshotConditionally(void)
bool ThereAreNoPriorRegisteredSnapshots(void)
void RestoreTransactionSnapshot(Snapshot snapshot, void *source_pgproc)
GlobalVisState * GlobalVisTestFor(Relation rel)
void SnapshotSetCommandId(CommandId curcid)
void PopActiveSnapshot(void)
void PushCopiedSnapshot(Snapshot snapshot)
char * ExportSnapshot(Snapshot snapshot)
PGDLLIMPORT SnapshotData SnapshotSelfData
Size EstimateSnapshotSpace(Snapshot snapshot)
void WaitForOlderSnapshots(TransactionId limitXmin, bool progress)
void SetupHistoricSnapshot(Snapshot historic_snapshot, struct HTAB *tuplecids)
PGDLLIMPORT bool FirstSnapshotSet
Snapshot RegisterSnapshotOnOwner(Snapshot snapshot, ResourceOwner owner)
void InvalidateCatalogSnapshot(void)
void PushActiveSnapshotWithLevel(Snapshot snapshot, int snap_level)
Snapshot GetNonHistoricCatalogSnapshot(Oid relid)
PGDLLIMPORT TransactionId RecentXmin
Snapshot GetActiveSnapshot(void)