Re: Invalid explain output for multi-plan statements - Mailing list pgsql-bugs

From Robert Haas
Subject Re: Invalid explain output for multi-plan statements
Date
Msg-id 603c8f070912141906o23266d34h2b70b0e6d11393cb@mail.gmail.com
Whole thread Raw
In response to Re: Invalid explain output for multi-plan statements  (Robert Haas <robertmhaas@gmail.com>)
Responses Re: Invalid explain output for multi-plan statements
List pgsql-bugs
On Mon, Dec 14, 2009 at 12:59 PM, Robert Haas <robertmhaas@gmail.com> wrote:
>> The new explain formats break if you have a multi-query statement.
> I will fix this, unless someone else beats me to it.

Proposed patch attached.  The problem with JSON output is pretty
simple - ExplainSeparatePlans() still thinks it's responsible for
comma-separating JSON plans, but in fact the new grouping_stack
machinery is smart enough to handle that on its own, so they each add
a comma.  The YAML format also inserts a needless separator, but the
real problem is that ExplainBeginGroup() and ExplainYAMLLineStarting()
have an odd division of labor for marking each list element with "- ",
with each providing one character.   That fails to work as expected.
I also noticed that ExplainDummyGroup() is hosed for the YAML format,
so I fixed that as well.

Along the way, I also made the YAML format use escape_yaml() in
situations where the JSON format uses escape_json().  Right now it
doesn't matter because all the values are known to not need escaping,
but it seems safer this way.  And, it took me a bit of time to
understand the YAML format as it was not really commented, so I added
some comments here as well.

...Robert

Attachment

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #5243: Segmentation fault when sending null to crypt();
Next
From: Mark Williamson
Date:
Subject: statement_timeout is not cancelling query