7
7
*
8
8
*
9
9
* IDENTIFICATION
10
- * $Header: /cvsroot/pgsql/src/backend/commands/explain.c,v 1.5 1996/12/03 05:50:11 vadim Exp $
10
+ * $Header: /cvsroot/pgsql/src/backend/commands/explain.c,v 1.6 1996/12/29 00:53:20 momjian Exp $
11
11
*
12
12
*-------------------------------------------------------------------------
13
13
*/
@@ -43,7 +43,7 @@ static char *Explain_PlanToString(Plan *plan, ExplainState *es);
43
43
void
44
44
ExplainQuery (Query * query ,List * options ,CommandDest dest )
45
45
{
46
- char * s ;
46
+ char * s = NULL , * s2 ;
47
47
Plan * plan ;
48
48
ExplainState * es ;
49
49
int len ;
@@ -69,21 +69,31 @@ ExplainQuery(Query *query, List *options, CommandDest dest)
69
69
memset (es ,0 ,sizeof (ExplainState ));
70
70
71
71
/* parse options */
72
+ es -> printCost = 1 ;/* default */
72
73
while (options ) {
73
74
char * ostr = strVal (lfirst (options ));
74
75
if (!strcasecmp (ostr ,"cost" ))
75
76
es -> printCost = 1 ;
76
- else if (!strcasecmp (ostr ,"full_plan " ))
77
+ else if (!strcasecmp (ostr ,"full " ))
77
78
es -> printNodes = 1 ;
79
+ else
80
+ elog (WARN ,"Unknown EXPLAIN option: %s" ,ostr );
78
81
79
82
options = lnext (options );
80
83
}
81
84
es -> rtable = query -> rtable ;
82
85
83
- if (es -> printNodes ) {
86
+ if (es -> printNodes )
84
87
s = nodeToString (plan );
85
- }else {
86
- s = Explain_PlanToString (plan ,es );
88
+
89
+ if (es -> printCost ) {
90
+ s2 = Explain_PlanToString (plan ,es );
91
+ if (s == NULL )
92
+ s = s2 ;
93
+ else {
94
+ strcat (s ,"\n\n" );
95
+ strcat (s ,s2 );
96
+ }
87
97
}
88
98
89
99
/* output the plan */