Bug #79461 [NEW]: Incorrect number returned for NUMERIC type field in php 7.3
| From: | michaelobe at mjws dot net | Date: | Wed, 08 Apr 2020 23:11:46 +0000 |
| Subject: | Bug #79461 [NEW]: Incorrect number returned for NUMERIC type field in php 7.3 | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-226496@lists.php.net to get a copy of this message | ||
From: michaelobe at mjws dot net
Operating system: FreeBSD 12.1
PHP version: 7.3.16
Package: PDO Firebird
Bug Type: Bug
Bug description:Incorrect number returned for NUMERIC type field in php 7.3
Description:
------------
I am attempting to change from the built in Firebird ibase_ functions to
PDO Firebird.
The Firebird version I am using is 2.5. php is 7.3.
Without modifying a query between both drivers, I got a totally
different number back.
The query is simple:
select
INVC_NUMBER,
invc_header.total_price
from
invc_header where invc_number = 'invc1';
The number in this case should be 3330.0000 and this works in ibase_.
But the number I get back is using PDO is 3459935.8848. It is obviously
quite different. When I try to get another numeric that is 2664.0000 in
the database, PDO again returns 3459935.8848
When investigating further I realized that NUMERIC type fields return
the wrong number.
If I cast the field as something else it works:
select
INVC_NUMBER,
cast(invc_header.total_price as float) TOTAL_PRICE
from
invc_header where invc_number = 'invc1';
The data type for the total_price field is:
NUMERIC(15, 4) Nullable
One other weird thing: if I cast it as the same type it also returns the
correct number.
cast(invc_header.total_price as numeric(15,4)) TOTAL_PRICE
yields 3330 but
invc_header.total_price TOTAL_PRICE
yields 3460355.6864
I saw this from years ago which seems to be the same issue.
https://stackoverflow.com/questions/39245467/php-pdo-firebird-select-sum-return-wrong-result
I can confirm the issue exists for me when using the sum on the numeric
type.
Thank you!
--
Edit bug report at https://bugs.php.net/bug.php?id=79461&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=79461&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=79461&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=79461&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=79461&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=79461&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=79461&r=support
Expected behavior: https://bugs.php.net/fix.php?id=79461&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=79461&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=79461&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=79461&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=79461&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=79461&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=79461&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=79461&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=79461&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=79461&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=79461&r=mysqlcfg