Bug #78255 | Foreign key allowed between InnoDB and MyISAM if "set foreign_key_checks=0" | ||
---|---|---|---|
Submitted: | 28 Aug 2015 8:37 | Modified: | 28 Aug 2015 14:07 |
Reporter: | Nick Moore | Email Updates: | |
Status: | Verified | Impact on me: | |
Category: | MySQL Server: InnoDB storage engine | Severity: | S3 (Non-critical) |
Version: | 5.6.24 (and earlier, too) | OS: | Any |
Assigned to: | CPU Architecture: | Any | |
Tags: | Foreign key constraint, innodb, myisam |
[28 Aug 2015 8:37]
Nick Moore
[28 Aug 2015 13:39]
MySQL Verification Team
Actually, this bug describes the expected behavior. But, I do think that a warning might be warranted. I also think that a warning is warranted for the situation, like in this test case: ------------------------------------------------- mysql 5.6 > USE test Database changed mysql 5.6 > set foreign_key_checks=0; Query OK, 0 rows affected (0.00 sec) mysql 5.6 > create table old_table ( id int) engine=innodb; Query OK, 0 rows affected (0.34 sec) mysql 5.6 > create table new_table ( -> id int(11) primary key, -> old_table_id int(11), -> foreign key (old_table_id) references old_table (id) -> ) engine=InnoDB; ERROR 1215 (HY000): Cannot add foreign key constraint mysql 5.6 > drop table old_table; Query OK, 0 rows affected (0.30 sec) mysql 5.6 > create table new_table ( -> id int(11) primary key, -> old_table_id int(11), -> foreign key (old_table_id) references old_table (id) -> ) engine=InnoDB; Query OK, 0 rows affected (0.38 sec) ------------------------------------------------- So, we have two situations which would require warnings. In essence this is a verified bug that is requesting two different warnings, for two similar cases.
[28 Aug 2015 14:07]
Nick Moore
G'day Sinisa, Yeah, I can see how in the MyISAM -> MyISAM case that silently ignoring the foreign key declaration makes sense ... I've never liked it as a decision, but so it goes. You can still add data to the tables just without the benefit of foreign key checks. But in the InnoDB -> MyISAM case, the table is left in an uninsertable state with no warnings or errors at schema definition time. It seems to me that if it is an error to try to define a InnoDB foreign key which references a non-indexed column, or a column of the wrong data type, then it should be an error to try to define a InnoDB foreign key which references a MyISAM table too. It won't work, so it should tell the user that as soon as possible. Thanks for having a look at it! Nick
[28 Aug 2015 14:35]
MySQL Verification Team
That information is added to the relevant database.