Re: How to find correct locale name for CREATEDATABASE - Mailing list pgsql-general

From Alban Hertroys
Subject Re: How to find correct locale name for CREATEDATABASE
Date
Msg-id 151C5617-573A-4CA2-93AE-F11C890C39DC@solfertje.student.utwente.nl
Whole thread Raw
In response to Re: How to find correct locale name for CREATEDATABASE  ("Andrus" <kobruleht2@hot.ee>)
Responses Re: How to find correct locale name for CREATEDATABASE  ("Andrus" <kobruleht2@hot.ee>)
List 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
justpick 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
performa simple test-query that should return a row encoded in the encoding you need and verify that it matches what
youexpect. 

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!



pgsql-general by date:

Previous
From: "Andrus"
Date:
Subject: Re: How to find correct locale name for CREATEDATABASE
Next
From:
Date:
Subject: Re: Looking for auto starting procedures