Re: BUG #14808: V10-beta4, backend abort
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Thomas Munro <thomas.munro@enterprisedb.com>
Cc: Michael Paquier <michael.paquier@gmail.com>,
Andrew Gierth <rhodiumtoad@postgresql.org>,
PostgreSQL mailing lists <pgsql-bugs@postgresql.org>,
Kevin Grittner <kgrittn@gmail.com>
Date: 2017-09-13T23:45:46Z
Lists: pgsql-bugs
Thomas Munro <thomas.munro@enterprisedb.com> writes: > On Thu, Sep 14, 2017 at 10:44 AM, Tom Lane <tgl@sss.pgh.pa.us> 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
Commits
-
Fix SQL-spec incompatibilities in new transition table feature.
- 54d4d0ff6cd4 10.0 landed
- 0f79440fb0b4 11.0 landed
-
Quick-hack fix for foreign key cascade vs triggers with transition tables.
- 5c11717185bc 10.0 landed
- 3c435952176a 11.0 landed
-
Fix transition tables for ON CONFLICT.
- 8c55244ae379 10.0 cited
-
Fix transition tables for wCTEs.
- c46c0e5202e8 10.0 cited
-
Repair problems occurring when multiple RI updates have to be done to the same
- 9cb84097623e 8.3.0 cited