Re: Support LIKE with nondeterministic collations

From: Peter Eisentraut <peter(at)eisentraut(dot)org>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Cc: Daniel Verite <daniel(at)manitou-mail(dot)org>
Subject: Re: Support LIKE with nondeterministic collations
Date: 2024-06-28 06:31:23
Message-ID: fdc379ce-4b88-4357-b622-2ae0ef08e295@eisentraut.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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.

Attachment Content-Type Size
v2-0001-Support-LIKE-with-nondeterministic-collations.patch text/plain 21.0 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tatsuro Yamada 2024-06-28 06:45:35 Re: Showing applied extended statistics in explain Part 2
Previous Message Amit Kapila 2024-06-28 06:18:26 Re: walsender.c comment with no context is hard to understand