You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Incorrect NUMERIC value returned from Firebird PDO query in PHP 8.1 #9971
//$pdo already connected with no dialect specified (Defaults to 3 ?)$sql="SELECT SOME_INDEX,SOME_NUMERIC_FIELD, CAST (SOME_NUMERIC_FIELD AS VARCHAR(255)) AS SOME_NUMERIC_FIELD_STRINGFROM MYTABLE WHERE SOME_INDEX='1234' ";
$objPDOStatement=$pdo->query($sql);
foreach($objPDOStatementas$arrRow){
print_r($arrRow);
exit;
}
changed the title [-]Incorrect NUMERIC value returned from PDO query in PHP 8.1[/-][+]Incorrect NUMERIC value returned from Firebird PDO query in PHP 8.1[/+]on Nov 18, 2022
Can you please specify the exact table definition – ideally having a complete script which creates and fills the table, and then does the query, printing the resulting row via var_dump()?
Additional comment added 19/11/2022: My apologies, I neglected to mention that I had to use "dialect=1;" to get the test to work in either PHP7.4 or 8.1.12. My previous scripts in PHP7.4 were only ever doing selects.
"Metadata update statement is not allowed by the current database SQL dialect 1"
Server Version: Firebird/Windows/Intel/i386 (access method), version "WI-V2.0.1.12855 Firebird 2.0" Firebird/Windows/Intel/i386 (remote server), version "WI-V2.0.1.12855 Firebird 2.0/tcp (DBSERVERHOSTNAME)/P10" Firebird/Linux/AMD/Intel/x64 (remote interface), version "LI-V3.0.5.33220 Firebird 3.0/tcp (arm-lnx-1)/P10" on disk structure version 11.0
PHP 8.1
Server Version: Firebird/Windows/Intel/i386 (access method), version "WI-V2.0.1.12855 Firebird 2.0" Firebird/Windows/Intel/i386 (remote server), version "WI-V2.0.1.12855 Firebird 2.0/tcp (DBSERVERHOSTNAME)/P10" Firebird/Linux/AMD/Intel/x64 (remote interface), version "LI-V3.0.5.33220 Firebird 3.0/tcp (arm-lnx-1)/P10" on disk structure version 11.0
Interesting! So apparently the issue was "only" the ZEND_ASSUME(0) which caused a compiler "optimization" which lead to reading of uninitialized memory. I've just submitted a PR with a slightly simplified solution; maybe you can try that, too.
Activity
[-]Incorrect NUMERIC value returned from PDO query in PHP 8.1[/-][+]Incorrect NUMERIC value returned from Firebird PDO query in PHP 8.1[/+]cmb69 commentedon Nov 18, 2022
Hmm, there is https://github.com/php/php-src/blob/PHP-8.1/ext/pdo_firebird/tests/bug_64037.phpt, which queries a
NUMERIC(15,2)row, and that works (also locally for me).Can you please specify the exact table definition – ideally having a complete script which creates and fills the table, and then does the query, printing the resulting row via
var_dump()?clarumedia commentedon Nov 18, 2022
Test Results for the script at https://github.com/php/php-src/blob/PHP-8.1/ext/pdo_firebird/tests/bug_64037.phpt
Additional comment added 19/11/2022: My apologies, I neglected to mention that I had to use "dialect=1;" to get the test to work in either PHP7.4 or 8.1.12. My previous scripts in PHP7.4 were only ever doing selects.
"Metadata update statement is not allowed by the current database SQL dialect 1"
PHP 7.4
string(5) "-1.00"
string(5) "-0.99"
string(5) "-1.01"
PHP 8.1.12 (php8.1-interbase 8.1.12-1+ubuntu20.04.1+deb.sury.org+1)
string(4) "0.00"
string(11) "20615843.02"
string(12) "-10307921.51"
hormus commentedon Nov 19, 2022
Hi @clarumedia please Test phpt code use pdo_firebird extension installed and enabled not interbase extension
https://github.com/php/php-src/blob/PHP-8.1/ext/pdo_firebird/tests/skipif.inc
https://github.com/php/php-src/blob/PHP-8.1/ext/pdo_firebird/tests/testdb.inc
and https://github.com/php/php-src/blob/PHP-8.1/ext/pdo_firebird/tests/bug_64037.phpt
the fix seems to me never came for the shortstop extension please @cmb69 can you confirm if you are not busy? Thank you
cmb69 commentedon Nov 19, 2022
This is seriously screwed. What's the version of your database server?
clarumedia commentedon Nov 19, 2022
@cmb69
print $dbh->getAttribute(PDO::ATTR_SERVER_INFO);
PHP 7.4
Server Version: Firebird/Windows/Intel/i386 (access method), version "WI-V2.0.1.12855 Firebird 2.0" Firebird/Windows/Intel/i386 (remote server), version "WI-V2.0.1.12855 Firebird 2.0/tcp (DBSERVERHOSTNAME)/P10" Firebird/Linux/AMD/Intel/x64 (remote interface), version "LI-V3.0.5.33220 Firebird 3.0/tcp (arm-lnx-1)/P10" on disk structure version 11.0
PHP 8.1
Server Version: Firebird/Windows/Intel/i386 (access method), version "WI-V2.0.1.12855 Firebird 2.0" Firebird/Windows/Intel/i386 (remote server), version "WI-V2.0.1.12855 Firebird 2.0/tcp (DBSERVERHOSTNAME)/P10" Firebird/Linux/AMD/Intel/x64 (remote interface), version "LI-V3.0.5.33220 Firebird 3.0/tcp (arm-lnx-1)/P10" on disk structure version 11.0
31 remaining items
Fix phpGH-9971: Incorrect NUMERIC value returned from PDO_Firebird
cmb69 commentedon Nov 29, 2022
Thanks for checking, @clarumedia!
Interesting! So apparently the issue was "only" the
ZEND_ASSUME(0)which caused a compiler "optimization" which lead to reading of uninitialized memory. I've just submitted a PR with a slightly simplified solution; maybe you can try that, too.clarumedia commentedon Nov 29, 2022
@cmb69
Test results for your simplified fix: https://github.com/php/php-src/pull/10021/files
Connecting with:firebird:dbname=localhost:/var/lib/firebird/3.0/data/second_database.fdb;dialect=1
string(5) "-1.00"
string(5) "-0.99"
string(5) "-1.01"
Looking good :-)
Fix GH-9971: Incorrect NUMERIC value returned from PDO_Firebird
Merge branch 'PHP-8.1' into PHP-8.2
Merge branch 'PHP-8.2'
clarumedia commentedon Nov 30, 2022
Thank you @cmb69 :-)