diff options
author | Andrew Dunstan <andrew@dunslane.net> | 2012-02-13 08:22:15 -0500 |
---|---|---|
committer | Andrew Dunstan <andrew@dunslane.net> | 2012-02-13 08:22:15 -0500 |
commit | 21320763a39994021a4ff045ff66f7204bdb6d78 (patch) | |
tree | bba25050a4bb55f55632ae0fcd44d0dc5a87fa9a /contrib/auto_explain/auto_explain.c | |
parent | 21b16342750d6623f3c78f639f07bf3b66b49417 (diff) | |
download | postgresql-21320763a39994021a4ff045ff66f7204bdb6d78.tar.gz postgresql-21320763a39994021a4ff045ff66f7204bdb6d78.zip |
Fix auto-explain JSON output to be valid JSON.
Problem reported by Peter Eisentraut.
Backpatched to release 9.0.
Diffstat (limited to 'contrib/auto_explain/auto_explain.c')
-rw-r--r-- | contrib/auto_explain/auto_explain.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/contrib/auto_explain/auto_explain.c b/contrib/auto_explain/auto_explain.c index 9fc0ae1d923..e48ea489dc5 100644 --- a/contrib/auto_explain/auto_explain.c +++ b/contrib/auto_explain/auto_explain.c @@ -299,6 +299,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 |