Re: Inconsistency between TO_CHAR() and TO_NUMBER()

Поиск
Список
Период
Сортировка
От Bruce Momjian
Тема Re: Inconsistency between TO_CHAR() and TO_NUMBER()
Дата
Msg-id 20130517002302.GE16506@momjian.us
обсуждение исходный текст
Ответ на Re: Inconsistency between TO_CHAR() and TO_NUMBER()  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-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. +

В списке pgsql-bugs по дате отправления:

Предыдущее
От: Robert Haas
Дата:
Сообщение: Re: BUG #8167: false EINVAL -22 for opening a file
Следующее
От: Boszormenyi Zoltan
Дата:
Сообщение: Bugfix patches in the next CF, was: Re: pg_ctl -D "/absolute/path" -m fast restart - doesn't work in some cases