Re: Use CASEFOLD() internally rather than LOWER()
Jeff Davis <pgsql@j-davis.com>
From: Jeff Davis <pgsql@j-davis.com>
To: Daniel Verite <daniel@manitou-mail.org>
Cc: pgsql-hackers@postgresql.org
Date: 2026-03-03T21:01:48Z
Lists: pgsql-hackers
Attachments
- v2-0001-ILIKE-use-CASEFOLD-rather-than-LOWER.patch (text/x-patch) patch v2-0001
- v2-0002-dict_xsyn-use-CASEFOLD-rather-than-LOWER.patch (text/x-patch) patch v2-0002
- v2-0003-tsearch-use-CASEFOLD-rather-than-LOWER.patch (text/x-patch) patch v2-0003
On Sat, 2026-02-28 at 14:27 +0100, Daniel Verite wrote: > I tried 0001 with a non-UTF8 database and got quickly stuck: Attached new versions. I moved the encoding check into the SQL-callable casefold() function, and other callers use str_casefold(). That slightly simplifies what happens in ILIKE, also. I removed the citext changes. citext has somewhat of a legacy status, I think, so I'm not sure it makes sense to try to modernize or change it. Also, some SQL-language functions in citext use LOWER(), so the changes aren't enough: we'd need to make the SQL CASEFOLD function callable in other encodings, and also run a citext upgrade script to change the definitions. Note that these changes affect the result of some expressions (e.g. ILIKE), so could theoretically make an expression index or predicate index inconsistent. Regards, Jeff Davis