diff options
author | unknown <aivanov@mysql.com> | 2005-12-15 18:48:08 +0300 |
---|---|---|
committer | unknown <aivanov@mysql.com> | 2005-12-15 18:48:08 +0300 |
commit | 52c044008508b1b445b21d780a238c9cb0b8c891 (patch) | |
tree | 9b272029a8f909f6854184ce5fe89b861c838022 /sql-common | |
parent | b6aaf4f6d16e1883910f06275a755c0e7ae6cc06 (diff) | |
download | mariadb-git-52c044008508b1b445b21d780a238c9cb0b8c891.tar.gz |
Fixed BUG #12440: "Incorrect processing of time values containing
long fraction and/or large exponent part".
mysql-test/r/type_time.result:
Fixed testcases results (bug #12440)
mysql-test/t/type_time.test:
Added testcases for bug #12440
sql-common/my_time.c:
Fixed bug #12440: "Incorrect processing of time values containing
long fraction and/or large exponent part".
Modified str_to_time(). Process properly fraction part containing
more than 6 digits. Check for existence of exponent part which
may result from %g formatting applied to time value specified as
large real number.
Diffstat (limited to 'sql-common')
-rw-r--r-- | sql-common/my_time.c | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/sql-common/my_time.c b/sql-common/my_time.c index 40d7799e274..3c46a944ba9 100644 --- a/sql-common/my_time.c +++ b/sql-common/my_time.c @@ -514,18 +514,34 @@ fractional: /* Get fractional second part */ if ((end-str) >= 2 && *str == '.' && my_isdigit(&my_charset_latin1,str[1])) { - uint field_length=5; + int field_length= 5; str++; value=(uint) (uchar) (*str - '0'); - while (++str != end && - my_isdigit(&my_charset_latin1,str[0]) && - field_length--) - value=value*10 + (uint) (uchar) (*str - '0'); - if (field_length) + while (++str != end && my_isdigit(&my_charset_latin1, *str)) + { + if (field_length-- > 0) + value= value*10 + (uint) (uchar) (*str - '0'); + } + if (field_length > 0) value*= (long) log_10_int[field_length]; + else if (field_length < 0) + *was_cut= 1; date[4]=value; } else date[4]=0; + + /* Check for exponent part: E<gigit> | E<sign><digit> */ + /* (may occur as result of %g formatting of time value) */ + if ((end - str) > 1 && + (*str == 'e' || *str == 'E') && + (my_isdigit(&my_charset_latin1, str[1]) || + ((str[1] == '-' || str[1] == '+') && + (end - str) > 2 && + my_isdigit(&my_charset_latin1, str[2])))) + { + *was_cut= 1; + return 1; + } if (internal_format_positions[7] != 255) { |