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

Commit02490d4

Browse files
committed
Export ExplainBeginOutput() and ExplainEndOutput() for auto_explain.
Without these functions, anyone outside of explain.c can't actually useExplainPrintPlan, because the ExplainState won't be initialized properly.The user-visible result of this was a crash when using auto_explain withthe JSON output format.Report by Euler Taveira de Oliveira. Analysis by Tom Lane. Patch by me.
1 parent6b45e3b commit02490d4

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

‎contrib/auto_explain/auto_explain.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Copyright (c) 2008-2009, PostgreSQL Global Development Group
77
*
88
* IDENTIFICATION
9-
* $PostgreSQL: pgsql/contrib/auto_explain/auto_explain.c,v 1.8 2009/12/11 01:33:35 adunstan Exp $
9+
* $PostgreSQL: pgsql/contrib/auto_explain/auto_explain.c,v 1.9 2009/12/12 00:35:33 rhaas Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -223,7 +223,9 @@ explain_ExecutorEnd(QueryDesc *queryDesc)
223223
es.verbose=auto_explain_log_verbose;
224224
es.format=auto_explain_log_format;
225225

226+
ExplainBeginOutput(&es);
226227
ExplainPrintPlan(&es,queryDesc);
228+
ExplainEndOutput(&es);
227229

228230
/* Remove last line break */
229231
if (es.str->len>0&&es.str->data[es.str->len-1]=='\n')

‎src/backend/commands/explain.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1994-5, Regents of the University of California
88
*
99
* IDENTIFICATION
10-
* $PostgreSQL: pgsql/src/backend/commands/explain.c,v 1.194 2009/12/11 01:33:35 adunstan Exp $
10+
* $PostgreSQL: pgsql/src/backend/commands/explain.c,v 1.195 2009/12/12 00:35:33 rhaas Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -91,8 +91,6 @@ static void ExplainCloseGroup(const char *objtype, const char *labelname,
9191
boollabeled,ExplainState*es);
9292
staticvoidExplainDummyGroup(constchar*objtype,constchar*labelname,
9393
ExplainState*es);
94-
staticvoidExplainBeginOutput(ExplainState*es);
95-
staticvoidExplainEndOutput(ExplainState*es);
9694
staticvoidExplainXMLTag(constchar*tagname,intflags,ExplainState*es);
9795
staticvoidExplainJSONLineEnding(ExplainState*es);
9896
staticvoidExplainYAMLLineStarting(ExplainState*es);
@@ -1791,7 +1789,7 @@ ExplainDummyGroup(const char *objtype, const char *labelname, ExplainState *es)
17911789
* This is just enough different from processing a subgroup that we need
17921790
* a separate pair of subroutines.
17931791
*/
1794-
staticvoid
1792+
void
17951793
ExplainBeginOutput(ExplainState*es)
17961794
{
17971795
switch (es->format)
@@ -1822,7 +1820,7 @@ ExplainBeginOutput(ExplainState *es)
18221820
/*
18231821
* Emit the end-of-output boilerplate.
18241822
*/
1825-
staticvoid
1823+
void
18261824
ExplainEndOutput(ExplainState*es)
18271825
{
18281826
switch (es->format)

‎src/include/commands/explain.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994-5, Regents of the University of California
88
*
9-
* $PostgreSQL: pgsql/src/include/commands/explain.h,v 1.42 2009/12/11 01:33:35 adunstan Exp $
9+
* $PostgreSQL: pgsql/src/include/commands/explain.h,v 1.43 2009/12/12 00:35:34 rhaas Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -65,6 +65,8 @@ extern void ExplainOnePlan(PlannedStmt *plannedstmt, ExplainState *es,
6565

6666
externvoidExplainPrintPlan(ExplainState*es,QueryDesc*queryDesc);
6767

68+
externvoidExplainBeginOutput(ExplainState*es);
69+
externvoidExplainEndOutput(ExplainState*es);
6870
externvoidExplainSeparatePlans(ExplainState*es);
6971

7072
#endif/* EXPLAIN_H */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp