diff options
author | Alexander Barkov <bar@mariadb.com> | 2018-08-18 23:22:22 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.com> | 2018-08-18 23:22:22 +0400 |
commit | 4299b82ad813a1ad5dfc84f02415eedfcf731bbc (patch) | |
tree | 5539215946222fd4b445730cdd335781d28a3356 | |
parent | bf1c53e9be84437ada32393bb7b4a8ff06dbf369 (diff) | |
download | mariadb-git-4299b82ad813a1ad5dfc84f02415eedfcf731bbc.tar.gz |
MDEV-17015 Assertion `m_year <= 9999' failed in Year::Year upon bad argument to MAKEDATE
-rw-r--r-- | mysql-test/main/type_year.result | 6 | ||||
-rw-r--r-- | mysql-test/main/type_year.test | 4 | ||||
-rw-r--r-- | sql/sql_type.cc | 4 |
3 files changed, 12 insertions, 2 deletions
diff --git a/mysql-test/main/type_year.result b/mysql-test/main/type_year.result index 3fdca099a94..6485a825f5b 100644 --- a/mysql-test/main/type_year.result +++ b/mysql-test/main/type_year.result @@ -554,5 +554,11 @@ MIN(a) MAX(a) 70 69 DROP TABLE t1; # +# MDEV-17015 Assertion `m_year <= 9999' failed in Year::Year upon bad argument to MAKEDATE +# +SELECT MAKEDATE(18446744073709551615, 1); +MAKEDATE(18446744073709551615, 1) +NULL +# # End of 10.4 tests # diff --git a/mysql-test/main/type_year.test b/mysql-test/main/type_year.test index 657940a62a8..cc02acd8fbb 100644 --- a/mysql-test/main/type_year.test +++ b/mysql-test/main/type_year.test @@ -294,6 +294,10 @@ SELECT a, CAST(a AS DATE), CAST(COALESCE(a) AS DATE) FROM t1; SELECT MIN(a), MAX(a) FROM t1; DROP TABLE t1; +--echo # +--echo # MDEV-17015 Assertion `m_year <= 9999' failed in Year::Year upon bad argument to MAKEDATE +--echo # +SELECT MAKEDATE(18446744073709551615, 1); --echo # --echo # End of 10.4 tests diff --git a/sql/sql_type.cc b/sql/sql_type.cc index 7746ce76004..e7fcdf499ec 100644 --- a/sql/sql_type.cc +++ b/sql/sql_type.cc @@ -323,8 +323,8 @@ VSec6::VSec6(Item *item, const char *type_str, ulonglong limit) Year::Year(longlong value, bool unsigned_flag, uint length) { - if ((m_truncated= (value < 0 && !unsigned_flag))) - m_year= 0; + if ((m_truncated= (value < 0))) // Negative or huge unsigned + m_year= unsigned_flag ? 9999 : 0; else if (value > 9999) { m_truncated= true; |