Okay, now I understand the problem better.
How about, as an intermediate solution, a list of 'sane' locales in which
the optimization applied to the C/POSIX locale works? It should be fairly
straight forward to write a test program that will test a locale and see if
any of the common problems apply. And I expect that several locales can be
added straight away as they are known to obey simple sorting rules.
Alternately, though I don't think this would be a very good idea, a SET
option along the lines of enable_dangerous_like_optimization or such that
would (of course) default to off.
-Matt
-----Original Message-----
From: Tom Lane [mailto:tgl@sss.pgh.pa.us]
Unfortunately, locale-dependent sorting rules are much stranger than you
seem to think. You can dig in the pghackers archives for some of the
reasons that we had to disable that optimization (we tried repeatedly to
find ways around this, btw). Special digraph rules and multipass
comparisons are a couple of examples of things that completely break
the LIKE optimization.
regards, tom lane