Bug #34456 Non-standard CONSTRAINT clause is accepted
Submitted: 11 Feb 2008 12:34 Modified: 12 Feb 2008 0:30
Reporter: Dmitry Lenev Email Updates:
Status: Won't fix Impact on me:
None 
Category:MySQL Server: Parser Severity:S3 (Non-critical)
Version:4.1, 5.0, 5.1 OS:Any
Assigned to: Marc ALFF CPU Architecture:Any

[11 Feb 2008 12:34] Dmitry Lenev
Description:
MySQL accepts CONSTRAINT clause with constraint name omitted in table and column constraint definitions in CREATE TABLE. This is documented as supported syntax at   http://dev.mysql.com/doc/refman/5.1/en/create-table.html but is not standard. It might cause problems if we will ever introduce in our grammar rule in which this clause will be followed by non-reserved word (currently in server and in the standard it can be followed only by FOREIGN, UNIQUE, PRIMARY, NOT, CHECK, which are all reserved).

How to repeat:
create table parent (pk int, constraint primary key (pk));
create table child (fk int, constraint foreign key (fk) references parent (pk));
[12 Feb 2008 0:30] Marc ALFF
After internal discussion, the decision is to support the
[CONSTRAINT [name]]
syntax.

No conflicts are anticipated in the parser,
and this syntax allows backward compatibility.