summaryrefslogtreecommitdiff
path: root/sql/sql_analyse.cc
diff options
context:
space:
mode:
authorunknown <hf@deer.(none)>2005-11-01 16:14:26 +0400
committerunknown <hf@deer.(none)>2005-11-01 16:14:26 +0400
commitf9dbcd558a52652692c4593c93656431e4cbf043 (patch)
tree72fa10e7ca020598101a3a72681588c392407cab /sql/sql_analyse.cc
parentcc6db6d8886d4897408b032e7d3a2e6836a2311a (diff)
downloadmariadb-git-f9dbcd558a52652692c4593c93656431e4cbf043.tar.gz
Additional fix for bug #14445 (analyse.test fails)
mysql-test/r/analyse.result: test result fixed mysql-test/t/disabled.def: user_var disabled sql/sql_analyse.cc: rounding added
Diffstat (limited to 'sql/sql_analyse.cc')
-rw-r--r--sql/sql_analyse.cc17
1 files changed, 14 insertions, 3 deletions
diff --git a/sql/sql_analyse.cc b/sql/sql_analyse.cc
index fe77628497a..e1f4b8f6076 100644
--- a/sql/sql_analyse.cc
+++ b/sql/sql_analyse.cc
@@ -466,7 +466,9 @@ void field_real::add()
void field_decimal::add()
{
+ /*TODO - remove rounding stuff after decimal_div returns proper frac */
my_decimal dec_buf, *dec= item->val_decimal(&dec_buf);
+ my_decimal rounded;
uint length;
TREE_ELEMENT *element;
@@ -476,6 +478,9 @@ void field_decimal::add()
return;
}
+ my_decimal_round(E_DEC_FATAL_ERROR, dec, item->decimals, FALSE,&rounded);
+ dec= &rounded;
+
length= my_decimal_string_length(dec);
if (decimal_is_zero(dec))
@@ -1021,10 +1026,16 @@ String *field_decimal::avg(String *s, ha_rows rows)
s->set((double) 0.0, 1,my_thd_charset);
return s;
}
- my_decimal num, avg_val;
+ my_decimal num, avg_val, rounded_avg;
+ int prec_increment= current_thd->variables.div_precincrement;
+
int2my_decimal(E_DEC_FATAL_ERROR, rows - nulls, FALSE, &num);
- my_decimal_div(E_DEC_FATAL_ERROR, &avg_val, sum+cur_sum, &num, 0);
- my_decimal2string(E_DEC_FATAL_ERROR, &avg_val, 0, 0, '0', s);
+ my_decimal_div(E_DEC_FATAL_ERROR, &avg_val, sum+cur_sum, &num, prec_increment);
+ /* TODO remove this after decimal_div returns proper frac */
+ my_decimal_round(E_DEC_FATAL_ERROR, &avg_val,
+ min(sum[cur_sum].frac + prec_increment, DECIMAL_MAX_SCALE),
+ FALSE,&rounded_avg);
+ my_decimal2string(E_DEC_FATAL_ERROR, &rounded_avg, 0, 0, '0', s);
return s;
}