Bug #33322 | Incorrect Double/Single value saved to MySQL database using MySQL Connector for | ||
---|---|---|---|
Submitted: | 18 Dec 2007 6:43 | Modified: | 24 Jul 2008 15:28 |
Reporter: | Carsten Breum | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | Connector / NET | Severity: | S1 (Critical) |
Version: | 5.1.4 (and earlier) | OS: | Windows |
Assigned to: | CPU Architecture: | Any |
[18 Dec 2007 6:43]
Carsten Breum
[18 Dec 2007 7:10]
Tonci Grgin
Hi Carsten and thanks for your report. Your problem is not a result of bug; please check http://msdn2.microsoft.com/en-us/library/system.double(VS.80).aspx for details. "By default, a Double value contains 15 decimal digits of precision, although a maximum of 17 digits is maintained internally."
[24 Jun 2008 12:13]
Carsten Breum
I have to disagree. Why are you making our data less precise just because you can, instead of returning the same value as originally stored? By the way the Core Lab MySql .NET provider does it correctly and the provider for SQL server does it correctly so please take that into account and update the provider as described in the original post as it is the correct way to convert the value to a string.
[22 Jul 2008 13:21]
Reggie Burnett
Verified but the users description is not 100% correct. Both Connector/Net and CoreLabs drivers work correctly when using prepared statements. The reason the user was seeing errors using prepared statements is because he had not enabled server side prepared statements. By default, calling .Prepare is a no-op and you have to add 'ignore prepare=false' to your connection string to enable server side PS. Once you do this, it works. Using non-ps, there problem explained by the user is correct but it will still fail (as of mysqld 5.1) unless you give a display size of double greater than 15. For the following table it will still fail because mysql will just return 15 digits. CREATE TABLE test (d DOUBLE); If you create the column as DOUBLE(25,20) for example (this is non-standard syntax), then up to 25 digits will be returned.
[22 Jul 2008 13:29]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/50193
[22 Jul 2008 13:29]
Reggie Burnett
Fixed in 5.0.10, 5.1.7, and 5.2.3+
[24 Jul 2008 15:28]
Tony Bedford
An entry was added to the 5.0.10, 5.1.7 and 5.2.3 changelogs: When reading back a stored double or single value using the .NET provider, the value had less precision than the one stored.