summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Dunstan <andrew@dunslane.net>2012-02-13 08:23:13 -0500
committerAndrew Dunstan <andrew@dunslane.net>2012-02-13 08:23:13 -0500
commit0f3fcbbb613467fd78744da17d5228c813c5958b (patch)
treec44ad781db382357dbd3ae580400ad82ad20d0da
parent03c66ca5dfd4e0e8fec506315f581b21817f47f4 (diff)
Fix auto-explain JSON output to be valid JSON.
Problem reported by Peter Eisentraut. Backpatched to release 9.0.
-rw-r--r--contrib/auto_explain/auto_explain.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/contrib/auto_explain/auto_explain.c b/contrib/auto_explain/auto_explain.c
index ffc1a4a1063..0bd23478b12 100644
--- a/contrib/auto_explain/auto_explain.c
+++ b/contrib/auto_explain/auto_explain.c
@@ -248,6 +248,13 @@ explain_ExecutorEnd(QueryDesc *queryDesc)
if (es.str->len > 0 && es.str->data[es.str->len - 1] == '\n')
es.str->data[--es.str->len] = '\0';
+ /* Fix JSON to output an object */
+ if (auto_explain_log_format == EXPLAIN_FORMAT_JSON)
+ {
+ es.str->data[0] = '{';
+ es.str->data[es.str->len - 1] = '}';
+ }
+
/*
* Note: we rely on the existing logging of context or
* debug_query_string to identify just which statement is being