Re: Sigh, LIKE indexing is *still* broken in foreign locales - Mailing list pgsql-hackers

From Peter Eisentraut
Subject Re: Sigh, LIKE indexing is *still* broken in foreign locales
Date
Msg-id Pine.LNX.4.21.0006081922450.23619-100000@localhost.localdomain
Whole thread Raw
In response to Sigh, LIKE indexing is *still* broken in foreign locales  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Sigh, LIKE indexing is *still* broken in foreign locales  (Giles Lean <giles@nemeton.com.au>)
List pgsql-hackers
Tom Lane writes:

> Evidently the collation rule is that different accent forms sort the
> same unless the strings would otherwise be considered equal, in which
> case an ordering is assigned to them.

Yes, that's fairly common.

> I am now thinking that maybe we should search for a string that compares
> greater than "fooz" when the prefix is "foo" --- that is, append a 'z'
> to the prefix string.  But I wouldn't be surprised if that fails too
> in some locales.

It most definitely will. sv_SE, no_NO, and hr_HR are the early candidates.
And there's also nothing that says that you can only use LIKE on letters,
Latin letters at that.

The only thing you can really do in this direction is to append the very
last character in the complete collation sequence, if there's a way to
find that out. If there isn't, it might be worth hard-coding a few popular
ones.

> I'm also wondering if the left-hand inequality ('foo' <= any string
> beginning with 'foo') might fail in some locales ... we haven't seen
> it reported but who knows ...

I think that's pretty safe. Shorter strings are always "less than" longer
ones.


-- 
Peter Eisentraut                  Sernanders väg 10:115
peter_e@gmx.net                   75262 Uppsala
http://yi.org/peter-e/            Sweden



pgsql-hackers by date:

Previous
From: Erich Stamberger
Date:
Subject: Re: Sigh, LIKE indexing is *still* broken in foreign locales
Next
From: Tatsuo Ishii
Date:
Subject: Re: Proposal: TRUNCATE TABLE table RESTRICT