diff options
author | Magne Mahre <magne.mahre@sun.com> | 2009-11-03 23:29:16 +0100 |
---|---|---|
committer | Magne Mahre <magne.mahre@sun.com> | 2009-11-03 23:29:16 +0100 |
commit | 5388fbaed027a5fd04adc48dff24084052994295 (patch) | |
tree | d6fd7fd45a167b2be748245c69b2a7dc5ef5548d /sql/item_timefunc.cc | |
parent | 0dae88ca2af903668c7221f2447b7be42c3a78d9 (diff) | |
download | mariadb-git-5388fbaed027a5fd04adc48dff24084052994295.tar.gz |
Bug #36466: Adding days to day_microsecond changes interpretation of microseco
When less than six places are given for microseconds, we zerofill from
the right (leftmost place is always 1/10s). We only did this when all
announced date/time fields were given; now we also format fractional
seconds when more significant fields are left out.
mysql-test/r/func_time.result:
show that we treat fractions of seconds correctly (zerofill from
right to six places) even if we left out fields on the left
mysql-test/t/func_time.test:
show that we treat fractions of seconds correctly (zerofill from
right to six places) even if we left out fields on the left
sql/item_timefunc.cc:
format fractions of seconds even if announced
more significant fields were left out
Diffstat (limited to 'sql/item_timefunc.cc')
-rw-r--r-- | sql/item_timefunc.cc | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index eefc8429f5e..b5dddc38d2a 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -865,6 +865,8 @@ static bool get_interval_info(const char *str,uint length,CHARSET_INFO *cs, { const char *end=str+length; uint i; + long msec_length= 0; + while (str != end && !my_isdigit(cs,*str)) str++; @@ -874,12 +876,7 @@ 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*LL(10) + (longlong) (*str - '0'); - if (transform_msec && i == count - 1) // microseconds always last - { - long msec_length= 6 - (uint) (str - start); - if (msec_length > 0) - value*= (long) log_10_int[msec_length]; - } + msec_length= 6 - (str - start); values[i]= value; while (str != end && !my_isdigit(cs,*str)) str++; @@ -893,6 +890,10 @@ static bool get_interval_info(const char *str,uint length,CHARSET_INFO *cs, break; } } + + if (transform_msec && msec_length > 0) + values[count - 1] *= (long) log_10_int[msec_length]; + return (str != end); } |