From: | Peter Eisentraut <peter(at)eisentraut(dot)org> |
---|---|
To: | Jeff Davis <pgsql(at)j-davis(dot)com>, Andreas Karlsson <andreas(at)proxel(dot)se>, pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: tiny step toward threading: reduce dependence on setlocale() |
Date: | 2024-08-07 20:44:25 |
Message-ID: | 4f562d84-87f4-44dc-8946-01d6c437936f@eisentraut.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 06.08.24 23:40, Jeff Davis wrote:
> With these changes, collations are no longer dependent on the
> environment locale (setlocale()) at all for either collation behavior
> (ORDER BY) or ctype behavior (LOWER(), etc.).
>
> Additionally, unless I missed something, nothing in the server is
> dependent on LC_COLLATE at all.
>
> There are still some things that depend on setlocale() in one way or
> another:
>
> - char2wchar() & wchar2char()
> - ts_locale.c
> - various places that depend on LC_CTYPE unrelated to the collation
> infrastructure
> - things that depend on other locale settings, like LC_NUMERIC
>
> We can address those as part of a separate thread. I'll count this as
> committed.
I have a couple of small follow-up patches for this.
First, in like.c, SB_lower_char() now reads:
static char
SB_lower_char(unsigned char c, pg_locale_t locale, bool locale_is_c)
{
if (locale_is_c)
return pg_ascii_tolower(c);
else if (locale)
return tolower_l(c, locale->info.lt);
else
return pg_tolower(c);
}
But after this patch set, locale cannot be NULL anymore, so the third
branch is obsolete.
(Now that I look at it, pg_tolower() has some short-circuiting for ASCII
letters, so it would not handle Turkish-i correctly if that had been the
global locale. By removing the use of pg_tolower(), we fix that issue
in passing.)
Second, there are a number of functions in like.c like the above that
take separate arguments like pg_locale_t locale, bool locale_is_c.
Because pg_locale_t now contains the locale_is_c information, these can
be combined.
Attachment | Content-Type | Size |
---|---|---|
0001-Remove-dead-code.patch | text/plain | 887 bytes |
0002-Remove-separate-locale_is_c-arguments.patch | text/plain | 5.0 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Thomas Munro | 2024-08-07 20:52:41 | Re: Remaining dependency on setlocale() |
Previous Message | Jelte Fennema-Nio | 2024-08-07 20:42:08 | Re: Add trim_trailing_whitespace to editorconfig file |