yugabyte/yugabyte-db

[YSQL] Describe (\d) does not quote index names correctly

Open

#18.876 aperta il 28 ago 2023

Vedi su GitHub
 (0 commenti) (0 reazioni) (1 assegnatario)C (1003 fork)batch import
area/ysqlgood first issuekind/enhancementpriority/medium

Metriche repository

Star
 (8229 star)
Metriche merge PR
 (Merge medio 17g 21h) (92 PR mergiate in 30 g)

Descrizione

Jira Link: DB-7736

Description

It looks like describe code we added here to get the tablegroup information does not handle quoting correctly. At a higher level, it's not clear if this code is even necessary with the latest colocation GA work. So we should review if this code is even necessary (or should be re-worked) before just fixing the quoting bug.

Simple Repro

Create a simple table

Describe will work as expected

yugabyte=# create table test(k int primary key, v1 int, v2 int);
CREATE TABLE
yugabyte=# \d test
                Table "public.test"
 Column |  Type   | Collation | Nullable | Default
--------+---------+-----------+----------+---------
 k      | integer |           | not null |
 v1     | integer |           |          |
 v2     | integer |           |          |
Indexes:
    "test_pkey" PRIMARY KEY, lsm (k HASH)

Create an index with mixed case (quoted) name

Describe will get an error, where the relation not being found because it's searching for the lower-case name.

yugabyte=# create index "abC" on test(v1 DESC);
CREATE INDEX
yugabyte=# \d test
ERROR:  relation "public.abc" does not exist
LINE 2: FROM yb_table_properties('public.abC'::regclass) props,
                                 ^
                Table "public.test"
 Column |  Type   | Collation | Nullable | Default
--------+---------+-----------+----------+---------
 k      | integer |           | not null |
 v1     | integer |           |          |
 v2     | integer |           |          |
Indexes:
    "test_pkey" PRIMARY KEY, lsm (k HASH)
    "abC" lsm (v1 DESC)

Create another index with matching lowercase name

Now there is no error again, but the code is likely wrongly looking up the info for the abc index when it should be searching for abC.

yugabyte=# create index "abc" on test(v2 HASH);
CREATE INDEX
yugabyte=# \d test
                Table "public.test"
 Column |  Type   | Collation | Nullable | Default
--------+---------+-----------+----------+---------
 k      | integer |           | not null |
 v1     | integer |           |          |
 v2     | integer |           |          |
Indexes:
    "test_pkey" PRIMARY KEY, lsm (k HASH)
    "abC" lsm (v1 DESC)
    "abc" lsm (v2 HASH)

Warning: Please confirm that this issue does not contain any sensitive information

  • I confirm this issue does not contain any sensitive information.

Guida contributor