Re: UTF8MatchText - Mailing list pgsql-patches

From Dennis Bjorklund
Subject Re: UTF8MatchText
Date
Msg-id 464FFC76.9060308@zigo.dhs.org
Whole thread Raw
In response to Re: UTF8MatchText  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: UTF8MatchText  (Andrew Dunstan <andrew@dunslane.net>)
List pgsql-patches
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.

Other than this part that I think can be optimized I don't see anything
wrong with the idea behind the patch. To make the '%' case fast might be
an important optimization for a lot of use cases. It's not uncommon that
'%' matches a bigger part of the string than the rest of the pattern.

It's easy to make a misstake when one is used to think about the simple
fixed size characters like ascii. Strange that this simple topic can be
so difficult to think about... :-)

/Dennis

pgsql-patches by date:

Previous
From: NikhilS
Date:
Subject: Re: CREATE TABLE LIKE INCLUDING INDEXES support
Next
From: "Henry B. Hotz"
Date:
Subject: Re: Preliminary GSSAPI Patches