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)

ogrmysqltablelayer.diff (571 bytes ) - added by rigid 9 years ago.
quick fix

Download all attachments as: .zip

Change History (3)

by rigid, 9 years ago

Attachment: ogrmysqltablelayer.diff added

quick fix

comment:1 by Even Rouault, 9 years ago

trunk r27915, branches/1.11 r27916 "MySQL: don't be dependant on locale when building spatial filter (#5720, patch by rigid)"

comment:2 by Even Rouault, 9 years ago

Milestone: 1.11.2
Resolution: fixed
Status: newclosed

Core problem addressed by #5731

Note: See TracTickets for help on using tickets.