yugabyte/yugabyte-db

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

Open

#18,876 opened on 2023年8月28日

GitHub で見る
 (0 comments) (0 reactions) (1 assignee)C (1,003 forks)batch import
area/ysqlgood first issuekind/enhancementpriority/medium

Repository metrics

Stars
 (8,229 stars)
PR merge metrics
 (平均マージ 17d 21h) (30d で 92 merged PRs)

説明

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.

コントリビューターガイド