]> granicus.if.org Git - postgresql/commitdiff
Fix auto-explain JSON output to be valid JSON.
authorAndrew Dunstan <andrew@dunslane.net>
Mon, 13 Feb 2012 13:22:15 +0000 (08:22 -0500)
committerAndrew Dunstan <andrew@dunslane.net>
Mon, 13 Feb 2012 13:22:15 +0000 (08:22 -0500)
Problem reported by Peter Eisentraut.

Backpatched to release 9.0.

contrib/auto_explain/auto_explain.c

index 9fc0ae1d92338417c416fe79f44a84332b4a9735..e48ea489dc5bb87f48037d058a4aae9f30a54f0d 100644 (file)
@@ -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