Re: How to find correct locale name for CREATEDATABASE

From: Alban Hertroys <dalroi(at)solfertje(dot)student(dot)utwente(dot)nl>
To: "Andrus" <kobruleht2(at)hot(dot)ee>
Cc: "Craig Ringer" <craig(at)postnewspapers(dot)com(dot)au>, "Peter Eisentraut" <peter_e(at)gmx(dot)net>, "Thom Brown" <thom(at)linux(dot)com>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: How to find correct locale name for CREATEDATABASE
Date: 2010-12-02 18:30:35
Message-ID: 151C5617-573A-4CA2-93AE-F11C890C39DC@solfertje.student.utwente.nl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 2 Dec 2010, at 18:53, Andrus wrote:

>> However, if the locale that your database needs isn't available, what did you intend to do about that? You can't just pick a different one, it probably wouldn't behave the same. Apparently you can't just use the default locales either, or you wouldn't be asking about this.
>
> I'm trying to create portable application which can automatically create database using estonian locale in any server.
> Postgres returns different values for same locale:
>
> In Fedora et_EE.UTF8
> Other linuxes et_EE.UTF-8

These are the same locales, just a differently named encoding.

> In Windows Estonian_Estonia.1257
> In some other Linuxes something like Estonian.Estonia

What do you need the locale for in your case? Collation? Monetary values? Numeric representation?
Or just for encoding - which isn't part of the locale AFAIK?

> For this reason I'm looking for a way to probe server for locale existence.

I'm thinking you may be able to use your clients settings to determine the right locale from the database's session variables. You can, for example, "set lc_ctype to 'et_EE';" and verify that you get the same locale back. Or you could perform a simple test-query that should return a row encoded in the encoding you need and verify that it matches what you expect.

I can't say for certain that this will work, my database is in C locale, and besides, I don't think my OS supports collation. You can just try it out and see what you get on different systems.

Alban Hertroys

--
If you can't see the forest for the trees,
cut the trees and you'll see there is no forest.

!DSPAM:737,4cf7e5ea802651502012066!

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message mabra 2010-12-02 18:32:23 Re: Looking for auto starting procedures
Previous Message Andrus 2010-12-02 17:53:58 Re: How to find correct locale name for CREATEDATABASE