Commit d66c171e authored by Igor Babaev's avatar Igor Babaev

Fixed the bug mdev-12554.

When the WHERE condition is always FALSE then JOIN::join_tab is NULL.
parent 54a995cd
...@@ -2759,3 +2759,15 @@ set standard_compliant_cte=default; ...@@ -2759,3 +2759,15 @@ set standard_compliant_cte=default;
select @@standard_compliant_cte; select @@standard_compliant_cte;
@@standard_compliant_cte @@standard_compliant_cte
1 1
#
# mdev-12554: impossible where in recursive select
#
CREATE TABLE t1 (i int);
INSERT INTO t1 VALUES (1),(2);
WITH RECURSIVE
cte(f) AS ( SELECT i FROM t1 UNION SELECT f FROM t1, cte WHERE 1=0 )
SELECT * FROM cte;
f
1
2
DROP TABLE t1;
...@@ -1834,3 +1834,15 @@ drop table objects, modules, module_arguments, module_results; ...@@ -1834,3 +1834,15 @@ drop table objects, modules, module_arguments, module_results;
set standard_compliant_cte=default; set standard_compliant_cte=default;
select @@standard_compliant_cte; select @@standard_compliant_cte;
--echo #
--echo # mdev-12554: impossible where in recursive select
--echo #
CREATE TABLE t1 (i int);
INSERT INTO t1 VALUES (1),(2);
WITH RECURSIVE
cte(f) AS ( SELECT i FROM t1 UNION SELECT f FROM t1, cte WHERE 1=0 )
SELECT * FROM cte;
DROP TABLE t1;
...@@ -1261,7 +1261,7 @@ bool st_select_lex_unit::exec_recursive() ...@@ -1261,7 +1261,7 @@ bool st_select_lex_unit::exec_recursive()
!is_unrestricted); !is_unrestricted);
if (!with_element->rec_result->first_rec_table_to_update) if (!with_element->rec_result->first_rec_table_to_update)
with_element->rec_result->first_rec_table_to_update= rec_table; with_element->rec_result->first_rec_table_to_update= rec_table;
if (with_element->level == 1) if (with_element->level == 1 && rec_table->reginfo.join_tab)
rec_table->reginfo.join_tab->preread_init_done= true; rec_table->reginfo.join_tab->preread_init_done= true;
} }
for (Item_subselect *sq= with_element->sq_with_rec_ref.first; for (Item_subselect *sq= with_element->sq_with_rec_ref.first;
......
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