-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
10.6-mdev-31744: frame_range_n_bottom assertion error #4300
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
10.6-mdev-31744: frame_range_n_bottom assertion error #4300
Conversation
6d54f7b
to
0ef7cf8
Compare
It's interesting that the testcase requires using a VIEW...
When not using a VIEW (do
|
Even for table query, shouldn't |
Also, what is the need for a temporary table here? |
A testcase without VIEWs: create table t1 (a int);
insert into t1 values (1),(2);
select
count(*) over (order by 'abc','xyz'),
count(*) over (order by 123 RANGE BETWEEN CURRENT ROW AND 5 FOLLOWING)
from t1;
|
sure, will include this testcase as well. |
0ef7cf8
to
86cda2c
Compare
A testcase that even uses a meaningful ordering, not just "order by const" : select
count(*) over (order by 'abc',a),
count(*) over (order by a RANGE BETWEEN CURRENT ROW AND 5 FOLLOWING)
from t1; |
The commit title and text:
Need to be improved.
Trying to come up with another description...
|
in get_frame_cursor(), please add a comment before the added code explaining why we use save_order_list. |
…N...) When the query uses several Window Functions: SELECT WIN_FUNC1() OVER (ORDER BY 'const', col1), WIN_FUNC2() OVER (ORDER BY col1 RANGE BETWEEN CURRENT ROW AND 5 FOLLOWING) compare_window_funcs_by_window_specs() will try to get the Window Specs to reuse the ORDER BY lists. If the lists produce the same order (like above) Window Spec of the WIN_FUNC2 will reuse the ORDER BY list of WIN_FUNC1. However, WIN_FUNC2 has a RANGE-type window frame. It expects to get ORDER BY list with one element, which it will use to compute frame bounds. Proving it with ORDER BY list from WIN_FUNC1 ('const', col1) was caused an assertion failure The fix is to use the original ORDER BY list when constructing RANGE-type frames.
86cda2c
to
ab189f0
Compare
sure. done |
sure. added this test. |
Please add more to the commit comment: - The fix is to use the original ORDER BY list when constructing RANGE-type frames.
+ The fix is to
+ - use the original ORDER BY list when constructing RANGE-type frames
+ - fix an apparent typo bug in compare_window_funcs_by_window_specs():
+ assignment
+ win_spec1->save_order_list= win_spec2->order_list;
+ saved the order list from the wrong spec. Take one from win_spec1. In the test case, please rename used tables to (one more small input coming) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good after the above is addressed.
Final question is, which version should this go into? I don't think we can put this into 10.6, as this is not a security issue.
In release builds, assert will not be checked. A release build will try to use wrong expression for the RANGE-type bound, which theoretically could cause a wrong query result. But that's it.
Considering this, I think this should go into 10.11.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok to push after the above is addressed.
moving the changes to 10.11 branch |
MDEV-31744: Assertion with COUNT(*) OVER (ORDER BY const RANGE BETWEEN...)
When the query uses several Window Functions:
SELECT
WIN_FUNC1() OVER (ORDER BY 'const', col1),
WIN_FUNC2() OVER (ORDER BY col1 RANGE BETWEEN CURRENT ROW
AND 5 FOLLOWING)
compare_window_funcs_by_window_specs() will try to get the Window Specs to
reuse the ORDER BY lists. If the lists produce the same order (like above)
Window Spec of the WIN_FUNC2 will reuse the ORDER BY list of WIN_FUNC1.
However, WIN_FUNC2 has a RANGE-type window frame. It expects to get
ORDER BY list with one element, which it will use to compute frame bounds.
Proving it with ORDER BY list from WIN_FUNC1 ('const', col1) was caused an
assertion failure
The fix is to:
assignment
win_spec1->save_order_list= win_spec2->order_list;
saved the order list from the wrong spec. Instead, take one from win_spec1.