Commit 8ae65920 authored by Igor Babaev's avatar Igor Babaev

Fixed bug mdev-10737.

This bug in st_select_lex_node::move_node could result
in invalid select lists in recursive units that could
cause falling into infinite loops when iterating over
selects in such units.
parent aaedb63e
...@@ -1611,3 +1611,15 @@ EXPLAIN ...@@ -1611,3 +1611,15 @@ EXPLAIN
} }
} }
drop table t1; drop table t1;
#
# MDEV-10737: recursive union with several anchors at the end
#
WITH RECURSIVE cte(n) AS
( SELECT n+1 FROM cte WHERE n < 5 UNION SELECT 1 UNION SELECT 1 )
SELECT * FROM cte;
n
1
2
3
4
5
...@@ -1177,3 +1177,10 @@ select * from t; ...@@ -1177,3 +1177,10 @@ select * from t;
drop table t1; drop table t1;
--echo #
--echo # MDEV-10737: recursive union with several anchors at the end
--echo #
WITH RECURSIVE cte(n) AS
( SELECT n+1 FROM cte WHERE n < 5 UNION SELECT 1 UNION SELECT 1 )
SELECT * FROM cte;
...@@ -551,6 +551,8 @@ class st_select_lex_node { ...@@ -551,6 +551,8 @@ class st_select_lex_node {
{ {
if (where_to_move == this) if (where_to_move == this)
return; return;
if (next)
next->prev= prev;
*prev= next; *prev= next;
*where_to_move->prev= this; *where_to_move->prev= this;
next= where_to_move; next= where_to_move;
......
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