Re: LIKE 'bla%' - Mailing list pgsql-bugs

From Tom Lane
Subject Re: LIKE 'bla%'
Date
Msg-id 1388.967915094@sss.pgh.pa.us
Whole thread Raw
In response to LIKE 'bla%'  (pgsql-bugs@postgresql.org)
List pgsql-bugs
pgsql-bugs@postgresql.org writes:
> DELETE FROM MYTABLE WHERE NAME LIKE 'Ant%';
> knowing that there existed only one record with 'Anton' as name.
> However, the code above delivered 'DELETE 0'

> DELETE FROM MYTABLE WHERE NAME LIKE 'Anto%';
> which gave 'DELETE 1'

> Isn't this strange?

Yup.  What PG version are you using, and are you running it with a
non-English LOCALE setting?  Is there an index on the NAME column?

I suspect you are running into another variant of the problem we've
had for a long time concerning how to derive upper and lower index
boundes for a LIKE string.  In ASCII locale it's pretty easy:
    name >= 'Ant' AND name < 'Anu'
can be used to scan the index for all entries that might match the
given LIKE pattern.  But in non-ASCII locales with complicated collation
rules that method tends to fail.  See the pgsql-hackers mailing lists;
latest go-round was thread
    Sigh, LIKE indexing is *still* broken in foreign locales
in early June 2000.  At the moment I don't think we know a bulletproof
solution, other than not using indexes for LIKE, which won't make people
happy either ...

            regards, tom lane

pgsql-bugs by date:

Previous
From: pgsql-bugs@postgresql.org
Date:
Subject: PG still fussy to compile on Solaris + GCC, may still need Sun ld
Next
From: Tom Lane
Date:
Subject: Re: PG still fussy to compile on Solaris + GCC, may still need Sun ld