mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Bug #27807.
Non-correlated scalar subqueries may get executed in EXPLAIN at the optimization phase if they are part of a right hand sargable expression. If the scalar subquery uses a temp table to materialize its results it will replace the subquery structure from the parser with a simple select from the materialization table. As a result the EXPLAIN will crash as the temporary materialization table is not to be shown in EXPLAIN at all. Fixed by preserving the original query structure right after calling optimize() for scalar subqueries with temp tables executed during EXPLAIN. mysql-test/r/subselect.result: Bug #27807: test case mysql-test/t/subselect.test: Bug #27807: test case sql/item_subselect.cc: Bug #27807: preserve the join structure sql/sql_select.cc: Bug #27807: introduce initialization function for tmp_join sql/sql_select.h: Bug #27807: introduce initialization function for tmp_join
This commit is contained in:
@ -4012,3 +4012,11 @@ WHERE (SELECT COUNT(t0.b) FROM t1 t WHERE t.b>20) GROUP BY a;
|
||||
ERROR HY000: Invalid use of group function
|
||||
SET @@sql_mode=default;
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (a int, b int, KEY (a));
|
||||
INSERT INTO t1 VALUES (1,1),(2,1);
|
||||
EXPLAIN SELECT 1 FROM t1 WHERE a = (SELECT COUNT(*) FROM t1 GROUP BY b);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ref a a 5 const 1 Using where; Using index
|
||||
2 SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort
|
||||
DROP TABLE t1;
|
||||
End of 5.0 tests.
|
||||
|
@ -2845,3 +2845,13 @@ SELECT a FROM t1 t0
|
||||
SET @@sql_mode=default;
|
||||
|
||||
DROP TABLE t1;
|
||||
|
||||
#
|
||||
# Bug #27807: Server crash when executing subquery with EXPLAIN
|
||||
#
|
||||
CREATE TABLE t1 (a int, b int, KEY (a));
|
||||
INSERT INTO t1 VALUES (1,1),(2,1);
|
||||
EXPLAIN SELECT 1 FROM t1 WHERE a = (SELECT COUNT(*) FROM t1 GROUP BY b);
|
||||
DROP TABLE t1;
|
||||
|
||||
--echo End of 5.0 tests.
|
||||
|
Reference in New Issue
Block a user