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

On Sat, 2012-03-24 at 19:07 -0400, Tom Lane wrote:
> Jeff Davis <pgsql@j-davis.com> writes:
> > Surely we don't want it to be set from the environment, right?
> 
> Why not?

I agree that we shouldn't change the documented behavior of those GUCs.

But a SQL command like CREATE DATABASE being environment sensitive does
seem like surprising behavior to me, and it did indirectly
lead to a bug.

> 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.

Yes, that's the worst of the problem. I should have mentioned that more
explicitly in the original report.

> However, ISTM the right fix is to replace an empty-string
> value with the implied locale name at createdb time.  Proposed patch
> attached.

+1.

> 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?

I assume you are talking about the code that results in writing the
settings to postgresql.conf?

It doesn't look quite as dangerous in that area because (a) it ignores
zero-length strings; and (b) setting the GUC to the wrong value will
either be prevented or will not cause any major problem. However, it
does seem like a good idea to canonicalize the settings unless there is
some reason not to.

Regards,
	Jeff Davis




view thread (5+ messages)  latest in thread

Message-ID: <1332704612.8251.11.camel@jdavis>
Permalink:  ../1332704612.8251.11.camel@jdavis/
Also on:    postgresql.org/message-id/1332704612.8251.11.camel@jdavis

 · 

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: pgsql@j-davis.com, tgl@sss.pgh.pa.us
  Subject: Re: check_locale() and the empty string
  In-Reply-To: <1332704612.8251.11.camel@jdavis>
  References: <1331490004.6425.20.camel@jdavis> <2306.1332630440@sss.pgh.pa.us> <1332704612.8251.11.camel@jdavis>

* 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