pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Peter Eisentraut <peter_e@gmx.net>
To: Tom Lane <tgl@sss.pgh.pa.us>
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 17:30:32 +0300
Message-ID: <1317047432.1759.27.camel@fsopti579.F-Secure.com> (raw)
In-Reply-To: <5358.1317046134@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>

On mån, 2011-09-26 at 10:08 -0400, Tom Lane wrote:
> Peter Eisentraut <peter_e@gmx.net> writes:
> > On fre, 2011-09-23 at 20:35 +0300, Marcin Mańk wrote:
> >> One idea:
> >> col like 'foo%' could be translated to col >= 'foo' and col <= foo || 'zzz' , where 'z' is the largest possible character. This should be good enough  for calculating stats.
> >> How to find such a character, i do not know.
> 
> > That's what makes this so difficult.
> 
> > If we knew the largest character, we could probably also find the
> > largest-1, largest-2, etc. characters and determine the total order of
> > everything.
> 
> 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
we don't know which character that is, and likely there isn't one, so
we'd need to largest character that maps to an actually assigned weight,
and that's not possible without exhaustive search of all collating
elements.

We could possibly try to make this whole thing work differently by
storing the strxfrm results in the histograms.





view thread (57+ messages)  latest in thread

Message-ID: <1317047432.1759.27.camel@fsopti579.F-Secure.com>
Permalink:  ../1317047432.1759.27.camel@fsopti579.F-Secure.com/
Also on:    postgresql.org/message-id/1317047432.1759.27.camel@fsopti579.F-Secure.com

 · 

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: peter_e@gmx.net, tgl@sss.pgh.pa.us, 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: <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>

* 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