Re: make tsearch use the database default locale
Peter Eisentraut <peter@eisentraut.org>
From: Peter Eisentraut <peter@eisentraut.org>
To: Jeff Davis <pgsql@j-davis.com>, pgsql-hackers@postgresql.org
Date: 2025-10-17T16:15:47Z
Lists: pgsql-hackers
On 08.10.25 00:49, Jeff Davis wrote: > Previously, tsearch used the database CTYPE for parsing, but that's not > good because it creates an unnecessary dependency on libc even when the > user has requested another provider. > > This patch series allows tsearch to use the database default locale for > parsing. If the database collation is libc, there's no change. This looks good to me overall. > * Most of the patches are straightforward, but v1-0005 might need extra > attention. There are quite a few cases there with subtle distinctions, > and I might have missed something. For example, in the "C" locale, > tsearch treats non-ascii characters as alpha, even though the libc > functions do not do so (I preserved this behavior). This is indeed a bit mysterious. AFAICT, the behavior you describe is conditional on if (prs->usewide), so it apparently depends also on the encoding? I'm not sure if the new code covers this. After this patch set, char2wchar() can become a local function in pg_locale_libc.c. (But we still need wchar2char() externally, so maybe it's not worth changing this (yes).)
Commits
-
Make char2wchar() static.
- ff53907c3571 19 (unreleased) landed
-
Remove obsolete global database_ctype_is_c.
- 844385d12e75 19 (unreleased) landed
-
tsearch: use database default collation for parsing.
- e113f9c102b7 19 (unreleased) landed
-
Add pg_database_locale() to retrieve database default locale.
- e533524b23b8 19 (unreleased) landed
-
Add pg_iswxdigit(), useful for tsearch.
- 67a8b49e96ca 19 (unreleased) landed
-
Add pg_iswalpha() and related functions.
- af164f31b9f5 19 (unreleased) landed
-
pg_regc_locale.c: rename some static functions.
- 8efe982fe2c5 19 (unreleased) landed