From 422c55a2404a7ec31d43962cdda0d782ef32dc45 Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Fri, 20 Sep 2013 14:47:38 +0400 Subject: MDEV-5037: Server crash on a JOIN on a derived table with join_cache_level > 2 - The crash was caused because the optimizer called handler->multi_range_read_info() on a derived temporary table. That table has been created, but not opened yet. Because of that, handler::table was NULL, which caused crash. Fixed by changing DS-MRR methods to use handler::table_share instead. handler::table_share is set in handler ctor, so this should be safe. --- mysql-test/r/innodb_mrr_cpk.result | 23 +++++++++++++++++++++++ mysql-test/t/innodb_mrr_cpk.test | 27 +++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) (limited to 'mysql-test') diff --git a/mysql-test/r/innodb_mrr_cpk.result b/mysql-test/r/innodb_mrr_cpk.result index 15ef32447a8..bcee428bc57 100644 --- a/mysql-test/r/innodb_mrr_cpk.result +++ b/mysql-test/r/innodb_mrr_cpk.result @@ -171,3 +171,26 @@ a b c d e g 2 6 two 12 2 6 DROP TABLE t1, t2; set optimizer_switch=@tmp_mdev3817; +# +# MDEV-5037: Server crash on a JOIN on a derived table with join_cache_level > 2 +# +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +CREATE TABLE t1 ( +id char(8) CHARACTER SET utf8 NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +CREATE TABLE t2 ( +id char(8) CHARACTER SET utf8 DEFAULT NULL, +url text CHARACTER SET utf8 +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +insert into t1 select '03b2ca8c' from t0 A, t0 B limit 80; +insert into t2 select '03b2ca8c','' from t0 A, t0 B, t0 C; +set @tmp_mdev5037=@@join_cache_level; +set join_cache_level=3; +explain SELECT 1 FROM (SELECT url, id FROM t2 LIMIT 1 OFFSET 20) derived RIGHT JOIN t1 ON t1.id = derived.id; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL # +1 PRIMARY hash_ALL key0 #hash#key0 25 test.t1.id # Using join buffer (flat, BNLH join) +2 DERIVED t2 ALL NULL NULL NULL NULL # +set join_cache_level= @tmp_mdev5037; +drop table t0,t1,t2; diff --git a/mysql-test/t/innodb_mrr_cpk.test b/mysql-test/t/innodb_mrr_cpk.test index a7b2d9c0ddd..bee8d5796ce 100644 --- a/mysql-test/t/innodb_mrr_cpk.test +++ b/mysql-test/t/innodb_mrr_cpk.test @@ -165,3 +165,30 @@ SELECT * FROM t1, t2 WHERE g = b AND ( a < 7 OR a > e ); DROP TABLE t1, t2; set optimizer_switch=@tmp_mdev3817; +--echo # +--echo # MDEV-5037: Server crash on a JOIN on a derived table with join_cache_level > 2 +--echo # +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); + +CREATE TABLE t1 ( + id char(8) CHARACTER SET utf8 NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +CREATE TABLE t2 ( + id char(8) CHARACTER SET utf8 DEFAULT NULL, + url text CHARACTER SET utf8 +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +insert into t1 select '03b2ca8c' from t0 A, t0 B limit 80; +insert into t2 select '03b2ca8c','' from t0 A, t0 B, t0 C; + +set @tmp_mdev5037=@@join_cache_level; +set join_cache_level=3; + +--replace_column 9 # +explain SELECT 1 FROM (SELECT url, id FROM t2 LIMIT 1 OFFSET 20) derived RIGHT JOIN t1 ON t1.id = derived.id; + +set join_cache_level= @tmp_mdev5037; + +drop table t0,t1,t2; -- cgit v1.2.1 From 45d3ada7c2f81227bb0b8b219b787f4d9746ca21 Mon Sep 17 00:00:00 2001 From: Sergey Vojtovich Date: Tue, 17 Sep 2013 18:51:14 +0400 Subject: MDEV-4684 - Enhancement request: --init-command support for mysqlslap Added --init-command argument to mysqlslap: SQL Command to execute when connecting to MySQL server. Will automatically be re-executed when reconnecting. --- mysql-test/r/mysqlslap.result | 4 ++++ mysql-test/t/mysqlslap.test | 7 +++++++ 2 files changed, 11 insertions(+) (limited to 'mysql-test') diff --git a/mysql-test/r/mysqlslap.result b/mysql-test/r/mysqlslap.result index 069c9182de2..af78677647f 100644 --- a/mysql-test/r/mysqlslap.result +++ b/mysql-test/r/mysqlslap.result @@ -251,3 +251,7 @@ Benchmark Number of clients running queries: 1 Average number of queries per client: 0 +# +# MDEV-4684 - Enhancement request: --init-command support for mysqlslap +# +DROP TABLE t1; diff --git a/mysql-test/t/mysqlslap.test b/mysql-test/t/mysqlslap.test index 69eaae76409..c49c4ab3d7d 100644 --- a/mysql-test/t/mysqlslap.test +++ b/mysql-test/t/mysqlslap.test @@ -73,3 +73,10 @@ DROP DATABASE bug58090; --replace_regex /queries: [0-9]+.[0-9]+/queries: TIME/ --exec $MYSQL_SLAP + +--echo # +--echo # MDEV-4684 - Enhancement request: --init-command support for mysqlslap +--echo # + +--exec $MYSQL_SLAP --create-schema=test --init-command="CREATE TABLE t1(a INT)" --silent --concurrency=1 --iterations=1 +DROP TABLE t1; -- cgit v1.2.1