On Thu, Dec 10, 2009 at 8:39 PM, Andrew Dunstan <[email protected]> wrote:
> OK, I've committed the YAML stuff, so who is working on the auto-explain
> bug? Robert? I'd like that fixed before I add in the query text to
> auto-explain output.
I'm going to propose fixing this in what seems to me to be the
simplest possible way, per the attached. Anyone want to argue?
...Robert
diff --git a/contrib/auto_explain/auto_explain.c b/contrib/auto_explain/auto_explain.c
index 75ac9ca..f0d907d 100644
--- a/contrib/auto_explain/auto_explain.c
+++ b/contrib/auto_explain/auto_explain.c
@@ -223,7 +223,9 @@ explain_ExecutorEnd(QueryDesc *queryDesc)
es.verbose = auto_explain_log_verbose;
es.format = auto_explain_log_format;
+ ExplainBeginOutput(&es);
ExplainPrintPlan(&es, queryDesc);
+ ExplainEndOutput(&es);
/* Remove last line break */
if (es.str->len > 0 && es.str->data[es.str->len - 1] == '\n')
diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c
index 0437ffa..2067636 100644
--- a/src/backend/commands/explain.c
+++ b/src/backend/commands/explain.c
@@ -91,8 +91,6 @@ static void ExplainCloseGroup(const char *objtype, const char *labelname,
bool labeled, ExplainState *es);
static void ExplainDummyGroup(const char *objtype, const char *labelname,
ExplainState *es);
-static void ExplainBeginOutput(ExplainState *es);
-static void ExplainEndOutput(ExplainState *es);
static void ExplainXMLTag(const char *tagname, int flags, ExplainState *es);
static void ExplainJSONLineEnding(ExplainState *es);
static void ExplainYAMLLineStarting(ExplainState *es);
@@ -1791,7 +1789,7 @@ ExplainDummyGroup(const char *objtype, const char *labelname, ExplainState *es)
* This is just enough different from processing a subgroup that we need
* a separate pair of subroutines.
*/
-static void
+void
ExplainBeginOutput(ExplainState *es)
{
switch (es->format)
@@ -1822,7 +1820,7 @@ ExplainBeginOutput(ExplainState *es)
/*
* Emit the end-of-output boilerplate.
*/
-static void
+void
ExplainEndOutput(ExplainState *es)
{
switch (es->format)
diff --git a/src/include/commands/explain.h b/src/include/commands/explain.h
index ab48825..ba2ba08 100644
--- a/src/include/commands/explain.h
+++ b/src/include/commands/explain.h
@@ -65,6 +65,8 @@ extern void ExplainOnePlan(PlannedStmt *plannedstmt, ExplainState *es,
extern void ExplainPrintPlan(ExplainState *es, QueryDesc *queryDesc);
+extern void ExplainBeginOutput(ExplainState *es);
+extern void ExplainEndOutput(ExplainState *es);
extern void ExplainSeparatePlans(ExplainState *es);
#endif /* EXPLAIN_H */
--
Sent via pgsql-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers