Commit 15ea7238 authored by Sergey Petrunya's avatar Sergey Petrunya

BUG#906385: EXPLAIN EXTENDED crashes in TABLE_LIST::print with limited max_join_size

- Take into account that subquery's optimization can fail because of @@max_join_size error.
parent be3e5298
......@@ -897,3 +897,25 @@ set optimizer_switch=default;
select @@optimizer_switch like '%materialization=on%';
@@optimizer_switch like '%materialization=on%'
1
#
# BUG#906385: EXPLAIN EXTENDED crashes in TABLE_LIST::print with limited max_join_size
#
CREATE TABLE t1 ( a INT );
CREATE TABLE t2 ( b INT );
INSERT INTO t1 VALUES (1),(2);
INSERT INTO t2 VALUES
(1),(2),(3),(4),(5),
(6),(7),(8),(9),(10),
(11),(12),(13),(14),(15),
(16),(17),(18),(19),(20);
set @tmp_906385=@@max_join_size;
SET max_join_size = 80;
EXPLAIN EXTENDED
SELECT COUNT(*) FROM t1
WHERE a IN
( SELECT b FROM t2 GROUP BY b )
AND ( 6 ) IN
( SELECT MIN( t2.b ) FROM t2 alias1, t2 );
ERROR 42000: The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET MAX_JOIN_SIZE=# if the SELECT is okay
DROP TABLE t1, t2;
set max_join_size= @tmp_906385;
......@@ -8,3 +8,32 @@ set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on';
set optimizer_switch=default;
select @@optimizer_switch like '%materialization=on%';
--echo #
--echo # BUG#906385: EXPLAIN EXTENDED crashes in TABLE_LIST::print with limited max_join_size
--echo #
CREATE TABLE t1 ( a INT );
CREATE TABLE t2 ( b INT );
INSERT INTO t1 VALUES (1),(2);
INSERT INTO t2 VALUES
(1),(2),(3),(4),(5),
(6),(7),(8),(9),(10),
(11),(12),(13),(14),(15),
(16),(17),(18),(19),(20);
set @tmp_906385=@@max_join_size;
SET max_join_size = 80;
--error ER_TOO_BIG_SELECT
EXPLAIN EXTENDED
SELECT COUNT(*) FROM t1
WHERE a IN
( SELECT b FROM t2 GROUP BY b )
AND ( 6 ) IN
( SELECT MIN( t2.b ) FROM t2 alias1, t2 );
DROP TABLE t1, t2;
set max_join_size= @tmp_906385;
......@@ -21396,8 +21396,17 @@ void TABLE_LIST::print(THD *thd, table_map eliminated_tables, String *str,
}
else if (jtbm_subselect)
{
if (jtbm_subselect->is_jtbm_const_tab)
if (jtbm_subselect->engine->engine_type() ==
subselect_engine::SINGLE_SELECT_ENGINE)
{
/*
We get here when conversion into materialization didn't finish (this
happens when
- The subquery is a degenerate case which produces 0 or 1 record
- subquery's optimization didn't finish because of @@max_join_size
limits
- ... maybe some other cases like this
*/
str->append(STRING_WITH_LEN(" <materialize> ("));
jtbm_subselect->engine->print(str, query_type);
str->append(')');
......
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