When executing a WHEN NOT MATCHED BY SOURCE action in MERGE, if the tuple from the target table was concurrently deleted, the retry code would incorrectly execute a WHEN NOT MATCHED BY TARGET action for the row instead, giving incorrect results. Fix in ExecMergeMatched() -- when handling a TM_Deleted failure status, it should only set *matched to false (telling the caller to execute any WHEN NOT MATCHED BY TARGET actions) if the failed action was a WHEN MATCHED action. For a failed WHEN NOT MATCHED BY SOURCE action, the source tuple did not exist, and the target tuple has just been deleted, so it should do nothing. Back-patch to v17, where support for WHEN NOT MATCHED BY SOURCE actions was introduced. Reported-by: Jeff Davis <pgsql@j-davis.com> Author: Tender Wang <tndrwang@gmail.com> Reviewed-by: Dean Rasheed <dean.a.rasheed@gmail.com> Discussion: https://postgr.es/m/ccdab5ba02c65af195b5a6d2d744a01d9de47cd3.camel@j-davis.com Backpatch-through: 17
PostgreSQL Database Management System
This directory contains the source code distribution of the PostgreSQL database management system.
PostgreSQL is an advanced object-relational database management system that supports an extended subset of the SQL standard, including transactions, foreign keys, subqueries, triggers, user-defined types and functions. This distribution also contains C language bindings.
Copyright and license information can be found in the file COPYRIGHT.
General documentation about this version of PostgreSQL can be found at https://www.postgresql.org/docs/19/. In particular, information about building PostgreSQL from the source code can be found at https://www.postgresql.org/docs/19/installation.html.
The latest version of this software, and related software, may be obtained at https://www.postgresql.org/download/. For more information look at our web site located at https://www.postgresql.org/.