From: | Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> |
---|---|
To: | Luca Ferrari <fluca1978(at)gmail(dot)com> |
Cc: | pgsql-general <pgsql-general(at)lists(dot)postgresql(dot)org> |
Subject: | Re: MERGE output doubt |
Date: | 2022-11-17 11:36:51 |
Message-ID: | 20221117113651.wlgmdrx653tqihzt@alvherre.pgsql |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 2022-Oct-20, Luca Ferrari wrote:
> Now, if I use a do nothing merge:
>
> estdb=> MERGE INTO average_scores a
> USING ( SELECT name, avg( score ) AS avg_score
> FROM scores GROUP BY name ) s
> ON s.name = a.name
> WHEN MATCHED THEN
> do nothing
> WHEN NOT MATCHED THEN
> do nothing;
> MERGE 2
>
> I was expecting an output tag like "MERGE 0" since both branches have
> "do nothing", so no tuples should be updated at all on the target
> table.
Hmm, yeah, it should report 0 tuples, according to the documentation.
AFAICS this patch fixes it, will push shortly.
> Moreover, if I truncate the target table and execute again the merge
> query, I got the result of 0:
>
> testdb=> truncate average_scores ;
> TRUNCATE TABLE
> testdb=> MERGE INTO average_scores a
> USING ( SELECT name, avg( score ) AS avg_score
> FROM scores GROUP BY name ) s
> ON s.name = a.name
> WHEN MATCHED THEN -- caso di match
> do nothing
> WHEN NOT MATCHED THEN
> do nothing;
> MERGE 0
>
> What am I missing here?
Hmm, is this not what you were expecting? Or are you saying that it
should have been affected by the same bug?
--
Álvaro Herrera Breisgau, Deutschland — https://www.EnterpriseDB.com/
Attachment | Content-Type | Size |
---|---|---|
0001-fix-MERGE-tuple-count-with-DO-NOTHING.patch | text/x-diff | 760 bytes |
From | Date | Subject | |
---|---|---|---|
Next Message | Giovanni Biscontini | 2022-11-17 12:20:55 | replication phisical + logical |
Previous Message | shashidhar Reddy | 2022-11-17 06:22:12 | Re: unrecognized node type: 350 |