diff options
-rw-r--r-- | mysql-test/main/type_date.result | 15 | ||||
-rw-r--r-- | mysql-test/main/type_date.test | 8 | ||||
-rw-r--r-- | sql-common/my_time.c | 6 |
3 files changed, 28 insertions, 1 deletions
diff --git a/mysql-test/main/type_date.result b/mysql-test/main/type_date.result index c5c892b5e4d..a9d17b8eb83 100644 --- a/mysql-test/main/type_date.result +++ b/mysql-test/main/type_date.result @@ -1025,5 +1025,20 @@ INSERT INTO t1 SELECT * FROM t2; DROP TABLE t1,t2; SET sql_mode=DEFAULT; # +# MDEV-19301 Assertion `!is_valid_datetime() || fraction_remainder(((item->decimals) < (6) ? (item->decimals) : (6))) == 0' failed in Datetime_truncation_not_needed::Datetime_truncation_not_needed +# +SELECT NULLIF(CAST(1012.5 AS DATE), 1); +NULLIF(CAST(1012.5 AS DATE), 1) +2000-10-12 +Warnings: +Note 1292 Truncated incorrect date value: '1012.5' +Warning 1292 Truncated incorrect datetime value: '1' +Note 1292 Truncated incorrect date value: '1012.5' +SELECT CAST(1012.5 AS DATE) * 1.0; +CAST(1012.5 AS DATE) * 1.0 +20001012.0 +Warnings: +Note 1292 Truncated incorrect date value: '1012.5' +# # End of 10.4 tests # diff --git a/mysql-test/main/type_date.test b/mysql-test/main/type_date.test index 4639c004740..d795a01fd36 100644 --- a/mysql-test/main/type_date.test +++ b/mysql-test/main/type_date.test @@ -692,5 +692,13 @@ SET sql_mode=DEFAULT; --echo # +--echo # MDEV-19301 Assertion `!is_valid_datetime() || fraction_remainder(((item->decimals) < (6) ? (item->decimals) : (6))) == 0' failed in Datetime_truncation_not_needed::Datetime_truncation_not_needed +--echo # + +SELECT NULLIF(CAST(1012.5 AS DATE), 1); +SELECT CAST(1012.5 AS DATE) * 1.0; + + +--echo # --echo # End of 10.4 tests --echo # diff --git a/sql-common/my_time.c b/sql-common/my_time.c index b8054aa2c23..22ea32e5076 100644 --- a/sql-common/my_time.c +++ b/sql-common/my_time.c @@ -1728,7 +1728,11 @@ longlong number_to_datetime_or_date(longlong nr, ulong sec_part, !check_date(time_res, nr || sec_part, flags, was_cut)) { if (time_res->time_type == MYSQL_TIMESTAMP_DATE && sec_part != 0) - *was_cut= MYSQL_TIME_NOTE_TRUNCATED; + { + /* Date format, but with fractional digits, e.g. 20010203.5 */ + *was_cut= MYSQL_TIME_NOTE_TRUNCATED; + time_res->second_part= 0; + } return nr; } |