xref: /PHP-8.3/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->exec('CREATE TABLE gh13119 (f_val FLOAT, d_val DOUBLE PRECISION)');
16
17$dbh->exec('INSERT INTO gh13119 VALUES (0.1, 0.1)');
18$dbh->exec('INSERT INTO gh13119 VALUES (0.0000000000000001, 0.0000000000000001)');
19$dbh->exec('INSERT INTO gh13119 VALUES (12.000000, 12.00000000000000)');
20$dbh->exec('INSERT INTO gh13119 VALUES (12.000001, 12.00000000000001)');
21$dbh->exec('INSERT INTO gh13119 VALUES (12.345678, 12.34567890123456)');
22$dbh->exec('INSERT INTO gh13119 VALUES (0.0000000000000000012345678, 0.000000000000000001234567890123456)');
23
24$stmt = $dbh->query('select * from gh13119');
25var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
26?>
27--CLEAN--
28<?php
29require 'testdb.inc';
30@$dbh->exec('DROP TABLE gh13119');
31unset($dbh);
32?>
33--EXPECT--
34array(6) {
35  [0]=>
36  array(2) {
37    ["F_VAL"]=>
38    string(3) "0.1"
39    ["D_VAL"]=>
40    string(3) "0.1"
41  }
42  [1]=>
43  array(2) {
44    ["F_VAL"]=>
45    string(7) "1.0E-16"
46    ["D_VAL"]=>
47    string(7) "1.0E-16"
48  }
49  [2]=>
50  array(2) {
51    ["F_VAL"]=>
52    string(2) "12"
53    ["D_VAL"]=>
54    string(2) "12"
55  }
56  [3]=>
57  array(2) {
58    ["F_VAL"]=>
59    string(9) "12.000001"
60    ["D_VAL"]=>
61    string(17) "12.00000000000001"
62  }
63  [4]=>
64  array(2) {
65    ["F_VAL"]=>
66    string(9) "12.345678"
67    ["D_VAL"]=>
68    string(17) "12.34567890123456"
69  }
70  [5]=>
71  array(2) {
72    ["F_VAL"]=>
73    string(13) "1.2345678E-18"
74    ["D_VAL"]=>
75    string(21) "1.234567890123456E-18"
76  }
77}
78