[MDEV-10334] Wrong result with CTEs (name resolution?) Created: 2016-07-04  Updated: 2016-09-04  Resolved: 2016-09-04

Status: Closed
Project: MariaDB Server
Component/s: Optimizer - CTE
Affects Version/s: 10.2
Fix Version/s: 10.2.2

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


 Description   

I am trying an example with CTEs, using branch bb-10.2-mdev9864, tip cset

commit 8c6a9aa30f9e74388aaf923ac8e3b19ca0f86188
Author: Igor Babaev <igor@askmonty.org>
Date:   Thu Jun 30 15:13:12 2016 -0700
 
    Added a proper check for acceptable mutually recursive CTE.

create table ten(a int primary key);
insert into ten values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
 
create table one_k(a int primary key);
insert into one_k select A.a + B.a* 10 + C.a * 100 from ten A, ten B, ten C;
 
create view v1 as select * from ten;

mysql> select * from v1;
+------+
| a    |
+------+
|    0 |
|    1 |
|    2 |
|    3 |
|    4 |
|    5 |
|    6 |
|    7 |
|    8 |
|    9 |
+------+
10 rows in set (0.01 sec)
 
mysql> with ten as (select  a from one_k where a<20) select * from v1;
+------+
| a    |
+------+
|    0 |
|    1 |
|    2 |
|    3 |
|    4 |
|    5 |
|    6 |
|    7 |
|    8 |
|    9 |
|   10 |
|   11 |
|   12 |
|   13 |
|   14 |
|   15 |
|   16 |
|   17 |
|   18 |
|   19 |
+------+
20 rows in set (0.06 sec)

I think, the last query should produce 10 rows, not 20.



 Comments   
Comment by Sergei Petrunia [ 2016-07-04 ]

CC: igor, shagalla.

Comment by Sergei Petrunia [ 2016-09-04 ]

Fixed in the current 10.2 tree

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