[MDEV-11868] min ( distinct ) over ( ) returns wrong value Created: 2017-01-21  Updated: 2017-02-15  Resolved: 2017-02-15

Status: Closed
Project: MariaDB Server
Component/s: Optimizer - Window functions
Affects Version/s: 10.2.3
Fix Version/s: 10.2.4

Type: Bug Priority: Major
Reporter: the6campbells Assignee: Vicențiu Ciorbaru
Resolution: Fixed Votes: 0
Labels: 10.2-rc


 Description   

10.2.3 beta

The following query works

select TDEC.CDEC, min( distinct TDEC.CDEC ) over () from TDEC 
 
CDEC	min( distinct TDEC.CDEC ) over ()
<null>	-1
-1	-1
0	-1
1	-1
0.1	-1
10	-1

The same query applied to a simple view that projects the table does not

select `tdec`.`RNUM` AS `RNUM`,`tdec`.`CDEC` AS `CDEC` from `tdec` 
 
 
select VDEC.CDEC, min( distinct VDEC.CDEC ) over () from VDEC 
 
CDEC	min( distinct VDEC.CDEC ) over ()
<null>	10
-1	10
0	10
1	10
0.1	10
10	10



 Comments   
Comment by Elena Stepanova [ 2017-01-23 ]

Thanks for the report.

Test case

create table TDEC (CDEC int, RNUM int);
create view VDEC as select * from TDEC;
insert into TDEC (CDEC) values (null),(-1),(0),(1),(0),(10);
select TDEC.CDEC, min( distinct TDEC.CDEC ) over () from TDEC ;
select VDEC.CDEC, min( distinct VDEC.CDEC ) over () from VDEC ;

MariaDB [test]> select TDEC.CDEC, min( distinct TDEC.CDEC ) over () from TDEC ;
+------+-----------------------------------+
| CDEC | min( distinct TDEC.CDEC ) over () |
+------+-----------------------------------+
| NULL |                                -1 |
|   -1 |                                -1 |
|    0 |                                -1 |
|    1 |                                -1 |
|    0 |                                -1 |
|   10 |                                -1 |
+------+-----------------------------------+
6 rows in set (0.00 sec)

MariaDB [test]> select VDEC.CDEC, min( distinct VDEC.CDEC ) over () from VDEC ;
+------+-----------------------------------+
| CDEC | min( distinct VDEC.CDEC ) over () |
+------+-----------------------------------+
| NULL |                                10 |
|   -1 |                                10 |
|    0 |                                10 |
|    1 |                                10 |
|    0 |                                10 |
|   10 |                                10 |
+------+-----------------------------------+
6 rows in set (0.00 sec)

Comment by Vicențiu Ciorbaru [ 2017-02-14 ]

No longer reproducible. Probably fixed by one of Igor's patches. Adding testcase and closing.

Comment by Vicențiu Ciorbaru [ 2017-02-15 ]

Current HEAD doesn't feature this problem. Added test case just in case.

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