]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Fix AFTER ROW trigger execution in MERGE cross-partition update.
authorDean Rasheed <dean.a.rasheed@gmail.com>
Thu, 9 Nov 2023 11:27:04 +0000 (11:27 +0000)
committerDean Rasheed <dean.a.rasheed@gmail.com>
Thu, 9 Nov 2023 11:27:04 +0000 (11:27 +0000)
commit06a546382aafe0cc9d895b2861c5b8a8e9f0b002
tree45b02d992a5f86da039808b3396ba4f39c6fa36b
parentef7c36555179e5b80054eb9e9e303c7ae53eb7a1
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
src/backend/executor/nodeModifyTable.c
src/test/regress/expected/triggers.out
src/test/regress/sql/triggers.sql