From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: michael.aiello@asg.com
Subject: BUG #15091: to_number() returns incorrect value
Date: Mon, 26 Feb 2018 13:55:41 +0000
Message-ID: <151965334143.21242.9862077287740270901@wrigleys.postgresql.org> (raw)
The following bug has been logged on the website:
Bug reference: 15091
Logged by: Michael Aiello
Email address: michael.aiello@asg.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
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: noreply@postgresql.org, michael.aiello@asg.com
Subject: Re: BUG #15091: to_number() returns incorrect value
In-Reply-To: <151965334143.21242.9862077287740270901@wrigleys.postgresql.org>
References: <151965334143.21242.9862077287740270901@wrigleys.postgresql.org>
* 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