Re: ILIKE vs indices - Mailing list pgsql-hackers

From James Cloos
Subject Re: ILIKE vs indices
Date
Msg-id m3vcblcg1v.fsf@carbon.jhcloos.org
Whole thread Raw
In response to Re: ILIKE vs indices  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
>>>>> "TL" == Tom Lane <tgl@sss.pgh.pa.us> writes:

JC>> Is there any contraindication to recasting:
JC>> foo ILIKE 'bar'
JC>> into:
JC>> LOWER(foo) LIKE LOWER('bar')

TL> In some locales those are not equivalent, I believe, or at least
TL> shouldn't be.  (What the current code actually does is a separate
TL> question.)

I see.  After determining indexing based on th existance of an initial
fixed string, exluding anything matching isalpha(), it uses tolower(3)
and friends to do the actual match.

So my proposal wouldn't change what matches, but might make fixing any
bugs in what *should* match more difficult?

TL> In any case it's not obvious why LOWER rather than UPPER.

I suggested lower() because that matched all of the suggestions I found.
And as it turns out matches the current behaviour, too.

The footnote about adding explicit mention to the docs was expressly
because it is not otherwise obvious whether indices should use lower()
or upper().

I'll ask on one of the unicode lists whether there are any locales where
a case-insensitive match should be different than a case-preserving match
of tolower() vs tolower().

-JimC
-- 
James Cloos <cloos@jhcloos.com>         OpenPGP: 1024D/ED7DAEA6



pgsql-hackers by date:

Previous
From: Pavel Stehule
Date:
Subject: Re: proposal: ANSI SQL 2011 syntax for named parameters
Next
From: Daniel Farina
Date:
Subject: Re: pg_stat_statements: calls under-estimation propagation