pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Robert Haas <robertmhaas@gmail.com>
Cc: Kyotaro HORIGUCHI <horiguchi.kyotaro@oss.ntt.co.jp>
Cc: pgsql-hackers@postgresql.org
Subject: Re: [v9.2] make_greater_string() does not return a string in some cases
Date: Fri, 23 Sep 2011 08:51:28 -0400
Message-ID: <24673.1316782288@sss.pgh.pa.us> (raw)
In-Reply-To: <CA+TgmoZEoR4UbYoiAb=NOJzwmswv7_dt-pp1ATi_gE2g8XnMoQ@mail.gmail.com>
References: <CA+TgmoYAoGSnk1zMEeq_RWB+D5OjfPX6zmXFetoSZfW70S1p6Q@mail.gmail.com>
	<20110711.155531.15100243.horiguchi.kyotaro@oss.ntt.co.jp>
	<20110712.161231.138791411.horiguchi.kyotaro@oss.ntt.co.jp>
	<20110914.111320.18404009.horiguchi.kyotaro@oss.ntt.co.jp>
	<CA+TgmoYO3UbyCekzDTdVWTG2goEQtr7H_f=9mous9u_uH_StSA@mail.gmail.com>
	<6425.1316656167@sss.pgh.pa.us>
	<CA+TgmoY9+ZUHNju7ERi7QM36FjiXzfT38S63564L_14qf3hgYg@mail.gmail.com>
	<8755.1316665444@sss.pgh.pa.us>
	<CA+Tgmoax-SHNgHe77cJZGsqgsB+Z=n_jzQZ5h0RG1+NcWGHkBg@mail.gmail.com>
	<18434.1316702188@sss.pgh.pa.us>
	<CA+TgmoZEoR4UbYoiAb=NOJzwmswv7_dt-pp1ATi_gE2g8XnMoQ@mail.gmail.com>

Robert Haas <robertmhaas@gmail.com> writes:
> On Thu, Sep 22, 2011 at 10:36 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> Anyway, I won't stand in the way of the patch as long as it's modified
>> to limit the number of values considered for any one character position
>> to something reasonably small.

> I think that limit in both the old and new code is 1, except that the
> new code does it more efficiently.

> Am I confused?

Yes, or else I am.  Consider a 4-byte UTF8 character at the end of the
string.  The existing code increments the last byte up to 255 (rejecting
everything past 0xBF), then gives up and truncates that character away.
So the maximum number of tries for that character position is between 0
and 127 depending on what the original character was (with at most 63 of
the incremented values getting past the verifymbstr test).

The proposed patch is going to iterate through all Unicode code points
up to U+7FFFFF before giving up.  Since it's possible that we need to
increment something further left to succeed at all, this doesn't seem
like a good plan.

			regards, tom lane



view thread (57+ messages)  latest in thread

Message-ID: <24673.1316782288@sss.pgh.pa.us>
Permalink:  ../24673.1316782288@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/24673.1316782288@sss.pgh.pa.us

 · 

reply

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, robertmhaas@gmail.com, horiguchi.kyotaro@oss.ntt.co.jp, pgsql-hackers@postgresql.org
  Subject: Re: [v9.2] make_greater_string() does not return a string in some cases
  In-Reply-To: <24673.1316782288@sss.pgh.pa.us>
  References: <CA+TgmoYAoGSnk1zMEeq_RWB+D5OjfPX6zmXFetoSZfW70S1p6Q@mail.gmail.com> <20110711.155531.15100243.horiguchi.kyotaro@oss.ntt.co.jp> <20110712.161231.138791411.horiguchi.kyotaro@oss.ntt.co.jp> <20110914.111320.18404009.horiguchi.kyotaro@oss.ntt.co.jp> <CA+TgmoYO3UbyCekzDTdVWTG2goEQtr7H_f=9mous9u_uH_StSA@mail.gmail.com> <6425.1316656167@sss.pgh.pa.us> <CA+TgmoY9+ZUHNju7ERi7QM36FjiXzfT38S63564L_14qf3hgYg@mail.gmail.com> <8755.1316665444@sss.pgh.pa.us> <CA+Tgmoax-SHNgHe77cJZGsqgsB+Z=n_jzQZ5h0RG1+NcWGHkBg@mail.gmail.com> <18434.1316702188@sss.pgh.pa.us> <CA+TgmoZEoR4UbYoiAb=NOJzwmswv7_dt-pp1ATi_gE2g8XnMoQ@mail.gmail.com> <24673.1316782288@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