Re: Sigh, LIKE indexing is *still* broken in foreign locales

Giles Lean <giles@nemeton.com.au>

From: Giles Lean <giles@nemeton.com.au>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: "Matthias Urlichs" <smurf@noris.de>, MouchaV@radiomobil.cz, pgsql-hackers@postgresql.org
Date: 2000-06-08T20:45:21Z
Lists: pgsql-bugs, pgsql-hackers
On Thu, 08 Jun 2000 10:04:11 -0400  Tom Lane wrote:

> The bounds do not have to be perfectly tight, in the sense of being
> the least string >= or largest string <= the desired strings.  It's
> OK if we scan a few extra tuples in some cases.  But we have to have
> reasonably close bounds or we can't implement LIKE with an index.

Determining the bounding (sub-)strings looks like a very hard problem.

I think there is enough information in a POSIX locale to determine
what the rules for constructing such bounds would be ... but there is
no programatic interface to determine the rules a locale uses for
collation.  (I have no idea what non-POSIX systems provide.)

(The localedef program can build a locale.  strcoll() and strxfrm()
can use the collation information.  That's all I see.)

In the absence of a way to do this "right" we need someone to see a
"good enough" hack that happens to work everywhere, or else give up
using indexes for LIKE which I doubt would please anyone.  I suppose
the mismatch comes about because LIKE is about pattern matching and
not collation. :(

Regards,

Giles