summaryrefslogtreecommitdiff
path: root/sql-common
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.com>2018-11-23 19:04:42 +0400
committerAlexander Barkov <bar@mariadb.com>2018-11-26 08:10:47 +0400
commit4447a02cf13a49876001a40ca7db8fdedb731fd5 (patch)
tree1ccf39024e26a1efa68237e5d44a2296a990441d /sql-common
parent27f3329ff6cb755b600d536347669bef1a7d98b5 (diff)
downloadmariadb-git-4447a02cf13a49876001a40ca7db8fdedb731fd5.tar.gz
MDEV-16991 Rounding vs truncation for TIME, DATETIME, TIMESTAMPbb-10.4-mdev16991
Diffstat (limited to 'sql-common')
-rw-r--r--sql-common/my_time.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/sql-common/my_time.c b/sql-common/my_time.c
index d16970c0a5f..2aa657ca14e 100644
--- a/sql-common/my_time.c
+++ b/sql-common/my_time.c
@@ -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;
}