Re: Unexpected behavior with transition tables in update statement trigger
Thomas Munro <thomas.munro@enterprisedb.com>
From: Thomas Munro <thomas.munro@enterprisedb.com>
To: Tom Kazimiers <tom@voodoo-arts.net>
Cc: PG-General Mailing List <pgsql-general@postgresql.org>
Date: 2018-02-26T10:15:44Z
Lists: pgsql-hackers, pgsql-general
Attachments
- named-tuplestore-scan-select.patch (application/octet-stream) patch
On Sat, Feb 24, 2018 at 4:47 PM, Tom Kazimiers <tom@voodoo-arts.net> wrote: > I am on Postgres 10.2 and try to get a statement level trigger to work that > is executed after UPDATE statements on a particular table. This trigger > references both the old and new transition table and for some reason I am > unable to reference each transition table multiple times in a CTE or > subquery. E.g. forming a UNION ALL with all rows of the new transition table > with itself, does only use the new table row once. I don't understand why > and would appreciate some insight. Thanks for the reproducer. Yeah, that seems to be a bug. nodeNamedTuplestorescan.c allocates a new read pointer for each separate scan of the named tuplestore, but it doesn't call tuplestore_select_read_pointer() so that the two scans that appear in your UNION ALL plan are sharing the same read pointer. At first glance the attached seems to fix the problem, but I'll need to look more carefully tomorrow. -- Thomas Munro http://www.enterprisedb.com
Commits
-
Use the correct tuplestore read pointer in a NamedTuplestoreScan.
- e98a4de7d23a 11.0 landed
- b9dac4a6eb41 10.4 landed