Drizzledump not preserving FOREIGN KEY information during migration from MySQL

Bug #683940 reported by Patrick Crews
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Drizzle
Fix Released
Medium
Andrew Hutchings
7.0
Fix Released
Medium
Andrew Hutchings

Bug Description

This MySQL table:
CREATE TABLE t2(a INT NOT NULL, b INT , PRIMARY KEY(a), KEY b_key (b),
CONSTRAINT fk_constraint_t2 FOREIGN KEY (b) REFERENCES t1(b)
ON DELETE SET NULL
ON UPDATE CASCADE) ENGINE=Innodb;

Ends up as this in Drizzle post-migration:
SHOW CREATE TABLE drizzledump_migrate_test.t2;
Table Create Table
t2 CREATE TABLE `t2` (
  `a` INT NOT NULL,
  `b` INT DEFAULT NULL,
  PRIMARY KEY (`a`),
  KEY `b_key` (`b`)
) ENGINE=InnoDB COLLATE = utf8_general_ci

To repeat:
./test-run --suite=mysql_migrate foreign_key
The .result file is incorrect at the moment.

Please check the README file in the drizzle/tests/mysql_migrate directory for setup instructions.

Related branches

Changed in drizzle:
status: New → Confirmed
assignee: nobody → Andrew Hutchings (linuxjedi)
Revision history for this message
Andrew Hutchings (linuxjedi) wrote :

ok, this is bad as I added support for this not too long ago :/

Revision history for this message
Andrew Hutchings (linuxjedi) wrote :

Something is wrong with this query around the last where condition for this foreign key (other test ones from the MySQL manual still work):

select rc.constraint_name, rc.referenced_table_name, group_concat(distinct concat('`',kc.column_name,'`')), rc.update_rule, rc.delete_rule, rc.match_option, group_concat(distinct concat('`',kt.column_name,'`')) from information_schema.referential_constraints rc join information_schema.key_column_usage kt on (rc.constraint_schema = kt.constraint_schema and rc.constraint_name = kt.constraint_name) join information_schema.key_column_usage kc on (rc.constraint_schema = kc.constraint_schema and rc.referenced_table_name = kc.table_name and rc.unique_constraint_name = kc.constraint_name) where rc.constraint_schema='SCHEMA' and rc.table_name='TABLE' group by rc.constraint_name

So headaches ahoy!

Revision history for this message
Andrew Hutchings (linuxjedi) wrote :

See also http://bugs.mysql.com/bug.php?id=58656 <- this is the way I wanted to do it

Revision history for this message
Andrew Hutchings (linuxjedi) wrote :

testing this one:

select kc.constraint_name, kc.table_name, group_concat(distinct concat('`',kc.column_name,'`')), kc.referenced_table_name, group_concat(distinct concat('`',kc.referenced_column_name,'`')), update_rule, delete_rule, match_option from information_schema.key_column_usage kc join information_schema.referential_constraints rc on (rc.constraint_schema = kc.constraint_schema and rc.constraint_name = kc.constraint_name) where kc.referenced_table_name is not null group by rc.constraint_name\G

Revision history for this message
Andrew Hutchings (linuxjedi) wrote :

This query hits this in MySQL 5.5:
http://bugs.mysql.com/?id=58658

Also in Leithal's words "it performs like ass".

Switching to a regex on SHOW CREATE TABLE

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.