|
7 | 7 | * Portions Copyright (c) 1994-5, Regents of the University of California
|
8 | 8 | *
|
9 | 9 | * IDENTIFICATION
|
10 |
| - * $PostgreSQL: pgsql/src/backend/commands/explain.c,v 1.171 2008/03/26 18:48:59 alvherre Exp $ |
| 10 | + * $PostgreSQL: pgsql/src/backend/commands/explain.c,v 1.172 2008/04/17 18:30:18 tgl Exp $ |
11 | 11 | *
|
12 | 12 | *-------------------------------------------------------------------------
|
13 | 13 | */
|
@@ -61,6 +61,8 @@ static void explain_outNode(StringInfo str,
|
61 | 61 | Plan*plan,PlanState*planstate,
|
62 | 62 | Plan*outer_plan,
|
63 | 63 | intindent,ExplainState*es);
|
| 64 | +staticvoidshow_plan_tlist(Plan*plan, |
| 65 | +StringInfostr,intindent,ExplainState*es); |
64 | 66 | staticvoidshow_scan_qual(List*qual,constchar*qlabel,
|
65 | 67 | intscanrelid,Plan*outer_plan,Plan*inner_plan,
|
66 | 68 | StringInfostr,intindent,ExplainState*es);
|
@@ -443,7 +445,7 @@ explain_outNode(StringInfo str,
|
443 | 445 | Plan*outer_plan,
|
444 | 446 | intindent,ExplainState*es)
|
445 | 447 | {
|
446 |
| -char*pname; |
| 448 | +constchar*pname; |
447 | 449 | inti;
|
448 | 450 |
|
449 | 451 | if (plan==NULL)
|
@@ -744,6 +746,9 @@ explain_outNode(StringInfo str,
|
744 | 746 | appendStringInfo(str," (never executed)");
|
745 | 747 | appendStringInfoChar(str,'\n');
|
746 | 748 |
|
| 749 | +/* target list */ |
| 750 | +show_plan_tlist(plan,str,indent,es); |
| 751 | + |
747 | 752 | /* quals, sort keys, etc */
|
748 | 753 | switch (nodeTag(plan))
|
749 | 754 | {
|
@@ -1043,6 +1048,56 @@ explain_outNode(StringInfo str,
|
1043 | 1048 | }
|
1044 | 1049 | }
|
1045 | 1050 |
|
| 1051 | +/* |
| 1052 | + * Show the targetlist of a plan node |
| 1053 | + */ |
| 1054 | +staticvoid |
| 1055 | +show_plan_tlist(Plan*plan, |
| 1056 | +StringInfostr,intindent,ExplainState*es) |
| 1057 | +{ |
| 1058 | +#ifdefEXPLAIN_PRINT_TLISTS |
| 1059 | +List*context; |
| 1060 | +booluseprefix; |
| 1061 | +ListCell*lc; |
| 1062 | +inti; |
| 1063 | + |
| 1064 | +/* No work if empty tlist (this occurs eg in bitmap indexscans) */ |
| 1065 | +if (plan->targetlist==NIL) |
| 1066 | +return; |
| 1067 | +/* The tlist of an Append isn't real helpful, so suppress it */ |
| 1068 | +if (IsA(plan,Append)) |
| 1069 | +return; |
| 1070 | + |
| 1071 | +/* Set up deparsing context */ |
| 1072 | +context=deparse_context_for_plan((Node*)outerPlan(plan), |
| 1073 | + (Node*)innerPlan(plan), |
| 1074 | +es->rtable); |
| 1075 | +useprefix=list_length(es->rtable)>1; |
| 1076 | + |
| 1077 | +/* Emit line prefix */ |
| 1078 | +for (i=0;i<indent;i++) |
| 1079 | +appendStringInfo(str," "); |
| 1080 | +appendStringInfo(str," Output: "); |
| 1081 | + |
| 1082 | +/* Deparse each non-junk result column */ |
| 1083 | +i=0; |
| 1084 | +foreach(lc,plan->targetlist) |
| 1085 | +{ |
| 1086 | +TargetEntry*tle= (TargetEntry*)lfirst(lc); |
| 1087 | + |
| 1088 | +if (tle->resjunk) |
| 1089 | +continue; |
| 1090 | +if (i++>0) |
| 1091 | +appendStringInfo(str,", "); |
| 1092 | +appendStringInfoString(str, |
| 1093 | +deparse_expression((Node*)tle->expr,context, |
| 1094 | +useprefix, false)); |
| 1095 | +} |
| 1096 | + |
| 1097 | +appendStringInfoChar(str,'\n'); |
| 1098 | +#endif/* EXPLAIN_PRINT_TLISTS */ |
| 1099 | +} |
| 1100 | + |
1046 | 1101 | /*
|
1047 | 1102 | * Show a qualifier expression for a scan plan node
|
1048 | 1103 | *
|
|