| 1057 | |
| 1058 | |
| 1059 | String *field_decimal::std(String *s, ha_rows rows) |
| 1060 | { |
| 1061 | if (!(rows - nulls)) |
| 1062 | { |
| 1063 | s->set_real((double) 0.0, 1,my_thd_charset); |
| 1064 | return s; |
| 1065 | } |
| 1066 | my_decimal num, tmp, sum2, sum2d; |
| 1067 | int prec_increment= current_thd->variables.div_precincrement; |
| 1068 | |
| 1069 | int2my_decimal(E_DEC_FATAL_ERROR, rows - nulls, FALSE, &num); |
| 1070 | my_decimal_mul(E_DEC_FATAL_ERROR, &sum2, sum+cur_sum, sum+cur_sum); |
| 1071 | my_decimal_div(E_DEC_FATAL_ERROR, &tmp, &sum2, &num, prec_increment); |
| 1072 | my_decimal_sub(E_DEC_FATAL_ERROR, &sum2, sum_sqr+cur_sum, &tmp); |
| 1073 | my_decimal_div(E_DEC_FATAL_ERROR, &tmp, &sum2, &num, prec_increment); |
| 1074 | double std_sqr= tmp.to_double(); |
| 1075 | s->set_real(((double) std_sqr <= 0.0 ? 0.0 : sqrt(std_sqr)), |
| 1076 | MY_MIN(item->decimals + prec_increment, NOT_FIXED_DEC), my_thd_charset); |
| 1077 | |
| 1078 | return s; |
| 1079 | } |
| 1080 | |
| 1081 | |
| 1082 | int collect_string(void *element_, element_count, void *info_) |
no test coverage detected