Connecting Tech Pros Worldwide Help | Site Map
 
 
LinkBack Thread Tools Search this Thread
  #1  
Old November 22nd, 2005, 08:46 AM
Daniel Gaudreault
Guest
 
Posts: n/a
Default Sorting is ignoring spaces

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?

Thanks,
Dan



  #2  
Old November 22nd, 2005, 08:48 AM
Alvaro Herrera
Guest
 
Posts: n/a
Default Re: Sorting is ignoring spaces

On Wed, Jan 28, 2004 at 09:32:56AM -0500, Daniel Gaudreault wrote:[color=blue]
> 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?[/color]

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)

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

  #3  
Old November 22nd, 2005, 08:48 AM
Tom Lane
Guest
 
Posts: n/a
Default Re: Sorting is ignoring spaces

Daniel Gaudreault <danielg@cadlink.com> writes:[color=blue]
> 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?[/color]

Sounds like you initdb'd in a non-C locale. Unfortunately the only fix
is to re-initdb. You can't change locale on the fly because it affects
the sort ordering of indexes.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 205,414 network members.