Bug #79461 [Opn->Fbk]: Incorrect number returned for NUMERIC type field in php 7.3

From: Date: Thu, 09 Apr 2020 07:01:16 +0000
Subject: Bug #79461 [Opn->Fbk]: Incorrect number returned for NUMERIC type field in php 7.3
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-226500@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=79461&edit=1 ID: 79461 Updated by: cmb@php.net Reported by: michaelobe at mjws dot net Summary: Incorrect number returned for NUMERIC type field in php 7.3 -Status: Open +Status: Feedback Type: Bug Package: PDO Firebird Operating System: FreeBSD 12.1 PHP Version: 7.3.16 -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: 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? Previous Comments: ------------------------------------------------------------------------ [2020-04-09 02:17:03] 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-08 23:11:46] 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! ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=79461&edit=1

« previous php.bugs (#226500) next »