diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2015-02-17 18:04:11 -0500 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2015-02-17 18:04:11 -0500 |
commit | abe45a9b315d7b3739f442597f570f9454bd466d (patch) | |
tree | 7d4005816c81f185cc14df78a110e9d81e7e072d /src/backend/commands/explain.c | |
parent | 931bf3eb9b203ca02d729f5122a44cc250c27695 (diff) | |
download | postgresql-abe45a9b315d7b3739f442597f570f9454bd466d.tar.gz postgresql-abe45a9b315d7b3739f442597f570f9454bd466d.zip |
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
Diffstat (limited to 'src/backend/commands/explain.c')
-rw-r--r-- | src/backend/commands/explain.c | 14 |
1 files changed, 2 insertions, 12 deletions
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); } /* |