summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.com>2019-04-19 21:04:44 +0400
committerAlexander Barkov <bar@mariadb.com>2019-04-19 21:04:44 +0400
commitf4b27400185bab217da11f8781eebb09a8502304 (patch)
tree820d0cf08d6946a8347927774d0ba852a3e0b619
parent056b6fe1d59b515a6380e50783b3c4ad0f93959f (diff)
downloadmariadb-git-f4b27400185bab217da11f8781eebb09a8502304.tar.gz
MDEV-17299 Assertion `maybe_null' failed in make_sortkey
-rw-r--r--mysql-test/r/type_date.result25
-rw-r--r--mysql-test/t/type_date.test14
-rw-r--r--sql/item_func.cc2
3 files changed, 41 insertions, 0 deletions
diff --git a/mysql-test/r/type_date.result b/mysql-test/r/type_date.result
index 661dcabbcfe..e2c3b7f3b28 100644
--- a/mysql-test/r/type_date.result
+++ b/mysql-test/r/type_date.result
@@ -854,5 +854,30 @@ d COUNT(*)
NULL 2
DROP TABLE t1;
#
+# MDEV-17299 Assertion `maybe_null' failed in make_sortkey
+#
+CREATE TABLE t1 (pk int NOT NULL, d1 date, d2 date NOT NULL);
+INSERT INTO t1 values (1,'2018-06-22','2018-06-22'),(2,'2018-07-11','2018-07-11');
+CREATE VIEW v1 AS SELECT * FROM t1;
+SELECT group_concat(d1/(CASE 'b' WHEN 'j' THEN 'c' END))
+FROM v1 GROUP BY greatest(pk, 0, d2);
+group_concat(d1/(CASE 'b' WHEN 'j' THEN 'c' END))
+NULL
+Warnings:
+Warning 1292 Incorrect datetime value: '1' for column 'pk' at row 1
+Warning 1292 Incorrect datetime value: '2' for column 'pk' at row 1
+Warning 1292 Incorrect datetime value: '1' for column 'pk' at row 1
+Warning 1292 Incorrect datetime value: '1' for column 'pk' at row 1
+Warning 1292 Incorrect datetime value: '2' for column 'pk' at row 2
+CREATE TABLE t2 AS SELECT greatest(pk, 0, d2) AS c1 FROM t1 LIMIT 0;
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `c1` date DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t2;
+DROP VIEW v1;
+DROP TABLE t1;
+#
# End of 10.1 tests
#
diff --git a/mysql-test/t/type_date.test b/mysql-test/t/type_date.test
index 8248386a93f..554542f9dd3 100644
--- a/mysql-test/t/type_date.test
+++ b/mysql-test/t/type_date.test
@@ -585,6 +585,20 @@ INSERT INTO t1 VALUES ('1985-05-13'),('1989-12-24');
SELECT d, COUNT(*) FROM t1 GROUP BY d WITH ROLLUP HAVING CASE d WHEN '2017-05-25' THEN 0 ELSE 1 END;
DROP TABLE t1;
+--echo #
+--echo # MDEV-17299 Assertion `maybe_null' failed in make_sortkey
+--echo #
+
+CREATE TABLE t1 (pk int NOT NULL, d1 date, d2 date NOT NULL);
+INSERT INTO t1 values (1,'2018-06-22','2018-06-22'),(2,'2018-07-11','2018-07-11');
+CREATE VIEW v1 AS SELECT * FROM t1;
+SELECT group_concat(d1/(CASE 'b' WHEN 'j' THEN 'c' END))
+ FROM v1 GROUP BY greatest(pk, 0, d2);
+CREATE TABLE t2 AS SELECT greatest(pk, 0, d2) AS c1 FROM t1 LIMIT 0;
+SHOW CREATE TABLE t2;
+DROP TABLE t2;
+DROP VIEW v1;
+DROP TABLE t1;
--echo #
--echo # End of 10.1 tests
diff --git a/sql/item_func.cc b/sql/item_func.cc
index e995903b940..a1a2c3f1d1c 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -2794,6 +2794,8 @@ void Item_func_min_max::fix_length_and_dec()
switch (tmp_cmp_type) {
case TIME_RESULT:
// At least one temporal argument was found.
+ if (temporal_type_count < arg_count)
+ maybe_null= true; // Non-temporal-to-temporal conversion can return NULL
collation.set_numeric();
set_handler_by_field_type(temporal_field_type);
if (is_temporal_type_with_time(temporal_field_type))