Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id 4459629F0D5 for ; Mon, 12 Mar 2012 13:54:55 -0300 (ADT) Received: from mail-pz0-f46.google.com ([209.85.210.46]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1S78WL-00054b-At for pgsql-bugs@postgresql.org; Mon, 12 Mar 2012 16:54:54 +0000 Received: by dajr28 with SMTP id r28so5410469daj.19 for ; Mon, 12 Mar 2012 09:54:40 -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:date:in-reply-to:references:content-type :x-mailer:mime-version:x-gm-message-state; bh=tbFTm1NVT0+w6TrsiUnYcVLsU3jcwRq4lvHMC2JNqtA=; b=fk70aW4DC61Fe8zGdRwcJP9AeFrCLhd4UnANk40Yo32xJGqzc1zPczp2tYsq/LPYzd 5upoyjUQ/HqQagyoIpZMB3g3B+vt4PmONtG1PkgQA+7ezBn6D5jZ8UtCnF1gk8Ec727S aJd4cuobjkTB7hpWEkGzOmJGtGp7oyV35a86ns6WNz6mAG6d+dhldort6p7hQNlb4Bm9 SeUtI2Be9+jEe++f0AaKRw4kJ8zc7zea65Z7Bid4EhHgJ5Mlk6TEoFZWYe2pQj9uLI1k Lxl5Y/VY3/b9rtRXyPwCrDBjQMh98ca6JZNvXtFyKtBBt/hmBEJpJ6P0BR2oNso4/Fkc nZgA== Received: by 10.68.239.195 with SMTP id vu3mr2130024pbc.49.1331571280701; Mon, 12 Mar 2012 09:54:40 -0700 (PDT) Received: from [192.168.1.103] (c-69-181-249-16.hsd1.ca.comcast.net. [69.181.249.16]) by mx.google.com with ESMTPS id q8sm10227884pbi.1.2012.03.12.09.54.39 (version=SSLv3 cipher=OTHER); Mon, 12 Mar 2012 09:54:39 -0700 (PDT) Message-ID: <1331571281.6425.47.camel@jdavis> Subject: Re: check_locale() and the empty string From: Jeff Davis To: pgsql-bugs@postgresql.org Date: Mon, 12 Mar 2012 09:54:41 -0700 In-Reply-To: <1331490004.6425.20.camel@jdavis> References: <1331490004.6425.20.camel@jdavis> Content-Type: multipart/mixed; boundary="=-CrB1U5AeGTvSOmy8Ha1p" X-Mailer: Evolution 3.2.2- Mime-Version: 1.0 X-Gm-Message-State: ALoCoQkpwkLBymtbdgw5tHzm0O9JmCz5my9qQBPa9CNmFSt778Yh5ueVgQjzg3/MVowbLyswwyfA X-Pg-Spam-Score: -2.6 (--) X-Archive-Number: 201203/93 X-Sequence-Number: 32654 --=-CrB1U5AeGTvSOmy8Ha1p Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit On Sun, 2012-03-11 at 11:20 -0700, Jeff Davis wrote: > The problem seems to be in check_locale(), which just checks for a > non-NULL return value from setlocale(). However, the manual for > setlocale() says: > > If locale is "", each part of the locale that should be modified > is set according to the environment variables. The details > are implementation-dependent. Trivial patch attached. Regards, Jeff Davis --=-CrB1U5AeGTvSOmy8Ha1p Content-Disposition: attachment; filename="check_locale.patch" Content-Type: text/x-patch; name="check_locale.patch"; charset="UTF-8" Content-Transfer-Encoding: 7bit *** a/src/backend/utils/adt/pg_locale.c --- b/src/backend/utils/adt/pg_locale.c *************** *** 229,234 **** check_locale(int category, const char *value) --- 229,241 ---- char *save; bool ret; + /* + * The empty string is not a valid locale; it causes the locale to be set + * from the environment, which is not what we want. + */ + if (strcmp(value, "") == 0) + return false; + save = setlocale(category, NULL); if (!save) return false; /* won't happen, we hope */ --=-CrB1U5AeGTvSOmy8Ha1p--