| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
| |
When join output is just one row, we still need to compute window
function values for it. We could skip invoking filesort for it,
but it doesn't seem to be worth it to do such optimization.
|
|
|
|
|
|
|
|
|
|
|
| |
Make Frame_range_current_row_bottom to take into account partition bounds.
Other partition bounds that could potentially hit the end of partition are
Frame_range_n_bottom, Frame_n_rows_following, Frame_unbounded_following,
and they all had end-of-partition protection.
To simplify the code, factored out end-of-partition checks into
class Partition_read_cursor.
|
| |
|
|
|
|
|
|
|
| |
This bug revealed a serious problem: if the same partition list
was used in two window specifications then the temporary table created
to calculate window functions contained fields for two identical
partitions. This problem was fixed as well.
|
|
|
|
|
|
| |
The bug was caused by a weird behaviour in test_if_group_changed, not
returning true when testing for the first time after initializing
the Cached_item list.
|
|
|
|
|
|
|
| |
constructs
Implement the "DISTINCT must not be converted into GROUP BY when window
functions are present" part.
|
|
|
|
|
|
|
|
|
| |
n=0 in "ROWS 0 PRECEDING" is valid, add handling for it:
- Adjust the assert
- Bottom bound of 'ROW 0 PRECEDING' is actually looking at the current
row, that is, it needs to process partition's first row directly in
Frame_n_rows_preceding::next_partition().
- Added testcases
|
| |
|
|
|
|
|
|
|
| |
Window functions need to have their own column in the work (temp) table,
like aggregate functions do.
They don't need val_int() -> val_int_result() conversion though, so they
should be wrapped with Item_direct_ref, not Item_aggregate_ref.
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
- When window functions are present, JOIN::simple_order should be set
to FALSE. (Otherwise, the optimizer may attempt to do a "pre-sorting"
on the first join_tab. Which can work in some cases, but generally
isn't)
- filesort tries to only read table fields that it requires. Window
function requires its temp.table field. In order to pass this info
to filesort, added an implementation of Item_window_func::
register_field_in_read_map.
|
|
|
|
|
|
|
| |
" The sort order for the sub-sequence of window functions starting
from the element marked by SORTORDER_CHANGE_FLAG up to the next
element marked by SORTORDER_CHANGE_FLAG must be taken from the
last element of the sub-sequence (not from the first one)."
|
|
|
|
|
| |
- Move filesort's sort_positions argument into class Filesort.
- Make window function code construct Filesort with sort_positions=true.
|
|
|
|
|
|
|
| |
- Rename Window_funcs_computation to Window_funcs_computation_step
- Introduce Window_func_sort which invokes filesort and then
invokes computation of all window functions that use this ordering.
- Expose Window functions' sort operations in EXPLAIN|ANALYZE FORMAT=JSON
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
that the call-back comparison function returns a positive
number when arg1 < arg2, and a negative number when arg1 > arg2.
This is not in line with other implementation of sorting
algorithm.
Changed bubble_sort: now a negative result from the comparison
function means that arg1 < arg2, and positive result means
that arg1 > arg2.
Changed accordingly all call-back functions that are used as
parameters in the call of bubble_sort.
Added a test case to check the proper sorting of window functions.
|
|
|
|
| |
This will be useful for window functions development.
|
|
|
|
|
|
| |
- Hook window function computation into the right location.
- Add a testcase which shows that HAVING is now checked before
the window function computation step.
|
| |
|
|
|
|
|
|
|
|
|
|
| |
Item_func_or_sum.
Implemented method update_used_tables for class Item_findow_func.
Added the flag Item::with_window_func.
Made sure that window functions could be used only in SELECT list
and ORDER BY clause.
Added test cases that checked different illegal placements of
window functions.
|
| |
|
|
|
|
| |
Produce a "not supported" error if one attempts to exclude rows
|
|
|
|
| |
window frames in full accordance with the SQL standard.
|
|
|
|
| |
Each window name has to be resolved only once.
|
|
|
|
| |
Catch errors in window frame definitions
|
|
|
|
|
|
| |
with window functions. Added the test case for it.
Also allowed to use aliases for set functions in partition and order lists
that are specified in window functions.
|
| |
|
| |
|
|
|
|
|
| |
- Handle ORDER BY DESC in window definitions.
- Fix an issue in Frame_range_current_row_top
|
| |
|
|
|
|
|
|
|
| |
Add support for "RANGE n PRECEDING|FOLLOWING" frame bounds.
- n is currently limited to whatever Item and Item_sum_plus/minus
can handle (i.e. no DATETIME intervals).
- Didn't check NULL value handling yet.
|
|
|
|
|
|
|
|
|
|
| |
Part#2: Fix a couple more issues in rows-type frames.
This also has a code cleanup:
- introduce a separate Frame_rows_current_row_(top,bottom). This is
is a special case which doesn't need its cursor or partition bound check
- Split Frame_n_rows into
= Frame_n_rows_preceding (this one is now much simpler)
= Frame_n_rows_following (simpler and works but may need some work still)
|
|
|
|
|
|
|
| |
Part#1: Frame_n_rows::next_partition() should not assume that the
current table->record[0] points to the first row in the partition.
Since cursor supports move_to() operation, we dont need this.
|
|
|
|
| |
Add testcases for RANGE UNBOUNDED PRECEDING|FOLLOWING
|
|
|
|
| |
Support RANGE ... CURRENT ROW as frame's first and second bound.
|
|
|
|
|
|
|
|
| |
- Item_sum_count::remove() should check if the argument's value is NULL.
- Window Function item must have its Item_window_func::split_sum_func
called,
- and it must call split_sum_func for aggregate's arguments (see the
comment near Item_window_func::split_sum_func for explanation why)
|
|
|
|
|
|
| |
Resolved window names.
Checked some constraints for window frames.
Added test cases for window name resolution.
|
|
|
|
|
|
|
|
|
|
| |
- Add temporary code: clone_read_record() clones READ_RECORD structure,
as long as it is used for reading filesort() result that fits into
memory.
- Add frame bounds for ROWS-type frames. ROWS n PRECEDING|FOLLOWING,
ROWS UNBOUNDED PRECEDING|FOLLOWING, CURRENT ROW are supported.
- Add Item_sum_count::remove() which allows "streaming" computation
of COUNT() over a moving frame.
|
| |
|
| |
|
|
|
|
|
| |
- Make queries that use multiple window functions not to leak memory
- Code cleanup in sql_window.cc
|
| |
|
| |
|
| |
|
|
|