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

Am 06.05.2013 16:26, schrieb Tom Lane:
> Patryk Kordylewski <pk@fooby.de> writes:
>> Hi,
>> i have the following test-case:
>
>> http://psql.privatepaste.com/b3b431851a
>
> Just for the record: this is a completely unacceptable method of
> submitting a bug report.  After a month from now, when that paste has
> expired, nobody looking at the PG archives will have any way to find out
> what you were talking about.  Even without the archival consideration,
> you've added an extra step to fetch the test case for anyone reading
> your mail.
>
> Having said that, though, this does look wrong ...
>
> 			regards, tom lane

Hmpf, you're right. I'm sorry. Here is the test-case:

PostgreSQL 9.2.4 (also tested on 9.1 and 8.2)

### WORKS

SET lc_numeric TO 'en_US.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 | 123456789.123
(1 row)

### DOES NOT WORK

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)


### FORMAT STRING WITHOUT FM PREFIX AND EXACT NUMBER OF DIGITS WORKS

SELECT
   TO_CHAR(123456789.123, 'FM99G999G999G999G999G999G999D000'),
   TO_NUMBER(TO_CHAR(123456789.123, 'FM99G999G999G999G999G999G999D000'), 
'999G999G999D000');
      to_char     |   to_number
-----------------+---------------
  123.456.789,123 | 123456789.123
(1 row)

Thank you.

Best regards,
Patryk


-- 
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)  latest in thread

Message-ID: <5187C2FE.9000305@fooby.de>
Permalink:  ../5187C2FE.9000305@fooby.de/
Also on:    postgresql.org/message-id/5187C2FE.9000305@fooby.de

 · 

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: pk@fooby.de, tgl@sss.pgh.pa.us
  Subject: Re: Inconsistency between TO_CHAR() and TO_NUMBER()
  In-Reply-To: <5187C2FE.9000305@fooby.de>
  References: <51878292.6080003@fooby.de> <14272.1367850378@sss.pgh.pa.us> <5187C2FE.9000305@fooby.de>

* 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