summaryrefslogtreecommitdiff
path: root/mysql-test/suite/innodb/t/foreign_key.test
diff options
context:
space:
mode:
Diffstat (limited to 'mysql-test/suite/innodb/t/foreign_key.test')
-rw-r--r--mysql-test/suite/innodb/t/foreign_key.test24
1 files changed, 24 insertions, 0 deletions
diff --git a/mysql-test/suite/innodb/t/foreign_key.test b/mysql-test/suite/innodb/t/foreign_key.test
index b586f3e9406..7a8a9295ee7 100644
--- a/mysql-test/suite/innodb/t/foreign_key.test
+++ b/mysql-test/suite/innodb/t/foreign_key.test
@@ -289,3 +289,27 @@ insert into t2(f1) values(1);
drop table t2, t1;
--source include/wait_until_count_sessions.inc
+
+#
+# MDEV-12669 Circular foreign keys cause a loop and OOM upon LOCK TABLE
+#
+SET FOREIGN_KEY_CHECKS=0;
+CREATE TABLE staff (
+ staff_id TINYINT UNSIGNED NOT NULL AUTO_INCREMENT,
+ store_id TINYINT UNSIGNED NOT NULL,
+ PRIMARY KEY (staff_id),
+ KEY idx_fk_store_id (store_id),
+ CONSTRAINT fk_staff_store FOREIGN KEY (store_id) REFERENCES store (store_id) ON DELETE RESTRICT ON UPDATE CASCADE
+) ENGINE=InnoDB;
+CREATE TABLE store (
+ store_id TINYINT UNSIGNED NOT NULL AUTO_INCREMENT,
+ manager_staff_id TINYINT UNSIGNED NOT NULL,
+ PRIMARY KEY (store_id),
+ UNIQUE KEY idx_unique_manager (manager_staff_id),
+ CONSTRAINT fk_store_staff FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id) ON DELETE RESTRICT ON UPDATE CASCADE
+) ENGINE=InnoDB;
+SET FOREIGN_KEY_CHECKS=DEFAULT;
+
+LOCK TABLE staff WRITE;
+UNLOCK TABLES;
+DROP TABLES staff, store;