Are requests executed in a Postgres trigger procedure executed in the same transaction?

I have a trigger BEFORE DELETEthat inserts rows into another table with SPI_exec.

Are these requests INSERTexecuted in the same transaction as in the case when the initial deletion is performed? Consequently, are all inserts removed or fixed together?

If not, how can I do this?

+3
source share
1 answer

Yes, all triggers are in the same transaction as the triggering event.

Not directly related to the issue, but usually you want to put side effects in the trigger AFTER, not the trigger BEFORE.

+4

All Articles