summaryrefslogtreecommitdiff
path: root/mysql-test/t/cte_recursive.test
diff options
context:
space:
mode:
authorGalina Shalygina <galina.shalygina@mariadb.com>2017-12-19 11:49:40 +0200
committerGalina Shalygina <galina.shalygina@mariadb.com>2017-12-19 11:49:40 +0200
commit079c3599711b9cbd3ce323f32cf99693cc3d5e3b (patch)
treec44fcc44f549a8112ca70dfe1f25d82ba465d075 /mysql-test/t/cte_recursive.test
parent06f0b23a78ab15b6f3d4465e77ac1bdc747524d4 (diff)
downloadmariadb-git-bb-10.2-mdev14629.tar.gz
MDEV-14629: failing assertion when a user-defined variable is defined by the recursive CTEbb-10.2-mdev14629
During the user-defined variable defined by the recursive CTE handling procedure check_dependencies_in_with_clauses that checks dependencies between the tables that are defined in the CTE and find recursive definitions wasn't called.
Diffstat (limited to 'mysql-test/t/cte_recursive.test')
-rw-r--r--mysql-test/t/cte_recursive.test51
1 files changed, 51 insertions, 0 deletions
diff --git a/mysql-test/t/cte_recursive.test b/mysql-test/t/cte_recursive.test
index 36d948251c3..928f8a4334b 100644
--- a/mysql-test/t/cte_recursive.test
+++ b/mysql-test/t/cte_recursive.test
@@ -1947,3 +1947,54 @@ cte2 as (
)
SELECT *
FROM cte1;
+
+--echo #
+--echo # mdev-14629: a user-defined variable is defined by the recursive CTE
+--echo #
+
+set @var=
+(
+ with recursive cte_tab(a) as (
+ select 1
+ union
+ select a+1 from cte_tab
+ where a<3)
+ select count(*) from cte_tab
+);
+
+select @var;
+
+create table t1(a int, b int);
+insert into t1 values (3,8),(1,5),(5,7),(7,4),(4,3);
+
+set @var=
+(
+ with recursive summ(a,s) as (
+ select 1, 0 union
+ select t1.b, t1.b+summ.s from summ, t1
+ where summ.a=t1.a)
+ select s from summ
+ order by a desc
+ limit 1
+);
+
+select @var;
+
+--ERROR ER_UNACCEPTABLE_MUTUAL_RECURSION
+set @var=
+(
+ with recursive
+ cte_1 as (
+ select 1
+ union
+ select * from cte_2),
+ cte_2 as (
+ select * from cte_1
+ union
+ select a from t1, cte_2
+ where t1.a=cte_2.a)
+ select * from cte_2
+ limit 1
+);
+
+drop table t1;