Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Ud8SE-0002Zj-L2 for pgsql-bugs@arkaria.postgresql.org; Fri, 17 May 2013 00:23:26 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1Ud8SD-0006YN-HW for pgsql-bugs@arkaria.postgresql.org; Fri, 17 May 2013 00:23:25 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Ud8S0-0006O3-RW for pgsql-bugs@postgresql.org; Fri, 17 May 2013 00:23:12 +0000 Received: from momjian.us ([72.94.173.45]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Ud8Rs-0006tk-Ar for pgsql-bugs@postgresql.org; Fri, 17 May 2013 00:23:12 +0000 Received: from bruce by momjian.us with local (Exim 4.72) (envelope-from ) id 1Ud8Rq-0007Co-5f; Thu, 16 May 2013 20:23:02 -0400 Date: Thu, 16 May 2013 20:23:02 -0400 From: Bruce Momjian To: Tom Lane Cc: Patryk Kordylewski , pgsql-bugs@postgresql.org Subject: Re: Inconsistency between TO_CHAR() and TO_NUMBER() Message-ID: <20130517002302.GE16506@momjian.us> References: <51878292.6080003@fooby.de> <14272.1367850378@sss.pgh.pa.us> <5187C2FE.9000305@fooby.de> <8415.1368200958@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8415.1368200958@sss.pgh.pa.us> User-Agent: Mutt/1.5.20 (2009-06-14) X-Pg-Spam-Score: -2.5 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org On Fri, May 10, 2013 at 11:49:18AM -0400, Tom Lane wrote: > Patryk Kordylewski writes: > > SET lc_numeric TO 'de_DE.UTF-8'; > > SET > > > SELECT > > TO_CHAR(123456789.123, 'FM99G999G999G999G999G999G999D000'), > > TO_NUMBER(TO_CHAR(123456789.123, 'FM99G999G999G999G999G999G999D000'), > > 'FM99G999G999G999G999G999G999D000'); > > to_char | to_number > > -----------------+----------- > > 123.456.789,123 | 123.456 > > (1 row) > > I looked into this, and find that the reason it misbehaves is that > NUM_numpart_from_char() will treat a '.' as being a decimal point > *without any regard to locale considerations*. So even if we have > a locale-dependent format string and a locale that says '.' is a > thousands separator, it does the wrong thing. > > It's a bit surprising nobody's complained of this before. > > I propose the attached patch. I'm slightly worried though about whether > this might break any existing applications that are (incorrectly) > depending on a D format specifier being able to match '.' regardless of > locale. Perhaps we should only apply this to HEAD and not back-patch? I never trust to_char() changes for backpatching. ;-) -- Bruce Momjian http://momjian.us EnterpriseDB http://enterprisedb.com + It's impossible for everything to be true. + -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs