[MDEV-11990] Wrong result for query with window function when all tables are optimized away Created: 2017-02-04  Updated: 2017-07-31  Resolved: 2017-05-05

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

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

Issue Links:
Relates
relates to MDEV-13395 mysqld crash during executing Window ... Closed

 Description   

For the following table

create table t1 (id int);
insert into t1 values (1), (2), (3), (2);

the query

select sum(max(id)) over (order by max(id)) from t1;

returns the correct result:

MariaDB [test]> select sum(max(id)) over (order by max(id)) from t1;
+--------------------------------------+
| sum(max(id)) over (order by max(id)) |
+--------------------------------------+
| 3                                    |
+--------------------------------------+

However after creation of an index on t1(id) the same query returns a wrong result:

 
MariaDB [test]> create index idx on t1(id);
Query OK, 0 rows affected (0.05 sec)
Records: 0  Duplicates: 0  Warnings: 0
 
MariaDB [test]> select sum(max(id)) over (order by max(id)) from t1;
+--------------------------------------+
| sum(max(id)) over (order by max(id)) |
+--------------------------------------+
| NULL                                 |
+--------------------------------------+



 Comments   
Comment by Vicențiu Ciorbaru [ 2017-05-03 ]

Ok to push.

Comment by Igor Babaev [ 2017-05-05 ]

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

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