pg.ddx.io pgsql-admin@postgresql.org mailing list archive
help / color / mirror / Atom feedRES: Issue on Varchar Ordering
6+ messages / 4 participants
[nested] [flat]
* RES: Issue on Varchar Ordering
@ 2006-08-17 13:41 Erika Terahata Torres Prada e Silva - MPS <erika.prada@previdencia.gov.br>
0 siblings, 3 replies; 6+ messages in thread
From: Erika Terahata Torres Prada e Silva - MPS @ 2006-08-17 13:41 UTC (permalink / raw)
To: pgsql-admin; +Cc: Erika Terahata Torres Prada e Silva - MPS <erika.prada@previdencia.gov.br>
Peter,
Thanks for answering.
But it's not correct to my language pt_BR and it worked correctly with
PostgreSQL at Windows and FreeBSD. I have this problem only with Debian and
now I'm looking for some Debian related issue.
-----Mensagem original-----
De: Peter Eisentraut [mailto:peter_e@gmx.net]
Enviada em: quinta-feira, 17 de agosto de 2006 10:04
Para: pgsql-admin@postgresql.org
Cc: Erika Terahata Torres Prada e Silva - MPS
Assunto: Re: [ADMIN] Issue on Varchar Ordering
Erika Terahata Torres Prada e Silva - MPS wrote:
> I'm having the following issue:
>
> create table aluno (id serial, nome varchar(60));
>
> rodrigo=# select * from aluno order by nome offset 35 limit 5;
> 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 registros)
>
> The problem is that records with id 38 and 40 might come before the
> others. It seems that the spacing isn't considered on ordering.
That is, for practical purposes, correct.
May I suggest that you properly normalize your tables, by putting given
name and family name into separate columns.
--
Peter Eisentraut
http://developer.postgresql.org/~petere/
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: RES: Issue on Varchar Ordering
@ 2006-08-17 13:56 Paul B. Anderson <paul.a@pnlassociates.com>
parent: Erika Terahata Torres Prada e Silva - MPS <erika.prada@previdencia.gov.br>
2 siblings, 0 replies; 6+ messages in thread
From: Paul B. Anderson @ 2006-08-17 13:56 UTC (permalink / raw)
To: Erika Terahata Torres Prada e Silva - MPS <erika.prada@previdencia.gov.br>; +Cc: pgsql-admin
I just experienced this. I changed the collating sequence to POSIX and
sorting worked as I had expected.
To change the collating sequence you will have to backup the database,
issue initdb with the --lc-collate=POSIX and then restore the data. In
my case, the encoding is still UTF8.
Paul
Erika Terahata Torres Prada e Silva - MPS wrote:
> Peter,
>
> Thanks for answering.
>
> But it's not correct to my language pt_BR and it worked correctly with
> PostgreSQL at Windows and FreeBSD. I have this problem only with Debian and
> now I'm looking for some Debian related issue.
>
>
>
> -----Mensagem original-----
> De: Peter Eisentraut [mailto:peter_e@gmx.net]
> Enviada em: quinta-feira, 17 de agosto de 2006 10:04
> Para: pgsql-admin@postgresql.org
> Cc: Erika Terahata Torres Prada e Silva - MPS
> Assunto: Re: [ADMIN] Issue on Varchar Ordering
>
> Erika Terahata Torres Prada e Silva - MPS wrote:
>
>> I'm having the following issue:
>>
>> create table aluno (id serial, nome varchar(60));
>>
>> rodrigo=# select * from aluno order by nome offset 35 limit 5;
>> 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 registros)
>>
>> The problem is that records with id 38 and 40 might come before the
>> others. It seems that the spacing isn't considered on ordering.
>>
>
> That is, for practical purposes, correct.
>
> May I suggest that you properly normalize your tables, by putting given
> name and family name into separate columns.
>
>
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: RES: Issue on Varchar Ordering
@ 2006-08-17 14:52 Alvaro Herrera <alvherre@commandprompt.com>
parent: Erika Terahata Torres Prada e Silva - MPS <erika.prada@previdencia.gov.br>
2 siblings, 0 replies; 6+ messages in thread
From: Alvaro Herrera @ 2006-08-17 14:52 UTC (permalink / raw)
To: Erika Terahata Torres Prada e Silva - MPS <erika.prada@previdencia.gov.br>; +Cc: pgsql-admin
Erika Terahata Torres Prada e Silva - MPS wrote:
> Peter,
>
> Thanks for answering.
>
> But it's not correct to my language pt_BR and it worked correctly with
> PostgreSQL at Windows and FreeBSD. I have this problem only with Debian and
> now I'm looking for some Debian related issue.
It's still correct -- it's the ordering you'll find on the telephone
guide. It works the same for portuguese and for spanish and a lot
others. The problem with going to C locale (POSIX), as suggested in a
related follow-up, is that it sorts by byte value, which is not at all
correct when you start sorting stuff that contains funny letters
(accented vowels, etc). It works for english people just because they
don't worry about accents at all. I wonder if portuguese has special
sorting rules for "nh", for example? You'll lose that if you just
change to the C locale.
I think you _can_ define a collation on which spaces are significant,
but it's also a significant amount of work. (And IMHO not at all worth
the trouble.)
--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: RES: Issue on Varchar Ordering
@ 2006-08-17 16:15 Peter Eisentraut <peter_e@gmx.net>
parent: Erika Terahata Torres Prada e Silva - MPS <erika.prada@previdencia.gov.br>
2 siblings, 0 replies; 6+ messages in thread
From: Peter Eisentraut @ 2006-08-17 16:15 UTC (permalink / raw)
To: pgsql-admin; +Cc: Erika Terahata Torres Prada e Silva - MPS <erika.prada@previdencia.gov.br>
Erika Terahata Torres Prada e Silva - MPS wrote:
> But it's not correct to my language pt_BR and it worked correctly
> with PostgreSQL at Windows and FreeBSD. I have this problem only with
> Debian and now I'm looking for some Debian related issue.
String ordering is determined by national and international standards.
In your case, glibc seems to think that ISO 14651 applies. If you
think differently, complain to glibc, or work on changing the standard,
or define your own locale. I wouldn't know why Windows and FreeBSD
operate differently (I have some idea, but I won't spread rumours).
But unless they have a more substantial reason than "We thought this
looks reasonable", I'd rather go with the public standard.
For that matter, you have not told what you consider the "correct"
ordering in your example, nor have you proposed a computation rule to
get there. But in the overall scheme of things, first normal form will
cooperate better with established sorting rules (for any data type),
and vice versa.
--
Peter Eisentraut
http://developer.postgresql.org/~petere/
^ permalink raw reply [nested|flat] 6+ messages in thread
* RES: Issue on Varchar Ordering
@ 2006-08-18 13:34 Erika Terahata Torres Prada e Silva - MPS <erika.prada@previdencia.gov.br>
0 siblings, 1 reply; 6+ messages in thread
From: Erika Terahata Torres Prada e Silva - MPS @ 2006-08-18 13:34 UTC (permalink / raw)
To: pgsql-admin
OS Debian 3.1
Show lc_collate:
"pt_BR.ISO-8859-1"
It returns:
GABRIELA HELEDA DE SOUZA
GABRIELA JACOBY NOS
GABRIEL ALCIDES KLIM PERONDI
GABRIELA LETICIA BATISTA NUNES
GABRIEL ALEXANDRE DA SILVA MANICA
The correct would be:
GABRIEL ALCIDES KLIM PERONDI
GABRIEL ALEXANDRE DA SILVA MANICA
GABRIELA HELEDA DE SOUZA
GABRIELA JACOBY NOS
GABRIELA LETICIA BATISTA NUNES
As I told you, with OS Windows, it works correctly...
Erika Terahata T. P. e Silva
-----Mensagem original-----
De: Peter Eisentraut [mailto:peter_e@gmx.net]
Enviada em: sexta-feira, 18 de agosto de 2006 02:58
Para: pgsql-admin@postgresql.org
Cc: Alvaro Herrera; Erika Terahata Torres Prada e Silva - MPS
Assunto: Re: RES: RES: [ADMIN] Issue on Varchar Ordering
Alvaro Herrera wrote:
> LC_COLLATE=pt_PT sort << EOF
> GABRIEL ALEXANDRE DA SILVA MANICA
> GABRIELA JACOBY NOS
> GABRIELA HELEDA DE SOUZA
> GABRIELA LETICIA BATISTA NUNES
> GABRIEL ALCIDES KLIM PERONDI
> EOF
>
> On my system it outputs the order you show above, which shows that my
> locale is correctly defined per your expectations.
That is absolutely wild. This will indeed return a space-sensitive sort
under pt_BR, but not under, say, de_DE. So there is order in this
world! (heh)
This is on Debian, so the original poster has some configuration or
version difference. Please tell OS version, and the output of "SHOW
lc_collate".
--
Peter Eisentraut
http://developer.postgresql.org/~petere/
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: RES: Issue on Varchar Ordering
@ 2006-08-18 13:54 Alvaro Herrera <alvherre@commandprompt.com>
parent: Erika Terahata Torres Prada e Silva - MPS <erika.prada@previdencia.gov.br>
0 siblings, 0 replies; 6+ messages in thread
From: Alvaro Herrera @ 2006-08-18 13:54 UTC (permalink / raw)
To: Erika Terahata Torres Prada e Silva - MPS <erika.prada@previdencia.gov.br>; +Cc: pgsql-admin
Erika Terahata Torres Prada e Silva - MPS wrote:
> OS Debian 3.1
>
> Show lc_collate:
>
> "pt_BR.ISO-8859-1"
>
> It returns:
> GABRIELA HELEDA DE SOUZA
> GABRIELA JACOBY NOS
> GABRIEL ALCIDES KLIM PERONDI
> GABRIELA LETICIA BATISTA NUNES
> GABRIEL ALEXANDRE DA SILVA MANICA
>
> The correct would be:
>
> GABRIEL ALCIDES KLIM PERONDI
> GABRIEL ALEXANDRE DA SILVA MANICA
> GABRIELA HELEDA DE SOUZA
> GABRIELA JACOBY NOS
> GABRIELA LETICIA BATISTA NUNES
>
> As I told you, with OS Windows, it works correctly...
Strange. I'm using Debian unstable here and it works fine, i.e., just
as you expect. This sounds like a glibc bug to me; one corrected after
3.1. (Is that Sarge? I don't know the version numbers.)
What version of the libc6 package do you have installed? I have 2.3.6-18 here.
$ LC_MESSAGES=C dpkg -l libc6
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Installed/Config-files/Unpacked/Failed-config/Half-installed
|/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err: uppercase=bad)
||/ Name Version Description
+++-=======================-=======================-==============================================================
ii libc6 2.3.6-18 GNU C Library: Shared libraries
--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support
^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2006-08-18 13:54 UTC | newest]
Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-08-17 13:41 RES: Issue on Varchar Ordering Erika Terahata Torres Prada e Silva - MPS <erika.prada@previdencia.gov.br>
2006-08-17 13:56 ` Paul B. Anderson <paul.a@pnlassociates.com>
2006-08-17 14:52 ` Alvaro Herrera <alvherre@commandprompt.com>
2006-08-17 16:15 ` Peter Eisentraut <peter_e@gmx.net>
2006-08-18 13:34 RES: Issue on Varchar Ordering Erika Terahata Torres Prada e Silva - MPS <erika.prada@previdencia.gov.br>
2006-08-18 13:54 ` Alvaro Herrera <alvherre@commandprompt.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox