From: Date: April 21 2008 6:04am Subject: bk commit into 5.0 tree (holyfoot:1.2602) BUG#31616 List-Archive: http://lists.mysql.com/commits/45741 X-Bug: 31616 Message-Id: <20080421040404.9E4272C380A5@hfmain.localdomain> Below is the list of changes that have just been committed into a local 5.0 repository of holyfoot. When holyfoot 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, 2008-04-21 09:04:00+05:00, holyfoot@stripped +3 -0 Bug #31616 div_precision_increment description looks wrong Item_func_div didn't calculate the precision of the result properly. The result of 5/0.0001 is 5000 so we have to add decimals of the divisor to the planned precision. mysql-test/r/type_newdecimal.result@stripped, 2008-04-21 09:03:58+05:00, holyfoot@stripped +15 -0 Bug #31616 div_precision_increment description looks wrong test result mysql-test/t/type_newdecimal.test@stripped, 2008-04-21 09:03:58+05:00, holyfoot@stripped +10 -0 Bug #31616 div_precision_increment description looks wrong test case sql/item_func.cc@stripped, 2008-04-21 09:03:58+05:00, holyfoot@stripped +2 -1 Bug #31616 div_precision_increment description looks wrong precision must be increased with args[1]->decimals parameter diff -Nrup a/mysql-test/r/type_newdecimal.result b/mysql-test/r/type_newdecimal.result --- a/mysql-test/r/type_newdecimal.result 2007-11-17 22:05:29 +04:00 +++ b/mysql-test/r/type_newdecimal.result 2008-04-21 09:03:58 +05:00 @@ -1519,4 +1519,19 @@ SELECT f1 FROM t1; f1 99999999999999999999999999999.999999999999999999999999999999 DROP TABLE t1; +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 diff -Nrup a/mysql-test/t/type_newdecimal.test b/mysql-test/t/type_newdecimal.test --- a/mysql-test/t/type_newdecimal.test 2007-11-17 22:05:29 +04:00 +++ b/mysql-test/t/type_newdecimal.test 2008-04-21 09:03:58 +05:00 @@ -1216,4 +1216,14 @@ DESC t1; SELECT f1 FROM t1; DROP TABLE t1; +# +# 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 -Nrup a/sql/item_func.cc b/sql/item_func.cc --- a/sql/item_func.cc 2008-03-12 11:54:54 +04:00 +++ b/sql/item_func.cc 2008-04-21 09:03:58 +05:00 @@ -1315,7 +1315,8 @@ my_decimal *Item_func_div::decimal_op(my void Item_func_div::result_precision() { - uint precision=min(args[0]->decimal_precision() + prec_increment, + 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)