Re: Issue on Varchar Ordering

From: "Rodrigo Hjort" <rodrigo(dot)hjort(at)gmail(dot)com>
To: "Jonah H(dot) Harris" <jonah(dot)harris(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Issue on Varchar Ordering
Date: 2006-03-29 17:02:10
Message-ID: 731083980603290902s6eacf725x7d28c098ba7754f7@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Yeah, I think there's a problem on Linux locales.

Using the C locale, it works as expected:

rodrigo(at)asgard:~$ export LC_ALL=C && cat test.txt | sort
GABRIEL ALCIDES KLIM PERONDI
GABRIEL ALEXANDRE DA SILVA MANICA
GABRIELA HELEDA DE SOUZA
GABRIELA JACOBY NOS
GABRIELA LETICIA BATISTA NUNES

But when using Brazilian Portuguese, it gives:

rodrigo(at)asgard:~$ export LC_ALL=pt_BR && cat test.txt | sort
GABRIELA HELEDA DE SOUZA
GABRIELA JACOBY NOS
GABRIEL ALCIDES KLIM PERONDI
GABRIELA LETICIA BATISTA NUNES
GABRIEL ALEXANDRE DA SILVA MANICA

rodrigo(at)asgard:~$ export LC_ALL=pt_BR.UTF-8 && cat test.txt | sort
GABRIELA HELEDA DE SOUZA
GABRIELA JACOBY NOS
GABRIEL ALCIDES KLIM PERONDI
GABRIELA LETICIA BATISTA NUNES
GABRIEL ALEXANDRE DA SILVA MANICA

rodrigo(at)asgard:~$ export LC_ALL=pt_BR.ISO-8859-1 && cat test.txt | sort
GABRIELA HELEDA DE SOUZA
GABRIELA JACOBY NOS
GABRIEL ALCIDES KLIM PERONDI
GABRIELA LETICIA BATISTA NUNES
GABRIEL ALEXANDRE DA SILVA MANICA

The fact is that I can't raise PostgreSQL with C encoding, as special
characters are used on most tables.

Did anyone ever had the same problem on Linux?

2006/3/29, Jonah H. Harris <jonah(dot)harris(at)gmail(dot)com>:
>
> I don't think PostgreSQL's sorting it wrong... here's the output of
> Linux's sort utility:
>
> edb82(at)linux:~> cat test.txt
> GABRIEL ALEXANDRE DA SILVA MANICA
> GABRIELA LETICIA BATISTA NUNES
> GABRIEL ALCIDES KLIM PERONDI
> GABRIELA JACOBY NOS
> GABRIELA HELEDA DE SOUZA
>
> edb82(at)linux:~> cat test.txt | sort
> GABRIELA HELEDA DE SOUZA
> GABRIELA JACOBY NOS
> GABRIEL ALCIDES KLIM PERONDI
> GABRIELA LETICIA BATISTA NUNES
> GABRIEL ALEXANDRE DA SILVA MANICA
>
> edb82(at)linux:~> psql -c "SELECT * FROM aluno ORDER BY nome" postgres
> id | nome
> ----+-----------------------------------
> 36 | GABRIELA HELEDA DE SOUZA
> 37 | GABRIELA JACOBY NOS
> 38 | GABRIEL ALCIDES KLIM PERONDI
> 39 | GABRIELA LETICIA BATISTA NUNES
> 40 | GABRIEL ALEXANDRE DA SILVA MANICA
> (5 rows)
>
> --
> Jonah H. Harris, Database Internals Architect
> EnterpriseDB Corporation
> 732.331.1324
>

--
Regards,

Rodrigo Hjort
GTI - Projeto PostgreSQL
CELEPAR - Cia de Informática do Paraná
http://www.pr.gov.br

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2006-03-29 17:14:10 Re: Issue on Varchar Ordering
Previous Message Jonah H. Harris 2006-03-29 16:45:43 Re: Issue on Varchar Ordering