Re: like/ilike improvements

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, ITAGAKI Takahiro <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: like/ilike improvements
Date: 2007-05-22 16:51:51
Message-ID: 46531FA7.6060904@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

Andrew Dunstan wrote:
>
>
> Tom Lane wrote:
>> Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
>>
>>> ... It turns out (according to the analysis) that the only time we
>>> actually need to use NextChar is when we are matching an "_" in a
>>> like/ilike pattern.
>>>
>>
>> I thought we'd determined that advancing bytewise for "%" was also
>> risky,
>> in two cases:
>>
>> 1. Multibyte character set that is not UTF8 (more specifically, does not
>> have a guarantee that first bytes and not-first bytes are distinct)

I thought we disposed of the idea that there was a problem with charsets
that didn't do first byte special.

And Dennis said:

> Tom Lane skrev:
>> You could imagine trying to do
>> % a byte at a time (and indeed that's what I'd been thinking it did)
>> but that gets you out of sync which breaks the _ case.
>
> It is only when you have a pattern like '%_' when this is a problem
> and we could detect this and do byte by byte when it's not. Now we
> check (*p == '\\') || (*p == '_') in each iteration when we scan over
> characters for '%', and we could do it once and have different loops
> for the two cases.

That's pretty much what the patch does now - It never tries to match a
single byte when it sees "_", whether or not preceeded by "%".

cheers

andrew

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Martijn van Oosterhout 2007-05-22 16:56:10 Re: Re: [Oledb-dev] double precision error with pg linux server, but not with windows pg server
Previous Message Andrew Dunstan 2007-05-22 16:30:37 Re: like/ilike improvements

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2007-05-22 17:01:14 Re: like/ilike improvements
Previous Message Andrew Dunstan 2007-05-22 16:30:37 Re: like/ilike improvements