Re: [v9.2] make_greater_string() does not return a string in some cases

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: Marcin Mańk <marcin(dot)mank(at)gmail(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Kyotaro HORIGUCHI <horiguchi(dot)kyotaro(at)oss(dot)ntt(dot)co(dot)jp>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [v9.2] make_greater_string() does not return a string in some cases
Date: 2011-09-26 15:52:16
Message-ID: 7465.1317052336@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

Peter Eisentraut <peter_e(at)gmx(dot)net> writes:
> On mn, 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

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Robert Haas 2011-09-26 16:08:22 Re: BUG #6222: Segmentation fault on unlogged table
Previous Message Dave Page 2011-09-26 15:44:04 Re: BUG #6224: Installation Error of dotconnect for postgre SQL Professional

Browse pgsql-hackers by date

  From Date Subject
Next Message Kevin Grittner 2011-09-26 16:04:13 Re: random isolation test failures
Previous Message Andrew Dunstan 2011-09-26 15:43:37 random isolation test failures