Re: BUG #15106: The AFTER trigger is created separately on view, and the DML operation can not trigger the trigger

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: 691525127(at)qq(dot)com
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #15106: The AFTER trigger is created separately on view, and the DML operation can not trigger the trigger
Date: 2018-03-12 20:27:33
Message-ID: 32633.1520886453@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

=?utf-8?q?PG_Bug_reporting_form?= <noreply(at)postgresql(dot)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

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message P O'Toole 2018-03-12 21:19:54 Weird return-value from pg_get_function_identity_arguments() on certain aggregate functions?
Previous Message Peter Eisentraut 2018-03-12 17:45:26 Re: BUG #15096: Unable to CREATE TABLE LIKE with bigint identity column