From abe45a9b315d7b3739f442597f570f9454bd466d Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Tue, 17 Feb 2015 18:04:11 -0500 Subject: Fix EXPLAIN output for cases where parent table is excluded by constraints. The previous coding in EXPLAIN always labeled a ModifyTable node with the name of the target table affected by its first child plan. When originally written, this was necessarily the parent table of the inheritance tree, so everything was unconfusing. But when we added NO INHERIT constraints, it became possible for the parent table to be deleted from the plan by constraint exclusion while still leaving child tables present. This led to the ModifyTable plan node being labeled with the first surviving child, which was deemed confusing. Fix it by retaining the parent table's RT index in a new field in ModifyTable. Etsuro Fujita, reviewed by Ashutosh Bapat and myself --- src/backend/commands/explain.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) (limited to 'src/backend/commands/explain.c') diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c index 7cfc9bb612a..a951c55ed34 100644 --- a/src/backend/commands/explain.c +++ b/src/backend/commands/explain.c @@ -736,9 +736,8 @@ ExplainPreScanNode(PlanState *planstate, Bitmapset **rels_used) ((Scan *) plan)->scanrelid); break; case T_ModifyTable: - /* cf ExplainModifyTarget */ *rels_used = bms_add_member(*rels_used, - linitial_int(((ModifyTable *) plan)->resultRelations)); + ((ModifyTable *) plan)->nominalRelation); break; default: break; @@ -2192,16 +2191,7 @@ ExplainScanTarget(Scan *plan, ExplainState *es) static void ExplainModifyTarget(ModifyTable *plan, ExplainState *es) { - Index rti; - - /* - * We show the name of the first target relation. In multi-target-table - * cases this should always be the parent of the inheritance tree. - */ - Assert(plan->resultRelations != NIL); - rti = linitial_int(plan->resultRelations); - - ExplainTargetRel((Plan *) plan, rti, es); + ExplainTargetRel((Plan *) plan, plan->nominalRelation, es); } /* -- cgit v1.2.3