pgsql: Fix AFTER ROW trigger execution in MERGE cross-partition update. - Mailing list pgsql-committers

From Dean Rasheed
Subject pgsql: Fix AFTER ROW trigger execution in MERGE cross-partition update.
Date
Msg-id E1r13Eo-004eDZ-6Y@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Fix AFTER ROW trigger execution in MERGE cross-partition update.

When executing a MERGE UPDATE action, if the UPDATE is turned into a
cross-partition DELETE then INSERT, do not attempt to invoke AFTER
UPDATE ROW triggers, or any of the other post-update actions in
ExecUpdateEpilogue().

For consistency with a plain UPDATE command, such triggers should not
be fired (and typically fail anyway), and similarly, other post-update
actions, such as WCO/RLS checks should not be executed, and might also
lead to unexpected failures.

Therefore, as with ExecUpdate(), make ExecMergeMatched() return
immediately if ExecUpdateAct() reports that a cross-partition update
was done, to be sure that no further processing is done for that
tuple.

Back-patch to v15, where MERGE was introduced.

Discussion: https://postgr.es/m/CAEZATCWjBgagyNZs02vgDF0DvASYj-iHTFtXG2-nP3orZhmtcw%40mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/a4f7d33a904fcd4da7a12d249416dd2c5c5f2c1c

Modified Files
--------------
src/backend/executor/nodeModifyTable.c | 16 ++++++++++++
src/test/regress/expected/triggers.out | 45 ++++++++++++++++++++++++++++++++++
src/test/regress/sql/triggers.sql      | 36 +++++++++++++++++++++++++++
3 files changed, 97 insertions(+)


pgsql-committers by date:

Previous
From: David Rowley
Date:
Subject: pgsql: Ensure we use the correct spelling of "ensure"
Next
From: Dean Rasheed
Date:
Subject: pgsql: Avoid integer overflow hazard in interval_time().