On Tue, 2024-07-30 at 12:13 -0700, Jeff Davis wrote: > I found a couple issues with the later patches: > > * There was still some confusion about the default collation vs. > datcollate/datctype for callers of wchar2char() and char2wchar() > (those > functions only work for libc). I introduced a new pg_locale_t > structure > to represent datcollate/datctype regardless of datlocprovider to > solve > this.
I didn't quite like the API I introduced in 0001, so I skipped 0001. For 0002 I left char2wchar() and wchar2char() as-is, where they expect libc and accept a NULL pg_locale_t. I committed the rest of 0002. > * Another loose end relying on setlocale(): in selfuncs.c, there's > still a call directly to strxfrm(), which depends on setlocale(). I > changed this to lookup the collation and then use pg_strxfrm(). That > should improve histogram selectivity estimates because it uses the > correct provider, rather than relying on setlocale(), right? Committed 0003. 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. Regards, Jeff Davis