summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <holyfoot/hf@hfmain.(none)>2007-06-14 16:35:20 +0500
committerunknown <holyfoot/hf@hfmain.(none)>2007-06-14 16:35:20 +0500
commit167751b3f08295f9cdf752d48af196698867eca3 (patch)
treeeb0a6d3ab2139653b88ab2a0f4a0d70e79a24f63
parentdcd779cb3836c67e6c61cd232d0b28f9a5345363 (diff)
parentc0ebdff9c76c2b3e09bf5e44c22e68a35ef1affc (diff)
downloadmariadb-git-167751b3f08295f9cdf752d48af196698867eca3.tar.gz
Merge mysql.com:/d2/hf/mrg/mysql-5.0-opt
into mysql.com:/d2/hf/mrg/mysql-5.1-opt mysql-test/r/type_decimal.result: Auto merged sql/item_func.cc: Auto merged
-rw-r--r--mysql-test/r/type_decimal.result9
-rw-r--r--mysql-test/t/type_decimal.test14
-rw-r--r--sql/item_func.cc8
3 files changed, 30 insertions, 1 deletions
diff --git a/mysql-test/r/type_decimal.result b/mysql-test/r/type_decimal.result
index dfbd6619436..efac8cbe580 100644
--- a/mysql-test/r/type_decimal.result
+++ b/mysql-test/r/type_decimal.result
@@ -790,3 +790,12 @@ Warning 1292 Incorrect datetime value: '0000-00-00'
Warning 1292 Incorrect datetime value: '0000-00-00'
Warning 1292 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;
diff --git a/mysql-test/t/type_decimal.test b/mysql-test/t/type_decimal.test
index 4fdb0c8458f..5538f19f5f9 100644
--- a/mysql-test/t/type_decimal.test
+++ b/mysql-test/t/type_decimal.test
@@ -394,3 +394,17 @@ create table t1 as
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;
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 70859aeb457..fb2f361f676 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -1954,7 +1954,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;
}