Commit 93b7578d authored by Georgi Kodinov's avatar Georgi Kodinov

merge

parents 591a6914 6f9839d9
...@@ -3025,6 +3025,24 @@ Warnings: ...@@ -3025,6 +3025,24 @@ Warnings:
Note 1003 select 1 AS `1` from `test`.`t1` `t2` left join `test`.`t1` on(1) where 1 Note 1003 select 1 AS `1` from `test`.`t1` `t2` left join `test`.`t1` on(1) where 1
DEALLOCATE PREPARE stmt; DEALLOCATE PREPARE stmt;
DROP TABLE t1; DROP TABLE t1;
#
# Bug#54488 crash when using explain and prepared statements with subqueries
#
CREATE TABLE t1(f1 INT);
INSERT INTO t1 VALUES (1),(1);
PREPARE stmt FROM 'EXPLAIN SELECT 1 FROM t1 WHERE (SELECT (SELECT 1 FROM t1 GROUP BY f1))';
EXECUTE stmt;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 2
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used
3 SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort
EXECUTE stmt;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 2
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used
3 SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort
DEALLOCATE PREPARE stmt;
DROP TABLE t1;
End of 5.1 tests. End of 5.1 tests.
......
...@@ -3090,6 +3090,17 @@ EXECUTE stmt; ...@@ -3090,6 +3090,17 @@ EXECUTE stmt;
DEALLOCATE PREPARE stmt; DEALLOCATE PREPARE stmt;
DROP TABLE t1; DROP TABLE t1;
--echo #
--echo # Bug#54488 crash when using explain and prepared statements with subqueries
--echo #
CREATE TABLE t1(f1 INT);
INSERT INTO t1 VALUES (1),(1);
PREPARE stmt FROM 'EXPLAIN SELECT 1 FROM t1 WHERE (SELECT (SELECT 1 FROM t1 GROUP BY f1))';
EXECUTE stmt;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
DROP TABLE t1;
--echo --echo
--echo End of 5.1 tests. --echo End of 5.1 tests.
......
...@@ -1911,18 +1911,22 @@ int subselect_single_select_engine::exec() ...@@ -1911,18 +1911,22 @@ int subselect_single_select_engine::exec()
} }
if (!select_lex->uncacheable && thd->lex->describe && if (!select_lex->uncacheable && thd->lex->describe &&
!(join->select_options & SELECT_DESCRIBE) && !(join->select_options & SELECT_DESCRIBE) &&
join->need_tmp && item->const_item()) join->need_tmp)
{ {
/* item->update_used_tables();
Force join->join_tmp creation, because this subquery will be replaced if (item->const_item())
by a simple select from the materialization temp table by optimize() {
called by EXPLAIN and we need to preserve the initial query structure /*
so we can display it. Force join->join_tmp creation, because this subquery will be replaced
*/ by a simple select from the materialization temp table by optimize()
select_lex->uncacheable|= UNCACHEABLE_EXPLAIN; called by EXPLAIN and we need to preserve the initial query structure
select_lex->master_unit()->uncacheable|= UNCACHEABLE_EXPLAIN; so we can display it.
if (join->init_save_join_tab()) */
DBUG_RETURN(1); /* purecov: inspected */ select_lex->uncacheable|= UNCACHEABLE_EXPLAIN;
select_lex->master_unit()->uncacheable|= UNCACHEABLE_EXPLAIN;
if (join->init_save_join_tab())
DBUG_RETURN(1); /* purecov: inspected */
}
} }
if (item->engine_changed) if (item->engine_changed)
{ {
......
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