Postgresql – How to make a locale available in Postgresql

collationpostgresql

I needed to add new locales to our postgresql server (PostgreSQL 9.4.4 on x86_64-unknown-linux-gnu, compiled by gcc (Ubuntu 4.8.2-19ubuntu1) 4.8.2, 64-bit ).
As the locales were not yet installed on Ubuntu, I added them with

sudo locale-gen fr_FR.UTF-8

the locales do show now with

locale -a

I restarted the postgresql server, but the locales aren't visible in postgresql. I cant find themp in select * from pg_collation;

When I try to create the collation manually with create collation fr_FR (LOCALE=‘fr_FR.utf8’), I get this error

ERROR: could not create locale "‘tr_tr.utf8’": Success

Am I missing a step ?

Best Answer

It looks like a syntax problem. This statement:

create collation fr_FR (LOCALE=‘fr_FR.utf8’)

has Unicode non-ASCII quotes LEFT SINGLE QUOTATION MARK and RIGHT SINGLE QUOTATION MARK instead of the normal ASCII double-quote. These fancy quotes are not delimiters for the SQL syntax, so they get interpreted as being part of the locale's name.

Try with:

create collation fr_FR (LOCALE="fr_FR.utf8");