Bug #63050 | Workbench dies in Ubuntu when opening foreign keys tab | ||
---|---|---|---|
Submitted: | 31 Oct 2011 21:12 | Modified: | 8 Feb 2012 23:30 |
Reporter: | Mike Bates | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Workbench: SQL Editor | Severity: | S1 (Critical) |
Version: | 5.2.35 | OS: | Linux (Ubuntu 11.04 64bit) |
Assigned to: | CPU Architecture: | Any |
[31 Oct 2011 21:12]
Mike Bates
[1 Nov 2011 10:11]
MySQL Verification Team
Thank you for the bug report. Could you please provide the create table statement which cause the behavior reported?. Thanks in advance.
[1 Nov 2011 17:32]
Mike Bates
Is there a way to switch workbench into debug mode so I can get more info on what's happening? Here are 2 of the tables that have the problem: CREATE TABLE `inventory_checks` ( `id` int(11) NOT NULL AUTO_INCREMENT, `consignment_hospital_id` int(11) NOT NULL, `consignment_account_number` varchar(45) NOT NULL, `date` date NOT NULL, PRIMARY KEY (`id`), KEY `fk_inventory_checks_consignment_account_number` (`consignment_account_number`), CONSTRAINT `fk_inventory_checks_consignment_account_number` FOREIGN KEY (`consignment_account_number`) REFERENCES `consignment_hospitals` (`account_number`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8; CREATE TABLE `consignment_hospitals_products` ( `id` int(11) NOT NULL AUTO_INCREMENT, `consignment_hospital_id` int(11) NOT NULL, `consignment_account_number` varchar(45) NOT NULL, `consignment_product_id` int(11) NOT NULL, `consignment_product_number` varchar(45) NOT NULL, `quantity` int(11) NOT NULL, `account_price` double DEFAULT NULL, `active` tinyint(1) NOT NULL DEFAULT '1', `created` datetime DEFAULT NULL, `modified` datetime DEFAULT NULL, PRIMARY KEY (`id`), KEY `idx_quantity` (`quantity`), KEY `idx_account_price` (`account_price`), KEY `idx_active` (`active`), KEY `fk_consignment_hospitals_products_consignment_account_number` (`consignment_account_number`), KEY `fk_consignment_hospitals_products_consignment_productt_number` (`consignment_product_number`), CONSTRAINT `fk_consignment_hospitals_products_consignment_account_number` FOREIGN KEY (`consignment_account_number`) REFERENCES `consignment_hospitals` (`account_number`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `fk_consignment_hospitals_products_consignment_productt_number` FOREIGN KEY (`consignment_product_number`) REFERENCES `consignment_products` (`product_number`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB AUTO_INCREMENT=385527 DEFAULT CHARSET=utf8; They both have a foreign key constraint to this table, could it be something to do with the PK being a varchar(45) instead of the more usual int(11)? delimiter $$ CREATE TABLE `consignment_hospitals` ( `account_number` varchar(45) NOT NULL, `distribution_centre_id` int(11) NOT NULL, `consignment_hospital_group_id` int(11) DEFAULT NULL, `name` varchar(90) NOT NULL, `active` tinyint(1) NOT NULL, `created` datetime DEFAULT NULL, `modified` datetime DEFAULT NULL, PRIMARY KEY (`account_number`), KEY `idx_name` (`name`), KEY `idx_active` (`active`), KEY `fk_consignment_hospitals_distribution_center_id` (`distribution_centre_id`), KEY `fk_consignment_hospitals_consignment_hospital_group_id` (`consignment_hospital_group_id`), CONSTRAINT `fk_consignment_hospitals_consignment_hospital_group_id` FOREIGN KEY (`consignment_hospital_group_id`) REFERENCES `consignment_hospital_groups` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_consignment_hospitals_distribution_center_id` FOREIGN KEY (`distribution_centre_id`) REFERENCES `opskwan`.`distribution_centres` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION ) ENGINE=InnoDB DEFAULT CHARSET=utf8$$
[2 Nov 2011 1:11]
Alfredo Kojima
I can't import the tables because of missing referenced tables and I'm afraid just removing the FKs will cause the error to not trigger anymore. Could you upload the whole schema or at least all involved tables?
[3 Nov 2011 17:56]
Mike Bates
I may have found what's causing the problem. There are 2 databases, a few tables have FK Constraint to tables in the other database. When I 'Alter Table...' on any table that has a FK Constraint to a table in it's own database, that in turn has a FK Constraint to a table in another database. Workbench will die when I click on the 'Foreign Keys' tab. Also, if you try and use workbench to setup a FK Contraint to a table that already has a FK Constriant to a table in another database, workbench will die. To recreate this: open 'Alter Table...' click on the Foreign Keys tab add a new key, use whatever name you want click on the Reference Table cell, and select the 'offending' table from the drop down Here is the schema from 2 simple databases that exhibit this behavior. `database_two`.`alpha` has an FK Contraint to `database_one`.`one` `database_two`.`bravo` has an FK Contraint to `database_two`.`alpha` and the FK tab kills workbench `database_two`.`charlie` has an FK Contraint to `database_two`.`bravo` and the FK tab opens okay. here is the workbench export CREATE DATABASE IF NOT EXISTS `database_one` /*!40100 DEFAULT CHARACTER SET utf8 */; USE `database_one`; -- MySQL dump 10.13 Distrib 5.1.54, for debian-linux-gnu (x86_64) -- -- Host: 127.0.0.1 Database: database_one -- ------------------------------------------------------ -- Server version 5.1.54-1ubuntu4 /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8 */; /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; /*!40103 SET TIME_ZONE='+00:00' */; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; -- -- Table structure for table `one` -- DROP TABLE IF EXISTS `one`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `one` ( `id` varchar(45) NOT NULL, `name` varchar(45) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Table structure for table `three` -- DROP TABLE IF EXISTS `three`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `three` ( `id` varchar(45) NOT NULL, `name` varchar(45) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Table structure for table `two` -- DROP TABLE IF EXISTS `two`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `two` ( `id` varchar(45) NOT NULL, `name` varchar(45) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; -- Dump completed on 2011-11-03 10:52:44 CREATE DATABASE IF NOT EXISTS `database_two` /*!40100 DEFAULT CHARACTER SET utf8 */; USE `database_two`; -- MySQL dump 10.13 Distrib 5.1.54, for debian-linux-gnu (x86_64) -- -- Host: 127.0.0.1 Database: database_two -- ------------------------------------------------------ -- Server version 5.1.54-1ubuntu4 /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8 */; /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; /*!40103 SET TIME_ZONE='+00:00' */; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; -- -- Table structure for table `bravo` -- DROP TABLE IF EXISTS `bravo`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `bravo` ( `id` int(11) NOT NULL, `name` varchar(45) NOT NULL, `alpha_id` int(11) NOT NULL, PRIMARY KEY (`id`), KEY `fk_bravo_alpha_id` (`alpha_id`), CONSTRAINT `fk_bravo_alpha_id` FOREIGN KEY (`alpha_id`) REFERENCES `alpha` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Table structure for table `alpha` -- DROP TABLE IF EXISTS `alpha`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `alpha` ( `id` int(11) NOT NULL, `name` varchar(45) NOT NULL, `one_id` varchar(45) NOT NULL, PRIMARY KEY (`id`), KEY `fk_alpha_one_id` (`one_id`), CONSTRAINT `fk_alpha_one_id` FOREIGN KEY (`one_id`) REFERENCES `database_one`.`one` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Table structure for table `charlie` -- DROP TABLE IF EXISTS `charlie`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `charlie` ( `id` int(11) NOT NULL, `name` varchar(45) NOT NULL, `bravo_id` int(11) NOT NULL, PRIMARY KEY (`id`), KEY `fk_charlie_bravo_id` (`bravo_id`), CONSTRAINT `fk_charlie_bravo_id` FOREIGN KEY (`bravo_id`) REFERENCES `bravo` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; -- Dump completed on 2011-11-03 10:52:44
[12 Dec 2011 21:21]
Armando Lopez Valencia
Thanks a lot for your report Mike.
[8 Feb 2012 23:30]
Philip Olson
Fixed as of 5.2.38: Clicking the foreign keys tab within the "Alter table" context could crash Workbench.