Re: Thread-safe nl_langinfo() and localeconv()
Peter Eisentraut <peter@eisentraut.org>
From: Peter Eisentraut <peter@eisentraut.org>
To: Thomas Munro <thomas.munro@gmail.com>,
Heikki Linnakangas <hlinnaka@iki.fi>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2025-03-28T08:13:54Z
Lists: pgsql-hackers
Attachments
- v6.2-0001-Remove-setlocale-from-check_locale.patch (text/plain) patch v6-0001
- v6.2-0002-Add-646-as-a-codeset-name-for-ASCII.patch (text/plain) patch v6-0002
On 27.03.25 11:16, Peter Eisentraut wrote: >> Patch 0002 also looks okay, except that the error handling could be >> unified with existing code, as I had previously pointed out. Patch >> 0005 fixes that. > > I plan to commit this one next, after the above had a bit of time to stew. also done >> About patch 0003: >> >> I had previously pointed out that the canonicalization might have been >> intentional, and that we have canonicalization of ICU locale names. >> But we don't have to keep the setlocale()-based locale checking >> implementation just for that, I think. (If this was meant to be a >> real feature offered by libc, there should be a >> get_locale_name(locale_t) function.) > Anyway, this patch fails tests on CI on NetBSD, so it will need some > further investigation. It turns out the problem was that nl_langinfo_l() returns a codeset name of "646" for the C locale, which we didn't have in our mapping table. If we add that, then everything passes there as well. (But the use of nl_langinfo_l() wasn't added by this patch, it just exposes it to the tests. So this is apparently a pre-existing problem.) Attached are the remaining patches in this series.
Commits
-
Fix "‘static’ is not at beginning of declaration" warning
- 116e851db5b3 18.0 landed
-
Use thread-safe strftime_l() instead of strftime().
- 890fc826c91f 18.0 landed
-
Provide thread-safe pg_localeconv_r().
- b98be8a2a2a6 18.0 landed
-
Harmonize MinGW CODESET lookup with MSVC.
- bf3401fe813a 18.0 landed
-
Include <xlocale.h> for macOS, take II.
- 2488058dc356 18.0 landed
-
Use thread-safe nl_langinfo_l(), not nl_langinfo().
- 35eeea623022 18.0 landed
-
All POSIX systems have langinfo.h and CODESET.
- 14c648ff0094 18.0 landed