]> granicus.if.org Git - postgresql/commit
Fix EXPLAIN so that it doesn't emit invalid XML in corner cases.
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 20 Oct 2016 21:17:50 +0000 (17:17 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 20 Oct 2016 21:18:09 +0000 (17:18 -0400)
commitedb5143063ba2f63b37178df1fe2783dc6c9927f
tree1e942f86e9e969730db068b56dce46d036fc1ed7
parent92da7527892ebd5fccba62b4e07f04cbac805163
Fix EXPLAIN so that it doesn't emit invalid XML in corner cases.

With track_io_timing = on, EXPLAIN (ANALYZE, BUFFERS) will emit fields
named like "I/O Read Time".  The slash makes that invalid as an XML
element name, so that adding FORMAT XML would produce invalid XML.

We already have code in there to translate spaces to dashes, so let's
generalize that to convert anything that isn't a valid XML name character,
viz letters, digits, hyphens, underscores, and periods.  We could just
reject slashes, which would run a bit faster.  But the fact that this went
unnoticed for so long doesn't give me a warm feeling that we'd notice the
next creative violation, so let's make it a permanent fix.

Reported by Markus Winand, though this isn't his initial patch proposal.

Back-patch to 9.2 where track_io_timing was added.  The problem is only
latent in 9.1, so I don't feel a need to fix it there.

Discussion: <E0BF6A45-68E8-45E6-918F-741FB332C6BB@winand.at>
src/backend/commands/explain.c