Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 47DAD632A4F for ; Wed, 23 Jun 2010 06:43:01 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 96574-06 for ; Wed, 23 Jun 2010 09:42:53 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from serv2.oss.ntt.co.jp (serv2.oss.ntt.co.jp [222.151.198.100]) by mail.postgresql.org (Postfix) with ESMTP id E6BF863232D for ; Wed, 23 Jun 2010 06:42:53 -0300 (ADT) Received: from serv2.oss.ntt.co.jp (localhost [127.0.0.1]) by serv2.oss.ntt.co.jp (Postfix) with ESMTP id 01EFF24832D; Wed, 23 Jun 2010 18:42:50 +0900 (JST) Received: from serv1.oss.ntt.co.jp (serv1.oss.ntt.co.jp [172.19.0.2]) by serv2.oss.ntt.co.jp (Postfix) with ESMTP id E5EB624832C; Wed, 23 Jun 2010 18:42:49 +0900 (JST) Received: from [127.0.0.1] (unknown [172.17.1.89]) by serv1.oss.ntt.co.jp (Postfix) with ESMTP id 4667E13C302; Wed, 23 Jun 2010 18:42:49 +0900 (JST) Message-ID: <4C21D716.70808@oss.ntt.co.jp> Date: Wed, 23 Jun 2010 18:42:46 +0900 From: Tatsuhito Kasahara User-Agent: Thunderbird 1.5.0.9 (Windows/20061207) MIME-Version: 1.0 To: Tom Lane CC: pgsql-bugs@postgresql.org Subject: Re: make_greater_string() does not return a string in some cases References: <4C1F389B.1010606@oss.ntt.co.jp> <13689.1277136605@sss.pgh.pa.us> In-Reply-To: <13689.1277136605@sss.pgh.pa.us> Content-Type: text/plain; charset=ISO-2022-JP Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.79 tagged_above=-5 required=5 tests=BAYES_50=0.8, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201006/329 X-Sequence-Number: 27290 Tom Lane wrote: > The patch you propose for this is really untenable: it will re-introduce > many corner cases that we got rid of years ago, for example cases > wherein pg_verifymbstr and pg_mbcliplen index off the end of the string > because they think the last character occupies more bytes than are > there. > Another problem is that if the last character is several bytes long, > this coding would cause us to iterate through potentially many millions > of character values before giving up and truncating off the last > character. Hmm... OK, I see your points. I have another idea. 1. We prepare new operators ( <,<=,>,=>,= ) for text and bytea. 2. In make_greater_string(), if multi-byte-string was set and using locale-C and could not find greater string, returns bytea which has greater byte-code of last-character. User will get the following result. ======================================================================================================= -- 西 : 0xe8a5bf =# EXPLAIN ANALYZE SELECT * FROM test WHERE name LIKE '西%'; QUERY PLAN ---------------------------------------------------------------------------------------------------------------- Index Scan using test_name on test (cost=0.00..8.28 rows=1 width=4) (actual time=0.022..0.024 rows=1 loops=1) Index Cond: ((name >= '西'::text) AND (name < '\\xe8a5c0'::bytea)) Filter: (name ~~ '西%'::text) Total runtime: 0.053 ms (4 rows) ======================================================================================================= Is the idea reasonable ? Best regards, -- NTT OSS Center Tatsuhito Kasahara