[MDEV-12360] Error message on a valid recursive CTE with left join Created: 2017-03-25  Updated: 2017-03-28  Resolved: 2017-03-28

Status: Closed
Project: MariaDB Server
Component/s: Optimizer - CTE
Affects Version/s: 10.2.4
Fix Version/s: 10.2.5

Type: Bug Priority: Major
Reporter: Igor Babaev Assignee: Igor Babaev
Resolution: Fixed Votes: 0
Labels: None
Environment:

The following test case fails with the error message

ERROR 4008 (HY000): Restrictions imposed on recursive definitions are violated for table 'ancestor_ids'

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;

Meanwhile the specification for CTE ancestors is quite valid as the recursive reference is in left operand of left join operation.



 Comments   
Comment by Igor Babaev [ 2017-03-28 ]

The fix for this bug was pushed into the 10.2 tree.

Generated at Thu Feb 08 07:57:07 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.