mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
ext/pdo_firebird: Fixed GH-15604 Always make input parameters nullable (#15605)
Fixes #15604 Closes #15605
This commit is contained in:
parent
b221f21b49
commit
eb3e7a2c0c
3 changed files with 89 additions and 0 deletions
3
NEWS
3
NEWS
|
@ -14,6 +14,9 @@ PHP NEWS
|
||||||
- GD:
|
- GD:
|
||||||
. Added gdImageClone to bundled libgd. (David Carlier)
|
. Added gdImageClone to bundled libgd. (David Carlier)
|
||||||
|
|
||||||
|
- PDO_Firebird:
|
||||||
|
. Fixed GH-15604 (Always make input parameters nullable). (sim1984)
|
||||||
|
|
||||||
27 Aug 2024, PHP 8.4.0beta4
|
27 Aug 2024, PHP 8.4.0beta4
|
||||||
|
|
||||||
- Core:
|
- Core:
|
||||||
|
|
|
@ -681,6 +681,14 @@ static bool firebird_handle_preparer(pdo_dbh_t *dbh, zend_string *sql, /* {{{ */
|
||||||
if (isc_dsql_describe_bind(H->isc_status, &s, PDO_FB_SQLDA_VERSION, S->in_sqlda)) {
|
if (isc_dsql_describe_bind(H->isc_status, &s, PDO_FB_SQLDA_VERSION, S->in_sqlda)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* make all parameters nullable */
|
||||||
|
unsigned int i;
|
||||||
|
XSQLVAR* var;
|
||||||
|
for (i = 0, var = S->in_sqlda->sqlvar; i < S->in_sqlda->sqld; i++, var++) {
|
||||||
|
/* The low bit of sqltype indicates that the parameter can take a NULL value */
|
||||||
|
var->sqltype |= 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stmt->driver_data = S;
|
stmt->driver_data = S;
|
||||||
|
|
78
ext/pdo_firebird/tests/bug_15604.phpt
Normal file
78
ext/pdo_firebird/tests/bug_15604.phpt
Normal file
|
@ -0,0 +1,78 @@
|
||||||
|
--TEST--
|
||||||
|
Bug #15604 It is not possible to pass a NULL value as an input parameter if the field is marked as NOT NULL.
|
||||||
|
--EXTENSIONS--
|
||||||
|
pdo_firebird
|
||||||
|
--SKIPIF--
|
||||||
|
<?php require('skipif.inc'); ?>
|
||||||
|
--XLEAK--
|
||||||
|
A bug in firebird causes a memory leak when calling `isc_attach_database()`.
|
||||||
|
See https://github.com/FirebirdSQL/firebird/issues/7849
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
require_once 'testdb.inc';
|
||||||
|
|
||||||
|
$dbh = getDbConnection();
|
||||||
|
|
||||||
|
$dbh->exec('
|
||||||
|
recreate table t_bug_15604 (
|
||||||
|
id bigint not null,
|
||||||
|
a int not null,
|
||||||
|
b int,
|
||||||
|
constraint pk_bug_15604 primary key(id)
|
||||||
|
)
|
||||||
|
');
|
||||||
|
|
||||||
|
$dbh->exec('recreate sequence g_bug_15604');
|
||||||
|
|
||||||
|
$dbh->exec(<<<'SQL'
|
||||||
|
create or alter trigger t_bug_15604_bi0 for t_bug_15604
|
||||||
|
active before insert position 0
|
||||||
|
as
|
||||||
|
begin
|
||||||
|
if (new.id is null) then
|
||||||
|
new.id = next value for g_bug_15604;
|
||||||
|
end
|
||||||
|
SQL
|
||||||
|
);
|
||||||
|
|
||||||
|
$stmt = $dbh->prepare('insert into t_bug_15604(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_15604 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);
|
||||||
|
|
||||||
|
echo "\nOK\n";
|
||||||
|
?>
|
||||||
|
--CLEAN--
|
||||||
|
<?php
|
||||||
|
require_once 'testdb.inc';
|
||||||
|
$dbh = getDbConnection();
|
||||||
|
@$dbh->exec('drop table t_bug_15604');
|
||||||
|
@$dbh->exec('drop sequence g_bug_15604');
|
||||||
|
unset($dbh);
|
||||||
|
?>
|
||||||
|
--EXPECT--
|
||||||
|
bool(false)
|
||||||
|
array(3) {
|
||||||
|
["ID"]=>
|
||||||
|
int(2)
|
||||||
|
["A"]=>
|
||||||
|
int(2)
|
||||||
|
["B"]=>
|
||||||
|
NULL
|
||||||
|
}
|
||||||
|
|
||||||
|
OK
|
Loading…
Add table
Add a link
Reference in a new issue