You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Added comments.
Added reaction for exceeding maximum number of elements in with clause.
Added a test case to check this reaction.
Added a test case where the specification of a recursive table
uses two non-recursive with tables.
Copy file name to clipboardExpand all lines: mysql-test/r/cte_nonrecursive.result
+3Lines changed: 3 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -797,6 +797,9 @@ select t1.b from t2,t1 where t1.a = t2.c;
797
797
id select_type table type possible_keys key key_len ref rows Extra
798
798
1 PRIMARY t2 ALL NULL NULL NULL NULL 4
799
799
1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where; Using join buffer (flat, BNL join)
800
+
# too many with elements in with clause
801
+
with s65 as (select * from t1), s64 as (select * from t1) , s63 as (select * from t1) , s62 as (select * from t1) , s61 as (select * from t1) , s60 as (select * from t1) , s59 as (select * from t1) , s58 as (select * from t1) , s57 as (select * from t1) , s56 as (select * from t1) , s55 as (select * from t1) , s54 as (select * from t1) , s53 as (select * from t1) , s52 as (select * from t1) , s51 as (select * from t1) , s50 as (select * from t1) , s49 as (select * from t1) , s48 as (select * from t1) , s47 as (select * from t1) , s46 as (select * from t1) , s45 as (select * from t1) , s44 as (select * from t1) , s43 as (select * from t1) , s42 as (select * from t1) , s41 as (select * from t1) , s40 as (select * from t1) , s39 as (select * from t1) , s38 as (select * from t1) , s37 as (select * from t1) , s36 as (select * from t1) , s35 as (select * from t1) , s34 as (select * from t1) , s33 as (select * from t1) , s32 as (select * from t1) , s31 as (select * from t1) , s30 as (select * from t1) , s29 as (select * from t1) , s28 as (select * from t1) , s27 as (select * from t1) , s26 as (select * from t1) , s25 as (select * from t1) , s24 as (select * from t1) , s23 as (select * from t1) , s22 as (select * from t1) , s21 as (select * from t1) , s20 as (select * from t1) , s19 as (select * from t1) , s18 as (select * from t1) , s17 as (select * from t1) , s16 as (select * from t1) , s15 as (select * from t1) , s14 as (select * from t1) , s13 as (select * from t1) , s12 as (select * from t1) , s11 as (select * from t1) , s10 as (select * from t1) , s9 as (select * from t1) , s8 as (select * from t1) , s7 as (select * from t1) , s6 as (select * from t1) , s5 as (select * from t1) , s4 as (select * from t1) , s3 as (select * from t1) , s2 as (select * from t1) , s1 as (select * from t1) select * from s65;
802
+
ERROR HY000: Too many WITH elements in WITH clause
800
803
drop table t1,t2;
801
804
#
802
805
# Bug mdev-9937: View used in the specification of with table
# mutual recursion with one select in the first definition
481
548
with recursive
482
549
ancestor_couple_ids(h_id, w_id)
483
550
as
@@ -507,6 +574,7 @@ h_id w_id
507
574
20 30
508
575
10 9
509
576
8 7
577
+
# join of a mutually recursive table with base tables
510
578
with recursive
511
579
ancestor_couple_ids(h_id, w_id)
512
580
as
@@ -537,6 +605,7 @@ name dob name dob
537
605
Dad 1970-02-02 Mom 1975-03-03
538
606
Grandpa Bill 1940-04-05 Grandma Ann 1941-10-15
539
607
Grandpa Ben 1940-10-21 Grandma Sally 1943-08-23
608
+
# join of two mutually recursive tables
540
609
with recursive
541
610
ancestor_couple_ids(h_id, w_id)
542
611
as
@@ -607,6 +676,7 @@ NULL UNION RESULT <union3,4,5> ALL NULL NULL NULL NULL NULL NULL
607
676
2 UNCACHEABLE SUBQUERY <derived3> ALL NULL NULL NULL NULL 12 100.00 Using where
608
677
Warnings:
609
678
Note 1003 with recursive ancestor_couple_ids as (select `a`.`father` AS `h_id`,`a`.`mother` AS `w_id` from `coupled_ancestors` `a` where ((`a`.`father` is not null) and (`a`.`mother` is not null)))coupled_ancestors as (select `test`.`folks`.`id` AS `id`,`test`.`folks`.`name` AS `name`,`test`.`folks`.`dob` AS `dob`,`test`.`folks`.`father` AS `father`,`test`.`folks`.`mother` AS `mother` from `test`.`folks` where (`test`.`folks`.`name` = 'Me') union all select `test`.`p`.`id` AS `id`,`test`.`p`.`name` AS `name`,`test`.`p`.`dob` AS `dob`,`test`.`p`.`father` AS `father`,`test`.`p`.`mother` AS `mother` from `test`.`folks` `p` join `ancestor_couple_ids` `fa` where (`test`.`p`.`id` = `fa`.`h_id`) union all select `test`.`p`.`id` AS `id`,`test`.`p`.`name` AS `name`,`test`.`p`.`dob` AS `dob`,`test`.`p`.`father` AS `father`,`test`.`p`.`mother` AS `mother` from `test`.`folks` `p` join `ancestor_couple_ids` `ma` where (`test`.`p`.`id` = `ma`.`w_id`)), select `h`.`name` AS `name`,`h`.`dob` AS `dob`,`w`.`name` AS `name`,`w`.`dob` AS `dob` from `ancestor_couple_ids` `c` join `coupled_ancestors` `h` join `coupled_ancestors` `w` where ((`h`.`id` = `c`.`h_id`) and (`w`.`id` = `c`.`w_id`))
679
+
# simple mutual recursion
610
680
with recursive
611
681
ancestor_couple_ids(h_id, w_id)
612
682
as
@@ -640,6 +710,7 @@ NULL NULL
640
710
NULL NULL
641
711
NULL 6
642
712
NULL NULL
713
+
# join of two mutually recursive tables
643
714
with recursive
644
715
ancestor_couple_ids(h_id, w_id)
645
716
as
@@ -669,6 +740,7 @@ name dob name dob
669
740
Dad 1970-02-02 Mom 1975-03-03
670
741
Grandpa Bill 1940-04-05 Grandma Ann 1941-10-15
671
742
Grandpa Ben 1940-10-21 Grandma Sally 1943-08-23
743
+
# execution of prepared query using a recursive table
672
744
prepare stmt1 from "
673
745
with recursive
674
746
ancestors
@@ -705,6 +777,7 @@ id name dob father mother
705
777
8 Grandpa Ben 1940-10-21 NULL NULL
706
778
6 Grandgrandma Martha 1923-05-17 NULL NULL
707
779
deallocate prepare stmt1;
780
+
# view using a recursive table
708
781
create view v1 as
709
782
with recursive
710
783
ancestors
@@ -786,6 +859,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
786
859
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
787
860
Warnings:
788
861
Note 1003 with recursive ancestors as (select `test`.`folks`.`id` AS `id`,`test`.`folks`.`name` AS `name`,`test`.`folks`.`dob` AS `dob`,`test`.`folks`.`father` AS `father`,`test`.`folks`.`mother` AS `mother` from `test`.`folks` where ((`test`.`folks`.`name` = 'Me') and (`test`.`folks`.`dob` = DATE'2000-01-01')) union select `p`.`id` AS `id`,`p`.`name` AS `name`,`p`.`dob` AS `dob`,`p`.`father` AS `father`,`p`.`mother` AS `mother` from `test`.`folks` `p` join `ancestors` `a` where ((`a`.`father` = `p`.`id`) or (`a`.`mother` = `p`.`id`)))select `ancestors`.`id` AS `id`,`ancestors`.`name` AS `name`,`ancestors`.`dob` AS `dob`,`ancestors`.`father` AS `father`,`ancestors`.`mother` AS `mother` from `ancestors`
862
+
# recursive spec with two anchor selects and two recursive ones
0 commit comments