xref: /PHP-8.4/ext/pdo_firebird/tests/gh13119.phpt (revision fa751c7d)
1--TEST--
2GH-13119 (float, double value is incorrect)
3--EXTENSIONS--
4pdo_firebird
5--SKIPIF--
6<?php require('skipif.inc'); ?>
7--XLEAK--
8A bug in firebird causes a memory leak when calling `isc_attach_database()`.
9See https://github.com/FirebirdSQL/firebird/issues/7849
10--FILE--
11<?php
12
13require("testdb.inc");
14
15$dbh = getDbConnection();
16$dbh->exec('CREATE TABLE gh13119 (f_val FLOAT, d_val DOUBLE PRECISION)');
17
18$dbh->exec('INSERT INTO gh13119 VALUES (0.1, 0.1)');
19$dbh->exec('INSERT INTO gh13119 VALUES (0.0000000000000001, 0.0000000000000001)');
20$dbh->exec('INSERT INTO gh13119 VALUES (12.000000, 12.00000000000000)');
21$dbh->exec('INSERT INTO gh13119 VALUES (12.000001, 12.00000000000001)');
22$dbh->exec('INSERT INTO gh13119 VALUES (12.345678, 12.34567890123456)');
23$dbh->exec('INSERT INTO gh13119 VALUES (0.0000000000000000012345678, 0.000000000000000001234567890123456)');
24
25$stmt = $dbh->query('select * from gh13119');
26var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
27?>
28--CLEAN--
29<?php
30require 'testdb.inc';
31$dbh = getDbConnection();
32@$dbh->exec('DROP TABLE gh13119');
33unset($dbh);
34?>
35--EXPECT--
36array(6) {
37  [0]=>
38  array(2) {
39    ["F_VAL"]=>
40    string(3) "0.1"
41    ["D_VAL"]=>
42    string(3) "0.1"
43  }
44  [1]=>
45  array(2) {
46    ["F_VAL"]=>
47    string(7) "1.0E-16"
48    ["D_VAL"]=>
49    string(7) "1.0E-16"
50  }
51  [2]=>
52  array(2) {
53    ["F_VAL"]=>
54    string(2) "12"
55    ["D_VAL"]=>
56    string(2) "12"
57  }
58  [3]=>
59  array(2) {
60    ["F_VAL"]=>
61    string(9) "12.000001"
62    ["D_VAL"]=>
63    string(17) "12.00000000000001"
64  }
65  [4]=>
66  array(2) {
67    ["F_VAL"]=>
68    string(9) "12.345678"
69    ["D_VAL"]=>
70    string(17) "12.34567890123456"
71  }
72  [5]=>
73  array(2) {
74    ["F_VAL"]=>
75    string(13) "1.2345678E-18"
76    ["D_VAL"]=>
77    string(21) "1.234567890123456E-18"
78  }
79}
80