strange ORDER BY implementation - Mailing list pgsql-sql

From Alex Guryanow
Subject strange ORDER BY implementation
Date
Msg-id 4560.000518@nlr.ru
Whole thread Raw
List pgsql-sql
Hi,

I use Postgresql 7.0 on RedHat 6.1 . Postgres was configured with locale support and started using
the following command
   su postgres -c 'LC_CTYPE=ru_RU.cp1251; LC_COLLATE=ru_RU.cp1251; export LC_CTYPE LC_COLLATE; \
/postgress/pgsql/bin/postmaster-i -D/postgress/pgsql/data > /postgress/pm.log 2>&1 &'
 

It seems that localisation works fine (at least function lower()). I have a table bookmarks with
field label:
     CREATE TABLE bookmarks (id serial, label varchar(250));

But when I use in my SELECT-query ORDER BY clause I receive strange results - not all lines are
sorted. Here is an example (sorry, it's in russian):

SELECT id, label FROM bookmarks WHERE id=51463 OR id=50102 OR id=51466
OR id=50103 OR id=51474 ORDER BY label; id   |                              label
-------+-----------------------------------------------------------------50102 | Иванов А. А. Акушер. Д-р мед.
наук51463| Иванова А. В. Канд. мед. наук51466 | Иванова А. И. Канд. техн. наук50103 | Иванов А. А. Канд. геол.-мин.
наук(Вятская зона)51474 | Иванова Александра Михайловна Педагог-методист, канд. пед. наук
 
(5 rows)

For people that do not have russian support in the e-mail client or do not speak russian here is the
hexadecimal representation of the above lines maded by PHP3 function bin2hex:
 | 1  2  3  4  5  6  7  8  9  10 11
-------------------------------------
1 | c8 e2 e0 ed ee e2 20 c0 2e 20 c0
2 | c8 e2 e0 ed ee e2 e0 20 c0 2e 20
3 | c8 e2 e0 ed ee e2 e0 20 c0 2e 20
4 | c8 e2 e0 ed ee e2 20 c0 2e 20 c0
5 | c8 e2 e0 ed ee e2 e0 20 c0 eb e5                     ^^

The error is after 6th symbol: the line number 4 should be after 1st line and not after 3rd. Why
this happens?

Best regards,
Alex




pgsql-sql by date:

Previous
From: christine@observatoiredesmarques.fr
Date:
Subject: translate from oracle
Next
From: darcy@druid.net (D'Arcy J.M. Cain)
Date:
Subject: Re: Using substr with user defined types