summaryrefslogtreecommitdiff
path: root/sql/sql_analyse.cc
diff options
context:
space:
mode:
authorunknown <hf@deer.(none)>2005-11-01 13:08:14 +0400
committerunknown <hf@deer.(none)>2005-11-01 13:08:14 +0400
commitcc6db6d8886d4897408b032e7d3a2e6836a2311a (patch)
tree2f692dbef0f2b13284be3fff26e86d6f10d9dfc9 /sql/sql_analyse.cc
parent389018280db5fab79ec76fb286071734b014fc0e (diff)
downloadmariadb-git-cc6db6d8886d4897408b032e7d3a2e6836a2311a.tar.gz
Fix for bug #14445 (analyse.test fails)
mysql-test/r/analyse.result: test result fixed sql/sql_analyse.cc: missing sqrt(std_sqr) added
Diffstat (limited to 'sql/sql_analyse.cc')
-rw-r--r--sql/sql_analyse.cc16
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;
}