Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 5D428B5DBD6 for ; Mon, 26 Sep 2011 11:09:16 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 68975-02 for ; Mon, 26 Sep 2011 14:09:10 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.8.0-rc2 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id AEB54B5DD01 for ; Mon, 26 Sep 2011 11:08:57 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id p8QE8sLu005359; Mon, 26 Sep 2011 10:08:54 -0400 (EDT) To: Peter Eisentraut cc: Marcin =?UTF-8?Q?Ma=C5=84k?= , Robert Haas , Kyotaro HORIGUCHI , "pgsql-hackers@postgresql.org" Subject: Re: [v9.2] make_greater_string() does not return a string in some cases In-reply-to: <1317034343.1759.13.camel@fsopti579.F-Secure.com> References: <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> <6425.1316656167@sss.pgh.pa.us> <8755.1316665444@sss.pgh.pa.us> <18434.1316702188@sss.pgh.pa.us> <24673.1316782288@sss.pgh.pa.us> <624360DC-C26A-4FA6-8C6A-26D28EA79422@gmail.com> <1317034343.1759.13.camel@fsopti579.F-Secure.com> Comments: In-reply-to Peter Eisentraut message dated "Mon, 26 Sep 2011 13:52:23 +0300" Date: Mon, 26 Sep 2011 10:08:54 -0400 Message-ID: <5358.1317046134@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.404 tagged_above=-5 required=5 tests=BAYES_00=-1.9, RP_MATCHES_RCVD=-0.504 X-Spam-Level: X-Archive-Number: 201109/1371 X-Sequence-Number: 195560 Peter Eisentraut 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. regards, tom lane