Below is the list of changes that have just been committed into a local
5.0 repository of martin. When martin 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@stripped, 2007-12-20 16:31:19+01:00, mhansson@stripped +3 -0
Bug #33402: ROUND with decimal and non-constant cannot
round to 0 decimal places
The ROUND( X, D ) function did not work if X was DECIMAL andd D was a
non-constant equal to 0.
Fixed by including 0 in the range of valid values for D.
mysql-test/r/type_decimal.result@stripped, 2007-12-20 16:31:15+01:00, mhansson@stripped +6 -0
Bug#33402: Test result
mysql-test/t/type_decimal.test@stripped, 2007-12-20 16:31:15+01:00, mhansson@stripped +8 -0
Bug#33402: Test case
sql/item_func.cc@stripped, 2007-12-20 16:31:15+01:00, mhansson@stripped +1 -1
Bug#33402: The fix
diff -Nrup a/mysql-test/r/type_decimal.result b/mysql-test/r/type_decimal.result
--- a/mysql-test/r/type_decimal.result 2007-10-08 00:43:23 +02:00
+++ b/mysql-test/r/type_decimal.result 2007-12-20 16:31:15 +01:00
@@ -805,3 +805,9 @@ SELECT 1 % .1234567891234567891234567891
SELECT MOD(1, .123456789123456789123456789123456789123456789123456789123456789123456789123456789) AS 'MOD()';
MOD()
0.012345687012345687012345687012345687012345687012345687012345687012345687000000000
+CREATE TABLE t1 ( a DECIMAL(5, 4), b INT );
+INSERT INTO t1 VALUES (1.2345, 0), (1.2345, 1);
+SELECT ROUND(a, b) FROM t1;
+ROUND(a, b)
+1
+1.2
diff -Nrup a/mysql-test/t/type_decimal.test b/mysql-test/t/type_decimal.test
--- a/mysql-test/t/type_decimal.test 2007-10-08 00:43:15 +02:00
+++ b/mysql-test/t/type_decimal.test 2007-12-20 16:31:15 +01:00
@@ -416,3 +416,11 @@ DROP TABLE t1;
SELECT 1 % .123456789123456789123456789123456789123456789123456789123456789123456789123456789 AS '%';
SELECT MOD(1, .123456789123456789123456789123456789123456789123456789123456789123456789123456789) AS 'MOD()';
+
+#
+# Bug #33402: ROUND with decimal and non-constant cannot round to 0 decimal
+# places
+#
+CREATE TABLE t1 ( a DECIMAL(5, 4), b INT );
+INSERT INTO t1 VALUES (1.2345, 0), (1.2345, 1);
+SELECT ROUND(a, b) FROM t1;
diff -Nrup a/sql/item_func.cc b/sql/item_func.cc
--- a/sql/item_func.cc 2007-09-28 15:57:34 +02:00
+++ b/sql/item_func.cc 2007-12-20 16:31:15 +01:00
@@ -2107,7 +2107,7 @@ my_decimal *Item_func_round::decimal_op(
{
my_decimal val, *value= args[0]->val_decimal(&val);
longlong dec= args[1]->val_int();
- if (dec > 0 || (dec < 0 && args[1]->unsigned_flag))
+ if (dec >= 0 || args[1]->unsigned_flag)
{
dec= min((ulonglong) dec, DECIMAL_MAX_SCALE);
decimals= (uint8) dec; // to get correct output
| Thread |
|---|
| • bk commit into 5.0 tree (mhansson:1.2546) BUG#33402 | mhansson | 20 Dec |