Bug #31456 | Foreign keys (with InnoDB) aren't working (multiple problems) | ||
---|---|---|---|
Submitted: | 8 Oct 2007 15:43 | Modified: | 10 Oct 2007 12:05 |
Reporter: | Dmitry Tkach | Email Updates: | |
Status: | Duplicate | Impact on me: | |
Category: | MySQL Server: InnoDB storage engine | Severity: | S4 (Feature request) |
Version: | 5.0.45/4.1 | OS: | Any |
Assigned to: | Assigned Account | CPU Architecture: | Any |
[8 Oct 2007 15:43]
Dmitry Tkach
[8 Oct 2007 16:52]
MySQL Verification Team
Thank you for the bug report. I was not able to repeat with current source server: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.1.23-beta-debug Source distribution Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> create table x (a int primary key) engine innodb; Query OK, 0 rows affected (0.01 sec) mysql> create table y (b int references x) engine innodb; Query OK, 0 rows affected (0.01 sec) mysql> show create table y\G *************************** 1. row *************************** Table: y Create Table: CREATE TABLE `y` ( `b` int(11) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 1 row in set (0.00 sec) mysql> alter table y add foreign key (b) references x(a); Query OK, 0 rows affected (0.01 sec) Records: 0 Duplicates: 0 Warnings: 0 mysql> show create table y\G *************************** 1. row *************************** Table: y Create Table: CREATE TABLE `y` ( `b` int(11) DEFAULT NULL, KEY `b` (`b`), CONSTRAINT `y_ibfk_1` FOREIGN KEY (`b`) REFERENCES `x` (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 1 row in set (0.00 sec) mysql>
[8 Oct 2007 22:52]
Dmitry Tkach
mysql> create table y (b int references x) engine innodb; Query OK, 0 rows affected (0.01 sec) mysql> show create table y\G *************************** 1. row *************************** Table: y Create Table: CREATE TABLE `y` ( `b` int(11) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 1 row in set (0.00 sec) So, it seems that it happily and silently ignored the FK given with the table definition ... Looks like you very well CAN reproduce it :-)
[9 Oct 2007 0:34]
MySQL Verification Team
Thank you for the feedback. Yes at least that should be documented or fixed. mysql> create table y (b int references x) engine innodb; Query OK, 0 rows affected (0.01 sec) mysql> show create table y\G *************************** 1. row *************************** Table: y Create Table: CREATE TABLE `y` ( `b` int(11) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 1 row in set (0.00 sec)
[10 Oct 2007 12:05]
Heikki Tuuri
This is a feature request that is already filed at bugs.mysql.com.
[12 Aug 2011 14:01]
Morg. What?
This seems to not be fixed as of version 5.5.8, is that correct ?