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
2412c151
Commit
2412c151
authored
Jun 13, 2018
by
Alexander Barkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-15870 Using aggregate and window function in unexpected places can crash the server
parent
ae0aefb1
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
5 deletions
+30
-5
mysql-test/r/sp.result
mysql-test/r/sp.result
+11
-0
mysql-test/t/sp.test
mysql-test/t/sp.test
+14
-0
sql/item_sum.cc
sql/item_sum.cc
+2
-2
sql/item_windowfunc.cc
sql/item_windowfunc.cc
+3
-3
No files found.
mysql-test/r/sp.result
View file @
2412c151
...
...
@@ -8354,3 +8354,14 @@ drop procedure p3;
CREATE PROCEDURE foo ( IN i INT UNSIGNED ) BEGIN END;
CALL foo( LAST_INSERT_ID() );
DROP PROCEDURE foo;
#
# MDEV-15870 Using aggregate and window function in unexpected places can crash the server
#
CREATE PROCEDURE p1 (a TEXT) BEGIN END;
CALL p1(RANK() OVER (ORDER BY 1));
ERROR HY000: Window function is allowed only in SELECT list and ORDER BY clause
CALL p1(ROW_NUMBER() OVER ());
ERROR HY000: Window function is allowed only in SELECT list and ORDER BY clause
CALL p1(SUM(1));
ERROR HY000: Invalid use of group function
DROP PROCEDURE p1;
mysql-test/t/sp.test
View file @
2412c151
...
...
@@ -9865,3 +9865,17 @@ drop procedure p3;
CREATE
PROCEDURE
foo
(
IN
i
INT
UNSIGNED
)
BEGIN
END
;
CALL
foo
(
LAST_INSERT_ID
()
);
DROP
PROCEDURE
foo
;
--
echo
#
--
echo
# MDEV-15870 Using aggregate and window function in unexpected places can crash the server
--
echo
#
CREATE
PROCEDURE
p1
(
a
TEXT
)
BEGIN
END
;
--
error
ER_WRONG_PLACEMENT_OF_WINDOW_FUNCTION
CALL
p1
(
RANK
()
OVER
(
ORDER
BY
1
));
--
error
ER_WRONG_PLACEMENT_OF_WINDOW_FUNCTION
CALL
p1
(
ROW_NUMBER
()
OVER
());
--
error
ER_INVALID_GROUP_FUNC_USE
CALL
p1
(
SUM
(
1
));
DROP
PROCEDURE
p1
;
sql/item_sum.cc
View file @
2412c151
...
...
@@ -68,14 +68,14 @@ size_t Item_sum::ram_limitation(THD *thd)
bool
Item_sum
::
init_sum_func_check
(
THD
*
thd
)
{
SELECT_LEX
*
curr_sel
=
thd
->
lex
->
current_select
;
if
(
!
curr_sel
->
name_visibility_map
)
if
(
curr_sel
&&
!
curr_sel
->
name_visibility_map
)
{
for
(
SELECT_LEX
*
sl
=
curr_sel
;
sl
;
sl
=
sl
->
context
.
outer_select
())
{
curr_sel
->
name_visibility_map
|=
(
1
<<
sl
->
nest_level
);
}
}
if
(
!
(
thd
->
lex
->
allow_sum_func
&
curr_sel
->
name_visibility_map
))
if
(
!
curr_sel
||
!
(
thd
->
lex
->
allow_sum_func
&
curr_sel
->
name_visibility_map
))
{
my_message
(
ER_INVALID_GROUP_FUNC_USE
,
ER_THD
(
thd
,
ER_INVALID_GROUP_FUNC_USE
),
MYF
(
0
));
...
...
sql/item_windowfunc.cc
View file @
2412c151
...
...
@@ -71,9 +71,9 @@ Item_window_func::fix_fields(THD *thd, Item **ref)
{
DBUG_ASSERT
(
fixed
==
0
);
enum_parsing_place
place
=
thd
->
lex
->
current_select
->
context_analysis_place
;
if
(
!
(
place
==
SELECT_LIST
||
place
=
=
IN_ORDER_BY
))
if
(
!
thd
->
lex
->
current_select
||
(
thd
->
lex
->
current_select
->
context_analysis_place
!=
SELECT_LIST
&&
thd
->
lex
->
current_select
->
context_analysis_place
!
=
IN_ORDER_BY
))
{
my_error
(
ER_WRONG_PLACEMENT_OF_WINDOW_FUNCTION
,
MYF
(
0
));
return
true
;
...
...
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