Ruleutils_17 Fix EXPLAIN output for subplans in MERGE.

Relevant PG commit:
33e729c5148c3a697abc552621b34bdc5fd497ed
33e729c514
m3hm3t/pg17_isolation_test_cmd_from
naisila 2024-07-25 15:22:04 +02:00
parent 2e4bc1f816
commit 61b92ee697
No known key found for this signature in database
GPG Key ID: A824BA9862D73E6D
1 changed files with 13 additions and 10 deletions

View File

@ -1838,8 +1838,11 @@ set_deparse_plan(deparse_namespace *dpns, Plan *plan)
* For a WorkTableScan, locate the parent RecursiveUnion plan node and use * For a WorkTableScan, locate the parent RecursiveUnion plan node and use
* that as INNER referent. * that as INNER referent.
* *
* For MERGE, make the inner tlist point to the merge source tlist, which * For MERGE, pretend the ModifyTable's source plan (its outer plan) is
* is same as the targetlist that the ModifyTable's source plan provides. * INNER referent. This is the join from the target relation to the data
* source, and all INNER_VAR Vars in other parts of the query refer to its
* targetlist.
*
* For ON CONFLICT .. UPDATE we just need the inner tlist to point to the * For ON CONFLICT .. UPDATE we just need the inner tlist to point to the
* excluded expression's tlist. (Similar to the SubqueryScan we don't want * excluded expression's tlist. (Similar to the SubqueryScan we don't want
* to reuse OUTER, it's used for RETURNING in some modify table cases, * to reuse OUTER, it's used for RETURNING in some modify table cases,
@ -1854,17 +1857,17 @@ set_deparse_plan(deparse_namespace *dpns, Plan *plan)
dpns->inner_plan = find_recursive_union(dpns, dpns->inner_plan = find_recursive_union(dpns,
(WorkTableScan *) plan); (WorkTableScan *) plan);
else if (IsA(plan, ModifyTable)) else if (IsA(plan, ModifyTable))
{
if (((ModifyTable *) plan)->operation == CMD_MERGE)
dpns->inner_plan = outerPlan(plan);
else
dpns->inner_plan = plan; dpns->inner_plan = plan;
}
else else
dpns->inner_plan = innerPlan(plan); dpns->inner_plan = innerPlan(plan);
if (IsA(plan, ModifyTable)) if (IsA(plan, ModifyTable) && ((ModifyTable *) plan)->operation == CMD_INSERT)
{
if (((ModifyTable *) plan)->operation == CMD_MERGE)
dpns->inner_tlist = dpns->outer_tlist;
else
dpns->inner_tlist = ((ModifyTable *) plan)->exclRelTlist; dpns->inner_tlist = ((ModifyTable *) plan)->exclRelTlist;
}
else if (dpns->inner_plan) else if (dpns->inner_plan)
dpns->inner_tlist = dpns->inner_plan->targetlist; dpns->inner_tlist = dpns->inner_plan->targetlist;
else else