Fix transition tables for MERGE with cross-partition UPDATEs. When a MERGE UPDATE action moved a row between partitions, the old and new rows were not included in the transition tables of AFTER UPDATE statement triggers, and could instead be incorrectly included in the transition tables of AFTER INSERT and AFTER DELETE statement triggers.
Fix by capturing both halves of a cross-partition MERGE UPDATE action in the UPDATE transition tables and exclude them from the DELETE and INSERT transition tables, as we do for a plain UPDATE. Backpatch to v15, where MERGE was introduced. Reported-by: Michael Ries <[email protected]> Reported-by: Tender Wang <[email protected]> Author: Tender Wang <[email protected]> Reviewed-by: shihao zhong <[email protected]> Discussion: https://postgr.es/m/CAKWDHLgETF86qEW40HcEzMgn5DdmS6yR-nSYwemXF7zFGrU%2BsQ%40mail.gmail.com Discussion: https://postgr.es/m/CAHewXNk8MgaFMD87s%3DxHeguzmErEjsqeroxrMyQbKyXwG5eocw%40mail.gmail.com Backpatch-through: 15 Branch ------ REL_15_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/ea5eb6d62eaa76f5dc90ee2ca8fd0d75b042f809 Modified Files -------------- src/backend/executor/nodeModifyTable.c | 69 +++++++++++++++++----------------- src/test/regress/expected/triggers.out | 31 +++++++++++++++ src/test/regress/sql/triggers.sql | 30 +++++++++++++++ 3 files changed, 95 insertions(+), 35 deletions(-)
