Re: Incorrect explain output for updates/delete operations with returning-list on partitioned tables - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Incorrect explain output for updates/delete operations with returning-list on partitioned tables
Date
Msg-id 3797212.1715030311@sss.pgh.pa.us
Whole thread Raw
In response to Incorrect explain output for updates/delete operations with returning-list on partitioned tables  (SAIKIRAN AVULA <avulasaikiranreddy@gmail.com>)
Responses Re: Incorrect explain output for updates/delete operations with returning-list on partitioned tables
List pgsql-hackers
SAIKIRAN AVULA <avulasaikiranreddy@gmail.com> writes:
> I have been working on partitioned tables recently, and I have noticed
> something that doesn't seem correct with the EXPLAIN output of an
> update/delete query with a returning list.

What do you think is not right exactly?  The output has to use some
one of the correlation names for the partitioned table.  I think
it generally chooses the one corresponding to the first Append arm,
but really any would be good enough for EXPLAIN's purposes.

> 1. In the 'grouping_planner()' function, while generating paths for the
> final relation (
> https://github.com/postgres/postgres/blob/master/src/backend/optimizer/plan/planner.c#L1857),
> we only take care of adjusting the append_rel_attributes in returningList
> for resultRelation. Shouldn't we do that for other relations as well in
> query?

If the only difference is which way variables get labeled in EXPLAIN,
I'd be kind of disinclined to spend extra cycles.  But in any case,
I rather suspect you'll find that this actively breaks things.
Whether we change the varno on a Var isn't really optional, and there
are cross-checks in setrefs.c to make sure things match up.

            regards, tom lane



pgsql-hackers by date:

Previous
From: David Rowley
Date:
Subject: Re: 2024-05-09 release announcement draft
Next
From: Noah Misch
Date:
Subject: Re: Weird test mixup