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 categories are
       fixed for the lifetime of the cluster, so it is  important
       to  make  the  right  choice  when  running initdb.  Other
       locale categories can be changed later when the server  is
       started.  initdb will write those locale settings into the
       postgresql.conf  configuration  file  so  they   are   the
       default,  but they can be changed by editing that file. To
       set the locale that initdb uses, see  the  description  of
       the --locale option. 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 and case 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 are displayed."),
            NULL
        },
        &locale_messages,
        "", locale_messages_assign, NULL
    },

    {
        {"lc_monetary", PGC_USERSET, CLIENT_CONN_LOCALE,
            gettext_noop("Sets the locale for formatting monetary amounts."),
            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 time values."),
            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
  [EMAIL PROTECTED]               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Reply via email to