problem with nasty latin2 sorting

Started by Anna Domachowskaabout 20 years ago4 messages
#1Anna Domachowska
anka@zjednoczenie.com

Hello,
I've got a problem with sorting polish words in postgresql 7.4.2

For example, I've got couple of polish cities in my table 'x', results
of sorting are:
(select city from x order by city asc)

Bydgoszcz
Gda�sk
I�awa
��d�
�arn�w
Malbork
Warszawa

So "�arn�w" is placed in wrong place, because it should be found after
letter "Z" ??

What's wrong? Is there any patch to fix this? Does anybody had similar
problem?
I belive that postgres was compiled with "--enable-locale", and the
right locale is set.

Anna Domachowska

#2Greg Stark
gsstark@mit.edu
In reply to: Anna Domachowska (#1)
Re: problem with nasty latin2 sorting

Anna Domachowska <anka@zjednoczenie.com> writes:

So "�arn�w" is placed in wrong place, because it should be found after letter
"Z" ??

What's wrong? Is there any patch to fix this? Does anybody had similar problem?
I belive that postgres was compiled with "--enable-locale", and the right
locale is set.

What does "show lc_collate" say?
What does \l show in psql?

what do you get on your machine if you save that same list in a file and run
"sort" on it on the commandline set (with LC_COLLATE set to the same value as
above)?

--
greg

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Anna Domachowska (#1)
Re: [HACKERS] problem with nasty latin2 sorting

Anna Domachowska <anka@zjednoczenie.com> writes:

I've got a problem with sorting polish words in postgresql 7.4.2
...
I belive that postgres was compiled with "--enable-locale", and the
right locale is set.

How sure are you of that? This sure sounds like a wrong-locale problem
to me. Try "show lc_collate" and "show server_encoding".

regards, tom lane

#4Volkan YAZICI
yazicivo@ttnet.net.tr
In reply to: Anna Domachowska (#1)
Re: problem with nasty latin2 sorting

On Dec 21 11:01, Anna Domachowska wrote:

I've got a problem with sorting polish words in postgresql 7.4.2

For example, I've got couple of polish cities in my table 'x',
results of sorting are:
(select city from x order by city asc)

Bydgoszcz
Gda?sk
I?awa
?�d?
?arn�w
Malbork
Warszawa

So "?arn�w" is placed in wrong place, because it should be found
after letter "Z" ??

What's wrong? Is there any patch to fix this? Does anybody had
similar problem?
I belive that postgres was compiled with "--enable-locale", and the
right locale is set.

Beside previous suggestions, I'm curious about your libc version too.
PostgreSQL relies on system locale while making character related
processes - like case conversion, collation and etc. Does below
command set succeed in sorting above data:

$ export LC_COLLATE=<related_locale>
$ cat >/tmp/test.out <<EOF

Bydgoszcz
Gda...
...
EOF

$ sort /tmp/test.out

If above command set doesn't succeed, this means your problem is with
libc. Otherwise, as mentioned in the previous posts, please check your
database encoding.

Regards.

--
"We are the middle children of history, raised by television to believe
that someday we'll be millionaires and movie stars and rock stars, but
we won't. And we're just learning this fact," Tyler said. "So don't
fuck with us."