Re: Broken EXPLAIN output for SubPlan in MERGE
Alvaro Herrera <alvherre@alvh.no-ip.org>
From: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: Dean Rasheed <dean.a.rasheed@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2024-03-21T09:23:13Z
Lists: pgsql-hackers
On 2024-Mar-12, Dean Rasheed wrote:
> While playing around with EXPLAIN and SubPlans, I noticed that there's
> a bug in how this is handled for MERGE. [...]
> However, that isn't working properly for MERGE because the inner_plan
> and inner_tlist of the corresponding deparse_namespace aren't set
> correctly. Actually the inner_tlist is correct, but the inner_plan is
> set to the ModifyTable node, whereas it needs to be the outer child
> node -- in a MERGE, any references to the source relation will be
> INNER_VAR references to the targetlist of the join node immediately
> under the ModifyTable node.
Hmm, interesting, thanks for fixing it (commit 33e729c5148c). I remember
wondering whether the nodes ought to be set differently, and now I have to
admit that this
if (((ModifyTable *) plan)->operation == CMD_MERGE)
dpns->inner_plan = outerPlan(plan);
is very funny-looking. But I didn't come up with any examples where it
mattered.
--
Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/
"Thou shalt not follow the NULL pointer, for chaos and madness await
thee at its end." (2nd Commandment for C programmers)
Commits
-
Fix EXPLAIN output for subplans in MERGE.
- 89ee14a2f22b 15.7 landed
- 34c854b93fbe 16.3 landed
- 33e729c5148c 17.0 landed