mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Fixed bug mdev-10889
The bug was in the code of the recursive method With_element::check_unrestricted_recursive. For recursive calls of this method sel->get_with_element()->owner != owner.
This commit is contained in:
@ -1769,3 +1769,40 @@ WITH RECURSIVE cte(f) AS
|
||||
SELECT * FROM cte as t;
|
||||
f
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# MDEV-10889: mergeable derived in the spec of recursive CTE
|
||||
#
|
||||
create table t1 (a int);
|
||||
insert into t1 values
|
||||
(0), (1), (2), (3), (4);
|
||||
create table t2 (a int);
|
||||
insert into t2 values
|
||||
(1), (2), (3), (4), (5);
|
||||
with recursive
|
||||
t1 as
|
||||
(
|
||||
select x.a from (select a from t2 where t2.a=3) x
|
||||
union
|
||||
select t2.a from t1,t2 where t1.a+1=t2.a
|
||||
)
|
||||
select * from t1;
|
||||
a
|
||||
3
|
||||
4
|
||||
5
|
||||
explain
|
||||
with recursive
|
||||
t1 as
|
||||
(
|
||||
select x.a from (select a from t2 where t2.a=3) x
|
||||
union
|
||||
select t2.a from t1,t2 where t1.a+1=t2.a
|
||||
)
|
||||
select * from t1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 5
|
||||
2 SUBQUERY t2 ALL NULL NULL NULL NULL 5 Using where
|
||||
4 RECURSIVE UNION <derived2> ALL NULL NULL NULL NULL 5
|
||||
4 RECURSIVE UNION t2 ALL NULL NULL NULL NULL 5 Using where; Using join buffer (flat, BNL join)
|
||||
NULL UNION RESULT <union2,4> ALL NULL NULL NULL NULL NULL
|
||||
drop table t1,t2;
|
||||
|
@ -1304,3 +1304,35 @@ WITH RECURSIVE cte(f) AS
|
||||
(SELECT t1.f FROM t1 UNION ALL SELECT cte.f FROM cte)
|
||||
SELECT * FROM cte as t;
|
||||
DROP TABLE t1;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-10889: mergeable derived in the spec of recursive CTE
|
||||
--echo #
|
||||
|
||||
create table t1 (a int);
|
||||
insert into t1 values
|
||||
(0), (1), (2), (3), (4);
|
||||
create table t2 (a int);
|
||||
insert into t2 values
|
||||
(1), (2), (3), (4), (5);
|
||||
|
||||
with recursive
|
||||
t1 as
|
||||
(
|
||||
select x.a from (select a from t2 where t2.a=3) x
|
||||
union
|
||||
select t2.a from t1,t2 where t1.a+1=t2.a
|
||||
)
|
||||
select * from t1;
|
||||
|
||||
explain
|
||||
with recursive
|
||||
t1 as
|
||||
(
|
||||
select x.a from (select a from t2 where t2.a=3) x
|
||||
union
|
||||
select t2.a from t1,t2 where t1.a+1=t2.a
|
||||
)
|
||||
select * from t1;
|
||||
|
||||
drop table t1,t2;
|
||||
|
@ -1106,7 +1106,7 @@ bool With_element::check_unrestricted_recursive(st_select_lex *sel,
|
||||
table_map &unrestricted,
|
||||
table_map &encountered)
|
||||
{
|
||||
/* Check conditions 1-for restricted specification*/
|
||||
/* Check conditions 1 for restricted specification*/
|
||||
List_iterator<TABLE_LIST> ti(sel->leaf_tables);
|
||||
TABLE_LIST *tbl;
|
||||
while ((tbl= ti++))
|
||||
@ -1141,7 +1141,7 @@ bool With_element::check_unrestricted_recursive(st_select_lex *sel,
|
||||
encountered|= with_elem->get_elem_map();
|
||||
}
|
||||
}
|
||||
for (With_element *with_elem= sel->get_with_element()->owner->with_list.first;
|
||||
for (With_element *with_elem= owner->with_list.first;
|
||||
with_elem;
|
||||
with_elem= with_elem->next)
|
||||
{
|
||||
|
Reference in New Issue
Block a user