BUG #19681: ILIKE rejected on nondeterministic collations while LIKE works
The following bug has been logged on the website:
Bug reference: 19681
Logged by: chunling qin
Email address: 303677365@qq.com
PostgreSQL version: 18.6
Operating system: x86_64
Description:
On a column with a nondeterministic (case-insensitive) collation, the
pattern-matching operators split into two contradictory groups:
CREATE COLLATION ci (provider = icu, locale = 'und-u-ks-level2',
deterministic = false);
CREATE TABLE ndt(b text COLLATE ci);
INSERT INTO ndt VALUES ('a'),('A'),('str'),('STR'),('Hello');
Group 1 — silently supported (documented for LIKE):
SELECT count(*) FROM ndt WHERE b LIKE 's%'; -- 2 (matches 'str'
and 'STR')
SELECT count(*) FROM ndt WHERE b LIKE 'str'; -- 2
SELECT count(*) FROM ndt WHERE b IN ('str'); -- 2
SELECT count(*) FROM ndt WHERE b = 'str'; -- 1
SELECT count(*) FROM ndt WHERE upper(b) LIKE 'S%'; -- 2 (upper+LIKE:
ILIKE's definition!)
SELECT b LIKE 'str' COLLATE ci FROM ndt WHERE b = 'STR'; -- true
(documented example form)
Group 2 — rejected with an error:
SELECT count(*) FROM ndt WHERE b ILIKE 's%'; -- ERROR:
nondeterministic collations are not supported for ILIKE
SELECT b ILIKE 'str' COLLATE ci FROM ndt; -- ERROR: same
SELECT count(*) FROM ndt WHERE b ~ '^s'; -- ERROR:
nondeterministic collations are not supported for regular expressions
SELECT count(*) FROM ndt WHERE b SIMILAR TO 's%'; -- ERROR: same
The documentation (func-matching.sgml) states that LIKE supports
nondeterministic collations and that SIMILAR TO / POSIX regex do not — but
says nothing about ILIKE. Meanwhile ILIKE's documented definition is exactly
"matches LIKE, but case-insensitively" (implemented as case folding + LIKE),
and that folding path works fine on the same column (upper(b) LIKE 'S%'
returns 2 rows). The citext extension — the other case-insensitive subsystem
— accepts ILIKE without error on its columns, making the ND-collation
rejection of the same operator even more inconsistent.
On Thu, Sep 10, 2026 at 5:38 PM PG Bug reporting form
<noreply@postgresql.org> wrote:
The following bug has been logged on the website:
The documentation (func-matching.sgml) states that LIKE supports
nondeterministic collations and that SIMILAR TO / POSIX regex do not — but
says nothing about ILIKE. Meanwhile ILIKE's documented definition is exactly
I see that this doc
https://www.postgresql.org/docs/18/functions-matching.html#FUNCTIONS-LIKE
says that ILIKE doesn't support non-deterministic-collations.
"The key word ILIKE can be used instead of LIKE to make the match
case-insensitive according to the active locale. (But this does not
support nondeterministic collations.)"
So this looks like it is working as intended.
Thanks
Nitin Motiani
Senior Software Engineer,
Google