Commit e7c4e6d8 authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-5012 Server crashes in Item_ref::real_item on EXPLAIN with select...

MDEV-5012 Server crashes in Item_ref::real_item on EXPLAIN with select subqueries or views, constant table, derived_merge+derived_with_keys

revert incorrect change, merged from mysql-5.5
parent c570719e
......@@ -476,4 +476,18 @@ n d1 d2 result
2085 2012-01-01 00:00:00 2013-01-01 00:00:00 0
2084 2012-02-01 00:00:00 2013-01-01 00:00:00 0
drop table t1;
SET optimizer_switch = 'derived_merge=on,derived_with_keys=on,in_to_exists=on';
CREATE TABLE t1 (a INT) ENGINE=MyISAM;
INSERT INTO t1 VALUES (8);
CREATE TABLE t2 (b INT) ENGINE=MyISAM;
INSERT INTO t2 VALUES (1),(7);
EXPLAIN SELECT * FROM (SELECT * FROM t1) AS table1,
(SELECT DISTINCT * FROM t2) AS table2 WHERE b = a AND a <> ANY (SELECT 9);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 system NULL NULL NULL NULL 1
1 PRIMARY <derived3> ref key0 key0 5 const 0
3 DERIVED t2 ALL NULL NULL NULL NULL 2 Using temporary
Warnings:
Note 1249 Select 4 was reduced during optimization
DROP TABLE t1, t2;
set optimizer_switch=@save_derived_optimizer_switch;
......@@ -389,4 +389,16 @@ select * from (
) as calculated_result;
drop table t1;
#
# MDEV-5012 Server crashes in Item_ref::real_item on EXPLAIN with select subqueries or views, constant table, derived_merge+derived_with_keys
#
SET optimizer_switch = 'derived_merge=on,derived_with_keys=on,in_to_exists=on';
CREATE TABLE t1 (a INT) ENGINE=MyISAM;
INSERT INTO t1 VALUES (8);
CREATE TABLE t2 (b INT) ENGINE=MyISAM;
INSERT INTO t2 VALUES (1),(7);
EXPLAIN SELECT * FROM (SELECT * FROM t1) AS table1,
(SELECT DISTINCT * FROM t2) AS table2 WHERE b = a AND a <> ANY (SELECT 9);
DROP TABLE t1, t2;
set optimizer_switch=@save_derived_optimizer_switch;
......@@ -1746,7 +1746,7 @@ Item_in_subselect::single_value_transformer(JOIN *join)
of the statement. Thus one of 'substitution' arguments
can be broken in case of PS.
*/
substitution= func->create(left_expr->real_item(), where_item);
substitution= func->create(left_expr, where_item);
have_to_be_excluded= 1;
if (thd->lex->describe)
{
......
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