pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: 691525127@qq.com
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #15106: The AFTER trigger is created separately on view, and the DML operation can not trigger the trigger
Date: Mon, 12 Mar 2018 16:27:33 -0400
Message-ID: <32633.1520886453@sss.pgh.pa.us> (raw)
In-Reply-To: <152083391168.1215.16892140713507052796@wrigleys.postgresql.org>
References: <152083391168.1215.16892140713507052796@wrigleys.postgresql.org>

=?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




view thread (4+ messages)  latest in thread

Message-ID: <32633.1520886453@sss.pgh.pa.us>
Permalink:  ../32633.1520886453@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/32633.1520886453@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, 691525127@qq.com
  Subject: Re: BUG #15106: The AFTER trigger is created separately on view, and the DML operation can not trigger the trigger
  In-Reply-To: <32633.1520886453@sss.pgh.pa.us>
  References: <152083391168.1215.16892140713507052796@wrigleys.postgresql.org> <32633.1520886453@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox