pg_current_xact_id_if_assigned () → xid8Returns 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.