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 14:50:12
Message-ID: D07ADF4B-B32C-48A5-97C6-F6C8D4C09CCA@solfertje.student.utwente.nl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 2 Dec 2010, at 13:34, Andrus wrote:

>>> Because, as opposed to the developers of the projects that you're
>>> apparently familiar with, the Postgres developers have common sense ;)
>
> intidb fallbacks to en_US locale if locale specified in command line is not
> found.

Aren't you confusing different commands now? You were talking about CREATE DATABASE, but now you're suddenly saying initdb.
And if you can run initdb, you can also run locale -a

Locales are an operating system matter, just like disk space usage, user names, cpu load, etc. A database server has no responsibility to provide such information - it could even lead to security issues if it did.

Not that I'm saying that a database server _couldn't_ provide such information, it would probably be quite useful to have some "virtual tables" for available locales, logged in users, kernel tunables, etc (provided the security implications are taken care of properly, of course!). We just don't have them now, and I don't think any other database has something like this either.

>>> Seriously though, functionality like that has no place in a database
>>> server. That's the responsibility of the OS, or if it lacks in that
>>> respect, for third-party tools.
>
> Using CREATE DATABASE to determine server locale seems not reasonable since this command
> can fail for other reasons also. There is no way to know was this failing due to missing locale.
>
> What is best command to probe postgresql 9 server for locale existence ?

You're obviously leaving out some important information, for example why you insist on using the database server to determine available locales. Is that even what you're trying to do, determine available locales?

Judging from your earlier answer that only port 5432 is open it would appear that you don't have shell access to the database server. But then you're suddenly talking about initdb, for which you do need shell access. You're not making a lot of sense with the little information you gave us.

Anyway, if CREATE DATABASE fails because the locale isn't available, it says so:

postgres=> CREATE DATABASE asdf LC_CTYPE 'as_DF';
ERROR: invalid locale name as_DF

So you certainly do know why it failed.

If you indeed don't have shell access but only database access, then you're probably pretty much stuck with just trying to create the database and checking the error message.

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.

If the locale you need isn't available on the server and you don't have shell access to it, then you'll have to contact the server administrators to _make_ the locale available.
That means that either the OS doesn't have the required locale, or the database cluster was initialised with an incompatible default locale - neither of these situations can be solved by trying CREATE DATABASE with a different locale, not if the locale mattered in the first place.

Alban Hertroys

--
Screwing up is an excellent way to attach something to the ceiling.

!DSPAM:737,4cf7b25e802651003785035!

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Dimitri Fontaine 2010-12-02 16:34:28 Re: Full Text Partial Match at begining
Previous Message Samba 2010-12-02 14:03:43 Re: [REPOST] plpgsql : looping over multidimensional array : getting NULL for subdimension