]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Undo double-quoting of index names in non-text EXPLAIN output formats.
authorTom Lane <tgl@sss.pgh.pa.us>
Mon, 22 Jun 2020 15:46:41 +0000 (11:46 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Mon, 22 Jun 2020 15:46:41 +0000 (11:46 -0400)
commitd3d8755180b68b6d0d385e8f6989bfbc969a891a
tree2900e25ad227f292571f7201d4953ac77c3ca2e0
parent396a44a0153657bd4f5385b184b66b7ada8682ca
Undo double-quoting of index names in non-text EXPLAIN output formats.

explain_get_index_name() applied quote_identifier() to the index name.
This is fine for text output, but the non-text output formats all have
their own quoting conventions and would much rather start from the
actual index name.  For example in JSON you'd get something like

       "Index Name": "\"My Index\"",

which is surely not desirable, especially when the same does not
happen for table names.  Hence, move the responsibility for applying
quoting out to the callers, where it can go into already-existing
special code paths for text format.

This changes the API spec for users of explain_get_index_name_hook:
before, they were supposed to apply quote_identifier() if necessary,
now they should not.  Research suggests that the only publicly
available user of the hook is hypopg, and it actually forgot to
apply quoting anyway, so it's fine.  (In any case, there's no
behavioral change for the output of a hook as seen in non-text
EXPLAIN formats, so this won't break any case that programs should
be relying on.)

Digging in the commit logs, it appears that quoting was included in
explain_get_index_name's duties when commit 604ffd280 invented it;
and that was fine at the time because we only had text output format.
This should have been rethought when non-text formats were invented,
but it wasn't.

This is a fairly clear bug for users of non-text EXPLAIN formats,
so back-patch to all supported branches.

Per bug #16502 from Maciek Sakrejda.  Patch by me (based on
investigation by Euler Taveira); thanks to Julien Rouhaud for review.

Discussion: https://postgr.es/m/16502-57bd1c9f913ed1d1@postgresql.org
src/backend/commands/explain.c