77 *
88 *
99 * 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 $
1111 *
1212 *-------------------------------------------------------------------------
1313 */
@@ -43,7 +43,7 @@ static char *Explain_PlanToString(Plan *plan, ExplainState *es);
4343void
4444ExplainQuery (Query * query ,List * options ,CommandDest dest )
4545{
46- char * s ;
46+ char * s = NULL , * s2 ;
4747Plan * plan ;
4848ExplainState * es ;
4949int len ;
@@ -69,21 +69,31 @@ ExplainQuery(Query *query, List *options, CommandDest dest)
6969memset (es ,0 ,sizeof (ExplainState ));
7070
7171/* parse options */
72+ es -> printCost = 1 ;/* default */
7273while (options ) {
7374char * ostr = strVal (lfirst (options ));
7475if (!strcasecmp (ostr ,"cost" ))
7576es -> printCost = 1 ;
76- else if (!strcasecmp (ostr ,"full_plan " ))
77+ else if (!strcasecmp (ostr ,"full " ))
7778es -> printNodes = 1 ;
79+ else
80+ elog (WARN ,"Unknown EXPLAIN option: %s" ,ostr );
7881
7982options = lnext (options );
8083 }
8184es -> rtable = query -> rtable ;
8285
83- if (es -> printNodes ) {
86+ if (es -> printNodes )
8487s = 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+ }
8797 }
8898
8999/* output the plan */