Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 25BC06325DA for ; Mon, 21 Jun 2010 13:10:16 -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 79480-07 for ; Mon, 21 Jun 2010 16:10:09 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id 15E7C6323AE for ; Mon, 21 Jun 2010 13:10:08 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id o5LGA5sY013690; Mon, 21 Jun 2010 12:10:05 -0400 (EDT) To: Tatsuhito Kasahara cc: pgsql-bugs@postgresql.org Subject: Re: make_greater_string() does not return a string in some cases In-reply-to: <4C1F389B.1010606@oss.ntt.co.jp> References: <4C1F389B.1010606@oss.ntt.co.jp> Comments: In-reply-to Tatsuhito Kasahara message dated "Mon, 21 Jun 2010 19:02:03 +0900" Date: Mon, 21 Jun 2010 12:10:05 -0400 Message-ID: <13689.1277136605@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.595 tagged_above=-5 required=5 tests=BAYES_00=-1.9, SARE_MILLIONSOF=0.315, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201006/310 X-Sequence-Number: 27271 Tatsuhito Kasahara writes: > make_greater_string() does not return a string when some UTF8 strings > set to str_const. > # Especially UTF8 strings which contains 'BF' in last byte. 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. It's intentional that the existing code doesn't mess with the first byte of a multibyte character (which is the one that determines the character length, in all encodings of interest). 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. In a large number of cases that's just wasted time because there is no chance of getting a larger string without incrementing some character further to the left. So there's a tradeoff that limits how many values we should consider for each character position --- choosing to consider at most 255 is a bit arbitrary, but "all of them" isn't going to work. I don't think that the set of cases that could be improved this way is large enough to justify trying to find solutions to these problems. regards, tom lane