Re: BUG #16171: Potential malformed JSON in explain output
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Hamid Akhtar <hamid.akhtar@gmail.com>
Cc: pgsql-hackers@lists.postgresql.org, Daniel Gustafsson <daniel@yesql.se>
Date: 2020-02-01T19:37:55Z
Lists: pgsql-bugs, pgsql-hackers
Attachments
- 0001-place-subnodes-removed-correctly.patch (text/x-diff) patch 0001
- 0002-check-json-validity.patch (text/x-diff) patch 0002
Hamid Akhtar <hamid.akhtar@gmail.com> writes: > I've reviewed and verified this patch and IMHO, this is ready to be committed. I took a look at this and I don't think it's really going in the right direction. ISTM the clear intent of this code was to attach the "Subplans Removed" item as a field of the parent [Merge]Append node, but the author forgot about the intermediate "Plans" array. So I think that, rather than doubling down on a mistake, we ought to move where the field is generated so that it *is* a field of the parent node. Another failure to follow the design conventions for EXPLAIN output is that in non-text formats, the schema for each node type ought to be fixed; that is, if a given field can appear for a particular node type and EXPLAIN options, it should appear always, not be omitted just because it's zero. So that leads me to propose 0001 attached. This does lead to some field order rearrangement in text mode, as per the regression test changes, but I think that's not a big deal. (A change can only happen if there are initplan(s) attached to the parent node.) Also, I wondered whether we had any other violations of correct formatting in this code, which led me to the idea of running auto_explain in JSON mode and having it feed its result to json_in. This isn't a complete test because it won't whine about duplicate field names, but it did correctly find the current bug --- and I couldn't find any others while running the core regression tests with various auto_explain options. 0002 attached isn't committable, because nobody would want the overhead in production, but it seems like a good trick to keep up our sleeves. Thoughts? regards, tom lane
Commits
-
Fix handling of "Subplans Removed" field in EXPLAIN output.
- 9a85860e12aa 12.2 landed
- 842a23efa92a 11.7 landed
- 7d91b604d9b5 13.0 landed
-
Doc: Fix list of storage parameters available for ALTER TABLE
- c4c76d198e3d 12.2 cited