Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
10.2, 10.3, 10.4, 10.5, 10.6
-
None
Description
If the definition of a recursive CTE r is used in the WITH clause without RECURSIVE and this clause is part of the query expression that defines another CTE then the server falls into an infinite recursion calling With_element::clone_parsed_spec() again and again. Ultimately it causes a crash of the server.
Here's a test case that causes such crash:
create table t1 (a int); |
insert into t1 values (5), (7); |
with cte_e as ( |
with 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; |
It should be noted that the definition of cte_r is not considered as the definition of a recursive CTE. Rather it is considered as the definition of a non-recursive CTE referencing the base table or view with the name cte_r. This is because the WITH clause containing this definition lacks the keyword RECURSIVE.
So the expected reaction of the server should be similar to this:
MariaDB [test]> with cte_r as (
|
-> select a from t1 union select a+1 as a from cte_r r where a < 10
|
-> ) select * from cte_r
|
-> ;
|
ERROR 1146 (42S02): Table 'test.cte_r' doesn't exist
|
Attachments
Issue Links
- relates to
-
MDEV-29361 Infinite recursive calls when detecting CTE dependencies
-
- Closed
-