Fix MERGE tuple count with DO NOTHING
authorAlvaro Herrera <alvherre@alvh.no-ip.org>
Thu, 17 Nov 2022 17:56:11 +0000 (18:56 +0100)
committerAlvaro Herrera <alvherre@alvh.no-ip.org>
Thu, 17 Nov 2022 17:56:11 +0000 (18:56 +0100)
Reporting tuples for which nothing is done is useless and goes against
the documented behavior, so don't do it.

Backpatch to 15.

Reported by: Luca Ferrari
Discussion: https://postgr.es/m/CAKoxK+42MmACUh6s8XzASQKizbzrtOGA6G1UjzCP75NcXHsiNw@mail.gmail.com

src/backend/executor/nodeModifyTable.c

index 0f357f822178cb0e965bfc2a338d60e9ca914590..b7ea953b55f09baf878f94570933d23710858b00 100644 (file)
@@ -2799,7 +2799,7 @@ lmerge_matched:
        {
            case TM_Ok:
                /* all good; perform final actions */
-               if (canSetTag)
+               if (canSetTag && commandType != CMD_NOTHING)
                    (estate->es_processed)++;
 
                break;