--- ../mysql-5.1.30/sql-common/my_time.c 2008-10-11 14:54:11.000000000 -0700 +++ sql-common/my_time.c 2009-01-15 18:31:34.000000000 -0800 @@ -263,12 +263,36 @@ i++) { const char *start= str; - ulong tmp_value= (uint) (uchar) (*str++ - '0'); - while (str != end && my_isdigit(&my_charset_latin1,str[0]) && - (!is_internal_format || --field_length)) - { - tmp_value=tmp_value*10 + (ulong) (uchar) (*str - '0'); - str++; + + ulong tmp_value = 0; + if (i == format_position[6]) { /* fractional seconds */ + while (str < end || field_length > 0) { + if (str < end && my_isdigit(&my_charset_latin1,str[0])) { + if (field_length > 0) { /* don't lose precision */ + tmp_value=tmp_value*10 + (ulong) (uchar) (*str - '0'); + field_length--; /* unsigned int */ + } + else if (is_internal_format) /* beyond len, next part */ + break; + str++; + } + else { /* get place value right */ + while (field_length > 0) { + tmp_value *= 10; + field_length--; + } + break; + } + } + } + else { + tmp_value= (uint) (uchar) (*str++ - '0'); + while (str != end && my_isdigit(&my_charset_latin1,str[0]) && + (!is_internal_format || --field_length)) + { + tmp_value=tmp_value*10 + (ulong) (uchar) (*str - '0'); + str++; + } } date_len[i]= (uint) (str - start); if (tmp_value > 999999) /* Impossible date part */ @@ -369,12 +393,7 @@ l_time->hour= date[(uint) format_position[3]]; l_time->minute= date[(uint) format_position[4]]; l_time->second= date[(uint) format_position[5]]; - - frac_pos= (uint) format_position[6]; - frac_len= date_len[frac_pos]; - if (frac_len < 6) - date[frac_pos]*= (uint) log_10_int[6 - frac_len]; - l_time->second_part= date[frac_pos]; + l_time->second_part= date[(uint) format_position[6]]; if (format_position[7] != (uchar) 255) { @@ -394,8 +413,6 @@ l_time->hour= date[3]; l_time->minute= date[4]; l_time->second= date[5]; - if (date_len[6] < 6) - date[6]*= (uint) log_10_int[6 - date_len[6]]; l_time->second_part=date[6]; } l_time->neg= 0;