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
33b839b2
Commit
33b839b2
authored
Jun 01, 2020
by
Alexander Barkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-20280 PERCENTILE_DISC() rejects temporal and string input
parent
f22093ad
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
112 additions
and
14 deletions
+112
-14
mysql-test/main/win_percentile.result
mysql-test/main/win_percentile.result
+33
-3
mysql-test/main/win_percentile.test
mysql-test/main/win_percentile.test
+8
-3
plugin/type_inet/mysql-test/type_inet/type_inet6.result
plugin/type_inet/mysql-test/type_inet/type_inet6.result
+37
-0
plugin/type_inet/mysql-test/type_inet/type_inet6.test
plugin/type_inet/mysql-test/type_inet/type_inet6.test
+22
-0
sql/item_windowfunc.cc
sql/item_windowfunc.cc
+0
-7
sql/item_windowfunc.h
sql/item_windowfunc.h
+12
-1
No files found.
mysql-test/main/win_percentile.result
View file @
33b839b2
...
...
@@ -99,7 +99,14 @@ Tatiana
select score, percentile_cont(0.5) within group(order by name) over (partition by score) from t1;
ERROR HY000: Numeric datatype is required for percentile_cont function
select score, percentile_disc(0.5) within group(order by name) over (partition by score) from t1;
ERROR HY000: Numeric datatype is required for percentile_disc function
score percentile_disc(0.5) within group(order by name) over (partition by score)
3.0000 Chun
3.0000 Chun
4.0000 Tata
4.0000 Tata
4.0000 Tata
7.0000 Chun
7.0000 Chun
#parameter value should be in the range of [0,1]
select percentile_disc(1.5) within group(order by score) over (partition by name) from t1;
ERROR HY000: Argument to the percentile_disc function does not belong to the range [0,1]
...
...
@@ -452,7 +459,7 @@ Lord of the Ladybirds 30000000000.00
Lord of the Ladybirds 30000000000.00
DROP TABLE t2, t1;
#
# MDEV-202
72 PERCENTILE_DISC() crashes on a temporal type
input
# MDEV-202
80 PERCENTILE_DISC() rejects temporal and string
input
#
CREATE OR REPLACE TABLE t1 (name CHAR(30), star_rating TIME);
INSERT INTO t1 VALUES ('Lord of the Ladybirds', 5);
...
...
@@ -463,5 +470,28 @@ 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
name pc
Lady of the Flies 00:00:02
Lady of the Flies 00:00:02
Lady of the Flies 00:00:02
Lord of the Ladybirds 00:00:03
Lord of the Ladybirds 00:00:03
SELECT name, PERCENTILE_DISC(0)
WITHIN GROUP (ORDER BY star_rating)
OVER (PARTITION BY name) AS pc FROM t1;
name pc
Lady of the Flies 00:00:01
Lady of the Flies 00:00:01
Lady of the Flies 00:00:01
Lord of the Ladybirds 00:00:03
Lord of the Ladybirds 00:00:03
SELECT name, PERCENTILE_DISC(1)
WITHIN GROUP (ORDER BY star_rating)
OVER (PARTITION BY name) AS pc FROM t1;
name pc
Lady of the Flies 00:00:05
Lady of the Flies 00:00:05
Lady of the Flies 00:00:05
Lord of the Ladybirds 00:00:05
Lord of the Ladybirds 00:00:05
DROP TABLE t1;
mysql-test/main/win_percentile.test
View file @
33b839b2
...
...
@@ -61,7 +61,7 @@ select name from t1 a where (select percentile_disc(0.5) within group (order by
--
echo
#disallowed fields in order by
--
error
ER_WRONG_TYPE_FOR_PERCENTILE_FUNC
select
score
,
percentile_cont
(
0.5
)
within
group
(
order
by
name
)
over
(
partition
by
score
)
from
t1
;
--
error
ER_WRONG_TYPE_FOR_PERCENTILE_FUNC
select
score
,
percentile_disc
(
0.5
)
within
group
(
order
by
name
)
over
(
partition
by
score
)
from
t1
;
--
echo
#parameter value should be in the range of [0,1]
...
...
@@ -212,7 +212,7 @@ DROP TABLE t2, t1;
--
echo
#
--
echo
# MDEV-202
72 PERCENTILE_DISC() crashes on a temporal type
input
--
echo
# MDEV-202
80 PERCENTILE_DISC() rejects temporal and string
input
--
echo
#
CREATE
OR
REPLACE
TABLE
t1
(
name
CHAR
(
30
),
star_rating
TIME
);
...
...
@@ -221,8 +221,13 @@ 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
;
SELECT
name
,
PERCENTILE_DISC
(
0
)
WITHIN
GROUP
(
ORDER
BY
star_rating
)
OVER
(
PARTITION
BY
name
)
AS
pc
FROM
t1
;
SELECT
name
,
PERCENTILE_DISC
(
1
)
WITHIN
GROUP
(
ORDER
BY
star_rating
)
OVER
(
PARTITION
BY
name
)
AS
pc
FROM
t1
;
DROP
TABLE
t1
;
plugin/type_inet/mysql-test/type_inet/type_inet6.result
View file @
33b839b2
...
...
@@ -2021,3 +2021,40 @@ b ::1
DROP TABLE t2;
DROP TABLE t1;
DROP FUNCTION aggregate_min_inet6;
#
# MDEV-20280 PERCENTILE_DISC() rejects temporal and string input
#
CREATE TABLE t1 (name CHAR(30), star_rating INET6);
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;
name pc
Lady of the Flies ::2
Lady of the Flies ::2
Lady of the Flies ::2
Lord of the Ladybirds ::3
Lord of the Ladybirds ::3
SELECT name, PERCENTILE_DISC(0)
WITHIN GROUP (ORDER BY star_rating)
OVER (PARTITION BY name) AS pc FROM t1;
name pc
Lady of the Flies ::1
Lady of the Flies ::1
Lady of the Flies ::1
Lord of the Ladybirds ::3
Lord of the Ladybirds ::3
SELECT name, PERCENTILE_DISC(1)
WITHIN GROUP (ORDER BY star_rating)
OVER (PARTITION BY name) AS pc FROM t1;
name pc
Lady of the Flies ::5
Lady of the Flies ::5
Lady of the Flies ::5
Lord of the Ladybirds ::5
Lord of the Ladybirds ::5
DROP TABLE t1;
plugin/type_inet/mysql-test/type_inet/type_inet6.test
View file @
33b839b2
...
...
@@ -1494,3 +1494,25 @@ DROP TABLE t2;
DROP
TABLE
t1
;
DROP
FUNCTION
aggregate_min_inet6
;
--
echo
#
--
echo
# MDEV-20280 PERCENTILE_DISC() rejects temporal and string input
--
echo
#
CREATE
TABLE
t1
(
name
CHAR
(
30
),
star_rating
INET6
);
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
;
SELECT
name
,
PERCENTILE_DISC
(
0
)
WITHIN
GROUP
(
ORDER
BY
star_rating
)
OVER
(
PARTITION
BY
name
)
AS
pc
FROM
t1
;
SELECT
name
,
PERCENTILE_DISC
(
1
)
WITHIN
GROUP
(
ORDER
BY
star_rating
)
OVER
(
PARTITION
BY
name
)
AS
pc
FROM
t1
;
DROP
TABLE
t1
;
sql/item_windowfunc.cc
View file @
33b839b2
...
...
@@ -187,13 +187,6 @@ bool Item_window_func::check_result_type_of_order_item()
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
)
{
my_error
(
ER_WRONG_TYPE_FOR_PERCENTILE_FUNC
,
MYF
(
0
),
window_func
()
->
func_name
());
return
true
;
}
Item_sum_percentile_disc
*
func
=
static_cast
<
Item_sum_percentile_disc
*>
(
window_func
());
func
->
set_handler
(
src_item
->
type_handler
());
...
...
sql/item_windowfunc.h
View file @
33b839b2
...
...
@@ -779,12 +779,23 @@ class Item_sum_percentile_disc : public Item_sum_num,
if
(
get_row_count
()
==
0
||
get_arg
(
0
)
->
is_null
())
{
null_value
=
true
;
return
0
;
return
true
;
}
null_value
=
false
;
return
value
->
get_date
(
thd
,
ltime
,
fuzzydate
);
}
bool
val_native
(
THD
*
thd
,
Native
*
to
)
{
if
(
get_row_count
()
==
0
||
get_arg
(
0
)
->
is_null
())
{
null_value
=
true
;
return
true
;
}
null_value
=
false
;
return
value
->
val_native
(
thd
,
to
);
}
bool
add
()
{
Item
*
arg
=
get_arg
(
0
);
...
...
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