From: Tom Lane <tgl@sss.pgh.pa.us>
To: Tatsuhito Kasahara <kasahara.tatsuhito@oss.ntt.co.jp>
Cc: pgsql-bugs@postgresql.org
Subject: Re: make_greater_string() does not return a string in some cases
Date: Mon, 21 Jun 2010 12:10:05 -0400
Message-ID: <13689.1277136605@sss.pgh.pa.us> (raw)
In-Reply-To: <4C1F389B.1010606@oss.ntt.co.jp>
References: <4C1F389B.1010606@oss.ntt.co.jp>
Tatsuhito Kasahara <kasahara.tatsuhito@oss.ntt.co.jp> 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, kasahara.tatsuhito@oss.ntt.co.jp
Subject: Re: make_greater_string() does not return a string in some cases
In-Reply-To: <13689.1277136605@sss.pgh.pa.us>
References: <4C1F389B.1010606@oss.ntt.co.jp> <13689.1277136605@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox