From: Date: May 21 2007 7:22pm Subject: bk commit into 5.0 tree (holyfoot:1.2490) BUG#27984 List-Archive: http://lists.mysql.com/commits/27090 X-Bug: 27984 Message-Id: <20070521172252.085E32C380B7@hfmain.localdomain> Below is the list of changes that have just been committed into a local 5.0 repository of hf. When hf 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-05-21 22:22:47+05:00, holyfoot@stripped +3 -0 Bug #27984 Long Decimal Maths produces truncated results. decimal_round failed to perform a correct rounding of a decimal number if its first nine digits were '9'. It just sets those digits to 0. mysql-test/r/type_newdecimal.result@stripped, 2007-05-21 22:22:46+05:00, holyfoot@stripped +3 -0 Bug #27984 Long Decimal Maths produces truncated results. test result mysql-test/t/type_newdecimal.test@stripped, 2007-05-21 22:22:46+05:00, holyfoot@stripped +5 -0 Bug #27984 Long Decimal Maths produces truncated results. test case strings/decimal.c@stripped, 2007-05-21 22:22:46+05:00, holyfoot@stripped +2 -1 Bug #27984 Long Decimal Maths produces truncated results. when to == from we break the data if we do to->buf[0]=0 So now doing this after the data is moved and only if we really need to set to->buf[0] to zero # 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: holyfoot # Host: hfmain.(none) # Root: /home/hf/work/27984/my50-27984 --- 1.46/mysql-test/r/type_newdecimal.result 2007-05-21 22:22:51 +05:00 +++ 1.47/mysql-test/r/type_newdecimal.result 2007-05-21 22:22:51 +05:00 @@ -1465,4 +1465,7 @@ Error 1264 Out of range value adjusted f Error 1264 Out of range value adjusted for column 'cast(a as DECIMAL(3,2))' at row 1 Error 1264 Out of range value adjusted for column 'cast(a as DECIMAL(3,2))' at row 1 Error 1264 Out of range value adjusted for column 'cast(a as DECIMAL(3,2))' at row 1 +SELECT 1.000000000000 * 99.999999999998 / 100 a,1.000000000000 * (99.999999999998 / 100) b; +a b +0.9999999999999800000000000000 0.9999999999999800000000000000 End of 5.0 tests --- 1.44/mysql-test/t/type_newdecimal.test 2007-05-21 22:22:51 +05:00 +++ 1.45/mysql-test/t/type_newdecimal.test 2007-05-21 22:22:51 +05:00 @@ -1149,4 +1149,9 @@ select cast(a as DECIMAL(3,2)), count(*) UNION select 12.1234 ) t group by 1; +# +# Bug #27984 Long Decimal Maths produces truncated results +# + +SELECT 1.000000000000 * 99.999999999998 / 100 a,1.000000000000 * (99.999999999998 / 100) b; --echo End of 5.0 tests --- 1.79/strings/decimal.c 2007-05-21 22:22:51 +05:00 +++ 1.80/strings/decimal.c 2007-05-21 22:22:51 +05:00 @@ -1517,9 +1517,10 @@ decimal_round(decimal_t *from, decimal_t dec1 *p0= buf0+intg0+max(frac1, frac0); dec1 *p1= buf1+intg1+max(frac1, frac0); - to->buf[0]= 0; while (buf0 < p0) *(--p1) = *(--p0); + if (unlikely(intg1 > intg0)) + to->buf[0]= 0; intg0= intg1; buf0=to->buf;