mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 12:02:42 +01:00
Fixed LP bug #819716.
Do not optimize derived table for the second time ever.
This commit is contained in:
parent
2ea5096cec
commit
b7e9713ee3
5 changed files with 29 additions and 3 deletions
|
@ -1200,4 +1200,19 @@ Warnings:
|
|||
Note 1003 select `v2`.`b` AS `b` from `test`.`v2` where 0
|
||||
DROP VIEW v1,v2;
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# LP bug #819716: crash with embedded tableless materialized derived
|
||||
# with a variable
|
||||
#
|
||||
set optimizer_switch='derived_merge=off';
|
||||
EXPLAIN
|
||||
SELECT * FROM (SELECT * FROM (SELECT @b) AS t) AS s;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <derived2> system NULL NULL NULL NULL 1
|
||||
2 DERIVED <derived3> system NULL NULL NULL NULL 1
|
||||
3 DERIVED NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
SELECT * FROM (SELECT * FROM (SELECT @b) AS t) AS s;
|
||||
@b
|
||||
NULL
|
||||
set optimizer_switch=@exit_optimizer_switch;
|
||||
set optimizer_switch=@exit_optimizer_switch;
|
||||
|
|
|
@ -1284,7 +1284,7 @@ SELECT * FROM t1 INNER JOIN t2 ON t2.a != 0 AND t2.a IN (SELECT * FROM v1);
|
|||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
|
||||
2 DEPENDENT SUBQUERY <derived3> ALL NULL NULL NULL NULL 2 Using where
|
||||
2 DEPENDENT SUBQUERY <derived3> system NULL NULL NULL NULL 1
|
||||
3 DERIVED NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
SELECT * FROM t1 INNER JOIN t2 ON t2.a != 0 AND t2.a IN (SELECT * FROM v1);
|
||||
a a
|
||||
|
|
|
@ -1295,7 +1295,7 @@ SELECT * FROM t1 INNER JOIN t2 ON t2.a != 0 AND t2.a IN (SELECT * FROM v1);
|
|||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
|
||||
2 DEPENDENT SUBQUERY <derived3> ALL NULL NULL NULL NULL 2 Using where
|
||||
2 DEPENDENT SUBQUERY <derived3> system NULL NULL NULL NULL 1
|
||||
3 DERIVED NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
SELECT * FROM t1 INNER JOIN t2 ON t2.a != 0 AND t2.a IN (SELECT * FROM v1);
|
||||
a a
|
||||
|
|
|
@ -726,5 +726,16 @@ SELECT * FROM (SELECT b FROM v2 WHERE b = 0) t WHERE b;
|
|||
DROP VIEW v1,v2;
|
||||
DROP TABLE t1;
|
||||
|
||||
--echo #
|
||||
--echo # LP bug #819716: crash with embedded tableless materialized derived
|
||||
--echo # with a variable
|
||||
--echo #
|
||||
|
||||
set optimizer_switch='derived_merge=off';
|
||||
EXPLAIN
|
||||
SELECT * FROM (SELECT * FROM (SELECT @b) AS t) AS s;
|
||||
SELECT * FROM (SELECT * FROM (SELECT @b) AS t) AS s;
|
||||
set optimizer_switch=@exit_optimizer_switch;
|
||||
|
||||
# The following command must be the last one the file
|
||||
set optimizer_switch=@exit_optimizer_switch;
|
||||
|
|
|
@ -737,7 +737,7 @@ bool mysql_derived_optimize(THD *thd, LEX *lex, TABLE_LIST *derived)
|
|||
|
||||
bool res= FALSE;
|
||||
|
||||
if (unit->optimized && !unit->uncacheable && !unit->describe)
|
||||
if (unit->optimized)
|
||||
return FALSE;
|
||||
lex->current_select= first_select;
|
||||
|
||||
|
|
Loading…
Reference in a new issue