[php-src] Issue #15604: pdo_firebird: It is not possible to pass a NULL value as an input parameter if the field is marked as NOT NULL.

From: Date: Tue, 27 Aug 2024 18:38:58 +0000
Subject: [php-src] Issue #15604: pdo_firebird: It is not possible to pass a NULL value as an input parameter if the field is marked as NOT NULL.
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-247613@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/15604 Author: sim1984 ### Description The following code: ```php <?php $dbh = new PDO('firebird:dbname=inet://localhost/employee', 'SYSDBA', 'masterkey'); $dbh->exec(' recreate table t_bug_0001 ( id bigint not null, a int not null, b int, constraint pk_bug_0001 primary key(id) ) '); $dbh->exec('recreate sequence g_bug_0001'); $dbh->exec(<<<'SQL' create or alter trigger t_bug_0001_bi0 for t_bug_0001 active before insert position 0 as begin if (new.id is null) then new.id = next value for g_bug_0001; end SQL ); $stmt = $dbh->prepare('insert into t_bug_0001(id, a, b) values(?, ?, ?)'); $stmt->execute([null, 1, 2]); $stmt->execute([2, 2, null]); unset($stmt); $stmt2 = $dbh->prepare('SELECT id, a, b FROM t_bug_0001 WHERE id = ?'); $stmt2->execute([null]); $data = $stmt2->fetch(\PDO::FETCH_ASSOC); $stmt2->closeCursor(); var_dump($data); $stmt2->execute([2]); $data = $stmt2->fetch(\PDO::FETCH_ASSOC); $stmt2->closeCursor(); var_dump($data); unset($stmt2); $dbh->exec('drop table t_bug_0001'); $dbh->exec('drop sequence g_bug_0001'); echo "\nOK\n"; ``` Resulted in this output: ``` PHP Fatal error: Uncaught PDOException: SQLSTATE[HY105]: Invalid parameter type: -999 Parameter requires non-null value in D:\IBase\php-test\null_params.php:28 Stack trace: #0 D:\IBase\php-test\null_params.php(28): PDOStatement->execute() #1 {main} thrown in D:\IBase\php-test\null_params.php on line 28 ``` But I expected this output instead: ``` bool(false) array(3) { ["ID"]=> int(2) ["A"]=> int(2) ["B"]=> NULL } OK ``` ### PHP Version PHP 8.3, PHP 8.4Beta3 ### Operating System _No response_

« previous php.bugs (#247613) next »