diff options
author | Alexey Botchkov <holyfoot@mysql.com> | 2008-11-17 19:41:09 +0400 |
---|---|---|
committer | Alexey Botchkov <holyfoot@mysql.com> | 2008-11-17 19:41:09 +0400 |
commit | 88a88636271aee2b89000a99c18d551813f0dcc5 (patch) | |
tree | 8850c9cb1270fa36a87f2d7f363e834088dfbf6c /sql/item_func.cc | |
parent | 56b9586fd1d94ebd70662417a1d2ac1921da4ad2 (diff) | |
download | mariadb-git-88a88636271aee2b89000a99c18d551813f0dcc5.tar.gz |
Bug#31616 div_precision_increment description looks wrong
Item_func_div didn't calculate the precision of the result properly.
The result of 5/0.0001 is 5000 so we have to add decimals of the divisor
to the planned precision.
per-file comments:
mysql-test/r/type_newdecimal.result
Bug#31616 div_precision_increment description looks wrong
test result fixed
mysql-test/t/type_newdecimal.test
Bug#31616 div_precision_increment description looks wrong
test case
sql/item_func.cc
Bug#31616 div_precision_increment description looks wrong
precision must be increased with args[1]->decimals parameter
Diffstat (limited to 'sql/item_func.cc')
-rw-r--r-- | sql/item_func.cc | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/sql/item_func.cc b/sql/item_func.cc index e663e1fcf83..dfe1082fd73 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -1316,8 +1316,10 @@ my_decimal *Item_func_div::decimal_op(my_decimal *decimal_value) void Item_func_div::result_precision() { - uint arg_prec= args[0]->decimal_precision() + prec_increment; - uint precision=min(arg_prec, DECIMAL_MAX_PRECISION); + uint precision=min(args[0]->decimal_precision() + + args[1]->decimals + prec_increment, + DECIMAL_MAX_PRECISION); + /* Integer operations keep unsigned_flag if one of arguments is unsigned */ if (result_type() == INT_RESULT) unsigned_flag= args[0]->unsigned_flag | args[1]->unsigned_flag; |