pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #6495: mis-sorting on string field consisting of space-padded numbers
2+ messages / 2 participants
[nested] [flat]

* BUG #6495: mis-sorting on string field consisting of space-padded numbers
@ 2012-02-28 08:10  lou@paprikash.com
  0 siblings, 1 reply; 2+ messages in thread

From: lou@paprikash.com @ 2012-02-28 08:10 UTC (permalink / raw)
  To: pgsql-bugs

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.




^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: BUG #6495: mis-sorting on string field consisting of space-padded numbers
@ 2012-02-28 08:17  Pavel Stehule <pavel.stehule@gmail.com>
  parent: lou@paprikash.com
  0 siblings, 0 replies; 2+ messages in thread

From: Pavel Stehule @ 2012-02-28 08:17 UTC (permalink / raw)
  To: lou@paprikash.com; +Cc: pgsql-bugs

Hello

2012/2/28  <lou@paprikash.com>:
> 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.
>

This should not be bug - this behave depends on system libraries and
locales setting.

Please, check value of lc_collate variable

postgres=> show lc_collate;
 lc_collate
-------------
 en_US.UTF-8
(1 row)

different collations should have different order.

Regards

Pavel Stehule

>
> --
> Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2012-02-28 08:17 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2012-02-28 08:10 BUG #6495: mis-sorting on string field consisting of space-padded numbers lou@paprikash.com
2012-02-28 08:17 ` Pavel Stehule <pavel.stehule@gmail.com>

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