Hi, While working on BUG #19873 [1], I found that citext has a related problem. With a nondeterministic collation, adding an index changes the result.
create extension citext;
create collation ai (provider = icu, locale = 'und-u-ks-level1',
deterministic = false);
create table t (x citext collate ai);
insert into t values ('e'), ('é');
select count(*) from t where x = 'é';
count
-------
1
create index on t (x);
set enable_seqscan = off;
select count(*) from t where x = 'é';
count
-------
0
The index uses citext_cmp(), which follows the collation and says the
two values are equal. But "=" compares the lower-cased bytes and says
they are not. I see the same on 14 through master.
I think "=" and the hash functions should follow the collation too, like
they do for text. Does that sound right? I can write a patch.
[1] https://postgr.es/m/[email protected]
Thanks,
Shihao
repro.sql
Description: Binary data
