summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
authorDaniele Sciascia <daniele.sciascia@galeracluster.com>2016-06-20 14:35:22 +0200
committerNirbhay Choubey <nirbhay@mariadb.com>2016-08-21 16:17:16 -0400
commitdfa9012abbaaec15e99e3fb8cbe3c90cf6dc8e3b (patch)
treeba484cdb3565387d3214ac66b3ea9164e7769ff2 /mysql-test
parentc9ac48f8451d213cdf7fd4cee091025846306526 (diff)
downloadmariadb-git-dfa9012abbaaec15e99e3fb8cbe3c90cf6dc8e3b.tar.gz
MW-285 MTR test case for broken foreign key constraints
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/suite/galera/r/MW-285.result19
-rw-r--r--mysql-test/suite/galera/t/MW-285.test31
2 files changed, 50 insertions, 0 deletions
diff --git a/mysql-test/suite/galera/r/MW-285.result b/mysql-test/suite/galera/r/MW-285.result
new file mode 100644
index 00000000000..8c5a21fcbee
--- /dev/null
+++ b/mysql-test/suite/galera/r/MW-285.result
@@ -0,0 +1,19 @@
+CREATE TABLE parent1 ( id INT PRIMARY KEY, KEY (id) ) ENGINE=InnoDB;
+CREATE TABLE parent2 ( id INT PRIMARY KEY, KEY (id) ) ENGINE=InnoDB;
+CREATE TABLE child (
+id INT PRIMARY KEY,
+parent1_id INT,
+parent2_id INT,
+FOREIGN KEY (parent1_id) REFERENCES parent1(id),
+FOREIGN KEY (parent1_id) REFERENCES parent2(id)
+) ENGINE=InnoDB;
+INSERT INTO parent1 VALUES (1);
+INSERT INTO parent2 VALUES (1);
+INSERT INTO child VALUES (1,1,1);
+INSERT INTO child VALUES (2,1,1);
+SET foreign_key_checks=OFF;
+DROP TABLE parent1;
+UPDATE child SET parent1_id=2 WHERE id=1;
+DROP TABLE child;
+DROP TABLE parent2;
+SET foreign_key_checks=ON;
diff --git a/mysql-test/suite/galera/t/MW-285.test b/mysql-test/suite/galera/t/MW-285.test
new file mode 100644
index 00000000000..1c567f7b250
--- /dev/null
+++ b/mysql-test/suite/galera/t/MW-285.test
@@ -0,0 +1,31 @@
+#
+# Broken FK constraints cause assertions
+#
+
+--source include/galera_cluster.inc
+--source include/have_innodb.inc
+
+CREATE TABLE parent1 ( id INT PRIMARY KEY, KEY (id) ) ENGINE=InnoDB;
+CREATE TABLE parent2 ( id INT PRIMARY KEY, KEY (id) ) ENGINE=InnoDB;
+
+CREATE TABLE child (
+ id INT PRIMARY KEY,
+ parent1_id INT,
+ parent2_id INT,
+ FOREIGN KEY (parent1_id) REFERENCES parent1(id),
+ FOREIGN KEY (parent1_id) REFERENCES parent2(id)
+) ENGINE=InnoDB;
+
+INSERT INTO parent1 VALUES (1);
+INSERT INTO parent2 VALUES (1);
+INSERT INTO child VALUES (1,1,1);
+INSERT INTO child VALUES (2,1,1);
+
+SET foreign_key_checks=OFF;
+DROP TABLE parent1;
+
+UPDATE child SET parent1_id=2 WHERE id=1;
+
+DROP TABLE child;
+DROP TABLE parent2;
+SET foreign_key_checks=ON;