Re: Use CASEFOLD() internally rather than LOWER()

From: Jeff Davis <pgsql(at)j-davis(dot)com>
To: Daniel Verite <daniel(at)manitou-mail(dot)org>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Use CASEFOLD() internally rather than LOWER()
Date: 2026-03-03 21:01:48
Message-ID: 0a4f41b84efa5d821aba166658fb845f1ab97f03.camel@j-davis.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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

Attachment Content-Type Size
v2-0001-ILIKE-use-CASEFOLD-rather-than-LOWER.patch text/x-patch 5.7 KB
v2-0002-dict_xsyn-use-CASEFOLD-rather-than-LOWER.patch text/x-patch 1.1 KB
v2-0003-tsearch-use-CASEFOLD-rather-than-LOWER.patch text/x-patch 5.1 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Florin Irion 2026-03-03 21:04:45 Re: UBSAN crash in EventTriggerCollectAlterTSConfig (memcpy with NULL src)
Previous Message Tom Lane 2026-03-03 20:58:16 Re: Improve hash join's handling of tuples with null join keys