Re: Invalid explain output for multi-plan statements

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Greg Sabino Mullane <greg(at)turnstep(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: Invalid explain output for multi-plan statements
Date: 2009-12-15 03:06:52
Message-ID: 603c8f070912141906o23266d34h2b70b0e6d11393cb@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Mon, Dec 14, 2009 at 12:59 PM, Robert Haas <robertmhaas(at)gmail(dot)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 Content-Type Size
explain_fix.patch text/x-patch 3.4 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Philip Graham 2009-12-15 04:15:45 BUG #5244: Attempting to rollback to a savepoint after receiving an error with state 55000 the process hangs
Previous Message Tom Lane 2009-12-14 18:40:13 Re: BUG #5243: Segmentation fault when sending null to crypt();