1--TEST-- 2GH-10908 (Bus error with PDO Firebird on RPI with 64 bit kernel and 32 bit userland) 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$sql = <<<EOT 16CREATE TABLE gh10908( 17 ID BIGINT NOT NULL, 18 CODE VARCHAR(60) NOT NULL, 19 NUM NUMERIC(18, 3), 20 DBL DOUBLE PRECISION, 21 FLT FLOAT, 22 TS TIMESTAMP, 23 MYDATE DATE, 24 MYTIME TIME, 25 MYBLOB BLOB, 26 MYSMALLINT SMALLINT, 27 MYINT INT, 28 MYCHAR CHAR(10), 29 MYBOOL BOOLEAN 30); 31EOT; 32$dbh = getDbConnection(); 33$dbh->exec($sql); 34$dbh->exec("INSERT INTO gh10908 VALUES(1, 'ABC', 12.34, 1.0, 2.0, '2023-03-24 17:39', '2023-03-24', '17:39', 'abcdefg', 32767, 200000, 'azertyuiop', false);"); 35 36function query_and_dump($dbh, $sql) { 37 foreach ($dbh->query($sql) as $row) { 38 print_r($row); 39 print("\n"); 40 } 41} 42 43query_and_dump($dbh, "SELECT CODE FROM gh10908"); // works fine 44query_and_dump($dbh, "SELECT ID FROM gh10908"); // Used to "bus error" 45query_and_dump($dbh, "SELECT NUM FROM gh10908"); // Used to "bus error" 46query_and_dump($dbh, "SELECT DBL FROM gh10908"); // Used to "bus error" 47query_and_dump($dbh, "SELECT TS FROM gh10908"); // Used to "bus error" 48query_and_dump($dbh, "SELECT MYBLOB FROM gh10908"); // Used to "bus error" 49query_and_dump($dbh, "SELECT * FROM gh10908"); // Used to "bus error" 50 51query_and_dump($dbh, "SELECT CAST(NUM AS NUMERIC(9, 3)) FROM gh10908"); // works fine 52query_and_dump($dbh, "SELECT CAST(ID AS INTEGER) FROM gh10908"); // works fine 53query_and_dump($dbh, "SELECT CAST(ID AS BIGINT) FROM gh10908"); // Used to "bus error" 54 55echo "Did not crash\n"; 56 57?> 58--CLEAN-- 59<?php 60require 'testdb.inc'; 61$dbh = getDbConnection(); 62@$dbh->exec("DROP TABLE gh10908"); 63unset($dbh); 64?> 65--EXPECT-- 66Array 67( 68 [CODE] => ABC 69 [0] => ABC 70) 71 72Array 73( 74 [ID] => 1 75 [0] => 1 76) 77 78Array 79( 80 [NUM] => 12.340 81 [0] => 12.340 82) 83 84Array 85( 86 [DBL] => 1 87 [0] => 1 88) 89 90Array 91( 92 [TS] => 2023-03-24 17:39:00 93 [0] => 2023-03-24 17:39:00 94) 95 96Array 97( 98 [MYBLOB] => abcdefg 99 [0] => abcdefg 100) 101 102Array 103( 104 [ID] => 1 105 [0] => 1 106 [CODE] => ABC 107 [1] => ABC 108 [NUM] => 12.340 109 [2] => 12.340 110 [DBL] => 1 111 [3] => 1 112 [FLT] => 2 113 [4] => 2 114 [TS] => 2023-03-24 17:39:00 115 [5] => 2023-03-24 17:39:00 116 [MYDATE] => 2023-03-24 117 [6] => 2023-03-24 118 [MYTIME] => 17:39:00 119 [7] => 17:39:00 120 [MYBLOB] => abcdefg 121 [8] => abcdefg 122 [MYSMALLINT] => 32767 123 [9] => 32767 124 [MYINT] => 200000 125 [10] => 200000 126 [MYCHAR] => azertyuiop 127 [11] => azertyuiop 128 [MYBOOL] => 129 [12] => 130) 131 132Array 133( 134 [CAST] => 12.340 135 [0] => 12.340 136) 137 138Array 139( 140 [CAST] => 1 141 [0] => 1 142) 143 144Array 145( 146 [CAST] => 1 147 [0] => 1 148) 149 150Did not crash 151