Thread: Default locale in postgres

Default locale in postgres

From
Debraj Manna
Date:
Hi

Can someone let me know if I am not passing any locale while doing initdb what locale (Collate & Ctype) will postgres 9.5.4 pick?






Re: Default locale in postgres

From
Tom Lane
Date:
Debraj Manna <subharaj.manna@gmail.com> writes:
> Can someone let me know if I am not passing any locale while doing initdb
> what locale (Collate & Ctype) will postgres 9.5.4 pick?

Whatever is the prevailing default in initdb's environment ---
see LANG and LC_XXX environment variables.

If none of those are set, I imagine it'll fall back to C locale,
though this choice is possibly dependent on your local libc.
"man locale" might be informative.

            regards, tom lane


Re: Default locale in postgres

From
Debraj Manna
Date:
Thanks Tom for replying.


support@vrni-platform-release:~$ locale
LANG=en_US.UTF-8
LANGUAGE=
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=

My locale settings are like above. But I am seeing is C picked by postgres. Any idea why it is picking C instead of en_US.UTF-8. I am on Ubuntu 14 and postgres 9.5.4. In initdb I am just passing encoding as UTF-8 and data checksum as enabled.

support@vrni-platform-release:~$ psql -l -U postgres -h localhost
                             List of databases
   Name    |  Owner   | Encoding | Collate | Ctype |   Access privileges
-----------+----------+----------+---------+-------+-----------------------
 postgres  | postgres | UTF8     | C       | C     |
 template0 | postgres | UTF8     | C       | C     | =c/postgres          +
           |          |          |         |       | postgres=CTc/postgres
 template1 | postgres | UTF8     | C       | C     | =c/postgres          +
           |          |          |         |       | postgres=CTc/postgres
 vnera     | postgres | UTF8     | C       | C     |
(4 rows)

On Fri, Jul 13, 2018 at 11:56 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Debraj Manna <subharaj.manna@gmail.com> writes:
> Can someone let me know if I am not passing any locale while doing initdb
> what locale (Collate & Ctype) will postgres 9.5.4 pick?

Whatever is the prevailing default in initdb's environment ---
see LANG and LC_XXX environment variables.

If none of those are set, I imagine it'll fall back to C locale,
though this choice is possibly dependent on your local libc.
"man locale" might be informative.

                        regards, tom lane

Re: Default locale in postgres

From
Tom Lane
Date:
Debraj Manna <subharaj.manna@gmail.com> writes:
> Thanks Tom for replying.
> support@vrni-platform-release:~$ locale
> LANG=en_US.UTF-8

OK, so that's what you have in your interactive shell environment ...

> My locale settings are like above. But I am seeing is C picked by postgres.
> Any idea why it is picking C instead of en_US.UTF-8.

Presumably, initdb is not seeing that same environment.  Might be a side
effect of running it under sudo or some wrapper script.

            regards, tom lane


Re: Default locale in postgres

From
Debraj Manna
Date:
Is it possible to specify the default locale in postgres.conf in postgres 10 so that it takes this locale if no locale is specified in initdb?

On Sat, Jul 14, 2018 at 2:27 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Debraj Manna <subharaj.manna@gmail.com> writes:
> Thanks Tom for replying.
> support@vrni-platform-release:~$ locale
> LANG=en_US.UTF-8

OK, so that's what you have in your interactive shell environment ...

> My locale settings are like above. But I am seeing is C picked by postgres.
> Any idea why it is picking C instead of en_US.UTF-8.

Presumably, initdb is not seeing that same environment.  Might be a side
effect of running it under sudo or some wrapper script.

                        regards, tom lane

Re: Default locale in postgres

From
"David G. Johnston"
Date:
On Friday, July 13, 2018, Debraj Manna <subharaj.manna@gmail.com> wrote:
Is it possible to specify the default locale in postgres.conf in postgres 10 so that it takes this locale if no locale is specified in initdb?

No, postgres.conf doesn't exist until initdb is run.

David J.