agora inbox for pgsql-bugs@postgresql.org
help / color / mirror / Atom feedFrom: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: 303677365@qq.com
Subject: BUG #19681: ILIKE rejected on nondeterministic collations while LIKE works
Date: Tue, 08 Sep 2026 07:05:18 +0000
Message-ID: <19681-074ed6100d92cc5b@postgresql.org> (raw)
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.
Message-ID: <19681-074ed6100d92cc5b@postgresql.org>
Permalink: ../19681-074ed6100d92cc5b@postgresql.org/
Also on: postgresql.org/message-id/19681-074ed6100d92cc5b@postgresql.org
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: noreply@postgresql.org, pgsql-bugs@lists.postgresql.org, 303677365@qq.com
Subject: Re: BUG #19681: ILIKE rejected on nondeterministic collations while LIKE works
In-Reply-To: <19681-074ed6100d92cc5b@postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox