Bug #15492 Wrong scale after BigDecimal storing
Submitted: 5 Dec 2005 15:23 Modified: 12 Dec 2005 21:26
Reporter: Per Newgro Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Documentation Severity:S2 (Serious)
Version:5.0.15 OS:Linux (Linux version 2.6.13-15-default)
Assigned to: Stefan Hinz
Triage: D4 (Minor)

[5 Dec 2005 15:23] Per Newgro
Description:
I use mysql-connector-java-3.1.12-bin.jar and mysql-standard-5.0.15-linux-i686.

Inserting a java.lang.BigDecimal field containing 10.00 (scale set to 2) into a decimal (3,2) field results in db-field-content of 9.99. Because code and JDK not changed, i think its a 5.0.15 problem.

Until today i used my java-code (no changes), mysql-connector-java-3.1.12-bin.jar and mysql-standard-4.1.15-pc-linux-gnu-i686 and everything works fine.

How to repeat:
CREATE TABLE `myTable` (
  `businessId` int(11) default NULL,
  `deductibleFeeRate` decimal(3,2) default NULL,
  PRIMARY KEY (`businessId`)
) TYPE=InnoDB;

Insert a BigDecimal of 10.00 (scale set)
[5 Dec 2005 15:39] Aleksey Kishkin
Hi! it's not a bug. Decimal(N,M) means you field has N digits and M (that digits) after decimal point.

Please look at http://dev.mysql.com/doc/refman/5.0/en/precision-math-decimal-changes.html

Before version 5.0.3 mysql had another implementation of 'decimal' and that is why your code worked fine in versions 4.1 and etc..
[5 Dec 2005 15:55] Mark Matthews
Stefan,

This change should probably be listed more prominently at http://dev.mysql.com/doc/refman/5.0/en/upgrading-from-4-1.html.
[12 Dec 2005 21:26] Stefan Hinz
Added this as another Incompatible Change to the list on http://dev.mysql.com/doc/refman/5.0/en/upgrading-from-4-1.html:
            <emphasis role="bold">Incompatible change</emphasis>:
            The implementation of <literal>DECIMAL</literal> has changed
            in MySQL 5.0.4. You should make your applications aware of
            that change, which is described in
            <xref linkend="precision-math-decimal-changes"/>.