to_number nl_NL.utf8

From: "Erik Rijkers" <er(at)xs4all(dot)nl>
To: pgsql-bugs(at)postgresql(dot)org
Subject: to_number nl_NL.utf8
Date: 2013-12-27 22:14:17
Message-ID: 4da5ec27260a33ce8b9ec8b031e6e4c1.squirrel@webmail.xs4all.nl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-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

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Erik Rijkers 2013-12-27 22:22:52 Re: to_number nl_NL.utf8
Previous Message Andres Freund 2013-12-27 09:49:30 Re: BUG #8680: Fix initialization of pg_clog and pg_subtrans during hot standby startup