Re: Remaining dependency on setlocale() - Mailing list pgsql-hackers

From Jeff Davis
Subject Re: Remaining dependency on setlocale()
Date
Msg-id a3828ec6dd5877997e754300f3411f5839094749.camel@j-davis.com
Whole thread Raw
In response to Re: Remaining dependency on setlocale()  (Chao Li <li.evan.chao@gmail.com>)
List pgsql-hackers
On Thu, 2025-11-27 at 09:08 +0800, Chao Li wrote:
> > On Nov 26, 2025, at 09:50, Chao Li <li.evan.chao@gmail.com> wrote:
> >
> > I will review the rest 3 commits tomorrow.
>
> 10 - 0009
>
> Just curious. As isaplha() and toupper() come from the same header
> file ctype.h, if we replace toupper with pg_ascii_toupper, does
> isapha also need to be handled?

OK.

What do you think about the change overall? Is fuzzystrmatch inherently
ASCII-based? Does it cause behavior changes aside from soundex()? Does
the behavior change in soundex() matter?

> 11 - 0010
>
> I think assert both dstsize and len are redundant, because
> dstsize=len+1, and no place to change their values.

OK.

What do you think of the change overall?

>
> If (local == NULL || local->ctype == NULL)
>   Local = libc or other fallback;
> Return default_locale->ctype->strfold_ident(dest, destsize, src,
> srclen, local);
>
> This way avoids the duplicate code.

OK. The fallback would still be ASCII though, right?

> I just feel the GUC name is very misleading. Without carefully
> reading the doc, users may very easy to consider lc_collate the
> system’s locale. If it only affects extensions, then let’s name it
> accordingly, for example, “extension_lc_collate”, or
> “legacy_lc_collate”.

It is the system locale, it's just that we won't be using the system
locale for most purposes, so it has very little effect: PLs,
extensions, and libraries used by extensions that happen to rely on the
system locale. That is a bit confusing, which is why I previously just
set LC_COLLATE=C. This patch addresses Daniel's concern that people
might still want lc_collate set to something other than C. I'm not sure
we want this patch, it's just a POC.


I didn't attach a new series here yet, but will after some of the
earlier patches get committed.

Regards,
    Jeff Davis




pgsql-hackers by date:

Previous
From: Jeff Davis
Date:
Subject: Re: Remaining dependency on setlocale()
Next
From: Thomas Munro
Date:
Subject: Re: [PATCH] O_CLOEXEC not honored on Windows - handle inheritance chain