Re: BUG #15106: The AFTER trigger is created separately on view, and the DML operation can not trigger the trigger
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: 691525127@qq.com
Cc: pgsql-bugs@lists.postgresql.org
Date: 2018-03-12T20:27:33Z
Lists: pgsql-bugs
=?utf-8?q?PG_Bug_reporting_form?= <noreply@postgresql.org> writes: > It can be seen from the above example, the DML operation cannot trigger the > trigger when the Statement-level AFTER trigger is created on view alone. > But when create INSTEAD OF trigger at the same time, the DML operation can > trigger the AFTER trigger. When there's no INSTEAD OF trigger, the query is rewritten into an insert on the view's base table (assuming the view is simple enough to be auto-updatable), and we fire the base table's statement triggers, not the view's. I'm pretty sure this is intentional, though I couldn't find it mentioned in the manual either. Firing both sets of statement triggers would be confusing, and not firing the base table's triggers would perhaps miss processing that needs to happen. regards, tom lane
Commits
-
Doc: note that statement-level view triggers require an INSTEAD OF trigger.
- ff301166a9a6 10.4 landed
- b1e48cc9c79c 9.4.18 landed
- a46783204713 11.0 landed
- 9fcc0baa7973 9.5.13 landed
- 7b544c4e053b 9.6.9 landed
- 60c23ff76b1f 9.3.23 landed