1- /*-------------------------------------------------------------------------
2- *
1+ /*
32 * explain.c--
43 * Explain the query execution plan
54 *
65 * Copyright (c) 1994-5, Regents of the University of California
76 *
7+ * $Id: explain.c,v 1.29 1998/12/14 08:11:00 scrappy Exp $
88 *
9- * IDENTIFICATION
10- * $Header: /cvsroot/pgsql/src/backend/commands/explain.c,v 1.28 1998/12/14 05:18:43 scrappy Exp $
11- *
12- *-------------------------------------------------------------------------
139 */
1410#include <stdio.h>
1511#include <string.h>
@@ -217,7 +213,9 @@ explain_outNode(StringInfo str, Plan *plan, int indent, ExplainState *es)
217213{
218214relation = RelationIdCacheGetRelation ((int )lfirst (l ));
219215if (++ i > 1 )
216+ {
220217appendStringInfo (str ,", " );
218+ }
221219appendStringInfo (str , (RelationGetRelationName (relation ))-> data );
222220}
223221case T_SeqScan :
@@ -239,9 +237,8 @@ explain_outNode(StringInfo str, Plan *plan, int indent, ExplainState *es)
239237}
240238if (es -> printCost )
241239{
242- snprintf ( buf , 1000 ," (cost=%.2f size=%d width=%d)" ,
240+ appendStringInfo ( str ," (cost=%.2f size=%d width=%d)" ,
243241plan -> cost ,plan -> plan_size ,plan -> plan_width );
244- appendStringInfo (str ,buf );
245242}
246243appendStringInfo (str ,"\n" );
247244
@@ -251,14 +248,18 @@ explain_outNode(StringInfo str, Plan *plan, int indent, ExplainState *es)
251248List * saved_rtable = es -> rtable ;
252249List * lst ;
253250
254- for (i = 0 ;i < indent ;i ++ )
251+ for (i = 0 ;i < indent ;i ++ )
252+ {
255253appendStringInfo (str ," " );
254+ }
256255appendStringInfo (str ," InitPlan\n" );
257256foreach (lst ,plan -> initPlan )
258257{
259258es -> rtable = ((SubPlan * )lfirst (lst ))-> rtable ;
260259for (i = 0 ;i < indent ;i ++ )
260+ {
261261appendStringInfo (str ," " );
262+ }
262263appendStringInfo (str ," -> " );
263264explain_outNode (str , ((SubPlan * )lfirst (lst ))-> plan ,indent + 2 ,es );
264265}
@@ -269,7 +270,9 @@ explain_outNode(StringInfo str, Plan *plan, int indent, ExplainState *es)
269270if (outerPlan (plan ))
270271{
271272for (i = 0 ;i < indent ;i ++ )
273+ {
272274appendStringInfo (str ," " );
275+ }
273276appendStringInfo (str ," -> " );
274277explain_outNode (str ,outerPlan (plan ),indent + 3 ,es );
275278}
@@ -278,7 +281,9 @@ explain_outNode(StringInfo str, Plan *plan, int indent, ExplainState *es)
278281if (innerPlan (plan ))
279282{
280283for (i = 0 ;i < indent ;i ++ )
284+ {
281285appendStringInfo (str ," " );
286+ }
282287appendStringInfo (str ," -> " );
283288explain_outNode (str ,innerPlan (plan ),indent + 3 ,es );
284289}
@@ -290,13 +295,17 @@ explain_outNode(StringInfo str, Plan *plan, int indent, ExplainState *es)
290295List * lst ;
291296
292297for (i = 0 ;i < indent ;i ++ )
298+ {
293299appendStringInfo (str ," " );
300+ }
294301appendStringInfo (str ," SubPlan\n" );
295302foreach (lst ,plan -> subPlan )
296303{
297304es -> rtable = ((SubPlan * )lfirst (lst ))-> rtable ;
298305for (i = 0 ;i < indent ;i ++ )
306+ {
299307appendStringInfo (str ," " );
308+ }
300309appendStringInfo (str ," -> " );
301310explain_outNode (str , ((SubPlan * )lfirst (lst ))-> plan ,indent + 4 ,es );
302311}
@@ -327,7 +336,9 @@ explain_outNode(StringInfo str, Plan *plan, int indent, ExplainState *es)
327336es -> rtable = nth (whichplan ,appendplan -> unionrtables );
328337
329338for (i = 0 ;i < indent ;i ++ )
339+ {
330340appendStringInfo (str ," " );
341+ }
331342appendStringInfo (str ," -> " );
332343
333344explain_outNode (str ,subnode ,indent + 4 ,es );