Support for subselects.
authorVadim B. Mikheev
Fri, 13 Feb 1998 03:21:30 +0000 (03:21 +0000)
committerVadim B. Mikheev
Fri, 13 Feb 1998 03:21:30 +0000 (03:21 +0000)
src/backend/commands/explain.c

index 2d90ce4858dc176d7a8ef4027e1f637fc4433e30..879fdc82d05a370f37a25292c9902079a186ac41 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/commands/explain.c,v 1.16 1997/12/29 05:13:22 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/commands/explain.c,v 1.17 1998/02/13 03:21:30 vadim Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -176,8 +176,10 @@ explain_outNode(StringInfo str, Plan *plan, int indent, ExplainState *es)
            break;
    }
 
+#if 0
    for (i = 0; i < indent; i++)
        appendStringInfo(str, "  ");
+#endif
 
    appendStringInfo(str, pname);
    switch (nodeTag(plan))
@@ -202,14 +204,34 @@ explain_outNode(StringInfo str, Plan *plan, int indent, ExplainState *es)
        appendStringInfo(str, buf);
    }
    appendStringInfo(str, "\n");
+   
+   /* initPlan-s */
+   if (plan->initPlan)
+   {
+       List   *saved_rtable = es->rtable;
+       List   *lst;
+       
+       for (i = 0; i < indent; i++)
+           appendStringInfo(str, "  ");
+       appendStringInfo(str, "  InitPlan\n");
+       foreach (lst, plan->initPlan)
+       {
+           es->rtable = ((SubPlan*) lfirst(lst))->rtable;
+           for (i = 0; i < indent; i++)
+               appendStringInfo(str, "  ");
+           appendStringInfo(str, "    ->  ");
+           explain_outNode(str, ((SubPlan*) lfirst(lst))->plan, indent + 4, es);
+       }
+       es->rtable = saved_rtable;
+   }
 
    /* lefttree */
    if (outerPlan(plan))
    {
        for (i = 0; i < indent; i++)
            appendStringInfo(str, "  ");
-       appendStringInfo(str, "  -> ");
-       explain_outNode(str, outerPlan(plan), indent + 1, es);
+       appendStringInfo(str, "  ->  ");
+       explain_outNode(str, outerPlan(plan), indent + 3, es);
    }
 
    /* righttree */
@@ -217,8 +239,28 @@ explain_outNode(StringInfo str, Plan *plan, int indent, ExplainState *es)
    {
        for (i = 0; i < indent; i++)
            appendStringInfo(str, "  ");
-       appendStringInfo(str, "  -> ");
-       explain_outNode(str, innerPlan(plan), indent + 1, es);
+       appendStringInfo(str, "  ->  ");
+       explain_outNode(str, innerPlan(plan), indent + 3, es);
+   }
+   
+   /* subPlan-s */
+   if (plan->subPlan)
+   {
+       List   *saved_rtable = es->rtable;
+       List   *lst;
+       
+       for (i = 0; i < indent; i++)
+           appendStringInfo(str, "  ");
+       appendStringInfo(str, "  SubPlan\n");
+       foreach (lst, plan->subPlan)
+       {
+           es->rtable = ((SubPlan*) lfirst(lst))->rtable;
+           for (i = 0; i < indent; i++)
+               appendStringInfo(str, "  ");
+           appendStringInfo(str, "    ->  ");
+           explain_outNode(str, ((SubPlan*) lfirst(lst))->plan, indent + 4, es);
+       }
+       es->rtable = saved_rtable;
    }
    return;
 }