pgsql: Use thread-safe nl_langinfo_l(), not nl_langinfo().

From: Thomas Munro <tmunro(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Use thread-safe nl_langinfo_l(), not nl_langinfo().
Date: 2024-08-13 10:36:14
Message-ID: E1sdosw-003ycn-Rd@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Use thread-safe nl_langinfo_l(), not nl_langinfo().

This gets rid of some setlocale() calls. The remaining call to
setlocale() in pg_get_encoding_from_locale() is a query of the name
of the current locale when none was provided (in a multi-threaded future
that would need more work).

All known non-Windows targets have nl_langinfo_l(), from POSIX 2008, and
for Windows we already do something thread-safe.

Reviewed-by: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
Discussion: https://postgr.es/m/CA%2BhUKGJqVe0%2BPv9dvC9dSums_PXxGo9SWcxYAMBguWJUGbWz-A%40mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/35eeea62302260ec07fd11b287e488768d4543e2

Modified Files
--------------
src/port/chklocale.c | 67 +++++++++++++++-------------------------------------
1 file changed, 19 insertions(+), 48 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Thomas Munro 2024-08-13 11:00:09 pgsql: Include <xlocale.h> for older macOS.
Previous Message Peter Eisentraut 2024-08-13 08:10:00 pgsql: Use errmsg_internal for debug messages