Loading sql/field.cc +58 −65 Original line number Diff line number Diff line Loading @@ -479,23 +479,18 @@ void Field_decimal::store(const char *from,uint len) else expo_sign_char= '+'; /* Read digits of the exponent and compute its value. We must care about 'exponent' overflow, because as unsigned arithmetic is "modulo", big exponents will become small (e.g. 1e4294967296 will become 1e0, and the field will finally contain 1 instead of its max possible value). Read digits of the exponent and compute its value. We must care about 'exponent' overflow, because as unsigned arithmetic is "modulo", big exponents will become small (e.g. 1e4294967296 will become 1e0, and the field will finally contain 1 instead of its max possible value). */ for (;from!=end && isdigit(*from); from++) { exponent=10*exponent+(*from-'0'); if (exponent>MAX_EXPONENT) { exponent=MAX_EXPONENT; break; } } } /* We only have to generate warnings if count_cuted_fields is set. Loading Loading @@ -538,8 +533,8 @@ void Field_decimal::store(const char *from,uint len) /* Below tmp_uint cannot overflow with small enough MAX_EXPONENT setting, as int_digits_added_zeros<=exponent<4G and (ulonglong)(int_digits_end-int_digits_from)<=max_allowed_packet<=2G and (ulonglong)(frac_digits_from-int_digits_tail_from)<=max_allowed_packet<=2G (int_digits_end-int_digits_from)<=max_allowed_packet<=2G and (frac_digits_from-int_digits_tail_from)<=max_allowed_packet<=2G */ if (!expo_sign_char) Loading Loading @@ -577,9 +572,9 @@ void Field_decimal::store(const char *from,uint len) int_digits_added_zeros=0; } } tmp_uint=tmp_dec+(int_digits_end-int_digits_from) +(uint)(frac_digits_from-int_digits_tail_from)+ int_digits_added_zeros; tmp_uint= (tmp_dec+(int_digits_end-int_digits_from)+ (uint)(frac_digits_from-int_digits_tail_from)+ int_digits_added_zeros); } /* Loading @@ -590,8 +585,7 @@ void Field_decimal::store(const char *from,uint len) If the sign is defined and '-', we need one position for it */ if (field_length < tmp_uint + (sign_char == '-')) //the rightmost sum above cannot overflow if (field_length < tmp_uint + (int) (sign_char == '-')) { // too big number, change to max or min number Field_decimal::overflow(sign_char == '-'); Loading Loading @@ -654,8 +648,6 @@ void Field_decimal::store(const char *from,uint len) *pos--=' '; //fill with blanks } // if (tmp_dec) { /* Write digits of the frac_% parts ; Depending on current_thd->count_cutted_fields, we may also want Loading @@ -667,7 +659,8 @@ void Field_decimal::store(const char *from,uint len) pos=to+(uint)(field_length-tmp_dec); // Calculate post to '.' right_wall=to+field_length; if (pos != right_wall) *pos++='.'; if (pos != right_wall) *pos++='.'; if (expo_sign_char == '-') { Loading Loading @@ -716,7 +709,7 @@ void Field_decimal::store(const char *from,uint len) while (pos != right_wall) *pos++='0'; // Fill with zeros at right of '.' } } Loading Loading
sql/field.cc +58 −65 Original line number Diff line number Diff line Loading @@ -479,23 +479,18 @@ void Field_decimal::store(const char *from,uint len) else expo_sign_char= '+'; /* Read digits of the exponent and compute its value. We must care about 'exponent' overflow, because as unsigned arithmetic is "modulo", big exponents will become small (e.g. 1e4294967296 will become 1e0, and the field will finally contain 1 instead of its max possible value). Read digits of the exponent and compute its value. We must care about 'exponent' overflow, because as unsigned arithmetic is "modulo", big exponents will become small (e.g. 1e4294967296 will become 1e0, and the field will finally contain 1 instead of its max possible value). */ for (;from!=end && isdigit(*from); from++) { exponent=10*exponent+(*from-'0'); if (exponent>MAX_EXPONENT) { exponent=MAX_EXPONENT; break; } } } /* We only have to generate warnings if count_cuted_fields is set. Loading Loading @@ -538,8 +533,8 @@ void Field_decimal::store(const char *from,uint len) /* Below tmp_uint cannot overflow with small enough MAX_EXPONENT setting, as int_digits_added_zeros<=exponent<4G and (ulonglong)(int_digits_end-int_digits_from)<=max_allowed_packet<=2G and (ulonglong)(frac_digits_from-int_digits_tail_from)<=max_allowed_packet<=2G (int_digits_end-int_digits_from)<=max_allowed_packet<=2G and (frac_digits_from-int_digits_tail_from)<=max_allowed_packet<=2G */ if (!expo_sign_char) Loading Loading @@ -577,9 +572,9 @@ void Field_decimal::store(const char *from,uint len) int_digits_added_zeros=0; } } tmp_uint=tmp_dec+(int_digits_end-int_digits_from) +(uint)(frac_digits_from-int_digits_tail_from)+ int_digits_added_zeros; tmp_uint= (tmp_dec+(int_digits_end-int_digits_from)+ (uint)(frac_digits_from-int_digits_tail_from)+ int_digits_added_zeros); } /* Loading @@ -590,8 +585,7 @@ void Field_decimal::store(const char *from,uint len) If the sign is defined and '-', we need one position for it */ if (field_length < tmp_uint + (sign_char == '-')) //the rightmost sum above cannot overflow if (field_length < tmp_uint + (int) (sign_char == '-')) { // too big number, change to max or min number Field_decimal::overflow(sign_char == '-'); Loading Loading @@ -654,8 +648,6 @@ void Field_decimal::store(const char *from,uint len) *pos--=' '; //fill with blanks } // if (tmp_dec) { /* Write digits of the frac_% parts ; Depending on current_thd->count_cutted_fields, we may also want Loading @@ -667,7 +659,8 @@ void Field_decimal::store(const char *from,uint len) pos=to+(uint)(field_length-tmp_dec); // Calculate post to '.' right_wall=to+field_length; if (pos != right_wall) *pos++='.'; if (pos != right_wall) *pos++='.'; if (expo_sign_char == '-') { Loading Loading @@ -716,7 +709,7 @@ void Field_decimal::store(const char *from,uint len) while (pos != right_wall) *pos++='0'; // Fill with zeros at right of '.' } } Loading