AFTER INSERT trigger in separate transaction?

postgresql, transactions, triggers

Solution

All PostgreSQL triggers execute in the same transaction as the transaction that has triggered them.

Edit: You can also use `LISTEN` + `NOTIFY` to send a message from your trigger to a code that executes outside of the transaction. In that case, the message will only be delivered at the point of a successful commit. Errors in listeners will not roll back the triggering transaction.

Problem

Will an `AFTER INSERT` trigger (function written in pl/PGsql) fire in a separate transaction than the original insert? What I'm concerned about is if the trigger experiences an exception of some kind. Can the trigger be rolled back without the original insert being affected?

Original source