Skip site navigation (1) Skip section navigation (2)

Re: [HACKERS] like/ilike improvements

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Zeugswetter Andreas ADI SD <ZeugswetterA(at)spardat(dot)at>, andrew(at)supernews(dot)com, "Patches (PostgreSQL)" <pgsql-patches(at)postgresql(dot)org>
Subject: Re: [HACKERS] like/ilike improvements
Date: 2007-06-01 03:39:30
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackerspgsql-patches

Tom Lane wrote:
> Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
>>   do { (t)++; (tlen)--}  while ((*(t) & 0xC0) == 0x80 && tlen > 0)
> The while *must* test those two conditions in the other order.
> (Don't laugh --- we've had reproducible bugs before in which the backend
> dumped core because of running off the end of memory due to this type
> of mistake.)
>> In fact, I'm wondering if that might make the other UTF8 stuff redundant 
>> - the whole point of what we're doing is to avoid expensive calls to 
>> NextChar;
> +1 I think.  This test will be approximately the same expense as what
> the outer loop would otherwise be (tlen > 0 and *t != firstpat), and
> doing it this way removes an entire layer of intellectual complexity.
> Even though the code is hardly different, we are no longer dealing in
> misaligned pointers anywhere in the match algorithm.

OK, here is a patch that I think incorporates all the ideas discussed 
(including part of Mark Mielke's suggestion about optimising %_). There 
is now no special treatment of UTF8 other than its use of a faster 
NextChar macro.



Attachment: like.patch
Description: text/x-patch (26.7 KB)

In response to


pgsql-hackers by date

Next:From: Josh BerkusDate: 2007-06-01 03:47:49
Subject: Re: Hash joins vs small-integer join values
Previous:From: Tom LaneDate: 2007-06-01 03:22:40
Subject: Re: Autovacuum versus rolled-back transactions

pgsql-patches by date

Next:From: ITAGAKI TakahiroDate: 2007-06-01 05:07:29
Subject: Re: [HACKERS] like/ilike improvements
Previous:From: Jaime CasanovaDate: 2007-06-01 03:26:13
Subject: GUC temp_tablespaces (updated)

Privacy Policy | About PostgreSQL
Copyright © 1996-2018 The PostgreSQL Global Development Group