|From:||Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>|
|To:||Michael Meskes <meskes(at)postgresql(dot)org>|
|Subject:||Re: Thread-unsafe coding in ecpg|
|Views:||Raw Message | Whole Thread | Download mbox|
Michael Meskes <meskes(at)postgresql(dot)org> writes:
>> No, we shouldn't use setlocale(), because it clearly is hazardous
>> even on platforms where it doesn't fail outright. I don't see
>> anything so wrong with just documenting the hazard. The situation
> Actually I meant using setlocale() and documenting that it must not be
> used with threads, or document it must not be used with locales?
I tend to think that has more downside than upside, in situations where
people don't read the manual closely and try to do it anyway.
First, there's the probable crash if setlocale() is thread-unsafe.
(Though the lack of previous reports suggests that on most platforms,
Second, if the program is indeed trying to run with non-C LC_NUMERIC,
using setlocale() will have unsynchronized, hard-to-debug side effects
on other threads. Not using it will have no downside at all if ecpg
isn't trying to read numeric data, while if it does do so, the failures
will be reproducible and easy to understand/debug.
Admittedly, removing the setlocale() call will be a net negative for
single-threaded applications, which are likely the majority. But
I don't know any safe way to tell whether the app is multi threaded.
On the third hand, the lack of previous reports suggests that maybe
this whole thing is seldom a problem in practice. Maybe we should
just use uselocale() where available and otherwise hope it's OK
to keep on doing what we were doing.
regards, tom lane
|Next Message||Chapman Flack||2019-01-20 17:43:14||Re: PostgreSQL vs SQL/XML Standards|
|Previous Message||Dmitry Dolgov||2019-01-20 17:17:34||Re: Pluggable Storage - Andres's take|