summaryrefslogtreecommitdiff
path: root/mysql-test/r/cte_recursive.result
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.org>2017-03-29 07:24:05 +0400
committerAlexander Barkov <bar@mariadb.org>2017-03-29 07:24:05 +0400
commitfb43180c4f46bccaee054524ff532dea4bef41d4 (patch)
tree7d53d19866b749debb71b7d4979800ecbef44bdd /mysql-test/r/cte_recursive.result
parent48c59f394bb9bd4dfd34be19ff4cf933557eb017 (diff)
parentc5520a37d6111991157d8da91b1ae4b9e7cbf50c (diff)
downloadmariadb-git-fb43180c4f46bccaee054524ff532dea4bef41d4.tar.gz
Merge remote-tracking branch 'origin/10.2' into bb-10.2-ext
Diffstat (limited to 'mysql-test/r/cte_recursive.result')
-rw-r--r--mysql-test/r/cte_recursive.result141
1 files changed, 141 insertions, 0 deletions
diff --git a/mysql-test/r/cte_recursive.result b/mysql-test/r/cte_recursive.result
index e64e14bbd01..207a2ca3549 100644
--- a/mysql-test/r/cte_recursive.result
+++ b/mysql-test/r/cte_recursive.result
@@ -2419,3 +2419,144 @@ ANALYZE
}
}
}
+#
+# mdev-12360: recursive reference in left operand of LEFT JOIN
+#
+create table folks(id int, name char(32), dob date, father int, mother int);
+insert into folks values
+(100, 'Me', '2000-01-01', 20, 30),
+(20, 'Dad', '1970-02-02', 10, 9),
+(30, 'Mom', '1975-03-03', 8, 7),
+(10, 'Grandpa Bill', '1940-04-05', null, null),
+(9, 'Grandma Ann', '1941-10-15', null, null),
+(25, 'Uncle Jim', '1968-11-18', 8, 7),
+(98, 'Sister Amy', '2001-06-20', 20, 30),
+(7, 'Grandma Sally', '1943-08-23', null, 6),
+(8, 'Grandpa Ben', '1940-10-21', null, null),
+(6, 'Grandgrandma Martha', '1923-05-17', null, null),
+(67, 'Cousin Eddie', '1992-02-28', 25, 27),
+(27, 'Auntie Melinda', '1971-03-29', null, null);
+with recursive
+ancestor_ids (id)
+as
+(
+select father from folks where name = 'Me'
+ union
+select mother from folks where name = 'Me'
+ union
+select father from ancestor_ids as a left join folks on folks.id = a.id
+union
+select mother from ancestor_ids as a left join folks on folks.id = a.id
+),
+ancestors
+as
+(
+select p.* from folks as p, ancestor_ids as a
+where p.id = a.id
+)
+select * from ancestors;
+id name dob father mother
+20 Dad 1970-02-02 10 9
+30 Mom 1975-03-03 8 7
+10 Grandpa Bill 1940-04-05 NULL NULL
+9 Grandma Ann 1941-10-15 NULL NULL
+7 Grandma Sally 1943-08-23 NULL 6
+8 Grandpa Ben 1940-10-21 NULL NULL
+6 Grandgrandma Martha 1923-05-17 NULL NULL
+drop table folks;
+#
+# mdev-12368: crash with mutually recursive CTE
+# that arenot Standard compliant
+#
+create table value_nodes (v char(4));
+create table module_nodes(m char(4));
+create table module_arguments(m char(4), v char(4));
+create table module_results(m char(4), v char(4));
+with recursive
+reached_values as
+(
+select v from value_nodes where v in ('v3','v7','v9')
+union
+select module_results.v from module_results, applied_modules
+where module_results.m = applied_modules.m
+),
+applied_modules as
+(
+select module_nodes.m
+from
+module_nodes
+left join
+(
+module_arguments
+left join
+reached_values
+on module_arguments.v = reached_values.v
+)
+on reached_values.v is null and
+module_nodes.m = module_arguments.m
+where module_arguments.m is null
+)
+select * from reached_values;
+ERROR HY000: Restrictions imposed on recursive definitions are violated for table 'applied_modules'
+drop table value_nodes, module_nodes, module_arguments, module_results;
+#
+# mdev-12375: query using one of two mutually recursive CTEs
+# whose non-recursive part returns an empty set
+#
+create table value_nodes (v char(4));
+insert into value_nodes values
+('v1'), ('v2'), ('v3'), ('v4'), ('v5'), ('v6'), ('v7'), ('v8'), ('v9'),
+('v10'), ('v11'), ('v12'), ('v13'), ('v14'), ('v15'), ('v16');
+create table module_nodes(m char(4));
+insert into module_nodes values
+('m1'), ('m2'), ('m3'), ('m4'), ('m5'), ('m6'), ('m7');
+create table module_arguments(m char(4), v char(4));
+insert into module_arguments values
+('m1','v3'), ('m1','v9'),
+('m2','v4'), ('m2','v3'), ('m2','v7'),
+('m3','v6'),
+('m4','v4'), ('m4','v1'),
+('m5','v10'), ('m5','v8'), ('m5','v3'),
+('m6','v8'), ('m6','v1'),
+('m7','v11'), ('m7','v12');
+create table module_results(m char(4), v char(4));
+insert into module_results values
+('m1','v4'),
+('m2','v1'), ('m2','v6'),
+('m3','v10'),
+('m4','v8'),
+('m5','v11'), ('m5','v9'),
+('m6','v12'), ('m6','v4'),
+('m7','v2');
+set statement max_recursive_iterations=2, standard_compliant_cte=0 for
+with recursive
+reached_values as
+(
+select v from value_nodes where v in ('v3','v7','v9')
+union
+select module_results.v from module_results, applied_modules
+where module_results.m = applied_modules.m
+),
+applied_modules as
+(
+select * from module_nodes where 1=0
+union
+select module_nodes.m
+from
+module_nodes
+left join
+(
+module_arguments
+left join
+reached_values
+on module_arguments.v = reached_values.v
+)
+on reached_values.v is null and
+module_nodes.m = module_arguments.m
+where module_arguments.m is null
+)
+select * from applied_modules;
+m
+m1
+m2
+drop table value_nodes, module_nodes, module_arguments, module_results;