Re: Unexpected behavior with transition tables in update statement trigger

From: Thomas Munro <thomas(dot)munro(at)enterprisedb(dot)com>
To: Tom Kazimiers <tom(at)voodoo-arts(dot)net>
Cc: PG-General Mailing List <pgsql-general(at)postgresql(dot)org>
Subject: Re: Unexpected behavior with transition tables in update statement trigger
Date: 2018-02-26 10:15:44
Message-ID: CAEepm=3di-ptmkz5UmF=-VW65k3SPGMB8FaaDNkKokc0XQDtAw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

On Sat, Feb 24, 2018 at 4:47 PM, Tom Kazimiers <tom(at)voodoo-arts(dot)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 Content-Type Size
named-tuplestore-scan-select.patch application/octet-stream 593 bytes

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Łukasz Jarych 2018-02-26 10:44:13 Creating complex track changes database - challenge!
Previous Message Michael Paquier 2018-02-26 08:15:59 Re: is libpq and openssl 1.1.* compatible?

Browse pgsql-hackers by date

  From Date Subject
Next Message Jeevan Chalke 2018-02-26 11:38:30 Re: [HACKERS] Partition-wise aggregation/grouping
Previous Message Fabien COELHO 2018-02-26 10:14:48 Re: csv format for psql