Bug #38585 | Foreign key constraint for column in same table fails on delete when same row | ||
---|---|---|---|
Submitted: | 5 Aug 2008 22:01 | Modified: | 16 Oct 2008 3:48 |
Reporter: | Tim Faust | Email Updates: | |
Status: | Verified | Impact on me: | |
Category: | MySQL Server | Severity: | S3 (Non-critical) |
Version: | 6.0.5 alpha | OS: | Windows (Vista) |
Assigned to: | CPU Architecture: | Any | |
Tags: | foreign key |
[5 Aug 2008 22:01]
Tim Faust
[6 Aug 2008 3:15]
Valeriy Kravchuk
This is a documented limitation. Read http://dev.mysql.com/doc/refman/6.0/en/innodb-foreign-key-constraints.html: "Deviation from SQL standards: Like MySQL in general, in an SQL statement that inserts, deletes, or updates many rows, InnoDB checks UNIQUE and FOREIGN KEY constraints row-by-row. According to the SQL standard, the default behavior should be deferred checking. That is, constraints are only checked after the entire SQL statement has been processed. Until InnoDB implements deferred constraint checking, some things will be impossible, such as deleting a record that refers to itself via a foreign key."
[6 Aug 2008 16:02]
Tim Faust
Thansk, I missed that in the documentation. I'll implement my work around. Feel free to close if you prefer that to "To be fixed later"