Bug #45290 | Cant convert innodb tables from latin1 to utf8 if there is a varchar foreign key | ||
---|---|---|---|
Submitted: | 3 Jun 2009 9:35 | Modified: | 3 Jun 2009 12:54 |
Reporter: | James b | Email Updates: | |
Status: | Verified | Impact on me: | |
Category: | MySQL Server | Severity: | S1 (Critical) |
Version: | 5.0.75-0ubuntu10.2, 4.1, 5.0, 5.1, 6.0 bzr | OS: | Other (Ubuntu) |
Assigned to: | CPU Architecture: | Any |
[3 Jun 2009 9:35]
James b
[3 Jun 2009 9:39]
James b
Oh yes, and can I put in a general request for more informative innodb error messages please? Thank you!
[3 Jun 2009 10:00]
Sveta Smirnova
Thank you for the report. This is expected, because "parent" and "child" columns have different collation, so they can not be linked as foreign keys. Current workaround is: SET foreign_key_checks = 0; convert SET foreign_key_checks = 1; But you are right, it is not very convenient. So this problem can have potential resolution: change ALTER command, so it allows change both columns. Regarding to the error message I believe we have such a feature request already.
[3 Jun 2009 10:05]
Sveta Smirnova
Bug #24773 is feature request about error messages which I mentioned in previous comment.
[3 Jun 2009 12:54]
James b
Ok, that makes sense and the work around is OK for us. Thanks.
[12 Nov 2014 11:53]
Daniƫl van Eeden
Also affects 5.6
[17 Aug 2015 16:46]
Daniel Price
Posted by developer: The following content has been added to the ALTER TABLE documentation: https://dev.mysql.com/doc/refman/5.6/en/alter-table.html When foreign_key_checks is enabled, which is the default setting, character set conversion is not permitted on tables that include a character string column used in a foreign key constraint. The workaround is to disable foreign_key_checks before performing the character set conversion. You must perform the conversion on both tables involved in the foreign key constraint before re-enabling foreign_key_checks. If you re-enable foreign_key_checks after converting only one of the tables, an ON DELETE CASCADE or ON UPDATE CASCADE operation could corrupt data in the referencing table due to implicit conversion that occurs during these operations (Bug #45290, Bug #74816).