pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Peter Eisentraut <peter_e@gmx.net>
Cc: Marcin Mańk <marcin.mank@gmail.com>
Cc: Robert Haas <robertmhaas@gmail.com>
Cc: Kyotaro HORIGUCHI <horiguchi.kyotaro@oss.ntt.co.jp>
Cc: pgsql-hackers@postgresql.org <pgsql-hackers@postgresql.org>
Subject: Re: [v9.2] make_greater_string() does not return a string in some cases
Date: Mon, 26 Sep 2011 11:52:16 -0400
Message-ID: <7465.1317052336@sss.pgh.pa.us> (raw)
In-Reply-To: <1317047432.1759.27.camel@fsopti579.F-Secure.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>
	<24673.1316782288@sss.pgh.pa.us>
	<CA+TgmoavQP28OY0QRkXSQiS131u2sEFc7e72yU3x=pjr0BPU=w@mail.gmail.com>
	<624360DC-C26A-4FA6-8C6A-26D28EA79422@gmail.com>
	<1317034343.1759.13.camel@fsopti579.F-Secure.com>
	<5358.1317046134@sss.pgh.pa.us>
	<1317047432.1759.27.camel@fsopti579.F-Secure.com>

Peter Eisentraut <peter_e@gmx.net> writes:
> On mån, 2011-09-26 at 10:08 -0400, Tom Lane wrote:
>> No, it's a hundred times worse than that, because in collations other
>> than C there typically *is* no total order.  The collation behavior of
>> many characters is context-sensitive, thanks to the multi-pass behavior
>> of typical "dictionary" algorithms.

> Well, there is a total order of all strings, but it's not consistent
> under string concatenation.

> But there is a "largest character".  If the collation implementation
> uses four weights (the typical case), the largest character is the one
> that maps to <FFFF> <FFFF> <FFFF> <FFFF>.  If you appended that
> character to a string, you would get a larger string.  (Unless there are
> French backwards levels or other funny things in place, perhaps.)

But the problem is not "make a string greater than this given one".
It is "make a string greater than any string that begins with this
given one".  As an example, suppose we are given "xyz" where "z" is
the last letter in the collation.  We can probably find characters
such as "~" that are greater than "z", but no string x-y-nonletter
is going to be considered greater than x-y-z-z by a dictionary
sorting method.  This is why make_greater_string has to be prepared
to give up and go increment some character before the last one:
the only way to succeed for this input is to construct "xz".

			regards, tom lane



view thread (57+ messages)  latest in thread

Message-ID: <7465.1317052336@sss.pgh.pa.us>
Permalink:  ../7465.1317052336@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/7465.1317052336@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, peter_e@gmx.net, marcin.mank@gmail.com, 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: <7465.1317052336@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> <CA+TgmoavQP28OY0QRkXSQiS131u2sEFc7e72yU3x=pjr0BPU=w@mail.gmail.com> <624360DC-C26A-4FA6-8C6A-26D28EA79422@gmail.com> <1317034343.1759.13.camel@fsopti579.F-Secure.com> <5358.1317046134@sss.pgh.pa.us> <1317047432.1759.27.camel@fsopti579.F-Secure.com> <7465.1317052336@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