RE: BUG #15091: to_number() returns incorrect value

Поиск
Список
Период
Сортировка
От Michael Aiello
Тема RE: BUG #15091: to_number() returns incorrect value
Дата
Msg-id d5944076b6b1468dba99715b33014a84@asg.com
обсуждение исходный текст
Ответ на Re: BUG #15091: to_number() returns incorrect value  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-bugs
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 Windows, but Oracle 12 doesn't seem to like the
firstcase. 

Thanks
Mike



-----Original Message-----
From: Tom Lane [mailto:tgl@sss.pgh.pa.us]
Sent: Monday, February 26, 2018 12:48 PM
To: Michael Aiello <michael.aiello@asg.com>
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #15091: to_number() returns incorrect value

=?utf-8?q?PG_Bug_reporting_form?= <noreply@postgresql.org> writes:
> When to_number is called with a string that contains a decimal point,
> but there is no decimal indicator in the format string, the decimal
> digits are appended to the integer portion, having the effect of
> 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 the "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/?dmVyPTEuMDAxJiZjYjA3ZTMxZWNmOWYwMjc2ZD01QTk0NEQ3OV84MjUwM18yMTExXzEmJmI2ODRhNGYzODlkM2EwMT0xMjIzJiZ1cmw9aHR0cCUzQSUyRiUyRnJleHRlc3RlciUyRWNvbSUyRmwlMkZvcmFjbGUlNUZvbmxpbmUlNUZjb21waWxlcg==

            regards, tom lane


В списке pgsql-bugs по дате отправления:

Предыдущее
От: Jonathan Allen
Дата:
Сообщение: RE: BUG #15080: ecpg on windows doesn't define HAVE_LONG_LONG_INT
Следующее
От: Tom Lane
Дата:
Сообщение: Re: BUG #15080: ecpg on windows doesn't define HAVE_LONG_LONG_INT