Bug #111714 Table constraint name ignored

Submitted: 11 Jul 2023 9:10 Modified: 11 Jul 2023 10:16
Reporter: Pedro Ferreira Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: DDL Severity:S3 (Non-critical)
Version:8.0.33 OS:Ubuntu (22.04)
Assigned to: CPU Architecture:x86 (x86_64)
Tags: primary key

[11 Jul 2023 9:10] Pedro Ferreira
Description:
Run these statements:

mysql> CREATE TABLE t0 (c1 INT, CONSTRAINT k0 PRIMARY KEY (c1));
Query OK, 0 rows affected (0,10 sec)
mysql> ALTER TABLE t0 DROP CONSTRAINT k0;
ERROR 3940 (HY000): Constraint 'k0' does not exist.

I am confused about the error message. I named the primary key 'k0'. From reading the manual I see every primary key is named "PRIMARY". Shouldn't the create table generate an error, or a warning at least?

How to repeat:
Run the statements above.
[11 Jul 2023 10:16] MySQL Verification Team
Hello Pedro Ferreira,

Thank you for the report and test case.

regards,
Umesh
[31 Mar 2025 19:00] Raj Padnani
Hello,

The name of the primary key is being silently ignored by MySQL. What's the reason for this and when will it be fixed?

Thanks.

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.040 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.