↑↓ 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 the PG 18 manual

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

Reading PG 18current·documented in 8 of 27 versions, 13 to 20

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. 15 → 16 changed
  2. 12 → 13 added

Definition snapshot: b7bd9cda · English manual source