[MDEV-9634] Window function produces incorrect value Created: 2016-02-25 Updated: 2016-02-26 Resolved: 2016-02-26 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Optimizer |
| Fix Version/s: | N/A |
| Type: | Task | Priority: | Major |
| Reporter: | Sergei Petrunia | Assignee: | Sergei Petrunia |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Issue Links: |
|
||||||||
| Description |
|
In other settings the value of window can be different. |
| Comments |
| Comment by Sergei Petrunia [ 2016-02-25 ] | ||||||||||||||||||
|
An apparent fix is to make Item_sum_count::remove to take NULLs into account:
and it doesn't help. | ||||||||||||||||||
| Comment by Sergei Petrunia [ 2016-02-25 ] | ||||||||||||||||||
|
| ||||||||||||||||||
| Comment by Sergei Petrunia [ 2016-02-25 ] | ||||||||||||||||||
|
So, the parameters of window functions are not aware that they should be looking into the buffer tmp. table. They are looking at the field in the original table instead, which has some value that has nothing to do with the row pointed by the frame bound cursor. | ||||||||||||||||||
| Comment by Sergei Petrunia [ 2016-02-25 ] | ||||||||||||||||||
|
Checking how this is done for other kinds of queries. We need to read from temp. table #1 is achieved by setting JOIN::fields to point to tmp_fields_list1. #2 also explicity reads from the temp.table | ||||||||||||||||||
| Comment by Sergei Petrunia [ 2016-02-25 ] | ||||||||||||||||||
|
On the other hand, when process_window_functions() invokes filesort, it manages to sort the data in the temp.table. Looking how it does that. In process_window_functions() window's PARTITION/ORDER point into the temp.table already:
This is caused by
| ||||||||||||||||||
| Comment by Sergei Petrunia [ 2016-02-26 ] | ||||||||||||||||||
|
Pushed into bb-10.2-mdev9543 branch. |