summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey Botchkov <holyfoot@mysql.com>2008-11-17 19:43:10 +0400
committerAlexey Botchkov <holyfoot@mysql.com>2008-11-17 19:43:10 +0400
commited77f02a921d037cd92b968991731c2b8fed38a8 (patch)
tree39800cd023b58f4d19bf2ae99e61d741d303872e
parent9be8ab541ce8e0e15815636fd52bdb96ea538fa0 (diff)
parent88a88636271aee2b89000a99c18d551813f0dcc5 (diff)
downloadmariadb-git-ed77f02a921d037cd92b968991731c2b8fed38a8.tar.gz
merging
-rw-r--r--mysql-test/r/type_newdecimal.result15
-rw-r--r--mysql-test/t/type_newdecimal.test10
-rw-r--r--sql/item_func.cc6
3 files changed, 29 insertions, 2 deletions
diff --git a/mysql-test/r/type_newdecimal.result b/mysql-test/r/type_newdecimal.result
index 37b77dc4dc8..0487cd56da4 100644
--- a/mysql-test/r/type_newdecimal.result
+++ b/mysql-test/r/type_newdecimal.result
@@ -1534,6 +1534,21 @@ select (1.20396873 * 0.89550000 * 0.68000000 * 1.08721696 * 0.99500000 *
(1.20396873 * 0.89550000 * 0.68000000 * 1.08721696 * 0.99500000 *
1.01500000 * 1.01500000 * 0.99500000)
0.812988073953673124592306939480
+create table t1 as select 5.05 / 0.014;
+Warnings:
+Note 1265 Data truncated for column '5.05 / 0.014' at row 1
+show warnings;
+Level Code Message
+Note 1265 Data truncated for column '5.05 / 0.014' at row 1
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `5.05 / 0.014` decimal(10,6) default NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+select * from t1;
+5.05 / 0.014
+360.714286
+DROP TABLE t1;
End of 5.0 tests
select cast(143.481 as decimal(4,1));
cast(143.481 as decimal(4,1))
diff --git a/mysql-test/t/type_newdecimal.test b/mysql-test/t/type_newdecimal.test
index 4a6462a8e72..4cf9ea63dad 100644
--- a/mysql-test/t/type_newdecimal.test
+++ b/mysql-test/t/type_newdecimal.test
@@ -1235,6 +1235,16 @@ DROP TABLE t1;
select (1.20396873 * 0.89550000 * 0.68000000 * 1.08721696 * 0.99500000 *
1.01500000 * 1.01500000 * 0.99500000);
+#
+# Bug #31616 div_precision_increment description looks wrong
+#
+
+create table t1 as select 5.05 / 0.014;
+show warnings;
+show create table t1;
+select * from t1;
+DROP TABLE t1;
+
--echo End of 5.0 tests
#
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 185100bf125..c2c04f2509f 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -1301,8 +1301,10 @@ my_decimal *Item_func_div::decimal_op(my_decimal *decimal_value)
void Item_func_div::result_precision()
{
- uint arg_prec= args[0]->decimal_precision() + prec_increment;
- uint precision=min(arg_prec, DECIMAL_MAX_PRECISION);
+ uint precision=min(args[0]->decimal_precision() +
+ args[1]->decimals + prec_increment,
+ DECIMAL_MAX_PRECISION);
+
/* Integer operations keep unsigned_flag if one of arguments is unsigned */
if (result_type() == INT_RESULT)
unsigned_flag= args[0]->unsigned_flag | args[1]->unsigned_flag;