Contents
pg_current_xact_id()
A function returning the current transaction ID
pg_current_xact_id()
is a system function
pg_current_xact_id()
was added in PostgreSQL 13.
Usage
pg_current_xact_id () → xid8
pg_current_xact_id()
returns the current transaction ID as xid8
. Note that a new transaction ID will be assigned if the current transaction does not currently have one. Use pg_current_xact_id_if_assigned()
to only retrieve the current transaction ID if one is already assigned.
pg_current_xact_id()
replaces txid_current()
.
Change history
- PostgreSQL 13
- added (commit 4c04be9b)
Examples
Basic usage example for pg_current_xact_id()
:
postgres=# SELECT pg_current_xact_id(); pg_current_xact_id -------------------- 763 (1 row)
References
- PostgreSQL documentation: Transaction ID and Snapshot Information Functions