Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1eqNx7-0003Vg-7s for pgsql-bugs@arkaria.postgresql.org; Mon, 26 Feb 2018 18:56:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1eqNx5-0005Gh-Or for pgsql-bugs@arkaria.postgresql.org; Mon, 26 Feb 2018 18:56:43 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1eqNh1-0007F4-LE for pgsql-bugs@lists.postgresql.org; Mon, 26 Feb 2018 18:40:07 +0000 Received: from smtp-noram01b.asg.com ([67.239.247.137] helo=SMTP-NORAM01C.ASG.COM) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1eqNgs-000503-RR for pgsql-bugs@lists.postgresql.org; Mon, 26 Feb 2018 18:40:05 +0000 Received: from SMTP-NORAM01C.ASG.COM (localhost.localdomain [127.0.0.1]) by localhost (Email Security Appliance) with SMTP id DBD123B0D84_A94547BB; Mon, 26 Feb 2018 18:39:55 +0000 (GMT) Received: from smtp-noram01.asg.com (USAPFMAIL02V.asg.com [10.5.17.23]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by SMTP-NORAM01C.ASG.COM (Sophos Email Appliance) with ESMTPS id A95793AE957_A94547BF; Mon, 26 Feb 2018 18:39:55 +0000 (GMT) Received: from USAPFMAIL01V.asg.com (10.5.17.22) by USAPFMAIL02V.asg.com (10.5.17.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1261.35; Mon, 26 Feb 2018 13:39:53 -0500 Received: from USAPFMAIL01V.asg.com ([fe80::42e:6602:ca62:522d]) by USAPFMAIL01V.asg.com ([fe80::42e:6602:ca62:522d%14]) with mapi id 15.01.1261.036; Mon, 26 Feb 2018 13:39:53 -0500 From: Michael Aiello To: Tom Lane CC: "pgsql-bugs@lists.postgresql.org" Subject: RE: BUG #15091: to_number() returns incorrect value Thread-Topic: BUG #15091: to_number() returns incorrect value Thread-Index: AQHTry0Ih+CEQfiod0GdqrWEktyW7aO3AxBw Date: Mon, 26 Feb 2018 18:39:53 +0000 Message-ID: References: <151965334143.21242.9862077287740270901@wrigleys.postgresql.org> <27576.1519667309@sss.pgh.pa.us> In-Reply-To: <27576.1519667309@sss.pgh.pa.us> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.10.160.26] x-exclaimer-md-config: 5902c074-9711-4a94-8042-bf8180fde9c1 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-SASI-RCODE: 200 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi Tom, Thanks for the quick reply. I get different results when I tried the test with Oracle (using Oracle 12.= 1 running on Linux, from a Windows client) SELECT to_number('123.0', 'FM9999999') FROM DUAL; ORA-01722: invalid number 01722. 00000 - "invalid number" SELECT to_number('123.0', 'FM9999.999') FROM DUAL; 123 SELECT to_number('123.0', 'FM9999D999') FROM DUAL; 123 I'm not seeing the locale issue, maybe because of the client running on Win= dows, but Oracle 12 doesn't seem to like the first case. Thanks Mike -----Original Message----- From: Tom Lane [mailto:tgl@sss.pgh.pa.us]=20 Sent: Monday, February 26, 2018 12:48 PM To: Michael Aiello Cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #15091: to_number() returns incorrect value =3D?utf-8?q?PG_Bug_reporting_form?=3D writes: > When to_number is called with a string that contains a decimal point,=20 > but there is no decimal indicator in the format string, the decimal=20 > digits are appended to the integer portion, having the effect of=20 > increasing the the integer value. > This can be reproduced with a simple SELECT, as follows: > SELECT to_number('123.0', 'FM9999999'); returns value 1230 [ experiments ... ] I get the same result on Oracle, so I'd say this is th= e "correct" behavior. > by comparison, a decimal indicator in the format returns the correct > value: > SELECT to_number('123.0', 'FM99999D999'); returns 123.0 On the other hand, Oracle also returns 1230 for this case :-(. But that seems to be a locale issue --- if I change the D to "." I get the expected result 123. Tested at http://TOC.ASG.COM:8080/?dmVyPTEuMDAxJiZjYjA3ZTMxZWNmOWYwMjc2ZD01QTk0NEQ3OV= 84MjUwM18yMTExXzEmJmI2ODRhNGYzODlkM2EwMT0xMjIzJiZ1cmw9aHR0cCUzQSUyRiUyRnJle= HRlc3RlciUyRWNvbSUyRmwlMkZvcmFjbGUlNUZvbmxpbmUlNUZjb21waWxlcg=3D=3D regards, tom lane