select to_number('1,000', '999,999');

David Schweikert <dws@ee.ethz.ch>

From: David Schweikert <dws@ee.ethz.ch>
To: pgsql-bugs@postgresql.org
Date: 2004-11-19T12:20:34Z
Lists: pgsql-bugs
============================================================================
                        POSTGRESQL BUG REPORT TEMPLATE
============================================================================


Your name		: David Schweikert
Your email address	: dws@ee.ethz.ch


System Configuration
---------------------
  Architecture (example: Intel Pentium)  	: Intel Pentium 4

  Operating System (example: Linux 2.4.18) 	: 2.4.25

  PostgreSQL version (example: PostgreSQL-7.4.6): PostgreSQL-7.4.6

  Compiler used (example:  gcc 2.95.2)		: gcc 3.3.3


Please enter a FULL description of your problem:
------------------------------------------------

select to_number('1,000', '999,999') returns '100'.



Please describe a way to repeat the problem.   Please try to provide a
concise reproducible example, if at all possible: 
----------------------------------------------------------------------

Proposed addition to the regression tests:

--- src/test/regress/sql/numeric.sql.orig	2000-04-07 21:17:50.000000000 +0200
+++ src/test/regress/sql/numeric.sql	2004-11-19 12:51:57.071152000 +0100
@@ -701,3 +701,4 @@
 SELECT '' AS to_number_11, to_number('.-01', 'S99.99');
 SELECT '' AS to_number_12, to_number('.01-', '99.99S');
 SELECT '' AS to_number_13, to_number(' . 0 1 -', ' 9 9 . 9 9 S');
+SELECT '' AS to_number_14, to_number(to_char('1000'::int, '999G999'),'999G999');

--- src/test/regress/expected/numeric.out.orig	2003-09-25 08:58:06.000000000 +0200
+++ src/test/regress/expected/numeric.out	2004-11-19 12:56:13.464401000 +0100
@@ -1112,3 +1112,9 @@
               |     -0.01
 (1 row)
 
+SELECT '' AS to_number_14, to_number(to_char('1000'::int, '999G999'),'999G999');
+ to_number_14 | to_number 
+--------------+-----------
+              |      1000
+(1 row)
+


If you know how this problem might be fixed, list the solution below:
---------------------------------------------------------------------