Commit 1a56ad41 authored by Sergey Glukhov's avatar Sergey Glukhov

Bug#52177 crash with explain, row comparison, join, text field

The crash is the result of an attempt made by JOIN::optimize to evaluate
the WHERE condition when no records have been actually read.
The fix is to remove erroneous 'outer_join' variable check.
parent 658cf9e4
...@@ -930,4 +930,16 @@ Warnings: ...@@ -930,4 +930,16 @@ Warnings:
Note 1003 select 1 AS `1` from `test`.`t1` left join `test`.`t1` `t2` on((1 = 1)) left join (`test`.`t1` left join `test`.`t1` `t2` on((1 = 1))) on(rand()) where 1 Note 1003 select 1 AS `1` from `test`.`t1` left join `test`.`t1` `t2` on((1 = 1)) left join (`test`.`t1` left join `test`.`t1` `t2` on((1 = 1))) on(rand()) where 1
DROP VIEW v1; DROP VIEW v1;
DROP TABLE t1; DROP TABLE t1;
#
# Bug#52177 crash with explain, row comparison, join, text field
#
CREATE TABLE t1 (a TINYINT, b TEXT, KEY (a));
INSERT INTO t1 VALUES (0,''),(0,'');
FLUSH TABLES;
EXPLAIN SELECT 1 FROM t1 LEFT JOIN t1 a ON 1
WHERE ROW(t1.a, 1111.11) = ROW(1111.11, 1111.11) AND
ROW(t1.b, 1111.11) <=> ROW('','');
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
DROP TABLE t1;
End of 5.0 tests. End of 5.0 tests.
...@@ -725,4 +725,15 @@ SELECT 1 FROM v1 right join v1 AS v2 ON RAND(); ...@@ -725,4 +725,15 @@ SELECT 1 FROM v1 right join v1 AS v2 ON RAND();
DROP VIEW v1; DROP VIEW v1;
DROP TABLE t1; DROP TABLE t1;
--echo #
--echo # Bug#52177 crash with explain, row comparison, join, text field
--echo #
CREATE TABLE t1 (a TINYINT, b TEXT, KEY (a));
INSERT INTO t1 VALUES (0,''),(0,'');
FLUSH TABLES;
EXPLAIN SELECT 1 FROM t1 LEFT JOIN t1 a ON 1
WHERE ROW(t1.a, 1111.11) = ROW(1111.11, 1111.11) AND
ROW(t1.b, 1111.11) <=> ROW('','');
DROP TABLE t1;
--echo End of 5.0 tests. --echo End of 5.0 tests.
...@@ -1029,7 +1029,7 @@ JOIN::optimize() ...@@ -1029,7 +1029,7 @@ JOIN::optimize()
} }
} }
if (conds &&!outer_join && const_table_map != found_const_table_map && if (conds && const_table_map != found_const_table_map &&
(select_options & SELECT_DESCRIBE) && (select_options & SELECT_DESCRIBE) &&
select_lex->master_unit() == &thd->lex->unit) // upper level SELECT select_lex->master_unit() == &thd->lex->unit) // upper level SELECT
{ {
......
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