Bug #1956 Parser allows naming of PRIMARY KEY
Submitted: 25 Nov 2003 17:23 Modified: 27 Sep 2008 11:31
Reporter: Arjen Lentz
Status: Verified
Category:Server: Parser Severity:S3 (Non-critical)
Version:4.0.12,4.1.0 OS:Any (Any)
Assigned to: Target Version:
Triage: Triaged: D4 (Minor)

[25 Nov 2003 17:23] Arjen Lentz
Description:
When specifying a PRIMARY KEY, the parser still accepts a name for the index even though
the MySQL server will always name it PRIMARY.
So, the parser should NOT accept this, otherwise a user can get into a confusing
situation as his input is ignored/changed.

How to repeat:
CREATE TABLE pk (i INT NOT NULL);
ALTER TABLE ADD PRIMARY KEY bla (i);

'bla' after PRIMARY KEY should not be accepted.

Suggested fix:
Fix grammar in parser.
[26 Nov 2003 3:45] [ name withheld ]
>'bla' after PRIMARY KEY should not be accepted.

Or, rather, only 'PRIMARY' should be. This sould help dumps, shouldn't it ?

Reciprocally, no other index should be named as 'PRIMARY'.
[13 Dec 2003 19:45] Michael Widenius
This will be fixed in the new parser in MySQL 5.0
[27 Sep 2008 11:31] Konstantin Osipov
Verified against 5.1.29.
There is no reason to accept broken syntax.
Should be checked with the standard, and either documented or fixed.