summaryrefslogtreecommitdiff
path: root/mysql-test/r/cte_recursive.result
diff options
context:
space:
mode:
authorIgor Babaev <igor@askmonty.org>2017-03-26 22:59:33 -0700
committerIgor Babaev <igor@askmonty.org>2017-03-26 23:00:28 -0700
commitad7da60deda2cf97e60118a58f50f648abde6448 (patch)
tree00e488da434c5c51b7a882ed45f1279b16809035 /mysql-test/r/cte_recursive.result
parent5a4537f09296a1c6151c8dfc35ecad7584aa55c4 (diff)
downloadmariadb-git-ad7da60deda2cf97e60118a58f50f648abde6448.tar.gz
Fixed bug mdev-12368.
Mutually recursive CTE could cause a crash of the server in the case when they were not Standard compliant. The crash happened in mysql_derived_prepare(), because the destructor the derived_result object created for a CTE that was mutually recursive with some others was called twice. Yet this destructor should not be called for resursive references.
Diffstat (limited to 'mysql-test/r/cte_recursive.result')
-rw-r--r--mysql-test/r/cte_recursive.result35
1 files changed, 35 insertions, 0 deletions
diff --git a/mysql-test/r/cte_recursive.result b/mysql-test/r/cte_recursive.result
index 6d59d6749df..bfca93cf6d6 100644
--- a/mysql-test/r/cte_recursive.result
+++ b/mysql-test/r/cte_recursive.result
@@ -2453,3 +2453,38 @@ id name dob father mother
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;