summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Kosov <claprix@yandex.ru>2019-01-25 12:04:28 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2019-01-25 16:35:50 +0200
commit0e1f7f5c4a7eb90f345f2c2da6b4d7ce0b4056c4 (patch)
tree3306297d0edeee6e549bafcc160b28bba314c1a6
parent9bd80ada6facfb4ae3d159f3c924c1845c8d3481 (diff)
downloadmariadb-git-0e1f7f5c4a7eb90f345f2c2da6b4d7ce0b4056c4.tar.gz
MDEV-18057 Assertion `(node->state == 5) || (node->state == 6)' failed in row_upd_sec_step upon DELETE after UPDATE failed due to FK violation
The idea of the fix: reset state from previous query. row_upd_clust_step(): reset cached index before updating a clustered index Closes #1133
-rw-r--r--mysql-test/suite/versioning/r/foreign.result9
-rw-r--r--mysql-test/suite/versioning/t/foreign.test14
-rw-r--r--storage/innobase/row/row0upd.cc1
3 files changed, 24 insertions, 0 deletions
diff --git a/mysql-test/suite/versioning/r/foreign.result b/mysql-test/suite/versioning/r/foreign.result
index edf5632f027..a7a84f539bf 100644
--- a/mysql-test/suite/versioning/r/foreign.result
+++ b/mysql-test/suite/versioning/r/foreign.result
@@ -290,3 +290,12 @@ select count(*) from subchild;
count(*)
0
drop table subchild, child, parent;
+CREATE TABLE t1 (f1 INT, KEY(f1)) ENGINE=InnoDB;
+CREATE TABLE t2 (f2 INT, FOREIGN KEY (f2) REFERENCES t1 (f1)) ENGINE=InnoDB WITH SYSTEM VERSIONING;
+SET FOREIGN_KEY_CHECKS= OFF;
+INSERT IGNORE INTO t2 VALUES (1);
+SET FOREIGN_KEY_CHECKS= ON;
+UPDATE t2 SET f2= 2;
+ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`f2`) REFERENCES `t1` (`f1`))
+DELETE FROM t2;
+DROP TABLE t2, t1;
diff --git a/mysql-test/suite/versioning/t/foreign.test b/mysql-test/suite/versioning/t/foreign.test
index 566d481c2a8..075f15a216c 100644
--- a/mysql-test/suite/versioning/t/foreign.test
+++ b/mysql-test/suite/versioning/t/foreign.test
@@ -317,4 +317,18 @@ select count(*) from subchild;
drop table subchild, child, parent;
+CREATE TABLE t1 (f1 INT, KEY(f1)) ENGINE=InnoDB;
+CREATE TABLE t2 (f2 INT, FOREIGN KEY (f2) REFERENCES t1 (f1)) ENGINE=InnoDB WITH SYSTEM VERSIONING;
+
+SET FOREIGN_KEY_CHECKS= OFF;
+INSERT IGNORE INTO t2 VALUES (1);
+
+SET FOREIGN_KEY_CHECKS= ON;
+--error ER_NO_REFERENCED_ROW_2
+UPDATE t2 SET f2= 2;
+DELETE FROM t2;
+
+DROP TABLE t2, t1;
+
+
--source suite/versioning/common_finish.inc
diff --git a/storage/innobase/row/row0upd.cc b/storage/innobase/row/row0upd.cc
index 93a5d80035a..f9cb174088f 100644
--- a/storage/innobase/row/row0upd.cc
+++ b/storage/innobase/row/row0upd.cc
@@ -3200,6 +3200,7 @@ row_upd_clust_step(
if (node->cmpl_info & UPD_NODE_NO_ORD_CHANGE) {
+ node->index = NULL;
err = row_upd_clust_rec(
flags, node, index, offsets, &heap, thr, &mtr);
goto exit_func;