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.