[MDEV-10815] Window Function Expressions Wrong Results Created: 2016-09-15  Updated: 2022-02-22  Resolved: 2022-02-20

Status: Closed
Project: MariaDB Server
Component/s: Optimizer - Window functions
Affects Version/s: 10.2.1
Fix Version/s: N/A

Type: Bug Priority: Major
Reporter: Vicențiu Ciorbaru Assignee: Sergei Petrunia
Resolution: Duplicate Votes: 0
Labels: window-functions

Issue Links:
Relates
relates to MDEV-10669 Crash in SELECT with window function ... Closed

 Description   

The following query returns incorrect results:

create table t(a decimal(35,10), b int);
insert into t(a,b) values(1,1);
insert into t(a,b) values(2,1);
insert into t(a,b) values(0,1);
select * from t;
a	b
1.0000000000	1
2.0000000000	1
0.0000000000	1
select sum(t.a) over (partition by t.b) as s1, sum(t.a) over (partition by t.b) + 1 as s2
from t;
s1	s2
3.0000000000	1.0000000000
3.0000000000	1.0000000000
3.0000000000	1.0000000000

s2 should be s1 + 1, not the constant 1



 Comments   
Comment by Vicențiu Ciorbaru [ 2016-09-15 ]

CC:
sanjaigorpsergeyelenst

Comment by Vicențiu Ciorbaru [ 2016-09-16 ]

Hi Sergey,

Can you please review the patch for this MDEV? This does not fix MDEV-10669. I suspect there is a bit more work to be done wrt split_sum_func for the case operator.
Link to commit:
http://lists.askmonty.org/pipermail/commits/2016-September/009865.html

Comment by Igor Babaev [ 2017-02-11 ]

Sergey,
I think this should be closed .

Comment by Sergei Petrunia [ 2022-02-20 ]

Works ok in the current branch. Fixed at least since MariaDB 10.2.10 (likely earlier, but I can build to check)

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