Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 32B3EB5DC04 for ; Wed, 22 Jun 2011 17:10:33 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 20043-03 for ; Wed, 22 Jun 2011 20:10:27 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mailout-de.gmx.net (mailout-de.gmx.net [213.165.64.22]) by mail.postgresql.org (Postfix) with SMTP id 7A38BB5DBE1 for ; Wed, 22 Jun 2011 17:10:26 -0300 (ADT) Received: (qmail invoked by alias); 22 Jun 2011 20:10:24 -0000 Received: from a88-115-218-165.elisa-laajakaista.fi (EHLO [10.0.0.101]) [88.115.218.165] by mail.gmx.net (mp050) with SMTP; 22 Jun 2011 22:10:24 +0200 X-Authenticated: #495269 X-Provags-ID: V01U2FsdGVkX18HChx1z0UHsrY47dM0qmrI0BU2AzK/rPIkQ24mJe yjSmybG1JHncBs Subject: Re: a strange order by behavior From: Peter Eisentraut To: Samuel Gendler Cc: Eyal Wilde , pgsql-sql@postgresql.org In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Date: Wed, 22 Jun 2011 23:10:15 +0300 Message-ID: <1308773415.10498.6.camel@vanquo.pezone.net> Mime-Version: 1.0 X-Mailer: Evolution 2.32.3 Content-Transfer-Encoding: 7bit X-Y-GMX-Trusted: 0 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.909 tagged_above=-5 required=5 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201106/84 X-Sequence-Number: 35550 On ons, 2011-06-22 at 01:43 -0700, Samuel Gendler wrote: > I seem to recall a thread here about it ignoring spaces entirely in that > collation (and maybe ignoring capitalization, too?). The way it works is that every collating element (letter or other character or character group that you sort as a unit) is assigned four weights (primary, secondary, tertiary, and quaternary), and the sorting then first compares the primary weights, then the secondary weights, etc. The primary weight typically indicates the overall sort order, like A before B, the secondary weight has to do with diacritic marks, the tertiary with letter case, and the fourth level is only used in special cases. So that's why it looks as though the capitalization is "ignored" unless both the primary and secondary weights are the same. > This worked: > > createdb -E UTF-8 --lc-collate=C some_db > > A quick google search > reveals that there is some kind of standard for unicode collation ( > http://www.unicode.org/reports/tr10/ ) and I have no idea if that is what is > represented by the en_US.UTF-8 collation or not. At least the collate category of the en_US.UTF-8 locale on glibc is unaltered from the ISO 14651 default ordering, which is equivalent to the Unicode default ordering. There several other locales for which that is also the case. Unfortunately, this is not exposed outside of the glibc source code. So you can't just select "give me a neutral default ordering".