pg_transaction_status — Get the current in-transaction status
pg_transaction_status conn
pg_transaction_status
returns the current status of
the connection: whether it is inside a transaction block, outside a
transaction block, or inside a failed transaction block. A transaction
block begins with the SQL command BEGIN
, and ends with
one of the SQL commands COMMIT
or
ROLLBACK
. A failed transaction block is a transaction
block after any error occurs; PostgreSQL will
ignore all SQL commands until the end of the transaction block.
pg_transaction_status
allows an application to
determine if it is in a transaction block or failed transaction block.