Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
a74e8d36
Commit
a74e8d36
authored
Mar 18, 2016
by
Igor Babaev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
For some window functions an order list must be present.
parent
13f9535f
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
44 additions
and
0 deletions
+44
-0
mysql-test/r/win.result
mysql-test/r/win.result
+11
-0
mysql-test/t/win.test
mysql-test/t/win.test
+13
-0
sql/item_windowfunc.cc
sql/item_windowfunc.cc
+5
-0
sql/item_windowfunc.h
sql/item_windowfunc.h
+13
-0
sql/share/errmsg-utf8.txt
sql/share/errmsg-utf8.txt
+2
-0
No files found.
mysql-test/r/win.result
View file @
a74e8d36
...
...
@@ -470,6 +470,17 @@ dense_rank() over (partition by c order by pk
rows between 1 preceding and 1 following) as r
from t1;
ERROR HY000: Window frame is not allowed with 'dense_rank'
select
pk, c,
rank() over w1 as r
from t1
window w1 as (partition by c);
ERROR HY000: No order list in window specification for 'rank'
select
pk, c,
dense_rank() over (partition by c) as r
from t1;
ERROR HY000: No order list in window specification for 'dense_rank'
drop table t0,t1;
#
# MDEV-9634: Window function produces incorrect value
...
...
mysql-test/t/win.test
View file @
a74e8d36
...
...
@@ -311,6 +311,19 @@ select
rows
between
1
preceding
and
1
following
)
as
r
from
t1
;
--
error
ER_NO_ORDER_LIST_IN_WINDOW_SPEC
select
pk
,
c
,
rank
()
over
w1
as
r
from
t1
window
w1
as
(
partition
by
c
);
--
error
ER_NO_ORDER_LIST_IN_WINDOW_SPEC
select
pk
,
c
,
dense_rank
()
over
(
partition
by
c
)
as
r
from
t1
;
drop
table
t0
,
t1
;
--
echo
#
...
...
sql/item_windowfunc.cc
View file @
a74e8d36
...
...
@@ -59,6 +59,11 @@ Item_window_func::fix_fields(THD *thd, Item **ref)
return
true
;
}
if
(
window_spec
->
order_list
->
elements
==
0
&&
is_order_list_mandatory
())
{
my_error
(
ER_NO_ORDER_LIST_IN_WINDOW_SPEC
,
MYF
(
0
),
window_func
->
func_name
());
return
true
;
}
/*
TODO: why the last parameter is 'ref' in this call? What if window_func
decides to substitute itself for something else and does *ref=.... ?
...
...
sql/item_windowfunc.h
View file @
a74e8d36
...
...
@@ -448,6 +448,19 @@ class Item_window_func : public Item_result_field
default:
return
false
;
}
}
bool
is_order_list_mandatory
()
{
switch
(
window_func
->
sum_func
())
{
case
Item_sum
:
:
RANK_FUNC
:
case
Item_sum
:
:
DENSE_RANK_FUNC
:
case
Item_sum
:
:
PERCENT_RANK_FUNC
:
case
Item_sum
:
:
CUME_DIST_FUNC
:
return
true
;
default:
return
false
;
}
}
/*
...
...
sql/share/errmsg-utf8.txt
View file @
a74e8d36
...
...
@@ -7150,6 +7150,8 @@ ER_BAD_COMBINATION_OF_WINDOW_FRAME_BOUND_SPECS
eng "Unacceptable combination of window frame bound specifications"
ER_NOT_ALLOWED_WINDOW_FRAME
eng "Window frame is not allowed with '%s'"
ER_NO_ORDER_LIST_IN_WINDOW_SPEC
eng "No order list in window specification for '%s'"
ER_RANGE_FRAME_NEEDS_SIMPLE_ORDERBY
eng "RANGE-type frame requires ORDER BY clause with single sort key"
ER_WRONG_TYPE_FOR_ROWS_FRAME
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment