From fbcce08046bc553901ccbcf1ea6cf82f61968970 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sun, 5 Apr 2009 19:59:40 +0000 Subject: Change EXPLAIN output so that subplans and initplans (particularly CTEs) are individually labeled, rather than just grouped under an "InitPlan" or "SubPlan" heading. This in turn makes it possible for decompilation of a subplan reference to usefully identify which subplan it's referencing. I also made InitPlans identify which parameter symbol(s) they compute, so that references to those parameters elsewhere in the plan tree can be connected to the initplan that will be executed. Per a gripe from Robert Haas about EXPLAIN output of a WITH query being inadequate, plus some longstanding pet peeves of my own. --- src/backend/commands/explain.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/backend/commands/explain.c') diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c index 8ad877e1652..d8f27a1175b 100644 --- a/src/backend/commands/explain.c +++ b/src/backend/commands/explain.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1994-5, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/explain.c,v 1.184 2009/01/02 20:42:00 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/commands/explain.c,v 1.185 2009/04/05 19:59:39 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -951,14 +951,14 @@ explain_outNode(StringInfo str, { ListCell *lst; - for (i = 0; i < indent; i++) - appendStringInfo(str, " "); - appendStringInfo(str, " InitPlan\n"); foreach(lst, planstate->initPlan) { SubPlanState *sps = (SubPlanState *) lfirst(lst); SubPlan *sp = (SubPlan *) sps->xprstate.expr; + for (i = 0; i < indent; i++) + appendStringInfo(str, " "); + appendStringInfo(str, " %s\n", sp->plan_name); for (i = 0; i < indent; i++) appendStringInfo(str, " "); appendStringInfo(str, " -> "); @@ -1099,14 +1099,14 @@ explain_outNode(StringInfo str, { ListCell *lst; - for (i = 0; i < indent; i++) - appendStringInfo(str, " "); - appendStringInfo(str, " SubPlan\n"); foreach(lst, planstate->subPlan) { SubPlanState *sps = (SubPlanState *) lfirst(lst); SubPlan *sp = (SubPlan *) sps->xprstate.expr; + for (i = 0; i < indent; i++) + appendStringInfo(str, " "); + appendStringInfo(str, " %s\n", sp->plan_name); for (i = 0; i < indent; i++) appendStringInfo(str, " "); appendStringInfo(str, " -> "); -- cgit v1.2.3