diff options
-rw-r--r-- | mysql-test/main/derived_split_innodb.result | 37 | ||||
-rw-r--r-- | mysql-test/main/derived_split_innodb.test | 36 | ||||
-rw-r--r-- | sql/opt_split.cc | 1 |
3 files changed, 74 insertions, 0 deletions
diff --git a/mysql-test/main/derived_split_innodb.result b/mysql-test/main/derived_split_innodb.result index 736e6a2c020..855550f0e87 100644 --- a/mysql-test/main/derived_split_innodb.result +++ b/mysql-test/main/derived_split_innodb.result @@ -810,4 +810,41 @@ SELECT t1.* FROM t1 JOIN (SELECT id, COUNT(*) FROM t2 GROUP BY id) sq ON sq.id= a set optimizer_switch= @tmp1, join_cache_level= @tmp2; DROP TABLE t1, t2; +# +# MDEV-31240, MDEV-31241: Crashes in subselects in choose_best_splitting after upgrade +# +create table t1 ( +a int +); +insert into t1 select seq from seq_1_to_1000; +create table t2 ( +a int, +b int, +key (a) +); +create table t4 (a int); +insert into t4 values (1); +insert into t2 select mod(seq,10), mod(seq,10) from seq_1_to_1000; +analyze table t2 persistent for all; +Table Op Msg_type Msg_text +test.t2 analyze status Engine-independent statistics collected +test.t2 analyze status Table is already up to date +explain +select +a, +(select +concat(t4.a,'=',T2_GRP.SUM_B) +from +(select a, sum(b) as SUM_B from t2 group by a) as T2_GRP, +t4 +where +T2_GRP.a=t1.a +) +from t1; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 1000 +2 DEPENDENT SUBQUERY t4 system NULL NULL NULL NULL 1 +2 DEPENDENT SUBQUERY <derived3> ref key0 key0 5 test.t1.a 100 +3 DERIVED t2 ALL a NULL NULL NULL 1000 Using temporary; Using filesort +drop table t1,t2,t4; # End of 10.4 tests diff --git a/mysql-test/main/derived_split_innodb.test b/mysql-test/main/derived_split_innodb.test index b8dd5ad20e1..f6362806098 100644 --- a/mysql-test/main/derived_split_innodb.test +++ b/mysql-test/main/derived_split_innodb.test @@ -462,4 +462,40 @@ set optimizer_switch= @tmp1, join_cache_level= @tmp2; # Cleanup DROP TABLE t1, t2; +--echo # +--echo # MDEV-31240, MDEV-31241: Crashes in subselects in choose_best_splitting after upgrade +--echo # + +create table t1 ( + a int +); +insert into t1 select seq from seq_1_to_1000; + +create table t2 ( + a int, + b int, + key (a) +); + +create table t4 (a int); +insert into t4 values (1); + +insert into t2 select mod(seq,10), mod(seq,10) from seq_1_to_1000; +analyze table t2 persistent for all; + +explain +select + a, + (select + concat(t4.a,'=',T2_GRP.SUM_B) + from + (select a, sum(b) as SUM_B from t2 group by a) as T2_GRP, + t4 + where + T2_GRP.a=t1.a + ) +from t1; + +drop table t1,t2,t4; + --echo # End of 10.4 tests diff --git a/sql/opt_split.cc b/sql/opt_split.cc index bb3aec9ee8d..43363f622b2 100644 --- a/sql/opt_split.cc +++ b/sql/opt_split.cc @@ -1038,6 +1038,7 @@ SplM_plan_info * JOIN_TAB::choose_best_splitting(uint idx, table_map excluded_tables= remaining_tables | this->join->sjm_lookup_tables; if (best_table) { + best_param_tables &= ~PSEUDO_TABLE_BITS; *spl_pd_boundary= this->table->map; if (!best_param_tables) refills= 1; |