1--TEST--
2Bug #64037 Firebird return wrong value for numeric field
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->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
17$dbh->exec("CREATE TABLE test64037 (ID INTEGER NOT NULL, TEXT VARCHAR(10), COST NUMERIC(15, 2))");
18$dbh->exec("INSERT INTO test64037 (ID, TEXT, COST) VALUES (1, 'test', -1.0)");
19$dbh->exec("INSERT INTO test64037 (ID, TEXT, COST) VALUES (2, 'test', -0.99)");
20$dbh->exec("INSERT INTO test64037 (ID, TEXT, COST) VALUES (3, 'test', -1.01)");
21
22$query = "SELECT * from test64037 order by ID";
23$stmt = $dbh->prepare($query);
24$stmt->execute();
25$rows = $stmt->fetchAll();
26var_dump($rows[0]['COST']);
27var_dump($rows[1]['COST']);
28var_dump($rows[2]['COST']);
29
30
31$stmt = $dbh->prepare('DELETE FROM test64037');
32$stmt->execute();
33
34unset($stmt);
35unset($dbh);
36
37?>
38--CLEAN--
39<?php
40require 'testdb.inc';
41$dbh = getDbConnection();
42@$dbh->exec("DROP TABLE test64037");
43unset($dbh);
44?>
45--EXPECT--
46string(5) "-1.00"
47string(5) "-0.99"
48string(5) "-1.01"
49