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 1evU2n-0000Iw-N7 for pgsql-bugs@arkaria.postgresql.org; Mon, 12 Mar 2018 20:27:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1evU2l-0007mc-Pt for pgsql-bugs@arkaria.postgresql.org; Mon, 12 Mar 2018 20:27:39 +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 1evU2l-0007mT-Jp for pgsql-bugs@lists.postgresql.org; Mon, 12 Mar 2018 20:27:39 +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 1evU2i-0007oi-E5 for pgsql-bugs@lists.postgresql.org; Mon, 12 Mar 2018 20:27:38 +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 w2CKRXmg032634; Mon, 12 Mar 2018 16:27:33 -0400 From: Tom Lane 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 In-reply-to: <152083391168.1215.16892140713507052796@wrigleys.postgresql.org> References: <152083391168.1215.16892140713507052796@wrigleys.postgresql.org> Comments: In-reply-to =?utf-8?q?PG_Bug_reporting_form?= message dated "Mon, 12 Mar 2018 05:51:51 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <32632.1520886453.1@sss.pgh.pa.us> Date: Mon, 12 Mar 2018 16:27:33 -0400 Message-ID: <32633.1520886453@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk =?utf-8?q?PG_Bug_reporting_form?= 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