-
Alexander Barkov authored
MDEV-29149 Assertion `!is_valid_datetime() || fraction_remainder(((item->decimals) < (6) ? (item->decimals) : (6))) == 0' failed in Datetime_truncation_not_needed::Datetime_truncation_not_needed TIME-alike string and numeric arguments to TIMEDIFF() can get additional fractional seconds during the supported TIME range adjustment in get_time(). For example, during TIMEDIFF('839:00:00','00:00:00') evaluation in Item_func_timediff::get_date(), the call for args[0]->get_time() returns MYSQL_TIME '838:59:59.999999'. Item_func_timediff::get_date() did not handle these extra digits and returned a MYSQL_TIME result with fractional digits outside of Item_func_timediff::decimals. This mismatch could further be caught by a DBUG_ASSERT() in various other pieces of the code, leading to a crash. Fix: In case if get_time() returned MYSQL_TIMESTAMP_TIME, let's truncate all extra digits using my_time_trunc(&l_time,decimals). This guarantees that the rest of the code returns a MYSQL_TIME with second_part not conflicting with Item_func_timediff::decimals.
b697dce8