Re: Remaining dependency on setlocale()

From: Jeff Davis <pgsql(at)j-davis(dot)com>
To: Peter Eisentraut <peter(at)eisentraut(dot)org>, Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Remaining dependency on setlocale()
Date: 2025-06-06 22:23:41
Message-ID: a1396f17f462ee6561820f755caaf2d12eb9fd15.camel@j-davis.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, 2025-06-05 at 22:15 -0700, Jeff Davis wrote:
> To continue this thread, I did a symbol search in the meson build
> directory like (patterns.txt attached):

Attached a rough patch series which does what everyone seemed to agree
on:

* Change some trivial ASCII cases to use pg_ascii_* variants
* Set LC_COLLATE and LC_CTYPE to C with pg_perm_setlocale
* Introduce a new global_lc_ctype for callers that still need to use
operations that depend on datctype

There should be no behavior changes in this series.

Benefits:

* a tiny step toward multithreading, because connections to different
databases no longer require different setlocale() settings
* easier to identify dependence on datctype, because callers will
need to refer to global_lc_ctype.
* harder to accidentally depend on datctype or datcollate

Ideally, when the database locale provider is not libc, the user
shouldn't need to even think about a valid LC_CTYPE locale at all. But
that requires more work, and potentially risk of breakage.

Regards,
Jeff Davis

`

Attachment Content-Type Size
v1-0001-copyfromparse.c-use-pg_ascii_tolower-rather-than-.patch text/x-patch 789 bytes
v1-0002-contrib-spi-refint.c-use-pg_ascii_tolower-instead.patch text/x-patch 896 bytes
v1-0003-isn.c-use-pg_ascii_toupper-instead-of-toupper.patch text/x-patch 1.1 KB
v1-0004-inet_net_pton.c-use-pg_ascii_tolower-rather-than-.patch text/x-patch 961 bytes
v1-0005-Add-global_lc_ctype-to-hold-locale_t-for-datctype.patch text/x-patch 4.0 KB
v1-0006-Use-global_lc_ctype-for-callers-of-locale-aware-f.patch text/x-patch 7.3 KB
v1-0007-Fix-the-last-remaining-callers-relying-on-setloca.patch text/x-patch 4.1 KB
v1-0008-Set-process-LC_COLLATE-C-and-LC_CTYPE-C.patch text/x-patch 2.1 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Noah Misch 2025-06-06 22:34:13 Re: Issues with 2PC at recovery: CLOG lookups and GlobalTransactionData
Previous Message Andres Freund 2025-06-06 22:12:02 Re: md5 password deprecation might cause problems with PgBouncer setups