Postgresql – How to force Windows to support not supported LC_COLLATE and LC_TYPE in PostgreSQL

postgresqlwindows

I have fresh installation of PostgreSQL 9.1.x. Unfortunately, I discovered that OS doesn't support LC_COLLATE = 'pl_PL.utf8' and LC_CTYPE = 'pl_PL.utf8'. I read in PostgreSQL documentation that:

On all platforms, the collations named default, C, and POSIX are
available. Additional collations may be available depending on
operating system support.

Is a way, however to force Windows to support that locale ? I mean a patch, plugin or something.

Best Answer

On Windows, it's likely that the needed locale is already installed, it's just named differently than on Unix.

As an example, the following database creation appears to works fine for me with PG9.1 on my Windows XP, with its default locale French_France.1252 and no additional language pack installed that I'd recall.

CREATE DATABASE pldb
       ENCODING = 'UTF8'
       LC_COLLATE = 'Polish'
       LC_CTYPE = 'Polish'
       TEMPLATE=template0;

Also, a quick test of the sort order by submitting this query in UTF8 in this newly created database:

select * from (values ('z'), ('ź'), ('ż'), ('s'), ('ś'), ('x'), ('y')) as letters order by 1;

seems to output correct results:

s
ś
x
y
z
ź
ż