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
7fc86a73
Commit
7fc86a73
authored
Aug 07, 2019
by
Alexander Barkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-20272 PERCENTILE_DISC() crashes on a temporal type input
parent
d70dac20
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
10 deletions
+54
-10
mysql-test/main/win_percentile.result
mysql-test/main/win_percentile.result
+14
-0
mysql-test/main/win_percentile.test
mysql-test/main/win_percentile.test
+17
-0
sql/item_windowfunc.cc
sql/item_windowfunc.cc
+23
-10
No files found.
mysql-test/main/win_percentile.result
View file @
7fc86a73
...
@@ -451,3 +451,17 @@ Lady of the Flies 20000000000.00
...
@@ -451,3 +451,17 @@ Lady of the Flies 20000000000.00
Lord of the Ladybirds 30000000000.00
Lord of the Ladybirds 30000000000.00
Lord of the Ladybirds 30000000000.00
Lord of the Ladybirds 30000000000.00
DROP TABLE t2, t1;
DROP TABLE t2, t1;
#
# MDEV-20272 PERCENTILE_DISC() crashes on a temporal type input
#
CREATE OR REPLACE TABLE t1 (name CHAR(30), star_rating TIME);
INSERT INTO t1 VALUES ('Lord of the Ladybirds', 5);
INSERT INTO t1 VALUES ('Lord of the Ladybirds', 3);
INSERT INTO t1 VALUES ('Lady of the Flies', 1);
INSERT INTO t1 VALUES ('Lady of the Flies', 2);
INSERT INTO t1 VALUES ('Lady of the Flies', 5);
SELECT name, PERCENTILE_DISC(0.5)
WITHIN GROUP (ORDER BY star_rating)
OVER (PARTITION BY name) AS pc FROM t1;
ERROR HY000: Numeric datatype is required for percentile_disc function
DROP TABLE t1;
mysql-test/main/win_percentile.test
View file @
7fc86a73
...
@@ -209,3 +209,20 @@ CREATE OR REPLACE TABLE t2 AS SELECT name, PERCENTILE_DISC(0.5)
...
@@ -209,3 +209,20 @@ CREATE OR REPLACE TABLE t2 AS SELECT name, PERCENTILE_DISC(0.5)
SHOW
CREATE
TABLE
t2
;
SHOW
CREATE
TABLE
t2
;
SELECT
*
FROM
t2
ORDER
BY
name
,
pc
;
SELECT
*
FROM
t2
ORDER
BY
name
,
pc
;
DROP
TABLE
t2
,
t1
;
DROP
TABLE
t2
,
t1
;
--
echo
#
--
echo
# MDEV-20272 PERCENTILE_DISC() crashes on a temporal type input
--
echo
#
CREATE
OR
REPLACE
TABLE
t1
(
name
CHAR
(
30
),
star_rating
TIME
);
INSERT
INTO
t1
VALUES
(
'Lord of the Ladybirds'
,
5
);
INSERT
INTO
t1
VALUES
(
'Lord of the Ladybirds'
,
3
);
INSERT
INTO
t1
VALUES
(
'Lady of the Flies'
,
1
);
INSERT
INTO
t1
VALUES
(
'Lady of the Flies'
,
2
);
INSERT
INTO
t1
VALUES
(
'Lady of the Flies'
,
5
);
--
error
ER_WRONG_TYPE_FOR_PERCENTILE_FUNC
SELECT
name
,
PERCENTILE_DISC
(
0.5
)
WITHIN
GROUP
(
ORDER
BY
star_rating
)
OVER
(
PARTITION
BY
name
)
AS
pc
FROM
t1
;
DROP
TABLE
t1
;
sql/item_windowfunc.cc
View file @
7fc86a73
...
@@ -172,25 +172,38 @@ void Item_window_func::split_sum_func(THD *thd, Ref_ptr_array ref_pointer_array,
...
@@ -172,25 +172,38 @@ void Item_window_func::split_sum_func(THD *thd, Ref_ptr_array ref_pointer_array,
bool
Item_window_func
::
check_result_type_of_order_item
()
bool
Item_window_func
::
check_result_type_of_order_item
()
{
{
if
(
only_single_element_order_list
())
switch
(
window_func
()
->
sum_func
())
{
case
Item_sum
:
:
PERCENTILE_CONT_FUNC
:
{
{
Item
*
src_item
=
window_spec
->
order_list
->
first
->
item
[
0
];
Item_result
rtype
=
window_spec
->
order_list
->
first
->
item
[
0
]
->
cmp_type
();
Item_result
rtype
=
src_item
->
cmp_type
();
// TODO (varun) : support date type in percentile_cont function
// TODO (varun) : support date type in percentile_cont function
if
(
rtype
!=
REAL_RESULT
&&
rtype
!=
INT_RESULT
&&
if
(
rtype
!=
REAL_RESULT
&&
rtype
!=
INT_RESULT
&&
rtype
!=
DECIMAL_RESULT
&&
rtype
!=
TIME_RESULT
)
rtype
!=
DECIMAL_RESULT
&&
rtype
!=
TIME_RESULT
)
{
{
my_error
(
ER_WRONG_TYPE_FOR_PERCENTILE_FUNC
,
MYF
(
0
),
window_func
()
->
func_name
());
my_error
(
ER_WRONG_TYPE_FOR_PERCENTILE_FUNC
,
MYF
(
0
),
window_func
()
->
func_name
());
return
TRUE
;
return
true
;
}
}
if
(
window_func
()
->
sum_func
()
==
Item_sum
::
PERCENTILE_DISC_FUNC
)
return
false
;
}
case
Item_sum
:
:
PERCENTILE_DISC_FUNC
:
{
Item
*
src_item
=
window_spec
->
order_list
->
first
->
item
[
0
];
Item_result
rtype
=
src_item
->
cmp_type
();
// TODO-10.5: Fix MDEV-20280 PERCENTILE_DISC() rejects temporal and string input
if
(
rtype
!=
REAL_RESULT
&&
rtype
!=
INT_RESULT
&&
rtype
!=
DECIMAL_RESULT
)
{
{
Item_sum_percentile_disc
*
func
=
my_error
(
ER_WRONG_TYPE_FOR_PERCENTILE_FUNC
,
MYF
(
0
),
window_func
()
->
func_name
());
static_cast
<
Item_sum_percentile_disc
*>
(
window_func
());
return
true
;
func
->
set_handler
(
src_item
->
type_handler
());
func
->
Type_std_attributes
::
set
(
src_item
);
Type_std_attributes
::
set
(
src_item
);
}
}
Item_sum_percentile_disc
*
func
=
static_cast
<
Item_sum_percentile_disc
*>
(
window_func
());
func
->
set_handler
(
src_item
->
type_handler
());
func
->
Type_std_attributes
::
set
(
src_item
);
Type_std_attributes
::
set
(
src_item
);
return
false
;
}
default:
break
;
}
}
return
FALSE
;
return
FALSE
;
}
}
...
...
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