select open change scope Open full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

FUNCTIONS / SYSTEM INFORMATION FUNCTIONS AND OPERATORS

pg_current_xact_id_if_assigned

Read PG 18 manual ↗

Returns the current transaction's ID, or NULL if no ID is assigned yet.

Signatures & examples

pg_current_xact_id_if_assigned () → xid8
Returns the current transaction's ID, or NULL if no ID is assigned yet. (It's best to use this variant if the transaction might otherwise be read-only, to avoid unnecessary consumption of an XID.) If executed in a subtransaction, this will return the top-level transaction ID.
Version history 2
  1. PG 15 → 16changed
  2. PG 12 → 13added

Definition snapshot: 2026-09-14T13:14:25.684213+00:00@99e6866c · English manual source