Skip to content

Commit 730d7b8

Browse files
committed
Merge branch 'PHP-5.6'
* PHP-5.6: Fix bug #69344 (PDO PgSQL Incorrect binding numeric array with gaps) Fix bug #69362 (PDO-pgsql fails to connect if password contains a leading single quote) Fixed bug #61574 - No MSI Conflicts: ext/pdo_pgsql/pgsql_statement.c
2 parents cd5b7e9 + 3bb1a4f commit 730d7b8

File tree

2 files changed

+46
-2
lines changed

2 files changed

+46
-2
lines changed

ext/pdo_pgsql/pgsql_statement.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,8 +301,8 @@ static int pgsql_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data *
301301
if (param->paramno >= 0) {
302302
zval *parameter;
303303

304-
if (param->paramno >= zend_hash_num_elements(stmt->bound_param_map)) {
305-
pdo_pgsql_error_stmt(stmt, PGRES_FATAL_ERROR, "HY105");
304+
if (param->paramno >= zend_hash_num_elements(stmt->bound_params)) {
305+
pdo_raise_impl_error(stmt->dbh, stmt, "HY093", "parameter was not defined");
306306
return 0;
307307
}
308308

ext/pdo_pgsql/tests/bug69344.phpt

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
--TEST--
2+
PDO PgSQL Bug #69344 (PDO PgSQL Incorrect binding numeric array with gaps)
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('pdo') || !extension_loaded('pdo_pgsql')) die('skip not l$
6+
require dirname(__FILE__) . '/config.inc';
7+
require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
8+
PDOTest::skip();
9+
?>
10+
--FILE--
11+
<?php
12+
13+
require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
14+
$pdo = PDOTest::test_factory(dirname(__FILE__) . '/common.phpt');
15+
$pdo->setAttribute (\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
16+
$pdo->setAttribute (\PDO::ATTR_DEFAULT_FETCH_MODE, \PDO::FETCH_ASSOC);
17+
18+
$test = function () use ($pdo) {
19+
$arr = [
20+
0 => "a",
21+
2 => "b",
22+
];
23+
24+
$stmt = $pdo->prepare("SELECT (?)::text AS a, (?)::text AS b");
25+
26+
try {
27+
$stmt->execute($arr);
28+
var_dump($stmt->fetch());
29+
} catch (\Exception $e) {
30+
echo $e->getMessage()."\n";
31+
}
32+
};
33+
34+
$test();
35+
36+
$pdo->setAttribute(\PDO::ATTR_EMULATE_PREPARES, true);
37+
38+
$test();
39+
40+
?>
41+
--EXPECT--
42+
SQLSTATE[HY093]: Invalid parameter number: parameter was not defined
43+
SQLSTATE[HY093]: Invalid parameter number: parameter was not defined
44+

0 commit comments

Comments
 (0)