1--TEST-- 2Bug #15604 It is not possible to pass a NULL value as an input parameter if the field is marked as NOT NULL. 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 12require_once 'testdb.inc'; 13 14$dbh = getDbConnection(); 15 16$dbh->exec(' 17recreate table t_bug_15604 ( 18 id int not null, 19 a int not null, 20 b int, 21 constraint pk_bug_15604 primary key(id) 22) 23'); 24 25$dbh->exec('recreate sequence g_bug_15604'); 26 27$dbh->exec(<<<'SQL' 28create or alter trigger t_bug_15604_bi0 for t_bug_15604 29active before insert position 0 30as 31begin 32 if (new.id is null) then 33 new.id = next value for g_bug_15604; 34end 35SQL 36); 37 38$stmt = $dbh->prepare('insert into t_bug_15604(id, a, b) values(?, ?, ?)'); 39$stmt->execute([null, 1, 2]); 40$stmt->execute([2, 2, null]); 41unset($stmt); 42 43$stmt2 = $dbh->prepare('SELECT id, a, b FROM t_bug_15604 WHERE id = ?'); 44 45$stmt2->execute([null]); 46$data = $stmt2->fetch(\PDO::FETCH_ASSOC); 47$stmt2->closeCursor(); 48var_dump($data); 49 50$stmt2->execute([2]); 51$data = $stmt2->fetch(\PDO::FETCH_ASSOC); 52$stmt2->closeCursor(); 53var_dump($data); 54 55unset($stmt2); 56 57echo "\nOK\n"; 58?> 59--CLEAN-- 60<?php 61require_once 'testdb.inc'; 62$dbh = getDbConnection(); 63@$dbh->exec('drop table t_bug_15604'); 64@$dbh->exec('drop sequence g_bug_15604'); 65unset($dbh); 66?> 67--EXPECTF-- 68bool(false) 69array(3) { 70 ["ID"]=> 71 %r(int\(2\)|string\(1\) "2")%r 72 ["A"]=> 73 int(2) 74 ["B"]=> 75 NULL 76} 77 78OK 79