php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79461 Incorrect number returned for NUMERIC type field in php 7.3
Submitted: 2020-04-08 23:11 UTC Modified: 2020-04-19 04:22 UTC
From: michaelobe at mjws dot net Assigned: cmb (profile)
Status: No Feedback Package: PDO Firebird
PHP Version: 7.3.16 OS: FreeBSD 12.1
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: michaelobe at mjws dot net
New email:
PHP Version: OS:

 

 [2020-04-08 23:11 UTC] michaelobe at mjws dot net
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!


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-04-09 02:17 UTC] michaelobe at mjws dot net
This bug does not appear to be present in php 7.4.4.
I plan on switching to php 7.4 but it would be nice if both PDO firebird and ibase_* were working for me in 7.3 so I could transition.
I totally understand if this cannot be backported for some reason.
 [2020-04-09 07:01 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2020-04-09 07:01 UTC] cmb@php.net
I cannot reproduce the reported behavior with a Firebird 3.0.4
database on Windows using PHP 7.3.  Can you please provide a fully
self-contained minimal reproduce script?
 [2020-04-19 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 19:01:29 2024 UTC