Different sort order btwn Linux and Windows

Started by Doug Gorleyalmost 15 years ago3 messagesgeneral
Jump to latest
#1Doug Gorley
doug.gorley@gmail.com

I'm running the following SQL commands on a new PostgreSQL 9.0 database, one
on Linux, one on Windows.

create table i (j varchar(4));
insert into i (j) values ('A'), ('E'), ('<C P'), ('F');
select j from i order by j asc;

On the Windows server I get the following:

----
<C P
A
E
F
----

On the Linux server, I get this instead:

----
A
<C P
E
F
----

Can anyone tell me why the sort order would come out differently?

Thanks,
--
Doug Gorley | doug.gorley@gmail.com

#2Thom Brown
thom@linux.com
In reply to: Doug Gorley (#1)
Re: Different sort order btwn Linux and Windows

On 27 April 2011 20:28, Doug Gorley <doug.gorley@gmail.com> wrote:

I'm running the following SQL commands on a new PostgreSQL 9.0 database,
one on Linux, one on Windows.

create table i (j varchar(4));
insert into i (j) values ('A'), ('E'), ('<C P'), ('F');
select j from i order by j asc;

On the Windows server I get the following:

----
<C P
A
E
F
----

On the Linux server, I get this instead:

----
A
<C P
E
F
----

Can anyone tell me why the sort order would come out differently?

The collations are different on your two databases.

Try:

SHOW lc_collate;

--
Thom Brown
Twitter: @darkixion
IRC (freenode): dark_ixion
Registered Linux user: #516935

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

#3Doug Gorley
doug.gorley@gmail.com
In reply to: Thom Brown (#2)
Re: Different sort order btwn Linux and Windows

That does indeed appear to be the case -- the database on the Linux server
has en_CA.UTF-8 collation, while the database on the Windows server has
English_Canada.1252 collation. Thanks!

Doug

On Wed, Apr 27, 2011 at 1:04 PM, Thom Brown <thom@linux.com> wrote:

On 27 April 2011 20:28, Doug Gorley <doug.gorley@gmail.com> wrote:

I'm running the following SQL commands on a new PostgreSQL 9.0 database,
one on Linux, one on Windows.

create table i (j varchar(4));
insert into i (j) values ('A'), ('E'), ('<C P'), ('F');
select j from i order by j asc;

On the Windows server I get the following:

----
<C P
A
E
F
----

On the Linux server, I get this instead:

----
A
<C P
E
F
----

Can anyone tell me why the sort order would come out differently?

The collations are different on your two databases.

Try:

SHOW lc_collate;

--
Thom Brown
Twitter: @darkixion
IRC (freenode): dark_ixion
Registered Linux user: #516935

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

--
Doug Gorley | doug.gorley@gmail.com