Commits

Andrew Dunstan  committed 6c1603c

Fix auto-explain JSON output to be valid JSON.

Problem reported by Peter Eisentraut.

Backpatched to release 9.0.

  • Participants
  • Parent commits 6fb17ae
  • Branches rowexpr91

Comments (0)

Files changed (1)

File contrib/auto_explain/auto_explain.c

 			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