Bug #64601 | Error when creating foreign keys | ||
---|---|---|---|
Submitted: | 9 Mar 2012 16:24 | Modified: | 13 Sep 2012 19:41 |
Reporter: | Aur?lien Vairet | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Workbench: SQL Editor | Severity: | S1 (Critical) |
Version: | 5.2.38 | OS: | Any (Microsoft Windows XP Professional Service Pack 3 (build 2600), Mac OS X) |
Assigned to: | CPU Architecture: | Any | |
Tags: | WBBugReporter |
[9 Mar 2012 16:24]
Aur?lien Vairet
[14 Mar 2012 15:36]
Valeriy Kravchuk
Thank you for the bug report. I've got this eventually: ERROR 1005: Can't create table 'test.#sql-7267_11' (errno: 150) SQL Statement: ALTER TABLE `test`.`r` ADD CONSTRAINT `fk` FOREIGN KEY (`a_id` ) REFERENCES `test`.`a` (`id` , `id` ) ON DELETE NO ACTION ON UPDATE NO ACTION , DROP PRIMARY KEY , ADD PRIMARY KEY (`a_id`) ERROR: Error when running failback script. Details follow. ERROR 1050: Table 'r' already exists SQL Statement: CREATE TABLE `r` ( `id` int(11) NOT NULL, `a_id` int(11) DEFAULT NULL, PRIMARY KEY (`id`), KEY `fk` (`a_id`), CONSTRAINT `fk` FOREIGN KEY (`a_id`) REFERENCES `a` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION ) ENGINE=InnoDB DEFAULT CHARSET=latin1 with 5.2.38 on Mac OS X, while tried to add FK for a second time when I saw that no columns are selected for FK in GUI. So, looks like we have a bug in fallback script generated at least. No need to CREATE TABLE after whatever wrong ALTER that ended with error.
[21 Mar 2012 16:13]
Joaquin Barcelo Martinez
This error appears beacause in the generated script, mysql workbench uses the same name for the constraint and for the index related to this foreign key. The solution is to rename manualy in the script the connstraint or the index before submit.
[13 Sep 2012 19:41]
Philip Olson
This has been fixed. This bug report was documented with MySQL Bug #66285 (Oracle Bug #14486006).