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)