pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Etsuro Fujita <efujita@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix handling of multiple AFTER ROW triggers on a foreign table.
Date: Tue, 10 Dec 2019 09:30:35 +0000
Message-ID: <E1iebql-0008PE-MJ@gemulon.postgresql.org> (raw)

Fix handling of multiple AFTER ROW triggers on a foreign table.

AfterTriggerExecute() retrieves a fresh tuple or pair of tuples from a
tuplestore and then stores the tuple(s) in the passed-in slot(s) if
AFTER_TRIGGER_FDW_FETCH, while it uses the most-recently-retrieved
tuple(s) stored in the slot(s) if AFTER_TRIGGER_FDW_REUSE.  This was
done correctly before 12, but commit ff11e7f4b broke it by mistakenly
clearing the tuple(s) stored in the slot(s) in that function, leading to
an assertion failure as reported in bug #16139 from Alexander Lakhin.

Also, fix some other issues with the aforementioned commit in passing:

* For tg_newslot, which is a slot added to the TriggerData struct by the
  commit to store new updated tuples, it didn't ensure the slot was NULL
  if there was no such tuple.
* The commit failed to update the documentation about the trigger
  interface.

Author: Etsuro Fujita
Backpatch-through: 12
Discussion: https://postgr.es/m/16139-94f9ccf0db6119ec%40postgresql.org

Branch
------
REL_12_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/547e454cbc8f8896b535cf2debd61b2c5701d8c0

Modified Files
--------------
contrib/postgres_fdw/expected/postgres_fdw.out | 32 ++++++++++++++++++++-
contrib/postgres_fdw/sql/postgres_fdw.sql      | 17 +++++++++++
doc/src/sgml/trigger.sgml                      | 16 +++++------
src/backend/commands/trigger.c                 | 40 ++++++++++++++++----------
4 files changed, 81 insertions(+), 24 deletions(-)



view thread (2+ messages)  latest in thread

Message-ID: <E1iebql-0008PE-MJ@gemulon.postgresql.org>
Permalink:  ../E1iebql-0008PE-MJ@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1iebql-0008PE-MJ@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: efujita@postgresql.org
  Subject: Re: pgsql: Fix handling of multiple AFTER ROW triggers on a foreign table.
  In-Reply-To: <E1iebql-0008PE-MJ@gemulon.postgresql.org>
  References: <E1iebql-0008PE-MJ@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox