RE: [EXTERNAL] Re: Windows Application Issues | PostgreSQL | REF # 48475607 - Mailing list pgsql-bugs

From Haifang Wang (Centific Technologies Inc)
Subject RE: [EXTERNAL] Re: Windows Application Issues | PostgreSQL | REF # 48475607
Date
Msg-id PH8PR21MB3902E906C37A613A1F34C5B4E59C2@PH8PR21MB3902.namprd21.prod.outlook.com
Whole thread Raw
In response to Re: [EXTERNAL] Re: Windows Application Issues | PostgreSQL | REF # 48475607  (Thomas Munro <thomas.munro@gmail.com>)
Responses Windows Application Issues | PostgreSQL | REF # 48475607
Re: [EXTERNAL] Re: Windows Application Issues | PostgreSQL | REF # 48475607
List pgsql-bugs
Okay, I will ask our tester to try the patch. But have you tried it from your end? @Thomas Munro @Tom Lane

-----Original Message-----
From: Thomas Munro <thomas.munro@gmail.com>
Sent: Wednesday, September 4, 2024 3:35 PM
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Haifang Wang (Centific Technologies Inc) <v-haiwang@microsoft.com>; Andrew Dunstan <andrew@dunslane.net>; Sandeep
Thakkar<sandeep.thakkar@enterprisedb.com>; Rahul Pandey <pandeyrah@microsoft.com>; Vishwa Deepak
<Vishwa.Deepak@microsoft.com>;Shawn Steele <Shawn.Steele@microsoft.com>; Amy Wishnousky <amyw@microsoft.com>;
pgsql-bugs@lists.postgresql.org;Shweta Gulati <gulatishweta@microsoft.com>; Ashish Nawal <nawalashish@microsoft.com>
 
Subject: Re: [EXTERNAL] Re: Windows Application Issues | PostgreSQL | REF # 48475607

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
thischange.
 

But here is one thing Haifang might like to consider:  the documentation[1] for setlocale() could really use a note in
theremarks 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
quiteexplicitly 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
thatstring 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
theprogram’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
Windowsprogrammer, 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
recommendsthat applications prefer those[2].  It might be worth a note about that too?  (I guess stability and
backwardscompatibility 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 by date:

Previous
From: Thomas Munro
Date:
Subject: Re: [EXTERNAL] Re: Windows Application Issues | PostgreSQL | REF # 48475607
Next
From: "David G. Johnston"
Date:
Subject: Windows Application Issues | PostgreSQL | REF # 48475607