pingcap / pingcap/tidb

DESCRIBE <table> <column> not fully compatible

Open
#46,814 0 comments 0 reactions 0 assignees View on GitHub
compatibility-mysql80 severity/minor sig/sql-infra type/bug type/compatibility
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Bug Report

### 1. Minimal reproduce step (Required)

```sql
CREATE TABLE t1(id INT PRIMARY KEY, c1 INT, c2 INT);
DESCRIBE `t1` `id`;
DESCRIBE `t1` `c1`;
DESCRIBE `t1` `c%`;
DESCRIBE `t1` 'c1';
```

### 2. What did you expect to see? (Required)

```
sql> CREATE TABLE t1(id INT PRIMARY KEY, c1 INT, c2 INT);
Query OK, 0 rows affected (0.0596 sec)

sql> DESCRIBE `t1` `id`;
+-------+------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+------+------+-----+---------+-------+
| id | int | NO | PRI | NULL | |
+-------+------+------+-----+---------+-------+
1 row in set (0.0050 sec)

sql> DESCRIBE `t1` `c1`;
+-------+------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+------+------+-----+---------+-------+
| c1 | int | YES | | NULL | |
+-------+------+------+-----+---------+-------+
1 row in set (0.0036 sec)

sql> DESCRIBE `t1` `c%`;
+-------+------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+------+------+-----+---------+-------+
| c1 | int | YES | | NULL | |
| c2 | int | YES | | NULL | |
+-------+------+------+-----+---------+-------+
2 rows in set (0.0039 sec)

sql> DESCRIBE `t1` 'c1';
+-------+------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+------+------+-----+---------+-------+
| c1 | int | YES | | NULL | |
+-------+------+------+-----+---------+-------+
1 row in set (0.0034 sec)

sql> SELECT VERSION();
+-----------+
| VERSION() |
+-----------+
| 8.1.0 |
+-----------+
1 row in set (0.0007 sec)
```

### 3. What did you see instead (Required)

```
sql> CREATE TABLE t1(id INT PRIMARY KEY, c1 INT, c2 INT);
Query OK, 0 rows affected (0.0228 sec)

sql> DESCRIBE `t1` `id`;
+-------+---------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+---------+------+-----+---------+-------+
| id | int(11) | NO | PRI | NULL | |
+-------+---------+------+-----+---------+-------+
1 row in set (0.0008 sec)

sql> DESCRIBE `t1` `c1`;
+-------+---------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+---------+------+-----+---------+-------+
| c1 | int(11) | YES | | NULL | |
+-------+---------+------+-----+---------+-------+
1 row in set (0.0008 sec)

sql> DESCRIBE `t1` `c%`;
Empty set (0.0007 sec)

sql> DESCRIBE `t1` 'c1';
ERROR: 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your TiDB version for the right syntax to use line 1 column 18 near "'c1'"
```

1. `c%` is not processed as wildcard
2. `'c1'` style quoting results in a syntax error

### 4. What is your TiDB version? (Required)

```
sql> SELECT TIDB_VERSION()\G
*************************** 1. row ***************************
TIDB_VERSION(): Release Version: v7.4.0-alpha-343-gd3d30f5f55
Edition: Community
Git Commit Hash: d3d30f5f556e826ae5ec2d25c8d8fd6b9412e72a
Git Branch: master
UTC Build Time: 2023-09-09 17:45:57
GoVersion: go1.21.0
Race Enabled: false
Check Table Before Drop: false
Store: unistore
1 row in set (0.0013 sec)
```

This causes the following test in DBD::mysql (Perl) to fail on TiDB
- `t/40catalog.t`
- `t/40listfields.t`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.