Does an AFTER UPDATE trigger happen within the original table update transaction?
Q1: If an AFTER UPDATE trigger fails, will it roll back the original table update?
Q2: My application performs a database transaction that updates entries in two different PostgreSQL tables simultaneously. I want to create a trigger that calculates some data (using information from both tables) and inserts a new entry into a log table. If I create an AFTER UPDATE trigger on one of the tables, can I assume that both tables have already been updated by the time the trigger executes?
1 Reply
other-emerald•11mo ago
As far as I remember, after update occurs after the transaction has completed, thus it won't cancel the transaction
Hmm. This is incorrect, after consulting docs. It executes at the end of the statement, which still occurs within the transaction
As for Q2, if the trigger runs after the first query in the transaction, then it seems that it won't see the updates from the second query