Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id EA117673D6B for ; Sun, 25 Mar 2012 16:43:45 -0300 (ADT) Received: from mail-iy0-f174.google.com ([209.85.210.174]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SBtLs-000232-7O for pgsql-bugs@postgresql.org; Sun, 25 Mar 2012 19:43:45 +0000 Received: by iagz16 with SMTP id z16so7218914iag.19 for ; Sun, 25 Mar 2012 12:43:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:subject:from:to:cc:date:in-reply-to:references :content-type:x-mailer:content-transfer-encoding:mime-version :x-gm-message-state; bh=716ADxShGkVsPXorlnXXUl6t6PZByFP83PJJbqGcy7Y=; b=bCKF54Zk801CpCuUHCV+1Lf0fSUBPb7hf6fBV8B3P484n8rNcg/YEXpFVAyaNPLKz3 qqupf++iN2VPqvazXBPNNeBy65AAts+L+I/FQgkcDqxE/X+2F312v4BaO7gLLZzyH7ft Se64JYzmX30AtRqCkBI36noWJBZK/0i7pRTJ90shqT+jYBmlAJ5f8DdqEz78iQ0KrAZ0 aSAZuF+1bNaQklhIrg5cIapr0NNLRyMS61OxEBkglogeVIXN4OZc2oN18042TG/yrRf1 0BoRDXowtPe6YjaOPbkgnBTb50R4wb/42amgyvDydNJJP6InziFym0kW5O8XRaAP0gcY ozqA== Received: by 10.68.72.9 with SMTP id z9mr47821570pbu.124.1332704611078; Sun, 25 Mar 2012 12:43:31 -0700 (PDT) Received: from [192.168.1.102] (c-69-181-249-16.hsd1.ca.comcast.net. [69.181.249.16]) by mx.google.com with ESMTPS id f10sm10759862pbt.75.2012.03.25.12.43.28 (version=SSLv3 cipher=OTHER); Sun, 25 Mar 2012 12:43:29 -0700 (PDT) Message-ID: <1332704612.8251.11.camel@jdavis> Subject: Re: check_locale() and the empty string From: Jeff Davis To: Tom Lane Cc: pgsql-bugs@postgresql.org Date: Sun, 25 Mar 2012 12:43:32 -0700 In-Reply-To: <2306.1332630440@sss.pgh.pa.us> References: <1331490004.6425.20.camel@jdavis> <2306.1332630440@sss.pgh.pa.us> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.2.2- Content-Transfer-Encoding: 7bit Mime-Version: 1.0 X-Gm-Message-State: ALoCoQkmksbmzoa70oEetWkshpusunvcvJQ6PXLBjbMDWbuTp3cQP/Q0W8xTPPA7axRuPeYAN16k X-Pg-Spam-Score: -2.6 (--) X-Archive-Number: 201203/173 X-Sequence-Number: 32734 On Sat, 2012-03-24 at 19:07 -0400, Tom Lane wrote: > Jeff Davis 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