Bug #69719 sql::ResultSet::getDouble return wrong value with fr_CA locale
Submitted: 10 Jul 2013 20:51 Modified: 20 Apr 2017 14:24
Reporter: Jean-Francois Couture Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / C++ Severity:S3 (Non-critical)
Version:1.1.0,1.1.3 OS:Linux (Ubuntu 12.04)
Assigned to: Bogdan Degtyariov CPU Architecture:Any

[10 Jul 2013 20:51] Jean-Francois Couture
Description:
When I do a SELECT on a table wich have a double field type, the value returned by getDouble is trucated when the fr_CA locale is in use. If I use the C locale the value is returned with the decimal part.

The fr_CA locale use a comma as decimal separator and strtold(3) (used to do the conversion in cppconn re: mysql_resultset.cpp line 359 and mysql_util.cpp line 2263) is locale sensitive. So, the conversion stop at the dot in the string returned by the server.

How to repeat:
install the fr_CA locale.

In main fonction do:
 setlocale(LC_NUMERIC, "fr_CA.UTF-8");

Do a SELECT on a table with a field of double type.

Check the returned value.

Suggested fix:
Use a conversion function that parse the format of the server what ever the locale is.
[11 Jul 2013 11:59] Bogdan Degtyariov
Verified with Connector/C++ 1.1.3
[11 Jul 2013 12:04] Bogdan Degtyariov
test case

Attachment: bug69719.cpp (text/plain), 2.22 KiB.

[11 Jul 2013 12:07] Bogdan Degtyariov
Jean-Francois,

Thank you for reporting the problem in Connector/C++ and for your interest in MySQL software. I was able to repeat the problem in Windows and in Linux, so it does not seem to be the platform-dependent issue (except the parameters for setlocale).
[20 Apr 2017 14:24] Paul Dubois
Posted by developer:
 
Noted in 1.1.9 changelog.

Values returned by getDouble() from DOUBLE table columns were
truncated (decimal part missing) if the locale was set to fr_CA,
which uses comma as the decimal separator.
[17 Aug 2018 15:22] Stefan Seifert
the bug appears to be still around in version 1.1.8-8.1. At least I am having the described problem using de_DE locale setting.