Re: locale - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: locale
Date
Msg-id 200404071728.i37HSjI13944@candle.pha.pa.us
Whole thread Raw
In response to locale  (Dennis Bjorklund <db@zigo.dhs.org>)
Responses Re: locale
List pgsql-hackers
Dennis Bjorklund wrote:
> Is anyone working to make the locale support in pg better? Running initdb
> to set the locale is a bit heavy. It would be nice to at least be able to 
> set it per database.

Oops, I confused locale and multibyte.  Yes, I don't see a way to change
locale for new databases, but I don't see why we can't.

The initdb manual page says:
      initdb initializes the database cluster's  default  locale      and  character  set  encoding.  Some locale
categoriesare      fixed for the lifetime of the cluster, so it is  important      to  make  the  right  choice  when
runninginitdb.  Other      locale categories can be changed later when the server  is      started.  initdb will write
thoselocale settings into the      postgresql.conf  configuration  file  so  they   are   the      default,  but they
canbe changed by editing that file. To      set the locale that initdb uses, see  the  description  of      the
--localeoption. The character set encoding can be set      separately for each database as  it  is  created.   initdb
  determines  the encoding for the template1 database, which      will serve as the default  for  all  other
databases. To      alter the default encoding use the --encoding option.
 

and
      --locale=locale             Sets  the  default locale for the database cluster.             If this option is
not specified,  the  locale  is             inherited from the environment that initdb runs in.
 
      --lc-collate=locale
      --lc-ctype=locale
      --lc-messages=locale
      --lc-monetary=locale
      --lc-numeric=locale
      --lc-time=locale             Like --locale, but only  sets  the  locale  in  the             specified category.

My only guess is that you can use ALTER DATABASE SET to set some of the
values when someone connects to the database.

Looking at guc.c I see:
   {       {"lc_collate", PGC_INTERNAL, CLIENT_CONN_LOCALE,           gettext_noop("Shows the collation order
locale."),          NULL,           GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE       },       &locale_collate,       "C",
NULL,NULL   },
 
   {       {"lc_ctype", PGC_INTERNAL, CLIENT_CONN_LOCALE,           gettext_noop("Shows the character classification
andcase conversion locale."),           NULL,           GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE       },
&locale_ctype,      "C", NULL, NULL   },
 
   {       {"lc_messages", PGC_SUSET, CLIENT_CONN_LOCALE,           gettext_noop("Sets the language in which messages
aredisplayed."),           NULL       },       &locale_messages,       "", locale_messages_assign, NULL   },
 
   {       {"lc_monetary", PGC_USERSET, CLIENT_CONN_LOCALE,           gettext_noop("Sets the locale for formatting
monetaryamounts."),           NULL       },       &locale_monetary,       "C", locale_monetary_assign, NULL   },
 
   {       {"lc_numeric", PGC_USERSET, CLIENT_CONN_LOCALE,           gettext_noop("Sets the locale for formatting
numbers."),          NULL       },       &locale_numeric,       "C", locale_numeric_assign, NULL   },
 
   {       {"lc_time", PGC_USERSET, CLIENT_CONN_LOCALE,           gettext_noop("Sets the locale for formatting date and
timevalues."),           NULL       },       &locale_time,       "C", locale_time_assign, NULL   },
 


You can't change the internal ones, but you can modify some of the others.

Anyone know why we don't allow locale to be set per database?

--  Bruce Momjian                        |  http://candle.pha.pa.us pgman@candle.pha.pa.us               |  (610)
359-1001+  If your life is a hard drive,     |  13 Roberts Road +  Christ can be your backup.        |  Newtown Square,
Pennsylvania19073
 


pgsql-hackers by date:

Previous
From: Jan Wieck
Date:
Subject: Re: [GENERAL] Evening in NYC
Next
From: Peter Eisentraut
Date:
Subject: Re: locale