From 9bcd0f5fea8ca26742b10d37b95a966c69909ff1 Mon Sep 17 00:00:00 2001 From: Igor Babaev Date: Mon, 7 May 2018 13:22:00 -0700 Subject: [PATCH 1/2] Added the test case from MDEV-16086 tfixed by the patch for MDEV-15575 --- mysql-test/r/cte_recursive.result | 32 +++++++++++++++++++++++++++++++ mysql-test/t/cte_recursive.test | 32 +++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) diff --git a/mysql-test/r/cte_recursive.result b/mysql-test/r/cte_recursive.result index 70752c7200c..d6dfdf1ec6a 100644 --- a/mysql-test/r/cte_recursive.result +++ b/mysql-test/r/cte_recursive.result @@ -3201,3 +3201,35 @@ a 1 3 drop table t1; +# +# MDEV-16086: tmp table for CTE is created as ARIA tables +# +CREATE TABLE t1 ( +Id int(11) not null AUTO_INCREMENT, +Parent varchar(15) not null, +Child varchar(15) not null, +PRIMARY KEY (Id) +) ENGINE = MyISAM; +INSERT INTO t1 (Parent, Child) VALUES +('123', '456'),('456', '789'),('321', '654'),('654', '987'); +WITH RECURSIVE cte AS +( SELECT b.Parent, +b.Child, +CAST(CONCAT(b.Child,',') AS CHAR(513)) Path +FROM t1 b +LEFT OUTER JOIN t1 bc ON b.Child = bc.Parent +WHERE bc.Id IS NULL +UNION ALL SELECT c.Parent, +c.Child, +CONCAT(p.Path,c.Child,',') Path +FROM t1 c +INNER JOIN cte p ON c.Child = p.Parent) +SELECT * +FROM cte +ORDER BY Path; +Parent Child Path +456 789 789, +123 456 789,456, +654 987 987, +321 654 987,654, +DROP TABLE t1; diff --git a/mysql-test/t/cte_recursive.test b/mysql-test/t/cte_recursive.test index 332a64b30de..3a8795e114a 100644 --- a/mysql-test/t/cte_recursive.test +++ b/mysql-test/t/cte_recursive.test @@ -2214,3 +2214,35 @@ with recursive qn as select * from qn; drop table t1; + +--echo # +--echo # MDEV-16086: tmp table for CTE is created as ARIA tables +--echo # + +CREATE TABLE t1 ( + Id int(11) not null AUTO_INCREMENT, + Parent varchar(15) not null, + Child varchar(15) not null, + PRIMARY KEY (Id) +) ENGINE = MyISAM; + +INSERT INTO t1 (Parent, Child) VALUES + ('123', '456'),('456', '789'),('321', '654'),('654', '987'); + +WITH RECURSIVE cte AS + ( SELECT b.Parent, + b.Child, + CAST(CONCAT(b.Child,',') AS CHAR(513)) Path + FROM t1 b + LEFT OUTER JOIN t1 bc ON b.Child = bc.Parent + WHERE bc.Id IS NULL + UNION ALL SELECT c.Parent, + c.Child, + CONCAT(p.Path,c.Child,',') Path + FROM t1 c + INNER JOIN cte p ON c.Child = p.Parent) +SELECT * +FROM cte +ORDER BY Path; + +DROP TABLE t1; From bd1d152d05ba75bd1bdd2d9bc0358d8508df307a Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Tue, 8 May 2018 19:27:08 +0530 Subject: [PATCH 2/2] MDEV-16106 Record in index was not found on rollback, trying to insert: TUPLE During rollback of temporary table logs, secondary index should delete mark the index entry instead of removing it completely. --- mysql-test/suite/innodb/r/temporary_table.result | 12 ++++++++++++ mysql-test/suite/innodb/t/temporary_table.test | 11 +++++++++++ storage/innobase/row/row0umod.cc | 12 ++++-------- 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/mysql-test/suite/innodb/r/temporary_table.result b/mysql-test/suite/innodb/r/temporary_table.result index 310741b5798..64eb3270934 100644 --- a/mysql-test/suite/innodb/r/temporary_table.result +++ b/mysql-test/suite/innodb/r/temporary_table.result @@ -638,3 +638,15 @@ t1 CREATE TEMPORARY TABLE `t1` ( `j` int(11) DEFAULT NULL, PRIMARY KEY (`i`) KEY_BLOCK_SIZE=8 ) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC +DROP TABLE t1; +CREATE TEMPORARY TABLE t1(f1 INT, KEY(f1)) ENGINE=InnoDB; +INSERT INTO t1 VALUES(NULL); +UPDATE t1 SET f1 = 0; +START TRANSACTION; +UPDATE t1 SET f1 = 4; +UPDATE t1 SET f1 = 0; +ROLLBACK; +SELECT * FROM t1; +f1 +0 +DROP TABLE t1; diff --git a/mysql-test/suite/innodb/t/temporary_table.test b/mysql-test/suite/innodb/t/temporary_table.test index 4184daaf064..9a640657c4d 100644 --- a/mysql-test/suite/innodb/t/temporary_table.test +++ b/mysql-test/suite/innodb/t/temporary_table.test @@ -464,3 +464,14 @@ ALTER TABLE t1 ROW_FORMAT = DYNAMIC; set innodb_strict_mode = ON; ALTER TABLE t1 ADD COLUMN j INT; SHOW CREATE TABLE t1; +DROP TABLE t1; + +CREATE TEMPORARY TABLE t1(f1 INT, KEY(f1)) ENGINE=InnoDB; +INSERT INTO t1 VALUES(NULL); +UPDATE t1 SET f1 = 0; +START TRANSACTION; +UPDATE t1 SET f1 = 4; +UPDATE t1 SET f1 = 0; +ROLLBACK; +SELECT * FROM t1; +DROP TABLE t1; diff --git a/storage/innobase/row/row0umod.cc b/storage/innobase/row/row0umod.cc index b30194f3562..6fc72f806e0 100644 --- a/storage/innobase/row/row0umod.cc +++ b/storage/innobase/row/row0umod.cc @@ -428,7 +428,6 @@ row_undo_mod_del_mark_or_remove_sec_low( btr_pcur_t pcur; btr_cur_t* btr_cur; ibool success; - ibool old_has = FALSE; dberr_t err = DB_SUCCESS; mtr_t mtr; mtr_t mtr_vers; @@ -507,13 +506,10 @@ row_undo_mod_del_mark_or_remove_sec_low( /* For temporary table, we can skip to check older version of clustered index entry. Because the purge won't process any no-redo rollback segment undo logs. */ - if (!dict_table_is_temporary(node->table)) { - old_has = row_vers_old_has_index_entry( - FALSE, btr_pcur_get_rec(&(node->pcur)), - &mtr_vers, index, entry, 0, 0); - } - - if (old_has) { + if (dict_table_is_temporary(node->table) + || row_vers_old_has_index_entry( + FALSE, btr_pcur_get_rec(&(node->pcur)), + &mtr_vers, index, entry, 0, 0)) { err = btr_cur_del_mark_set_sec_rec(BTR_NO_LOCKING_FLAG, btr_cur, TRUE, thr, &mtr); ut_ad(err == DB_SUCCESS);