Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1exdlQ-00009i-Gh for pgsql-bugs@arkaria.postgresql.org; Sun, 18 Mar 2018 19:14:40 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1exdlO-0007rU-Kp for pgsql-bugs@arkaria.postgresql.org; Sun, 18 Mar 2018 19:14:38 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1exdlO-0007rL-Ep for pgsql-bugs@lists.postgresql.org; Sun, 18 Mar 2018 19:14:38 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1exdlK-0006cC-TD for pgsql-bugs@lists.postgresql.org; Sun, 18 Mar 2018 19:14:37 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id w2IJEULO031021; Sun, 18 Mar 2018 15:14:30 -0400 From: Tom Lane To: Thomas Munro cc: 691525127@qq.com, 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 In-reply-to: References: <152083391168.1215.16892140713507052796@wrigleys.postgresql.org> <32633.1520886453@sss.pgh.pa.us> Comments: In-reply-to Thomas Munro message dated "Tue, 13 Mar 2018 11:33:32 +1300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <31019.1521400470.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Sun, 18 Mar 2018 15:14:30 -0400 Message-ID: <31020.1521400470@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Thomas Munro writes: > On Tue, Mar 13, 2018 at 9:27 AM, Tom Lane wrote: >> When there's no INSTEAD OF trigger, the query is rewritten into an inse= rt >> 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 t= he >> 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%2B3FgaLzskuLB3hASW= 6iTUd6f40gq_q80a9NHXk92A%40mail.gmail.com > 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=3Dpostgresql.git;a=3Dcommitdiff;h=3Da= 4678320471380e5159a8d6e89466d74d6ee1739 regards, tom lane