Chapter 16. Autonomous Transactions

Table of Contents

16.1. Behavior
16.2. Visibility
16.3. SQL Grammar Extension for Autonomous Transactions
16.4. PL/pgSQL Grammar Extension for Autonomous Transactions
16.5. PL/Python Extension for Autonomous Transactions

An autonomous transaction is an independent transaction run within a parent transaction. Unlike subtransactions, which can only be committed as part of the transaction they belong to, autonomous transactions must be committed or rolled back before their parent is finished. While subtransactions are mostly used for error handling and in stored procedures, the main purpose of autonomous transactions is to implement audits, when an attempt to perform a transaction must be logged regardless of whether this transaction has been committed successfully.