summaryrefslogtreecommitdiff
path: root/sql/item_timefunc.cc
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.org>2018-03-14 14:46:23 +0400
committerAlexander Barkov <bar@mariadb.org>2018-03-14 14:46:23 +0400
commit38579cefa9f3a3f662e42dbe7808f82e94878686 (patch)
tree539231364400956626658e016c4882db266029e3 /sql/item_timefunc.cc
parent9005108234ca97ce9e86935fd79ea0b3fb97ec43 (diff)
downloadmariadb-git-38579cefa9f3a3f662e42dbe7808f82e94878686.tar.gz
MDEV-14452 Precision in INTERVAL xxx DAY_MICROSECOND parsed wrong?
Diffstat (limited to 'sql/item_timefunc.cc')
-rw-r--r--sql/item_timefunc.cc14
1 files changed, 10 insertions, 4 deletions
diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc
index 4a94c3a5f89..d7506026c62 100644
--- a/sql/item_timefunc.cc
+++ b/sql/item_timefunc.cc
@@ -702,7 +702,7 @@ static bool get_interval_info(const char *str,uint length,CHARSET_INFO *cs,
{
const char *end=str+length;
uint i;
- long msec_length= 0;
+ long field_length= 0;
while (str != end && !my_isdigit(cs,*str))
str++;
@@ -713,7 +713,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 - (str - start);
+ if ((field_length= str - start) >= 20)
+ return true;
values[i]= value;
while (str != end && !my_isdigit(cs,*str))
str++;
@@ -728,8 +729,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] *= (long) log_10_int[6 - field_length];
+ else if (field_length > 6)
+ values[count - 1] /= (long) log_10_int[field_length - 6];
+ }
return (str != end);
}