yugabyte/yugabyte-db

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

Open

#18 876 ouverte le 28 août 2023

Voir sur GitHub
 (0 commentaires) (0 réactions) (1 assigné)C (1 003 forks)batch import
area/ysqlgood first issuekind/enhancementpriority/medium

Métriques du dépôt

Stars
 (8 229 stars)
Métriques de merge PR
 (Merge moyen 17j 21h) (92 PRs mergées en 30 j)

Description

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.

Guide contributeur