Open xuyifangreeneyes opened 2 years ago
Some other similar errors also occur in create table partition by
and alter table add column
The root cause is that in parser.y
, we use ColumnName
for all the places. ColumnName
can parser db.tbl.col
, tbl.col
and col
. However, in some places only col
is allowed while db.tbl.col
and tbl.col
are not allowed.
create table t (a int, b int);
MySQL:
mysql> alter table t add column t.c int;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.c int' at line 1
TiDB:
mysql> alter table t add column t.c int;
Query OK, 0 rows affected (0.02 sec)
MySQL:
mysql> create table t (a int, t.b int);
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.b int)' at line 1
TiDB:
mysql> create table t (a int, t.b int);
Query OK, 0 rows affected (0.01 sec)
Bug Report
Please answer these questions before submitting your issue. Thanks!
1. Minimal reproduce step (Required)
2. What did you expect to see? (Required)
MySQL reports syntax error for the first three sqls.
Both the fourth sql and the fifth sql are wrong and TiDB should report error(analyze columns and extended stats are TiDB's own syntax).
3. What did you see instead (Required)
All the sqls run successfully.
4. What is your TiDB version? (Required)