Commit 036ca990 authored by Varun Gupta's avatar Varun Gupta

MDEV-18255: Server crashes in Bitmap<64u>::intersect

Calling st_select_lex::update_used_tables in JOIN::optimize_unflattened_subqueries
only when we are sure that the join have not been cleaned up.
This can happen for a case when we have a non-merged semi-join and an impossible
where which would lead to the cleanup of the join which has the non-merged semi-join
parent edeba0c8
......@@ -2822,3 +2822,19 @@ id select_type table type possible_keys key key_len ref rows Extra
SELECT * FROM t2 WHERE f IN ( SELECT LEFT('foo',0) FROM t1 ORDER BY 1 );
f
DROP TABLE t1, t2;
#
# MDEV-18255: Server crashes in Bitmap<64u>::intersect
#
create table t1 (v1 varchar(1)) engine=myisam ;
create table t2 (v1 varchar(1)) engine=myisam ;
explain
select 1 from t1 where exists
(select 1 from t1 where t1.v1 in (select t2.v1 from t2 having t2.v1 < 'j')) ;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table
3 MATERIALIZED NULL NULL NULL NULL NULL NULL NULL no matching row in const table
select 1 from t1 where exists
(select 1 from t1 where t1.v1 in (select t2.v1 from t2 having t2.v1 < 'j')) ;
1
drop table t1,t2;
......@@ -267,3 +267,16 @@ explain
SELECT * FROM t2 WHERE f IN ( SELECT LEFT('foo',0) FROM t1 ORDER BY 1 );
SELECT * FROM t2 WHERE f IN ( SELECT LEFT('foo',0) FROM t1 ORDER BY 1 );
DROP TABLE t1, t2;
--echo #
--echo # MDEV-18255: Server crashes in Bitmap<64u>::intersect
--echo #
create table t1 (v1 varchar(1)) engine=myisam ;
create table t2 (v1 varchar(1)) engine=myisam ;
explain
select 1 from t1 where exists
(select 1 from t1 where t1.v1 in (select t2.v1 from t2 having t2.v1 < 'j')) ;
select 1 from t1 where exists
(select 1 from t1 where t1.v1 in (select t2.v1 from t2 having t2.v1 < 'j')) ;
drop table t1,t2;
......@@ -3551,7 +3551,8 @@ bool st_select_lex::optimize_unflattened_subqueries(bool const_only)
inner_join->select_options|= SELECT_DESCRIBE;
}
res= inner_join->optimize();
sl->update_used_tables();
if (!inner_join->cleaned)
sl->update_used_tables();
sl->update_correlated_cache();
is_correlated_unit|= sl->is_correlated;
inner_join->select_options= save_options;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment