diff options
author | hf@deer.(none) <> | 2005-11-01 13:08:14 +0400 |
---|---|---|
committer | hf@deer.(none) <> | 2005-11-01 13:08:14 +0400 |
commit | b98c93e0a86cbbc24c964efdc23f509d93b1b8c1 (patch) | |
tree | 2f692dbef0f2b13284be3fff26e86d6f10d9dfc9 /sql/sql_analyse.cc | |
parent | 69cd4c1ebfc01d1ea624bea7436f1f61161a6f99 (diff) | |
download | mariadb-git-b98c93e0a86cbbc24c964efdc23f509d93b1b8c1.tar.gz |
Fix for bug #14445 (analyse.test fails)
Diffstat (limited to 'sql/sql_analyse.cc')
-rw-r--r-- | sql/sql_analyse.cc | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/sql/sql_analyse.cc b/sql/sql_analyse.cc index 669f998cde5..fe77628497a 100644 --- a/sql/sql_analyse.cc +++ b/sql/sql_analyse.cc @@ -1036,13 +1036,19 @@ String *field_decimal::std(String *s, ha_rows rows) s->set((double) 0.0, 1,my_thd_charset); return s; } - my_decimal num, std_val, sum2, sum2d; + my_decimal num, tmp, sum2, sum2d; + double std_sqr; + int prec_increment= current_thd->variables.div_precincrement; + int2my_decimal(E_DEC_FATAL_ERROR, rows - nulls, FALSE, &num); my_decimal_mul(E_DEC_FATAL_ERROR, &sum2, sum+cur_sum, sum+cur_sum); - my_decimal_div(E_DEC_FATAL_ERROR, &std_val, &sum2, &num, 0); - my_decimal_sub(E_DEC_FATAL_ERROR, &sum2, sum_sqr+cur_sum, &std_val); - my_decimal_div(E_DEC_FATAL_ERROR, &std_val, &sum2, &num, 0); - my_decimal2string(E_DEC_FATAL_ERROR, &std_val, 0, 0, '0', s); + my_decimal_div(E_DEC_FATAL_ERROR, &tmp, &sum2, &num, prec_increment); + my_decimal_sub(E_DEC_FATAL_ERROR, &sum2, sum_sqr+cur_sum, &tmp); + my_decimal_div(E_DEC_FATAL_ERROR, &tmp, &sum2, &num, prec_increment); + my_decimal2double(E_DEC_FATAL_ERROR, &tmp, &std_sqr); + s->set(((double) std_sqr <= 0.0 ? 0.0 : sqrt(std_sqr)), + min(item->decimals + prec_increment, NOT_FIXED_DEC), my_thd_charset); + return s; } |