pg_visible_in_snapshot()

A function showing whether a transaction ID is visible in a snapshot

pg_visible_in_snapshot() is a system function determining whether a transaction ID is visible in a snapshot.

pg_visible_in_snapshot() was added in PostgreSQL 13.

Usage

pg_visible_in_snapshot ( xid8, pg_snapshot ) → boolean

pg_visible_in_snapshot() returns true if the specified transaction was completed before the snapshot was taken, otherwise false.

The specified transaction must not be a subtransaction.

pg_visible_in_snapshot() replaces txid_visible_in_snapshot().

Change history

Examples

Usage example for pg_visible_in_snapshot():

postgres=# SELECT pg_current_snapshot();
 pg_current_snapshot 
---------------------
 795:799:795,797
(1 row)

postgres=# SELECT pg_visible_in_snapshot('794'::xid8, '795:799:795,797');
 pg_visible_in_snapshot 
------------------------
 t
(1 row)

postgres=# SELECT pg_visible_in_snapshot('796'::xid8, '795:799:795,797');
 pg_visible_in_snapshot 
------------------------
 t
(1 row)

postgres=# SELECT pg_visible_in_snapshot('797'::xid8, '795:799:795,797');
 pg_visible_in_snapshot 
------------------------
 f
(1 row)

postgres=# SELECT pg_visible_in_snapshot('798'::xid8, '795:799:795,797');
 pg_visible_in_snapshot 
------------------------
 t
(1 row)

postgres=# SELECT pg_visible_in_snapshot('799'::xid8, '795:799:795,797');
 pg_visible_in_snapshot 
------------------------
 f
(1 row)

Categories

System function, Transactions

See also

pg_snapshot_xmin(), pg_snapshot_xmax(), pg_snapshot_xip(), pg_current_snapshot()