Thread: Overriding local encoding defaults
I am trying to create a Pg 8.4 cluster with UTF8 encoding for JDBC access. But initdb insists that because my local console is en_US, it cannot do that. We're talking about setting up a server here. Why should it even care what the local console settings are? initdb and pg_ctl are the only commands that will ever be run through that console. Is there any way to force initdb to ignore the local environment and use UTF8? If not, how do I modify the local console to match the UTF8 requirement? This is on Slackware/64 13.1.0. Thank you, Bob McConnell
On Sunday 17. October 2010 15.03.52 Bob McConnell wrote: > I am trying to create a Pg 8.4 cluster with UTF8 encoding for JDBC > access. But initdb insists that because my local console is en_US, it > cannot do that. We're talking about setting up a server here. Why should > it even care what the local console settings are? initdb and pg_ctl are > the only commands that will ever be run through that console. > > Is there any way to force initdb to ignore the local environment and use > UTF8? > > If not, how do I modify the local console to match the UTF8 requirement? > This is on Slackware/64 13.1.0. Don't know Slackware, but in Gentoo I've got a file /etc/env.d/02locale which just says: LC_ALL="nb_NO.UTF-8" You should probably also set up your locales in the /etc/locale.gen and then run the command locale-gen from root. At least that's how it's done in Gentoo. Regards, Leif Biberg Kristensen
Bob McConnell <rmcconne@lightlink.com> writes: > I am trying to create a Pg 8.4 cluster with UTF8 encoding for JDBC > access. But initdb insists that because my local console is en_US, it > cannot do that. We're talking about setting up a server here. Why should > it even care what the local console settings are? You need a locale setting that's compatible with UTF8, and apparently your platform's version of "en_US" isn't. Try specifying locale en_US.utf8. (There are various ways of spelling that --- "locale -a" should give you a clue which one applies for you.) regards, tom lane
Tom Lane wrote: > Bob McConnell <rmcconne@lightlink.com> writes: >> I am trying to create a Pg 8.4 cluster with UTF8 encoding for JDBC >> access. But initdb insists that because my local console is en_US, it >> cannot do that. We're talking about setting up a server here. Why should >> it even care what the local console settings are? > > You need a locale setting that's compatible with UTF8, and apparently > your platform's version of "en_US" isn't. Try specifying locale > en_US.utf8. (There are various ways of spelling that --- "locale -a" > should give you a clue which one applies for you.) OK, this seems to work, so far. While logged in as the postgres user, I typed in: export LANG=en_US.UTF-8 Then: initdb -D /home/pgsql/data -E UTF8 built a cluster with UTF8 encoding. Just for safety, I also created ~/.profile with the same export line. So if I accidentally use pgsql via SSH, I should be safe. The 'export' syntax came from the CHANGES_AND_HINTS.TXT file for Slackware 13.1 under SCIM input methods. I still don't understand why a server process should care about the local console. Are there any plans to fix that? Thank you, Bob McConnell N2SPP
Bob McConnell <rmcconne@lightlink.com> writes: > I still don't understand why a server process should care about the > local console. Are there any plans to fix that? No, because it's not broken. Where else should initdb get the default locale setting, if not from the environment it's invoked in? regards, tom lane
Tom Lane wrote: > Bob McConnell <rmcconne@lightlink.com> writes: >> I still don't understand why a server process should care about the >> local console. Are there any plans to fix that? > > No, because it's not broken. Where else should initdb get the default > locale setting, if not from the environment it's invoked in? Something that critical should never be left to a default. It should be explicitly required in the command line and ignore all of the local settings. In this case, the local settings are irrelevant anyway. The console will never be used to access the DB on a headless server. But what I think is broken is that the command line argument is blocked by the local settings. When the command line says to use UTF-8, it should override any and all local settings. They become superfluous. Bob McConnell N2SPP
I have a similar problem. When I try to put up a cluster with encoding set to CP1250 I get an info that this is not a proper server encoding type. The initdb and pg_createcluster force me to use utf8 with pl_PL locale. Is there a way to override this as I know that CP1250 is supported by PG. The system is Ubuntu 10.04. 2010/10/18 Bob McConnell <rmcconne@lightlink.com>: > Tom Lane wrote: >> >> Bob McConnell <rmcconne@lightlink.com> writes: >>> >>> I still don't understand why a server process should care about the local >>> console. Are there any plans to fix that? >> >> No, because it's not broken. Where else should initdb get the default >> locale setting, if not from the environment it's invoked in? > > Something that critical should never be left to a default. It should be > explicitly required in the command line and ignore all of the local > settings. In this case, the local settings are irrelevant anyway. The > console will never be used to access the DB on a headless server. > > But what I think is broken is that the command line argument is blocked by > the local settings. When the command line says to use UTF-8, it should > override any and all local settings. They become superfluous. > > Bob McConnell > N2SPP > > > -- > Sent via pgsql-novice mailing list (pgsql-novice@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-novice > -- Łukasz Brodziak II MU Bioinformatyka
hi Bob, > If not, how do I modify the local console to match the UTF8 requirement? > This is on Slackware/64 13.1.0. modify the '/etc/profile.d/lang.*' files. -- regards, jr. (jr@tailorware.org.uk)
jr wrote: > hi Bob, > >> If not, how do I modify the local console to match the UTF8 >> requirement? This is on Slackware/64 13.1.0. > > modify the '/etc/profile.d/lang.*' files. > Got it. Thanks, Bob McConnell N2SPP