Received: from netrinsics.com (root@[210.74.172.223]) by hub.org (8.9.3/8.9.3) with ESMTP id WAA12707 for ; Wed, 9 Jun 1999 22:24:19 -0400 (EDT) (envelope-from robinson@netrinsics.com) Received: (from robinson@localhost) by netrinsics.com (8.9.3/8.8.7) id KAA11420 for pgsql-hackers@hub.org; Thu, 10 Jun 1999 10:14:10 +0800 (CST) (envelope-from robinson) Date: Thu, 10 Jun 1999 10:14:10 +0800 (CST) From: Michael Robinson Message-Id: <199906100214.KAA11420@netrinsics.com> To: pgsql-hackers@hub.org Subject: Re: [HACKERS] Postgres 6.5 beta2 and beta3 problem Hannu Krosing writes: >in single-byte locales it should be easy: If you do it right, in double-byte locales as well. >1. sort a char[256] array from 0-255 using the current locale settings, > do it once, either at startup or when first needed. Or, alternatively, maintain per-locale table files and mmap them. >2. use binary search on that array to locate the last char before % > in this sorted array: Or, alternatively, maintain another table that maps char values to lexicographic order (and a per-locale constant for maximum character order value): > if (it is not the last char in sorted array) > then (replace that char with the one at index+1) > else ( > if (it is not the first char in like string) > then (discard the last char and goto 2. > else (don't do the end restriction) > ) if ( (nextindex = charorder[c]+1) <= maxchar ) { nextchar = charmap[nextindex]; } else { no nextchar, append charmap[maxchar] to LIKE base string } I don't see where the pain is, but I may be missing something. -Michael Robinson