public inbox for [email protected]
help / color / mirror / Atom feedFrom: Alvaro Herrera <[email protected]>
To: Dean Rasheed <[email protected]>
Cc: PostgreSQL Hackers <[email protected]>
Subject: Re: Incorrect command tag row count for MERGE with a cross-partition update
Date: Tue, 21 Feb 2023 10:34:11 +0100
Message-ID: <[email protected]> (raw)
In-Reply-To: <CAEZATCWRMG7XX2QEsVL1LswmNo2d_YG8tKTLkpD3=Lp644S7rg@mail.gmail.com>
On 2023-Feb-20, Dean Rasheed wrote:
> Playing around with MERGE some more, I noticed that the command tag
> row count is wrong if it does a cross-partition update:
>
> CREATE TABLE target (a int, b int) PARTITION BY LIST (b);
> CREATE TABLE target_p1 PARTITION OF target FOR VALUES IN (1);
> CREATE TABLE target_p2 PARTITION OF target FOR VALUES IN (2);
> INSERT INTO target VALUES (1,1);
>
> MERGE INTO target t USING (VALUES (1)) v(a) ON t.a = v.a
> WHEN MATCHED THEN UPDATE SET b = 2;
>
> which returns "MERGE 2" when only 1 row was updated, because
> ExecUpdateAct() will update estate->es_processed for a cross-partition
> update (but not for a normal update), and then ExecMergeMatched() will
> update it again.
Hah.
> I think the best fix is to have ExecMergeMatched() pass canSetTag =
> false to ExecUpdateAct(), so that ExecMergeMatched() takes
> responsibility for updating estate->es_processed in all cases.
Sounds sensible.
--
Álvaro Herrera Breisgau, Deutschland — https://www.EnterpriseDB.com/
"Las mujeres son como hondas: mientras más resistencia tienen,
más lejos puedes llegar con ellas" (Jonas Nightingale, Leap of Faith)
view thread (3+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected]
Subject: Re: Incorrect command tag row count for MERGE with a cross-partition update
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox