Re: Fix RETURNING side effects for FOR PORTION OF leftover rows - Mailing list pgsql-hackers

From Paul A Jungwirth
Subject Re: Fix RETURNING side effects for FOR PORTION OF leftover rows
Date
Msg-id CA+renyXrMqiiNRWAA-pXj8peHRSP7RnT6PyiQ0gmuHK6i5gdkg@mail.gmail.com
Whole thread
In response to Re: Fix RETURNING side effects for FOR PORTION OF leftover rows  (Chao Li <li.evan.chao@gmail.com>)
List pgsql-hackers
On Mon, Jul 20, 2026 at 6:17 AM Chao Li <li.evan.chao@gmail.com> wrote:
>
> Okay. We cannot simply check node->forPortionOf to bypass RETURNING processing, because an FPO update on a
partitionedtable may move a row to a different partition. In that case, ExecInsert() is also called to insert the row
intothe new partition. 
>
> However, in that case, mtstate->operation is still CMD_UPDATE, while for leftover rows, mtstate->operation is
temporarilychanged to CMD_INSERT. So we can check both node->forPortionOf and mtstate->operation. 
>
> PFA v2 with the new implementation. I tried to run check-world and it passed.

Nice catch. I took a look at the v2 patch. It looks like a good fix to
me. I'm happy that we're testing cross-partition updates as well.
Thanks for the quick fix!

Yours,

--
Paul              ~{:-)
pj@illuminatedcomputing.com



pgsql-hackers by date:

Previous
From: Philip Alger
Date:
Subject: Re: [PATCH] Add pg_get_trigger_ddl() to retrieve the CREATE TRIGGER statement
Next
From: Marcos Pegoraro
Date:
Subject: Re: [PATCH] Add pg_get_trigger_ddl() to retrieve the CREATE TRIGGER statement