pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: lou@paprikash.com
To: pgsql-bugs@postgresql.org
Subject: BUG #6495: mis-sorting on string field consisting of space-padded numbers
Date: Tue, 28 Feb 2012 08:10:00 +0000
Message-ID: <E1S2I8G-0003fB-Uk@wrigleys.postgresql.org> (raw)

The following bug has been logged on the website:

Bug reference:      6495
Logged by:          Lou Duchez
Email address:      lou@paprikash.com
PostgreSQL version: 9.1.2
Operating system:   Fedora 16, CentOS 5
Description:        

Download the following file and feed it into psql:

http://www.paprikash.com/lou/missorttest.sql

Then run the command:

select * from missorttest order by hiercode;

Each "hiercode" entry contains concatenations of numbers, where each number
is left-padded to take exactly four characters.  PostgreSQL is sorting as if
the padding were on the right.  As a result, "   2  10" is coming before "  
2   2", even though a literal sorting of the string should put "   2   2"
first (because chr 32 comes before chr 49).

More info: this error does not occur on the Windows build of PostgreSQL. 
Also, I compile my own versions of PostgreSQL on Fedora and CentOS, taking
all the defaults.




view thread (2+ messages)  latest in thread

Message-ID: <E1S2I8G-0003fB-Uk@wrigleys.postgresql.org>
Permalink:  ../E1S2I8G-0003fB-Uk@wrigleys.postgresql.org/
Also on:    postgresql.org/message-id/E1S2I8G-0003fB-Uk@wrigleys.postgresql.org

 · 

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: lou@paprikash.com
  Subject: Re: BUG #6495: mis-sorting on string field consisting of space-padded numbers
  In-Reply-To: <E1S2I8G-0003fB-Uk@wrigleys.postgresql.org>
  References: <E1S2I8G-0003fB-Uk@wrigleys.postgresql.org>

* 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