Bug #26304 Inconsistently processed REFERENCES in column and in separate FK def
Submitted: 13 Feb 2007 0:06 Modified: 13 Feb 2007 0:26
Reporter: Alex Rytov Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: Parser Severity:S3 (Non-critical)
Version:5.1.15 OS:
Assigned to: CPU Architecture:Any
Tags: foreign key, references

[13 Feb 2007 0:06] Alex Rytov
Description:
In a table definition, a REFERENCES clause after a column is supposed to be exactly equivalent to a separate FOREIGN KEY definition.  However, in mySQL the former is ignored, while the latter does make an FK (on a suitable storage engine).  

Is this behaviour by design or is it a bug?  If this distinction is on purpose, please consider this report a feature request to make both the column-level REFERENCES and the FK-level one work the same way.

How to repeat:
Consider the following two tables:

create table t(
  i int not null key,
  j int references t(i)
) engine innodb;

and then:

create table t1(
  i int not null key,
  j int,
  foreign key (j) references t1(i)
) engine innodb;

now see what happens:

SELECT * FROM information_schema.TABLE_CONSTRAINTS T;

table T will only have a PK, while T1 has both the PK and the self-referencing FK.
[13 Feb 2007 0:23] Roland Bouman
this is a duplicate of http://bugs.mysql.com/bug.php?id=17943
[13 Feb 2007 0:26] Roland Bouman
Thank you for your bug report! An identical bug has already been reported and filed as bug #17943