Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4415e48

Browse files
committed
Improved EXPLAIN option handling.
1 parente981bcb commit4415e48

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

‎src/backend/commands/explain.c

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
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);
4343
void
4444
ExplainQuery(Query*query,List*options,CommandDestdest)
4545
{
46-
char*s;
46+
char*s=NULL,*s2;
4747
Plan*plan;
4848
ExplainState*es;
4949
intlen;
@@ -69,21 +69,31 @@ ExplainQuery(Query *query, List *options, CommandDest dest)
6969
memset(es,0,sizeof(ExplainState));
7070

7171
/* parse options */
72+
es->printCost=1;/* default */
7273
while (options) {
7374
char*ostr=strVal(lfirst(options));
7475
if (!strcasecmp(ostr,"cost"))
7576
es->printCost=1;
76-
elseif (!strcasecmp(ostr,"full_plan"))
77+
elseif (!strcasecmp(ostr,"full"))
7778
es->printNodes=1;
79+
else
80+
elog(WARN,"Unknown EXPLAIN option: %s",ostr);
7881

7982
options=lnext(options);
8083
}
8184
es->rtable=query->rtable;
8285

83-
if (es->printNodes) {
86+
if (es->printNodes)
8487
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+
}
8797
}
8898

8999
/* output the plan */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp