From: | Bruce Momjian <bruce(at)momjian(dot)us> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Patryk Kordylewski <pk(at)fooby(dot)de>, pgsql-bugs(at)postgresql(dot)org |
Subject: | Re: Inconsistency between TO_CHAR() and TO_NUMBER() |
Date: | 2013-05-17 00:23:02 |
Message-ID: | 20130517002302.GE16506@momjian.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
On Fri, May 10, 2013 at 11:49:18AM -0400, Tom Lane wrote:
> Patryk Kordylewski <pk(at)fooby(dot)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(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ It's impossible for everything to be true. +
From | Date | Subject | |
---|---|---|---|
Next Message | Boszormenyi Zoltan | 2013-05-17 08:57:15 | Bugfix patches in the next CF, was: Re: pg_ctl -D "/absolute/path" -m fast restart - doesn't work in some cases |
Previous Message | Robert Haas | 2013-05-17 00:12:27 | Re: BUG #8167: false EINVAL -22 for opening a file |