Re: Support LIKE with nondeterministic collations

Peter Eisentraut <peter@eisentraut.org>

From: Peter Eisentraut <peter@eisentraut.org>
To: pgsql-hackers <pgsql-hackers@postgresql.org>
Cc: Daniel Verite <daniel@manitou-mail.org>
Date: 2024-06-28T06:31:23Z
Lists: pgsql-hackers

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Support LIKE with nondeterministic collations

Attachments

Here is an updated patch for this.

I have added some more documentation based on the discussions, including 
some examples taken directly from the emails here.

One thing I have been struggling with a bit is the correct use of 
LIKE_FALSE versus LIKE_ABORT in the MatchText() code.  I have made some 
small tweaks about this in this version that I think are more correct, 
but it could use another look.  Maybe also some more tests to verify 
this one way or the other.


On 30.04.24 14:39, Daniel Verite wrote:
> 	Peter Eisentraut wrote:
> 
>> This patch adds support for using LIKE with nondeterministic
>>   collations.  So you can do things such as
>>
>>      col LIKE 'foo%' COLLATE case_insensitive
> 
> Nice!
> 
>> The pattern is partitioned into substrings at wildcard characters
>> (so 'foo%bar' is partitioned into 'foo', '%', 'bar') and then then
>> whole predicate matches if a match can be found for each partition
>> under the applicable collation
> 
> Trying with a collation that ignores punctuation:
> 
>    postgres=# CREATE COLLATION "ign_punct" (
>      provider = 'icu',
>      locale='und-u-ka-shifted',
>      deterministic = false
>    );
> 
>    postgres=# SELECT '.foo.' like 'foo' COLLATE ign_punct;
>     ?column?
>    ----------
>     t
>    (1 row)
> 
>    postgres=# SELECT '.foo.' like 'f_o' COLLATE ign_punct;
>     ?column?
>    ----------
>     t
>    (1 row)
> 
>    postgres=# SELECT '.foo.' like '_oo' COLLATE ign_punct;
>     ?column?
>    ----------
>     f
>    (1 row)
> 
> The first two results look fine, but the next one is inconsistent.