BUG #15091: to_number() returns incorrect value

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: michael(dot)aiello(at)asg(dot)com
Subject: BUG #15091: to_number() returns incorrect value
Date: 2018-02-26 13:55:41
Message-ID: 151965334143.21242.9862077287740270901@wrigleys.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 15091
Logged by: Michael Aiello
Email address: michael(dot)aiello(at)asg(dot)com
PostgreSQL version: 9.6.6
Operating system: Windows 10
Description:

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

by comparison, a decimal indicator in the format returns the correct
value:

SELECT to_number('123.0', 'FM99999D999');

returns 123.0

I would expect one of two behaviors when the decimal place is present in the
string to convert, but not the format, either:
a) truncate the value at the decimal point, discarding the decimal portion.
In this case, the first example above would return the integer 123, or
b) raise a number format exception.

Thanks
Mike Aiello

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2018-02-26 15:45:42 BUG #15092: pg_basebackup directory checking
Previous Message Greg Clough 2018-02-26 12:18:47 RE: BUG #15089: Complete details