yugabyte/yugabyte-db

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

Open

#18,876 建立於 2023年8月28日

在 GitHub 查看
 (0 留言) (0 反應) (1 負責人)C (1,003 fork)batch import
area/ysqlgood first issuekind/enhancementpriority/medium

倉庫指標

Star
 (8,229 star)
PR 合併指標
 (平均合併 17天 21小時) (30 天內合併 92 個 PR)

描述

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.

貢獻者指南