MDEV-16991 Rounding vs truncation for TIME, DATETIME, TIMESTAMP

This commit is contained in:
Alexander Barkov
2018-11-23 19:04:42 +04:00
parent 27f3329ff6
commit 4447a02cf1
59 changed files with 4774 additions and 398 deletions

View File

@ -256,6 +256,14 @@ static void get_microseconds(ulong *val, MYSQL_TIME_STATUS *status,
*val= (ulong) (tmp * log_10_int[6 - (*str - start)]);
else
*val= tmp;
if (str[0] < end && my_isdigit(&my_charset_latin1, str[0][0]))
{
/*
We don't need the exact nanoseconds value.
Knowing the first digit is enough for rounding.
*/
status->nanoseconds= 100 * (uint)(str[0][0] - '0');
}
if (skip_digits(str, end))
status->warnings|= MYSQL_TIME_NOTE_TRUNCATED;
}