Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 6c1603c

Browse files
committed
Fix auto-explain JSON output to be valid JSON.
Problem reported by Peter Eisentraut. Backpatched to release 9.0.
1 parent 6fb17ae commit 6c1603c

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

contrib/auto_explain/auto_explain.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,13 @@ explain_ExecutorEnd(QueryDesc *queryDesc)
282282
if (es.str->len > 0 && es.str->data[es.str->len - 1] == '\n')
283283
es.str->data[--es.str->len] = '\0';
284284

285+
/* Fix JSON to output an object */
286+
if (auto_explain_log_format == EXPLAIN_FORMAT_JSON)
287+
{
288+
es.str->data[0] = '{';
289+
es.str->data[es.str->len - 1] = '}';
290+
}
291+
285292
/*
286293
* Note: we rely on the existing logging of context or
287294
* debug_query_string to identify just which statement is being

0 commit comments

Comments
 (0)