pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Thomas Munro <thomas.munro@enterprisedb.com>
Cc: 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: Sun, 18 Mar 2018 15:14:30 -0400
Message-ID: <31020.1521400470@sss.pgh.pa.us> (raw)
In-Reply-To: <CAEepm=0UZpJMR26VBXM6a_1N-Q75m4=6L5+uEk=ky+7AnNknow@mail.gmail.com>
References: <152083391168.1215.16892140713507052796@wrigleys.postgresql.org>
	<32633.1520886453@sss.pgh.pa.us>
	<CAEepm=0UZpJMR26VBXM6a_1N-Q75m4=6L5+uEk=ky+7AnNknow@mail.gmail.com>

Thomas Munro <thomas.munro@enterprisedb.com> writes:
> On Tue, Mar 13, 2018 at 9:27 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> 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.

> We also discussed this here:

> https://www.postgresql.org/message-id/flat/CACjxUsOrn%2B3FgaLzskuLB3hASW6iTUd6f40gq_q80a9NHXk92A%40m...

> We resolved the main issue in that thread but we didn't do anything
> about this side issue.  You and Kevin both suggested that perhaps we
> shouldn't allow you to create such unfireable triggers, or perhaps we
> should raise a warning, or at least document the (IMHO) confusing
> behaviour.

A simple approach to raising an error or warning would create hazards
for pg_dump, ie it'd need to make sure the INSTEAD OF trigger was restored
first.  We could get around that no doubt, but I don't think it's worth
the work, at least not unless we get a lot more complaints.  For the
moment a documentation improvement seems sufficient, so I've pushed one.

https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=a4678320471380e5159a8d6e89466d74d...

			regards, tom lane




view thread (4+ messages)

Message-ID: <31020.1521400470@sss.pgh.pa.us>
Permalink:  ../31020.1521400470@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/31020.1521400470@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, thomas.munro@enterprisedb.com, 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: <31020.1521400470@sss.pgh.pa.us>
  References: <152083391168.1215.16892140713507052796@wrigleys.postgresql.org> <32633.1520886453@sss.pgh.pa.us> <CAEepm=0UZpJMR26VBXM6a_1N-Q75m4=6L5+uEk=ky+7AnNknow@mail.gmail.com> <31020.1521400470@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