Bug #92242 create table with primary key ,allow use index name,but it not real used
Submitted: 30 Aug 2018 9:44 Modified: 30 Aug 2018 11:29
Reporter: Wei Liu Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: Parser Severity:S3 (Non-critical)
Version: OS:Any
Assigned to: CPU Architecture:Any

[30 Aug 2018 9:44] Wei Liu
Description:
mysql> create table x(id int ,PRIMARY KEY  PK_COUPON_ACCESS_201805                (ID));
Query OK, 0 rows affected (0.06 sec)

mysql> show create table x;
+-------+-------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                          |
+-------+-------------------------------------------------------------------------------------------------------+
| x     | CREATE TABLE `x` (
  `id` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 |
+-------+-------------------------------------------------------------------------------------------------------+
1 row in set (0.03 sec)

mysql> show index from x\G
*************************** 1. row ***************************
        Table: x
   Non_unique: 0
     Key_name: PRIMARY
 Seq_in_index: 1
  Column_name: id
    Collation: A
  Cardinality: 0
     Sub_part: NULL
       Packed: NULL
         Null:
   Index_type: BTREE
      Comment:
Index_comment:
1 row in set (0.03 sec)

How to repeat:
as description

mysql> create table x(id int ,PRIMARY KEY  PK_COUPON_ACCESS_201805                (ID));
Query OK, 0 rows affected (0.06 sec)

mysql> show create table x;
+-------+-------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                          |
+-------+-------------------------------------------------------------------------------------------------------+
| x     | CREATE TABLE `x` (
  `id` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 |
+-------+-------------------------------------------------------------------------------------------------------+
1 row in set (0.03 sec)

mysql> show index from x\G
*************************** 1. row ***************************
        Table: x
   Non_unique: 0
     Key_name: PRIMARY
 Seq_in_index: 1
  Column_name: id
    Collation: A
  Cardinality: 0
     Sub_part: NULL
       Packed: NULL
         Null:
   Index_type: BTREE
      Comment:
Index_comment:
1 row in set (0.03 sec)

Suggested fix:
make this sql syntax failed for use index name on a primary key

or

use the name as key name
[30 Aug 2018 11:29] MySQL Verification Team
Hello Wei Liu,

Thank you for the report.
Imho key name is ignored here, and this is most likely duplicate of our Shane's Bug #47771 where such "parser" issues are tracked.

Also, please see Bug #1956

Thanks,
Umesh