Skip to content

create table for invisible unique key with auto_increment should have same behavior with it's show create tables #28093

@aytrack

Description

@aytrack

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

create table t0(a int auto_increment, unique key (a) invisible);
show create table t0;
CREATE TABLE `t1` (  `a` int(11) NOT NULL AUTO_INCREMENT,  UNIQUE KEY `a` (`a`) /*!80000 INVISIBLE */) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;

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

mysql> create table t0(a int auto_increment, unique key (a) invisible);
ERROR 3522 (HY000): A primary key index cannot be invisible

the sql of create table t0 should have same behavior with show create table result.

3. What did you see instead (Required)

MySQL root@127.0.0.1:test> create table t0(a int auto_increment, unique key (a) invisible);
                       ->  show create table t0;
                       ->  CREATE TABLE `t1` (  `a` int(11) NOT NULL AUTO_INCREMENT,  UNIQUE KEY `a` (`a`) /*!80000 INVISIBLE */) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
Query OK, 0 rows affected
Time: 0.145s

+-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                                                                                           |
+-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| t0    | CREATE TABLE `t0` (\n  `a` int(11) NOT NULL AUTO_INCREMENT,\n  UNIQUE KEY `a` (`a`) /*!80000 INVISIBLE */\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin |
+-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

1 row in set
Time: 0.010s
(3522, 'A primary key index cannot be invisible')

4. What is your TiDB version? (Required)

master( 6ebfe8a)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions