Re: auto_explain produces invalid JSON
Andrew Dunstan <andrew@dunslane.net>
From: Andrew Dunstan <andrew@dunslane.net>
To: Peter Eisentraut <peter_e@gmx.net>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2012-02-11T20:12:01Z
Lists: pgsql-hackers
Attachments
- explain.patch (text/x-patch) patch
On 02/11/2012 01:18 PM, Andrew Dunstan wrote: > > > On 02/10/2012 01:14 PM, Peter Eisentraut wrote: >> [ auto-explain JSON output should be an object instead of an array ] > > > > Yeah, looks like this dates back to when we first got JSON output. > > Auto-explain does this: > > ExplainBeginOutput(&es); > ExplainQueryText(&es, queryDesc); > ExplainPrintPlan(&es, queryDesc); > ExplainEndOutput(&es); > > > But ExplainBeginOutput says: > > case EXPLAIN_FORMAT_JSON: > /* top-level structure is an array of plans */ > appendStringInfoChar(es->str, '['); > > > Now that's not true in the auto-explain case, which prints one query + > one plan. > > Since this is an exposed API, I don't think we can just change it. We > probably need a new API that does the right thing for beginning and > ending auto_explain output. (ExplainBeginLabeledOutput?) > > PFA a patch along these lines, which seems to do the Right Thing (tm) cheers andrew