Contents
pg_xact_status()
A function reporting the commit status of a transaction
pg_xact_status()
is a system function reporting the commit status of a recent transaction.
pg_xact_status()
was added in PostgreSQL 13.
Usage
pg_xact_status (xid8
) →text
pg_xact_status()
returns one of the following values:
committed
in progress
aborted
pg_xact_status()
replaces txid_status()
.
Change history
- PostgreSQL 13
- added (commit 4c04be9b)
Examples
Basic usage example for pg_xact_status()
:
postgres=# BEGIN; BEGIN postgres=*# SELECT pg_current_xact_id(); pg_current_xact_id -------------------- 762 (1 row) postgres=*# SELECT pg_xact_status('762'); pg_xact_status ---------------- in progress (1 row)
postgres=*# COMMIT; COMMIT postgres=# SELECT pg_xact_status('762'); pg_xact_status ---------------- committed (1 row)
Attempting to retrieve the status of a transaction which has not yet taken place:
postgres=# SELECT pg_xact_status('9999'); ERROR: transaction ID 9999 is in the future
References
- PostgreSQL documentation: Transaction ID and Snapshot Information Functions