List:Internals« Previous MessageNext Message »
From:holyfoot Date:June 9 2005 10:27am
Subject:bk commit into 5.0 tree (holyfoot:1.1962) BUG#10083
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of hf. When hf does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.1962 05/06/09 15:27:26 holyfoot@hf-ibm.(none) +3 -0
  Fix for bug #10083 (round doesn't increase scale)

  sql/item_func.cc
    1.216 05/06/09 15:26:47 holyfoot@stripped +7 -12
    now we always use decimals_to_set

  mysql-test/t/func_math.test
    1.18 05/06/09 15:26:47 holyfoot@stripped +5 -0
    test case added

  mysql-test/r/func_math.result
    1.26 05/06/09 15:26:47 holyfoot@stripped +3 -0
    test result fixed

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	holyfoot
# Host:	hf-ibm.(none)
# Root:	/home/hf/work/mysql-5.0.10083

--- 1.215/sql/item_func.cc	Tue Jun  7 15:54:41 2005
+++ 1.216/sql/item_func.cc	Thu Jun  9 15:26:47 2005
@@ -1876,7 +1876,8 @@
     max_length= float_length(decimals);
     break;
   case INT_RESULT:
-    if (truncate || (args[0]->decimal_precision() < DECIMAL_LONGLONG_DIGITS))
+    if ((decimals_to_set==0) &&
+        (truncate || (args[0]->decimal_precision() < DECIMAL_LONGLONG_DIGITS)))
     {
       /* Here we can keep INT_RESULT */
       hybrid_type= INT_RESULT;
@@ -1890,18 +1891,12 @@
     hybrid_type= DECIMAL_RESULT;
     int decimals_delta= args[0]->decimals - decimals_to_set;
     int precision= args[0]->decimal_precision();
-    if (decimals_delta > 0)
-    {
-      int length_increase= truncate ? 0:1;
-      precision-= decimals_delta - length_increase;
-      decimals= decimals_to_set;
-    }
-    else
-      /* Decimals to set is bigger that the original scale */
-      /* we keep original decimals value                   */
-      decimals= args[0]->decimals;
+    int length_increase= ((decimals_delta <= 0) || truncate) ? 0:1;
+
+    precision-= decimals_delta - length_increase;
+    decimals= decimals_to_set;
     max_length= my_decimal_precision_to_length(precision, decimals,
-                                              unsigned_flag);
+                                               unsigned_flag);
     break;
   }
   default:

--- 1.25/mysql-test/r/func_math.result	Wed Jun  8 15:49:00 2005
+++ 1.26/mysql-test/r/func_math.result	Thu Jun  9 15:26:47 2005
@@ -143,3 +143,6 @@
 format(col2,6)
 1,234,567,890,123,456.123450
 drop table t1;
+select round(150, 2);
+round(150, 2)
+150.00

--- 1.17/mysql-test/t/func_math.test	Wed Jun  8 15:49:00 2005
+++ 1.18/mysql-test/t/func_math.test	Thu Jun  9 15:26:47 2005
@@ -79,3 +79,8 @@
 select format(col2,6) from t1 where col1=7;
 drop table t1;
 
+
+#
+# Bug #10083 (round doesn't increase decimals)
+#
+select round(150, 2);
Thread
bk commit into 5.0 tree (holyfoot:1.1962) BUG#10083holyfoot9 Jun