Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dsHLr-0006kA-La for pgsql-bugs@arkaria.postgresql.org; Wed, 13 Sep 2017 23:45:51 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1dsHLr-0005um-9S for pgsql-bugs@arkaria.postgresql.org; Wed, 13 Sep 2017 23:45:51 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dsHLq-0005ub-O4 for pgsql-bugs@postgresql.org; Wed, 13 Sep 2017 23:45:50 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dsHLo-0007Yy-CR; Wed, 13 Sep 2017 23:45:49 +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 v8DNjkn8001343; Wed, 13 Sep 2017 19:45:46 -0400 From: Tom Lane To: Thomas Munro cc: Michael Paquier , Andrew Gierth , PostgreSQL mailing lists , Kevin Grittner Subject: Re: BUG #14808: V10-beta4, backend abort In-reply-to: References: <20170909064853.25630.12825@wrigleys.postgresql.org> <3702.1504976930@sss.pgh.pa.us> <9324.1504983594@sss.pgh.pa.us> <25326.1505070173@sss.pgh.pa.us> <14016.1505135324@sss.pgh.pa.us> <8201.1505149431@sss.pgh.pa.us> <31365.1505342642@sss.pgh.pa.us> Comments: In-reply-to Thomas Munro message dated "Thu, 14 Sep 2017 11:00:40 +1200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1341.1505346346.1@sss.pgh.pa.us> Date: Wed, 13 Sep 2017 19:45:46 -0400 Message-ID: <1342.1505346346@sss.pgh.pa.us> List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org Thomas Munro writes: > On Thu, Sep 14, 2017 at 10:44 AM, Tom Lane wrote: >> BTW, as I'm digging around in trigger.c, I can't help noticing that >> it provides a single "fdw_tuplestore" per trigger query level (a/k/a >> trigger execution context). I've not tried to test this, but it >> sure looks like a wCTE like your example above, directed at two >> separate foreign tables with triggers, would fail for exactly the >> same reason. That'd be a bug of pretty long standing. > I had the impression that that fdw_tuplestore was doing something a > bit sneaky that actually works out OK: tuples get enqueued and later > dequeued in exactly the same sequence as the after row trigger events > that need them, so even though it seems to violate at least the POLA > if not the spirit of tuplestores by storing tuples of potentially > different types in one tuplestore, nothing bad should happen. Oh? Now my fear level is up to 11, because it is completely trivial to cause triggers to fire in a different order than they were enqueued. All you need is a mix of deferrable and nondeferrable triggers. In fact, it also seems entirely broken that a per-query-level tuplestore is being used at all, because deferrable triggers might not get fired until some outer query level. [ Pokes around... ] Hm, looks like we get around that by forbidding constraint triggers on foreign tables, but I don't see anything in the CREATE TRIGGER man page saying that there's such a prohibition. And there's certainly no comments in the source code explaining this rickety set of requirements :-( regards, tom lane -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs