Bug #577: incorect sort using order by

Started by PostgreSQL Bugs Listabout 24 years ago2 messagesbugs
Jump to latest
#1PostgreSQL Bugs List
pgsql-bugs@postgresql.org

Christophe RIMBAUD (christophe.rimbaud@bull.net) reports a bug with a severity of 2
The lower the number the more severe it is.

Short Description
incorect sort using order by

Long Description
I have a problem with the order by command.
The column is in CHAR,
for example :
table WAPI (wapinom CHAR(6));

select wapinom from wapi order by wapinom ;
wapinom
----------
ACTI-ACC
ACTI-CRE
ACTIGINT
ACTI-MOD
ACTI-SUP
ACTU-CRE
ACTUGINT
ACTU-INL

my question : why 'ACTIGINT' is after 'ACTI-CRE'. Under Oracle 'ACTIGINT' is after 'ACTI-SUP' that's better.
I'm about to transform a big piece of oracle code to postgres and this bug is very annoyance for me .

Thanks in advance

Chris

Sample Code

No file was uploaded with this report

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: PostgreSQL Bugs List (#1)
Re: Bug #577: incorect sort using order by

pgsql-bugs@postgresql.org writes:

my question : why 'ACTIGINT' is after 'ACTI-CRE'. Under Oracle
'ACTIGINT' is after 'ACTI-SUP' that's better.

If you think that, you should be using C locale not whatever you are
using (perhaps en-US locale). Postgres sorts according to the rules
of the locale that the database was initialized in.

Unfortunately, you'll have to re-initdb to change the locale setting.

regards, tom lane