Opened 9 years ago
Closed 9 years ago
#5720 closed defect (fixed)
mysql datasource ignores LC_NUMERIC locale setting
Reported by: | rigid | Owned by: | warmerdam |
---|---|---|---|
Priority: | normal | Milestone: | 1.11.2 |
Component: | default | Version: | 1.11.1 |
Severity: | major | Keywords: | MySQL localization LC_NUMERIC |
Cc: |
Description
when the locale sets the decimal separator other than '.', all sprintf() calls that print float/doubles will print wrong separators.
Localization seems to be a general problem causing a whole bug-class fixed patchy at some places.
To squash the whole bug-class is not straight forward:
The problem is, that a library can't keep control on the locale without threading (uselocale() which is POSIX 2008 - affecting portability) or forking.
So 3 solutions come to mind:
- wrap every s*printf() call into CPLLocaleC::CPLLocaleC() and CPLLocaleC::~CPLLocaleC()
Pro: easy to implement, easy to maintain, wouldn't annoy downstream
Con: significant performance impact with high amount of frequent s*printf() calls
- implement a "locale-unaware" s*printf() that always uses '.' as radix character, replace all s*printf() call with that
Pro: no performance hit, wouldn't annoy downstream
Con: hard to implement, *printf() is not trivial
- set LC_NUMERIC="C" once, use s*printf() wrapper that issues a warning/error when LC_NUMERIC != "C"
Pro: clean solution, almost no performance hit, no additional code to maintain, can be implemented step-wise.
Con: might need downstream action (as with other depreciation issues)
I'd prefer the 3rd solution. As first step, one could wrap s*nprintf() calls just like with solution 1 but issue a warning if LC_NUMERIC != C ... At later releases, the setlocale() call could be removed and the warning could be turned into an errror.
Attachments (1)
Change History (3)
by , 9 years ago
Attachment: | ogrmysqltablelayer.diff added |
---|
comment:1 by , 9 years ago
comment:2 by , 9 years ago
Milestone: | → 1.11.2 |
---|---|
Resolution: | → fixed |
Status: | new → closed |
Core problem addressed by #5731
quick fix