Re: Remaining dependency on setlocale()

From: Jeff Davis <pgsql(at)j-davis(dot)com>
To: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
Cc: Peter Eisentraut <peter(at)eisentraut(dot)org>, Thomas Munro <thomas(dot)munro(at)gmail(dot)com>, 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-11-29 21:04:00
Message-ID: a3828ec6dd5877997e754300f3411f5839094749.camel@j-davis.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, 2025-11-27 at 09:08 +0800, Chao Li wrote:
> > On Nov 26, 2025, at 09:50, Chao Li <li(dot)evan(dot)chao(at)gmail(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Previous Message Jeff Davis 2025-11-29 20:50:56 Re: Remaining dependency on setlocale()