diff options
author | Vicențiu Ciorbaru <vicentiu@mariadb.org> | 2018-03-16 14:12:00 +0200 |
---|---|---|
committer | Vicențiu Ciorbaru <vicentiu@mariadb.org> | 2018-03-16 14:12:00 +0200 |
commit | 98eb9518db1da854048b09d94244a982a1d32f9a (patch) | |
tree | 9f00cc33b5cb43fd11da3c3d62903b4c009bffa0 /sql/item_timefunc.cc | |
parent | b0c43d0c381dba1ab859de8f643d8d91dd806009 (diff) | |
parent | 0a534348c75cf435d2017959855de2efa798fd0b (diff) | |
download | mariadb-git-98eb9518db1da854048b09d94244a982a1d32f9a.tar.gz |
Merge remote-tracking branch 'origin/10.1' into 10.2
Diffstat (limited to 'sql/item_timefunc.cc')
-rw-r--r-- | sql/item_timefunc.cc | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index 01b07c00816..87c6489189c 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -714,7 +714,7 @@ static bool get_interval_info(const char *str,uint length,CHARSET_INFO *cs, { const char *end=str+length; uint i; - int msec_length= 0; + size_t field_length= 0; while (str != end && !my_isdigit(cs,*str)) str++; @@ -725,7 +725,8 @@ static bool get_interval_info(const char *str,uint length,CHARSET_INFO *cs, const char *start= str; for (value= 0; str != end && my_isdigit(cs, *str); str++) value= value*10 + *str - '0'; - msec_length= 6 - (int)(str - start); + if ((field_length= (size_t)(str - start)) >= 20) + return true; values[i]= value; while (str != end && !my_isdigit(cs,*str)) str++; @@ -740,8 +741,13 @@ static bool get_interval_info(const char *str,uint length,CHARSET_INFO *cs, } } - if (transform_msec && msec_length > 0) - values[count - 1] *= (long) log_10_int[msec_length]; + if (transform_msec && field_length > 0) + { + if (field_length < 6) + values[count - 1] *= log_10_int[6 - field_length]; + else if (field_length > 6) + values[count - 1] /= log_10_int[field_length - 6]; + } return (str != end); } |