summaryrefslogtreecommitdiff
path: root/sql/compat56.cc
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2018-10-02 22:50:28 +0200
committerSergei Golubchik <serg@mariadb.org>2018-10-24 13:13:35 +0200
commit0140bfac5e216bd7ba8ad324bd914d596bf59a1f (patch)
tree3c7f79c8ba5ed69413881e8e4734e4caba7fd69b /sql/compat56.cc
parent5b735e8f09c81a2533c30cdd62d60dffa8226cd4 (diff)
downloadmariadb-git-0140bfac5e216bd7ba8ad324bd914d596bf59a1f.tar.gz
MDEV-16127 mroonga/storage.* tests fail with GCC 8
Tests were failing because in TIME_from_longlong_datetime_packed() GCC8 at -O2 assumed that tmp is always positive and used mul and shr while it used imul and sar at -O1 (where tests passed). GCC8 used multiplication (by 0x4ec4ec4ec4ec4ec5) and shift to implement division by 13. It could assume that tmp is always positive, because the function starts with `if (tmp < 0) tmp= -tmp;` But this assumption breaks if tmp=0x8000000000000000; This is invalid value and TIME_from_longlong_datetime_packed() should never see it, garbage in - garbage out. It was getting this invalid value because mroonga tried to convert a NULL key part to MYSQL_TIME. If the key part value is NULL, datetime2 value of it happens to be bzero-ed, which is invalid binary datetime2 value. The correct behavior is not to try to interpret the key part value, if it is marked as NULL. But this minimal fix only covers the datetime2 type.
Diffstat (limited to 'sql/compat56.cc')
-rw-r--r--sql/compat56.cc3
1 files changed, 3 insertions, 0 deletions
diff --git a/sql/compat56.cc b/sql/compat56.cc
index 3bd6b21a154..357b4bcf78b 100644
--- a/sql/compat56.cc
+++ b/sql/compat56.cc
@@ -252,6 +252,9 @@ void TIME_from_longlong_datetime_packed(MYSQL_TIME *ltime, longlong tmp)
{
longlong ymd, hms;
longlong ymdhms, ym;
+
+ DBUG_ASSERT(tmp != LONGLONG_MIN);
+
if ((ltime->neg= (tmp < 0)))
tmp= -tmp;