summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2017-09-15 15:02:24 +0200
committerSergei Golubchik <serg@mariadb.org>2017-09-18 10:12:23 +0200
commit50a8beedfe59f97d381e8f506344a6197b8b5702 (patch)
treec52e423a0d609824b469658645c4a38d67376e1a /mysql-test
parentfb2035a1a37bb3dfe8311e0bb2b9d474837c035c (diff)
downloadmariadb-git-50a8beedfe59f97d381e8f506344a6197b8b5702.tar.gz
MDEV-13708 Crash with indexed virtual columns and FK cascading deletes
InnoDB was too eager to forget the open table (m_mysql_table=NULL) and that caused it to try to open a table which was opened by the user not FK-prelocked. The server didn't expect that. After fixing this, it crashed in gcol.innodb_virtual_fk test, trying to compute virtual columns for a table that didn't have them. Because row_upd_store_row() was deleting a row from node->table, while computing virtual columns in thr->prebuilt->m_mysql_table. Which wasn't necessarily the same table, and might've not even had virtual columns, even if node->table did.
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/suite/vcol/r/innodb_virtual_fk.result12
-rw-r--r--mysql-test/suite/vcol/t/innodb_virtual_fk.test16
2 files changed, 28 insertions, 0 deletions
diff --git a/mysql-test/suite/vcol/r/innodb_virtual_fk.result b/mysql-test/suite/vcol/r/innodb_virtual_fk.result
new file mode 100644
index 00000000000..58db12583e2
--- /dev/null
+++ b/mysql-test/suite/vcol/r/innodb_virtual_fk.result
@@ -0,0 +1,12 @@
+set default_storage_engine=innodb;
+create table t1 (id int primary key, id2 int as (id) virtual, key id2 (id2));
+create table t2 (id int key, constraint fk_id foreign key (id) references t1 (id) on delete cascade);
+insert into t1 (id) values (1), (2);
+insert into t2 (id) values (1), (2);
+delete from t1;
+select * from t1;
+id id2
+select * from t2;
+id
+drop table t2;
+drop table t1;
diff --git a/mysql-test/suite/vcol/t/innodb_virtual_fk.test b/mysql-test/suite/vcol/t/innodb_virtual_fk.test
new file mode 100644
index 00000000000..c364adaa613
--- /dev/null
+++ b/mysql-test/suite/vcol/t/innodb_virtual_fk.test
@@ -0,0 +1,16 @@
+source include/have_innodb.inc;
+set default_storage_engine=innodb;
+
+#
+# MDEV-13708 Crash with indexed virtual columns and FK cascading deletes
+#
+
+create table t1 (id int primary key, id2 int as (id) virtual, key id2 (id2));
+create table t2 (id int key, constraint fk_id foreign key (id) references t1 (id) on delete cascade);
+insert into t1 (id) values (1), (2);
+insert into t2 (id) values (1), (2);
+delete from t1;
+select * from t1;
+select * from t2;
+drop table t2;
+drop table t1;