Re: Support LIKE with nondeterministic collations

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Peter Eisentraut <peter(at)eisentraut(dot)org>
Cc: Daniel Verite <daniel(at)manitou-mail(dot)org>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Support LIKE with nondeterministic collations
Date: 2024-05-03 13:20:52
Message-ID: CA+TgmoaKMO-PcqsdJj9246riXz1DNB+Bcpfww2P4y8SH+W27iA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, May 3, 2024 at 4:52 AM Peter Eisentraut <peter(at)eisentraut(dot)org> wrote:
> What the implementation does is, it walks through the pattern. It sees
> '_', so it steps over one character in the input string, which is '.'
> here. Then we have 'foo.' left to match in the input string. Then it
> takes from the pattern the next substring up to but not including either
> a wildcard character or the end of the string, which is 'oo', and then
> it checks if a prefix of the remaining input string can be found that is
> "equal to" 'oo'. So here it would try in turn
>
> '' = 'oo' collate ign_punct ?
> 'f' = 'oo' collate ign_punct ?
> 'fo' = 'oo' collate ign_punct ?
> 'foo' = 'oo' collate ign_punct ?
> 'foo.' = 'oo' collate ign_punct ?
>
> and they all fail, so the match fails.

Interesting. Does that imply that these matches are slower than normal ones?

> The second definition would satisfy the expectation here, because then
> '.f' matches '_' because '.f' is equal to some string of length one,
> such as 'f'. (And then 'oo.' matches 'oo' for the rest of the pattern.)
> However, off the top of my head, this definition has three flaws: (1)
> It would make the single-character wildcard effectively an
> any-number-of-characters wildcard, but only in some circumstances, which
> could be confusing, (2) it would be difficult to compute, because you'd
> have to check equality against all possible single-character strings,
> and (3) it is not what the SQL standard says.

Right, those are good arguments.

> In any case, yes, some explanation and examples should be added.

Cool.

--
Robert Haas
EDB: http://www.enterprisedb.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Justin Pryzby 2024-05-03 13:23:14 Re: Add SPLIT PARTITION/MERGE PARTITIONS commands
Previous Message Imseih (AWS), Sami 2024-05-03 12:57:18 Re: allow changing autovacuum_max_workers without restarting