pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Erik Rijkers <er@xs4all.nl>
To: pgsql-bugs@postgresql.org
Subject: to_number nl_NL.utf8
Date: Fri, 27 Dec 2013 23:14:17 +0100
Message-ID: <4da5ec27260a33ce8b9ec8b031e6e4c1.squirrel@webmail.xs4all.nl> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

Dutch locale uses a , as thousand separator, and . as decimal separator.

So to_number( '1.234,55'  ,  '999G999D99')
should return 1234.55

but:

set session lc_numeric to 'nl_NL.utf8';
select
      current_setting('server_version_num') server_num
    , current_setting('lc_numeric') lc_numeric
    , amt
    , to_number(amt, '999G999D99')

from (values
       ('1.234,55')
    ,  ('100,00')
)
    as f(amt)

 server_num | lc_numeric |   amt    | to_number
------------+------------+----------+-----------
 90400      | nl_NL.utf8 | 1.234,55 |    124.55
 90400      | nl_NL.utf8 | 100,00   |     10000
(2 rows)

It easy to work around:  translate( '1.234,55' , ',.', '.' )::numeric ,
but it'd be nice if it could be fixed.

FWIW, behaviour of some older versions:

$ ./lc_numeric_bug.sh
 server_num | lc_numeric |   amt    | to_number
------------+------------+----------+-----------
 90400      | nl_NL.utf8 | 1.234,55 |    124.55
 90400      | nl_NL.utf8 | 100,00   |     10000
(2 rows)

 server_num | lc_numeric |   amt    | to_number
------------+------------+----------+-----------
 90302      | nl_NL.utf8 | 1.234,55 |    124.55
 90302      | nl_NL.utf8 | 100,00   |     10000
(2 rows)

 server_num | lc_numeric |   amt    | to_number
------------+------------+----------+-----------
 90206      | nl_NL.utf8 | 1.234,55 |      1.24
 90206      | nl_NL.utf8 | 100,00   |     10000
(2 rows)


Thanks,

Erik Rijkers





-- 
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 (3+ messages)  latest in thread

Message-ID: <4da5ec27260a33ce8b9ec8b031e6e4c1.squirrel@webmail.xs4all.nl>
Permalink:  ../4da5ec27260a33ce8b9ec8b031e6e4c1.squirrel@webmail.xs4all.nl/
Also on:    postgresql.org/message-id/4da5ec27260a33ce8b9ec8b031e6e4c1.squirrel@webmail.xs4all.nl

 · 

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: er@xs4all.nl
  Subject: Re: to_number nl_NL.utf8
  In-Reply-To: <4da5ec27260a33ce8b9ec8b031e6e4c1.squirrel@webmail.xs4all.nl>
  References: <4da5ec27260a33ce8b9ec8b031e6e4c1.squirrel@webmail.xs4all.nl>

* 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