Skip site navigation (1) Skip section navigation (2)

Re: Sorting is ignoring spaces

From: Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl>
To: Daniel Gaudreault <danielg(at)cadlink(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Sorting is ignoring spaces
Date: 2004-01-31 22:54:04
Message-ID: 20040131225404.GB7024@dcc.uchile.cl (view raw or flat)
Thread:
Lists: pgsql-general
On Wed, Jan 28, 2004 at 09:32:56AM -0500, Daniel Gaudreault wrote:
> One of our developers came across the fact that postgres is ignoring 
> spaces when sorting results from a query.  We are using PGSQL 7.3.4 on 
> the backend.  Is there something that needs to be set somewhere to for 
> the sort to not ignore spaces?

This is locale related; Postgres just uses strcoll.  You could try
changing your locale, but it's difficult to do on an existing database.
I think the C locale orders by byte values, but most single-byte locales
have funny rules regarding whitespace.

See strcoll(3).

A workaround could be ask the server to sort not using the column
itself, but a function of it that replaces the spaces with something
else that has the desired sorting effect.

-- 
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
"¿Cómo puedes confiar en algo que pagas y que no ves,
y no confiar en algo que te dan y te lo muestran?" (Germán Poo)

In response to

pgsql-general by date

Next:From: Tom LaneDate: 2004-01-31 23:10:16
Subject: Re: Sorting is ignoring spaces
Previous:From: Alvaro HerreraDate: 2004-01-31 22:43:22
Subject: Re: Insert question null/not null serial, etc.

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group