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

Examples

Basic usage example for pg_current_xact_id():

postgres=# SELECT pg_current_xact_id();
 pg_current_xact_id 
--------------------
                763
(1 row)

Categories

System function, Transactions

See also

pg_current_xact_id_if_assigned(), pg_xact_status()