1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Merge branch 'PHP-8.3'

* PHP-8.3:
  Fix GH-13119 (#13125)
This commit is contained in:
Saki Takamachi
2024-01-17 01:41:40 +09:00
4 changed files with 89 additions and 8 deletions

2
NEWS
View File

@@ -72,6 +72,8 @@ PDO_FIREBIRD:
. Feature: Add transaction isolation level and mode settings to pdo_firebird.
(SakiTakamachi)
. Added class PdoFirebird. (danack, kocsismate)
. Fix GH-13119 (Changed to convert float and double values into strings using
`H` format). (SakiTakamachi)
PDO_MYSQL:
. Fixed setAttribute and getAttribute. (SakiTakamachi)

View File

@@ -463,11 +463,11 @@ static int pdo_firebird_stmt_get_col(
break;
case SQL_FLOAT:
/* TODO: Why is this not returned as the native type? */
ZVAL_STR(result, zend_strpprintf(0, "%F", php_get_float_from_sqldata(var->sqldata)));
ZVAL_STR(result, zend_strpprintf_unchecked(0, "%.8H", php_get_float_from_sqldata(var->sqldata)));
break;
case SQL_DOUBLE:
/* TODO: Why is this not returned as the native type? */
ZVAL_STR(result, zend_strpprintf(0, "%F", php_get_double_from_sqldata(var->sqldata)));
ZVAL_STR(result, zend_strpprintf_unchecked(0, "%.16H", php_get_double_from_sqldata(var->sqldata)));
break;
#ifdef SQL_BOOLEAN
case SQL_BOOLEAN:

View File

@@ -83,8 +83,8 @@ Array
Array
(
[DBL] => 1.000000
[0] => 1.000000
[DBL] => 1
[0] => 1
)
Array
@@ -107,10 +107,10 @@ Array
[1] => ABC
[NUM] => 12.340
[2] => 12.340
[DBL] => 1.000000
[3] => 1.000000
[FLT] => 2.000000
[4] => 2.000000
[DBL] => 1
[3] => 1
[FLT] => 2
[4] => 2
[TS] => 2023-03-24 17:39:00
[5] => 2023-03-24 17:39:00
[MYDATE] => 2023-03-24

View File

@@ -0,0 +1,79 @@
--TEST--
GH-13119 (float, double value is incorrect)
--EXTENSIONS--
pdo_firebird
--SKIPIF--
<?php require('skipif.inc'); ?>
--XLEAK--
A bug in firebird causes a memory leak when calling `isc_attach_database()`.
See https://github.com/FirebirdSQL/firebird/issues/7849
--FILE--
<?php
require("testdb.inc");
$dbh = getDbConnection();
$dbh->exec('CREATE TABLE gh13119 (f_val FLOAT, d_val DOUBLE PRECISION)');
$dbh->exec('INSERT INTO gh13119 VALUES (0.1, 0.1)');
$dbh->exec('INSERT INTO gh13119 VALUES (0.0000000000000001, 0.0000000000000001)');
$dbh->exec('INSERT INTO gh13119 VALUES (12.000000, 12.00000000000000)');
$dbh->exec('INSERT INTO gh13119 VALUES (12.000001, 12.00000000000001)');
$dbh->exec('INSERT INTO gh13119 VALUES (12.345678, 12.34567890123456)');
$dbh->exec('INSERT INTO gh13119 VALUES (0.0000000000000000012345678, 0.000000000000000001234567890123456)');
$stmt = $dbh->query('select * from gh13119');
var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
?>
--CLEAN--
<?php
require 'testdb.inc';
$dbh = getDbConnection();
@$dbh->exec('DROP TABLE gh13119');
unset($dbh);
?>
--EXPECT--
array(6) {
[0]=>
array(2) {
["F_VAL"]=>
string(3) "0.1"
["D_VAL"]=>
string(3) "0.1"
}
[1]=>
array(2) {
["F_VAL"]=>
string(7) "1.0E-16"
["D_VAL"]=>
string(7) "1.0E-16"
}
[2]=>
array(2) {
["F_VAL"]=>
string(2) "12"
["D_VAL"]=>
string(2) "12"
}
[3]=>
array(2) {
["F_VAL"]=>
string(9) "12.000001"
["D_VAL"]=>
string(17) "12.00000000000001"
}
[4]=>
array(2) {
["F_VAL"]=>
string(9) "12.345678"
["D_VAL"]=>
string(17) "12.34567890123456"
}
[5]=>
array(2) {
["F_VAL"]=>
string(13) "1.2345678E-18"
["D_VAL"]=>
string(21) "1.234567890123456E-18"
}
}