Below is the list of changes that have just been committed into a local
5.0 repository of igor. When igor 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-06-12 22:05:01-07:00, igor@stripped +3 -0
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@stripped, 2007-06-12 22:04:57-07:00, igor@stripped +9
-0
Added a test case for bug #28980.
mysql-test/t/type_decimal.test@stripped, 2007-06-12 22:04:58-07:00, igor@stripped +14
-0
Added a test case for bug #28980.
sql/item_func.cc@stripped, 2007-06-12 22:04:58-07:00, igor@stripped +2 -1
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.
# 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: igor
# Host: olga.mysql.com
# Root: /home/igor/dev-opt/mysql-5.0-opt-bug28980
--- 1.348/sql/item_func.cc 2007-06-12 22:05:07 -07:00
+++ 1.349/sql/item_func.cc 2007-06-12 22:05:07 -07:00
@@ -1957,7 +1957,8 @@
{
max_length= args[0]->max_length;
decimals= args[0]->decimals;
- hybrid_type= REAL_RESULT;
+ hybrid_type= args[0]->result_type() == DECIMAL_RESULT ?
+ DECIMAL_RESULT : REAL_RESULT;
return;
}
--- 1.42/mysql-test/r/type_decimal.result 2007-06-12 22:05:07 -07:00
+++ 1.43/mysql-test/r/type_decimal.result 2007-06-12 22:05:07 -07:00
@@ -790,3 +790,12 @@
Warning 1292 Truncated incorrect datetime value: '0000-00-00'
Warning 1292 Truncated incorrect datetime value: '0000-00-00'
drop table t1;
+CREATE TABLE t1 (
+qty decimal(16,6) default NULL,
+dps tinyint(3) unsigned default NULL
+);
+INSERT INTO t1 VALUES (1.1325,3);
+SELECT ROUND(qty,3), dps, ROUND(qty,dps) FROM t1;
+ROUND(qty,3) dps ROUND(qty,dps)
+1.133 3 1.133
+DROP TABLE t1;
--- 1.32/mysql-test/t/type_decimal.test 2007-06-12 22:05:07 -07:00
+++ 1.33/mysql-test/t/type_decimal.test 2007-06-12 22:05:07 -07:00
@@ -394,3 +394,17 @@
from (select 1 as s,'t' as t union select null, null ) as sub1;
select group_concat(t) from t1 group by week(date)/10;
drop table t1;
+
+#
+# Bug#28980: ROUND(<dec expr>, <int col>) returned double values
+#
+
+CREATE TABLE t1 (
+ qty decimal(16,6) default NULL,
+ dps tinyint(3) unsigned default NULL
+);
+INSERT INTO t1 VALUES (1.1325,3);
+
+SELECT ROUND(qty,3), dps, ROUND(qty,dps) FROM t1;
+
+DROP TABLE t1;
| Thread |
|---|
| • bk commit into 5.0 tree (igor:1.2533) BUG#28980 | igor | 13 Jun |