summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.com>2019-08-07 22:44:54 +0400
committerAlexander Barkov <bar@mariadb.com>2019-08-07 22:44:54 +0400
commit7fc86a73d8fbfa6d527d9eb1160bedaf939eae7a (patch)
treeab1c8eb40c1638ad5134dac9c96d5aa45892c375 /mysql-test
parentd70dac207930ab74add149be692a775bc2952aaa (diff)
downloadmariadb-git-7fc86a73d8fbfa6d527d9eb1160bedaf939eae7a.tar.gz
MDEV-20272 PERCENTILE_DISC() crashes on a temporal type input
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/main/win_percentile.result14
-rw-r--r--mysql-test/main/win_percentile.test17
2 files changed, 31 insertions, 0 deletions
diff --git a/mysql-test/main/win_percentile.result b/mysql-test/main/win_percentile.result
index 19c400c3f2b..a2ca775fcfb 100644
--- a/mysql-test/main/win_percentile.result
+++ b/mysql-test/main/win_percentile.result
@@ -451,3 +451,17 @@ Lady of the Flies 20000000000.00
Lord of the Ladybirds 30000000000.00
Lord of the Ladybirds 30000000000.00
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;
diff --git a/mysql-test/main/win_percentile.test b/mysql-test/main/win_percentile.test
index 2b3fffc4508..8705be123ff 100644
--- a/mysql-test/main/win_percentile.test
+++ b/mysql-test/main/win_percentile.test
@@ -209,3 +209,20 @@ CREATE OR REPLACE TABLE t2 AS SELECT name, PERCENTILE_DISC(0.5)
SHOW CREATE TABLE t2;
SELECT * FROM t2 ORDER BY name, pc;
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;