PostgreSQL Bugs

Collected from the PG bugs email list.

Bug ID16502
PG Version12.3
OSUbuntu 19.10
Opened2020-06-18 19:24:08+00
Reported byMaciek Sakrejda
StatusNew

Body of first available message related to this bug follows.

The following bug has been logged on the website:

Bug reference:      16502
Logged by:          Maciek Sakrejda
Email address:      (redacted)
PostgreSQL version: 12.3
Operating system:   Ubuntu 19.10
Description:        

When working with a table that needs quotes around its name (e.g., with
spaces in the name), EXPLAIN is inconsistent in handling this between
relation names and index names. A relation name is presented as-is in the
"Relation Name" field, but the "Index Name" field includes the quotes inside
the field value.

Here's an example:

maciek=# create table "needs quotes"(a int);
CREATE TABLE
maciek=# explain (costs off, format json) select * from "needs quotes";
               QUERY PLAN               
----------------------------------------
 [                                     +
   {                                   +
     "Plan": {                         +
       "Node Type": "Seq Scan",        +
       "Parallel Aware": false,        +
       "Relation Name": "needs quotes",+
       "Alias": "needs quotes"         +
     }                                 +
   }                                   +
 ]
(1 row)

maciek=# create index on "needs quotes"(a);
CREATE INDEX
maciek=# set enable_seqscan = off;
SET
maciek=# explain (costs off, format json) select * from "needs quotes";
                    QUERY PLAN                    
--------------------------------------------------
 [                                               +
   {                                             +
     "Plan": {                                   +
       "Node Type": "Bitmap Heap Scan",          +
       "Parallel Aware": false,                  +
       "Relation Name": "needs quotes",          +
       "Alias": "needs quotes",                  +
       "Plans": [                                +
         {                                       +
           "Node Type": "Bitmap Index Scan",     +
           "Parent Relationship": "Outer",       +
           "Parallel Aware": false,              +
           "Index Name": "\"needs quotes_a_idx\""+
         }                                       +
       ]                                         +
     }                                           +
   }                                             +
 ]
(1 row)

Given that there is no ambiguity here because the index or relation name is
the full value of the field, the quotes don't really add anything and I'd
argue they should be dropped.

I ran into this in 12.3, but it looks like it's still the case in HEAD. It
looks like this is because `explain_get_index_name` in `explain.c` always
quotes the index name, regardless of the format being used. I'd send a
patch, but I'm not sure how `explain_get_index_name_hook` should fit into
this.

Thanks,
Maciek

Messages

DateAuthorSubject
2020-06-18 19:24:08+00PG Bug reporting formBUG #16502: EXPLAIN JSON format adds extra quotes around index names
2020-06-20 18:22:17+00Euler TaveiraRe: BUG #16502: EXPLAIN JSON format adds extra quotes around index names
2020-06-20 19:06:40+00Tom LaneRe: BUG #16502: EXPLAIN JSON format adds extra quotes around index names
2020-06-20 22:11:09+00Tom LaneRe: BUG #16502: EXPLAIN JSON format adds extra quotes around index names
2020-06-20 23:15:40+00Euler TaveiraRe: BUG #16502: EXPLAIN JSON format adds extra quotes around index names
2020-06-21 02:35:16+00Maciek SakrejdaRe: BUG #16502: EXPLAIN JSON format adds extra quotes around index names
2020-06-21 06:45:02+00Julien RouhaudRe: BUG #16502: EXPLAIN JSON format adds extra quotes around index names
2020-06-21 14:29:17+00Tom LaneRe: BUG #16502: EXPLAIN JSON format adds extra quotes around index names
2020-06-21 18:16:53+00Julien RouhaudRe: BUG #16502: EXPLAIN JSON format adds extra quotes around index names
2020-06-22 15:49:40+00Tom LaneRe: BUG #16502: EXPLAIN JSON format adds extra quotes around index names
2020-06-22 16:07:39+00Julien RouhaudRe: BUG #16502: EXPLAIN JSON format adds extra quotes around index names