Bug 反馈
清晰准确地描述您发现的问题,提供任何可能复现问题的步骤有助于研发同学及时处理问题
【 Bug 的影响】使用注释语法创建单列非聚簇索引不符合预期
【可能的问题复现步骤】
使用用户文档上列明的注释语法语法,来使用创建非聚簇索引表
CREATE TABLE t (a BIGINT PRIMARY KEY /*T![clustered_index] NONCLUSTERED */, b VARCHAR(255));
CREATE TABLE t (a BIGINT, b VARCHAR(255), PRIMARY KEY(a) /*T![clustered_index] NONCLUSTERED */);
【看到的非预期行为】
使用上述两个语法创建非聚簇索引表,该表仍然创建出来仍然是个聚簇索引,不符合预期
mysql> CREATE TABLE t (a BIGINT PRIMARY KEY /*T![clustered_index] NONCLUSTERED */, b VARCHAR(255));
Query OK, 0 rows affected (0.52 sec)
mysql> show create table t;
+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| t | CREATE TABLE `t` (
`a` bigint(20) NOT NULL,
`b` varchar(255) DEFAULT NULL,
PRIMARY KEY (`a`) /*T![clustered_index] CLUSTERED */
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin |
+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.01 sec)
mysql> CREATE TABLE t2 (a BIGINT, b VARCHAR(255), PRIMARY KEY(a) /*T![clustered_index] NONCLUSTERED */);
Query OK, 0 rows affected (0.52 sec)
mysql> show create table t2;
+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| t2 | CREATE TABLE `t2` (
`a` bigint(20) NOT NULL,
`b` varchar(255) DEFAULT NULL,
PRIMARY KEY (`a`) /*T![clustered_index] CLUSTERED */
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin |
+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
【期望看到的行为】
创建出非聚簇索引表
【相关组件及具体版本】
测试了 v5.0.2 和 v5.0.3 都有这个表现,如下截图是 v5.0.3
【其他背景信息或者截图】
有关配置项和 system variables 如截图,使用默认值。集群是简单的三节点集群
mysql> SELECT @@global.tidb_enable_clustered_index;
+--------------------------------------+
| @@global.tidb_enable_clustered_index |
+--------------------------------------+
| INT_ONLY |
+--------------------------------------+
1 row in set (0.00 sec)
mysql> select * from information_schema.cluster_config where `key`='alter-primary-key';
+------+--------------------+-------------------+-------+
| TYPE | INSTANCE | KEY | VALUE |
+------+--------------------+-------------------+-------+
| tidb | 10.192.68.228:3306 | alter-primary-key | false |
| tidb | 10.192.68.220:3306 | alter-primary-key | false |
| tidb | 10.192.67.219:3306 | alter-primary-key | false |
+------+--------------------+-------------------+-------+
3 rows in set (0.03 sec)
如集群拓扑,系统和内核版本,应用 app 信息等;如果问题跟 SQL 有关,请提供 SQL 语句和相关表的 Schema 信息;如果节点日志存在关键报错,请提供相关节点的日志内容或文件;如果一些业务敏感信息不便提供,请留下联系方式,我们与您私下沟通。