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

From: Etsuro Fujita <efujita(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix handling of multiple AFTER ROW triggers on a foreign table.
Date: 2019-12-10 09:30:35
Message-ID: E1iebql-0008PC-Lb@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/5a20b0219e7684788a1b63e812dd44b31361b259

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(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2019-12-10 18:17:21 pgsql: In pg_ctl, work around ERROR_SHARING_VIOLATION on the postmaster
Previous Message Tom Lane 2019-12-09 20:04:14 pgsql: Fix race condition in our Windows signal emulation.