|
| 1 | +--TEST-- |
| 2 | +Bug #15604 It is not possible to pass a NULL value as an input parameter if the field is marked as NOT NULL. |
| 3 | +--EXTENSIONS-- |
| 4 | +pdo_firebird |
| 5 | +--SKIPIF-- |
| 6 | +<?php require('skipif.inc'); ?> |
| 7 | +--XLEAK-- |
| 8 | +A bug in firebird causes a memory leak when calling `isc_attach_database()`. |
| 9 | +See https://github.com/FirebirdSQL/firebird/issues/7849 |
| 10 | +--FILE-- |
| 11 | +<?php |
| 12 | +require_once 'testdb.inc'; |
| 13 | + |
| 14 | +$dbh = getDbConnection(); |
| 15 | + |
| 16 | +$dbh->exec(' |
| 17 | +recreate table t_bug_15604 ( |
| 18 | + id bigint 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' |
| 28 | +create or alter trigger t_bug_15604_bi0 for t_bug_15604 |
| 29 | +active before insert position 0 |
| 30 | +as |
| 31 | +begin |
| 32 | + if (new.id is null) then |
| 33 | + new.id = next value for g_bug_15604; |
| 34 | +end |
| 35 | +SQL |
| 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]); |
| 41 | +unset($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(); |
| 48 | +var_dump($data); |
| 49 | + |
| 50 | +$stmt2->execute([2]); |
| 51 | +$data = $stmt2->fetch(\PDO::FETCH_ASSOC); |
| 52 | +$stmt2->closeCursor(); |
| 53 | +var_dump($data); |
| 54 | + |
| 55 | +unset($stmt2); |
| 56 | + |
| 57 | +echo "\nOK\n"; |
| 58 | +?> |
| 59 | +--CLEAN-- |
| 60 | +<?php |
| 61 | +require_once 'testdb.inc'; |
| 62 | +$dbh = getDbConnection(); |
| 63 | +@$dbh->exec('drop table t_bug_15604'); |
| 64 | +@$dbh->exec('drop sequence g_bug_15604'); |
| 65 | +unset($dbh); |
| 66 | +?> |
| 67 | +--EXPECT-- |
| 68 | +bool(false) |
| 69 | +array(3) { |
| 70 | + ["ID"]=> |
| 71 | + int(2) |
| 72 | + ["A"]=> |
| 73 | + int(2) |
| 74 | + ["B"]=> |
| 75 | + NULL |
| 76 | +} |
| 77 | + |
| 78 | +OK |
0 commit comments