summaryrefslogtreecommitdiff
path: root/sql/item_func.cc
diff options
context:
space:
mode:
authorunknown <igor@olga.mysql.com>2007-06-13 09:32:36 -0700
committerunknown <igor@olga.mysql.com>2007-06-13 09:32:36 -0700
commitc0ebdff9c76c2b3e09bf5e44c22e68a35ef1affc (patch)
treef5072132a75069825238eb0a052ba011b5e9c8fa /sql/item_func.cc
parent119412f8d0cc364678e8e3b3c36c42e6fea69e3d (diff)
downloadmariadb-git-c0ebdff9c76c2b3e09bf5e44c22e68a35ef1affc.tar.gz
Fixed bug #28980: the result of ROUND(<decimal expr>,<int column>)
was erroneously converted to double, while the result of ROUND(<decimal expr>, <int literal>) was preserved as decimal. As a result of such a conversion the value of ROUND(D,A) could differ from the value of ROUND(D,val(A)) if D was a decimal expression. Now the result of the ROUND function is never converted to double if the first argument is decimal. mysql-test/r/type_decimal.result: Added a test case for bug #28980. mysql-test/t/type_decimal.test: Added a test case for bug #28980.
Diffstat (limited to 'sql/item_func.cc')
-rw-r--r--sql/item_func.cc8
1 files changed, 7 insertions, 1 deletions
diff --git a/sql/item_func.cc b/sql/item_func.cc
index cc8830c6d6f..ab4a9c50332 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -1957,7 +1957,13 @@ void Item_func_round::fix_length_and_dec()
{
max_length= args[0]->max_length;
decimals= args[0]->decimals;
- hybrid_type= REAL_RESULT;
+ if (args[0]->result_type() == DECIMAL_RESULT)
+ {
+ max_length++;
+ hybrid_type= DECIMAL_RESULT;
+ }
+ else
+ hybrid_type= REAL_RESULT;
return;
}