Re: check_locale() and the empty string

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Jeff Davis <pgsql(at)j-davis(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: check_locale() and the empty string
Date: 2012-03-24 23:07:20
Message-ID: 2306.1332630440@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Jeff Davis <pgsql(at)j-davis(dot)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

Attachment Content-Type Size
lock-down-db-locales.patch text/x-patch 6.2 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Jeff Davis 2012-03-25 19:43:32 Re: check_locale() and the empty string
Previous Message Tom Lane 2012-03-24 16:35:11 Re: Subquery with toplevel reference used to work in pg 8.4