Re: Unexpected behavior with transition tables in update statement trigger - Mailing list pgsql-general

From Thomas Munro
Subject Re: Unexpected behavior with transition tables in update statement trigger
Date
Msg-id CAEepm=3di-ptmkz5UmF=-VW65k3SPGMB8FaaDNkKokc0XQDtAw@mail.gmail.com
Whole thread Raw
In response to Unexpected behavior with transition tables in update statementtrigger  (Tom Kazimiers <tom@voodoo-arts.net>)
Responses Re: Unexpected behavior with transition tables in update statementtrigger  (Tom Kazimiers <tom@voodoo-arts.net>)
List pgsql-general
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

Attachment

pgsql-general by date:

Previous
From: Michael Paquier
Date:
Subject: Re: is libpq and openssl 1.1.* compatible?
Next
From: Łukasz Jarych
Date:
Subject: Creating complex track changes database - challenge!