Re: [EXTERNAL] Re: Windows Application Issues | PostgreSQL | REF # 48475607
От | Thomas Munro |
---|---|
Тема | Re: [EXTERNAL] Re: Windows Application Issues | PostgreSQL | REF # 48475607 |
Дата | |
Msg-id | CA+hUKGLbGaMPBWgj4GPR_i=0s8J9XVZZ4_-0DP_ZpCoCZbaDig@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: [EXTERNAL] Re: Windows Application Issues | PostgreSQL | REF # 48475607 (Tom Lane <tgl@sss.pgh.pa.us>) |
Ответы |
RE: [EXTERNAL] Re: Windows Application Issues | PostgreSQL | REF # 48475607
|
Список | pgsql-bugs |
On Thu, Sep 5, 2024 at 10:10 AM Tom Lane <tgl@sss.pgh.pa.us> wrote: > "Haifang Wang (Centific Technologies Inc)" <v-haiwang@microsoft.com> writes: > > Cool. is anyone going to try it out? Looking forward to the back-patch and release. > > I thought the implication was pretty clear that YOU ought to try it out. It would also be good to hear from Sandeep and crew, if possible, since they will be dealing with the consequences of this change. But here is one thing Haifang might like to consider: the documentation[1] for setlocale() could really use a note in the remarks section to highlight this danger. Nothing in there seems to alert the programmer to the fact that save = setlocale(NULL), setlocale("something else"), setlocale(save) might fail to restore the previous locale, and might even abort. Perhaps that's a weird, old, non-thread-safe thing to be doing (and we're working on removing that), but it is quite explicitly described in the standard. C99 7.11.1.1 paragraph 8: "The pointer to string returned by the setlocale function is such that a subsequent call with that string value and its associated category will restore that part of the program’s locale". Aborting also fails paragraph 6: "If the selection cannot be honored, the setlocale function returns a null pointer and the program’s locale is not changed" (perhaps this has to do with the crt report mode stuff, I don't know as I'm not a Windows programmer, I'm just trying to maintain a C program; or maybe it's actually a bug?). Another thing is that setlocale(NULL) continues to return the "old style" names while everything else in the OS is using the modern BCP 47 system since Vista, and the locale documentation recommends that applications prefer those[2]. It might be worth a note about that too? (I guess stability and backwards compatibility are behind that choice, but ... it's not really stable anyway.) [1] https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/setlocale-wsetlocale?view=msvc-170 [2] https://learn.microsoft.com/en-us/cpp/c-runtime-library/locale-names-languages-and-country-region-strings?view=msvc-170
В списке pgsql-bugs по дате отправления: