mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Fixed bug mdev-277 as part of the fix for lp:944706
The cause for this bug is that the method JOIN::get_examined_rows iterates over all JOIN_TABs of the join assuming they are just a sequence. In the query above, the innermost subquery is merged into its parent query. When we call JOIN::get_examined_rows for the second-level subquery, the iteration that assumes sequential order of join tabs goes outside the join_tab array and calls the method JOIN_TAB::get_examined_rows on uninitialized memory. The fix is to iterate over JOIN_TABs in a way that takes into account the nested semi-join structure of JOIN_TABs. In particular iterate as select_describe.
This commit is contained in:
@ -5561,5 +5561,24 @@ WHERE alias1.a = alias2.a OR ('Moscow') IN ( SELECT a FROM t1 );
|
||||
|
||||
drop table t1;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-277 CHEAP SQ: Server crashes in st_join_table::get_examined_rows
|
||||
--echo # with semijoin+materialization, IN and = subqueries
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 (a1 INT);
|
||||
INSERT INTO t1 VALUES (4),(6);
|
||||
CREATE TABLE t2 (b1 INT);
|
||||
INSERT INTO t2 VALUES (1),(7);
|
||||
|
||||
EXPLAIN
|
||||
SELECT * FROM t1
|
||||
WHERE a1 = (SELECT COUNT(*) FROM t1 WHERE a1 IN (SELECT a1 FROM t1, t2));
|
||||
|
||||
SELECT * FROM t1
|
||||
WHERE a1 = (SELECT COUNT(*) FROM t1 WHERE a1 IN (SELECT a1 FROM t1, t2));
|
||||
|
||||
drop table t1, t2;
|
||||
|
||||
--echo # return optimizer switch changed in the beginning of this test
|
||||
set optimizer_switch=@subselect_tmp;
|
||||
|
Reference in New Issue
Block a user