pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Jeff Davis <pgsql@j-davis.com>
Cc: pgsql-bugs@postgresql.org
Subject: Re: check_locale() and the empty string
Date: Sat, 24 Mar 2012 19:07:20 -0400
Message-ID: <2306.1332630440@sss.pgh.pa.us> (raw)
In-Reply-To: <1331490004.6425.20.camel@jdavis>
References: <1331490004.6425.20.camel@jdavis>

Jeff Davis <pgsql@j-davis.com> writes:
> The following SQL succeeds:
>   create database foodb with
>     template = template0
>     encoding = 'UTF8'
>     lc_collate=''
>     lc_ctype='';

Sure.

> Surely we don't want it to be set from the environment, right?

Why not?  We have always done that, and in fact the various lc_xxx GUC
variables are documented thusly:

	If this variable is set to the empty string (which is the
	default) then the value is inherited from the execution
	environment of the server in a system-dependent way. 

The "trivial patch" you propose breaks that behavior.

I do agree that it's probably unwise to store an empty string as the
value of pg_database.datcollate or datctype, because that would mean
that if the server is restarted with different LC_XXX environment values
then it will think the database has different locale settings, leading
to havoc.  However, ISTM the right fix is to replace an empty-string
value with the implied locale name at createdb time.  Proposed patch
attached.

Note 1: there's no need to change the behavior for the locale GUCs,
since we don't have any assumptions that those hold still over server
restarts.

Note 2: there is code in initdb that is supposed to be kept parallel
to this, but it's not currently making any attempt to canonicalize
non-empty locale names.  Should we make it do that too?

			regards, tom lane

view thread (5+ messages)  latest in thread

Message-ID: <2306.1332630440@sss.pgh.pa.us>
Permalink:  ../2306.1332630440@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/2306.1332630440@sss.pgh.pa.us

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, pgsql@j-davis.com
  Subject: Re: check_locale() and the empty string
  In-Reply-To: <2306.1332630440@sss.pgh.pa.us>
  References: <1331490004.6425.20.camel@jdavis> <2306.1332630440@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox