From: Andrew Dunstan Date: Mon, 13 Feb 2012 13:22:54 +0000 (-0500) Subject: Fix auto-explain JSON output to be valid JSON. X-Git-Tag: REL9_1_3~18 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6c1603cd8a6a90c6d1b509fb199edaab383ecf58;p=postgresql Fix auto-explain JSON output to be valid JSON. Problem reported by Peter Eisentraut. Backpatched to release 9.0. --- diff --git a/contrib/auto_explain/auto_explain.c b/contrib/auto_explain/auto_explain.c index b320698748..3ebc3b298e 100644 --- a/contrib/auto_explain/auto_explain.c +++ b/contrib/auto_explain/auto_explain.c @@ -282,6 +282,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