Arbitrary collation support for PostgreSQL

Started by Honza Pazdzioraalmost 22 years ago1 messages
#1Honza Pazdziora
adelton@informatics.muni.cz

Hello all,

PostgreSQL, at least until version 7.4, has rather weak support for
various collating sequences. What you get when you do

select * from table order by column

is hardcoded in the database cluster at the initdb time. Yet, it is
reasonable request to want one select to order by using English rules,
another one to run with German rules and yet another with Czech ones,
without having to dump, initdb, restore.

The distribution

http://www.fi.muni.cz/~adelton/l10n/postgresql-nls-string-0.50.tar.gz

defines a function nls_string which allows collation to be set at
runtime:

select * from table order by nls_string(name, 'en_US.UTF-8')
select * from table order by nls_string(name, 'cs_CZ.UTF-8')
select * from table order by nls_string(name, 'C')

The README and INSTALL files with more details are included in the
distribution.

I'd appreciate comments about the viability of the goal, name,
and / or solution presented.

Yours,

--
------------------------------------------------------------------------
Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
.project: Perl, mod_perl, DBI, Oracle, large Web systems, XML/XSL, ...
Only self-confident people can be simple.