pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bruce Momjian <bruce@momjian.us>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Patryk Kordylewski <pk@fooby.de>
Cc: pgsql-bugs@postgresql.org
Subject: Re: Inconsistency between TO_CHAR() and TO_NUMBER()
Date: Thu, 16 May 2013 20:23:02 -0400
Message-ID: <20130517002302.GE16506@momjian.us> (raw)
In-Reply-To: <8415.1368200958@sss.pgh.pa.us>
References: <51878292.6080003@fooby.de>
	<14272.1367850378@sss.pgh.pa.us>
	<5187C2FE.9000305@fooby.de>
	<8415.1368200958@sss.pgh.pa.us>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

On Fri, May 10, 2013 at 11:49:18AM -0400, Tom Lane wrote:
> Patryk Kordylewski <pk@fooby.de> 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  <bruce@momjian.us>        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



view thread (10+ messages)

Message-ID: <20130517002302.GE16506@momjian.us>
Permalink:  ../20130517002302.GE16506@momjian.us/
Also on:    postgresql.org/message-id/20130517002302.GE16506@momjian.us

 · 

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: bruce@momjian.us, tgl@sss.pgh.pa.us, pk@fooby.de
  Subject: Re: Inconsistency between TO_CHAR() and TO_NUMBER()
  In-Reply-To: <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> <20130517002302.GE16506@momjian.us>

* 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