diff options
author | Igor Babaev <igor@askmonty.org> | 2021-07-08 17:47:17 -0700 |
---|---|---|
committer | Igor Babaev <igor@askmonty.org> | 2021-07-08 17:47:17 -0700 |
commit | 78735dcaf757cd71c8f0ff3d21071b0f89018150 (patch) | |
tree | ae009d5bf0a890aa89d881b47acab11593da47ed /mysql-test/main/cte_recursive.test | |
parent | e56fe393104960eb62043c3777ce7d21de9362f4 (diff) | |
download | mariadb-git-78735dcaf757cd71c8f0ff3d21071b0f89018150.tar.gz |
MDEV-26108 Crash with query referencing twice CTE that uses embedded recursive CTE
This bug could affect queries that had at least two references to a CTE that
used an embedded recursive CTE.
Starting from version 10.4 some code in With_element::clone_parsed_spec()
that assumed a certain order of selects after parsing the specification of
a CTE became not valid anymore. It could lead to global select lists where
some selects were missing. If a missing CTE happened to belong to the
recursive part of a recursive CTE some recursive table references were not
set as references to materialized derived tables and this caused a crash of
the server.
Approved by Oleksandr Byelkin <sanja@mariadb.com>
Diffstat (limited to 'mysql-test/main/cte_recursive.test')
-rw-r--r-- | mysql-test/main/cte_recursive.test | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/mysql-test/main/cte_recursive.test b/mysql-test/main/cte_recursive.test index c3537e5bd0c..3b140b3cc6c 100644 --- a/mysql-test/main/cte_recursive.test +++ b/mysql-test/main/cte_recursive.test @@ -3087,3 +3087,20 @@ SELECT * FROM cte; DROP TABLE t1; --echo # End of 10.3 tests + +--echo # +--echo # MDEV-26108: Recursive CTE embedded into another CTE which is used twice +--echo # + +create table t1 (a int); +insert into t1 values (5), (7); + +with cte_e as ( + with recursive cte_r as ( + select a from t1 union select a+1 as a from cte_r r where a < 10 + ) select * from cte_r +) select * from cte_e s1, cte_e s2 where s1.a=s2.a; + +drop table t1; + +--echo # End of 10.4 tests |