yugabyte/yugabyte-db

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

Open

#18.876 geöffnet am 28. Aug. 2023

Auf GitHub ansehen
 (0 Kommentare) (0 Reaktionen) (1 zugewiesene Person)C (1.003 Forks)batch import
area/ysqlgood first issuekind/enhancementpriority/medium

Repository-Metriken

Stars
 (8.229 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 17T 21h) (92 gemergte PRs in 30 T)

Beschreibung

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.

Contributor Guide