com php-src: Fix bug #69344 (PDO PgSQL Incorrect binding numeric array with gaps): NEWS ext/pdo_pgsql/pgsql_statement.c ext/pdo_p
gsql/tests/bug69344.phpt
| From: | Matteo Beccati | Date: | Fri, 12 Jun 2015 00:05:28 +0000 |
| Subject: | com php-src: Fix bug #69344 (PDO PgSQL Incorrect binding numeric array with gaps): NEWS ext/pdo_pgsql/pgsql_statement.c ext/pdo_p gsql/tests/bug69344.phpt |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-87227@lists.php.net to get a copy of this message | ||
Commit: b60efdce9fe7e168ba37070a4307269483a66ea4
Author: Matteo Beccati <mbeccati@php.net> Fri, 12 Jun 2015 01:57:22 +0200
Parents: 7c0b8f872e3c15d50b1dc2d35be3674c24f82bf6
Branches: PHP-5.5 PHP-5.6 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=b60efdce9fe7e168ba37070a4307269483a66ea4
Log:
Fix bug #69344 (PDO PgSQL Incorrect binding numeric array with gaps)
Bugs:
https://bugs..php.net/69344
Changed paths:
M NEWS
M ext/pdo_pgsql/pgsql_statement.c
A ext/pdo_pgsql/tests/bug69344.phpt
Diff:
diff --git a/NEWS b/NEWS
index 80c2f9e..7d962d2 100644
--- a/NEWS
+++ b/NEWS
@@ -19,6 +19,8 @@
Statements when closeCuror() is u). (Philip Hofstetter)
. Fixed bug #69362 (PDO-pgsql fails to connect if password contains a
leading single quote). (Matteo)
+ . Fixed bug #69344 (PDO PgSQL Incorrect binding numeric array with gaps).
+ (Matteo)
- SimpleXML:
. Refactored the fix for bug #66084 (simplexml_load_string() mangles empty
diff --git a/ext/pdo_pgsql/pgsql_statement.c b/ext/pdo_pgsql/pgsql_statement.c
index 75c5a4a..51402c3 100644
--- a/ext/pdo_pgsql/pgsql_statement.c
+++ b/ext/pdo_pgsql/pgsql_statement.c
@@ -294,8 +294,8 @@ static int pgsql_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data *
sizeof(Oid));
}
if (param->paramno >= 0) {
- if (param->paramno >= zend_hash_num_elements(stmt->bound_param_map)) {
- pdo_pgsql_error_stmt(stmt, PGRES_FATAL_ERROR, "HY105");
+ if (param->paramno >= zend_hash_num_elements(stmt->bound_params)) {
+ pdo_raise_impl_error(stmt->dbh, stmt, "HY093", "parameter was not
defined" TSRMLS_CC);
return 0;
}
diff --git a/ext/pdo_pgsql/tests/bug69344.phpt b/ext/pdo_pgsql/tests/bug69344.phpt
new file mode 100644
index 0000000..4349814
--- /dev/null
+++ b/ext/pdo_pgsql/tests/bug69344.phpt
@@ -0,0 +1,44 @@
+--TEST--
+PDO PgSQL Bug #69344 (PDO PgSQL Incorrect binding numeric array with gaps)
+--SKIPIF--
+<?php
+if (!extension_loaded('pdo') || !extension_loaded('pdo_pgsql')) die('skip
not l$
+require dirname(__FILE__) . '/config.inc';
+require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
+PDOTest::skip();
+?>
+--FILE--
+<?php
+
+require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
+$pdo = PDOTest::test_factory(dirname(__FILE__) . '/common.phpt');
+$pdo->setAttribute (\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
+$pdo->setAttribute (\PDO::ATTR_DEFAULT_FETCH_MODE, \PDO::FETCH_ASSOC);
+
+$test = function () use ($pdo) {
+ $arr = [
+ 0 => "a",
+ 2 => "b",
+ ];
+
+ $stmt = $pdo->prepare("SELECT (?)::text AS a, (?)::text AS b");
+
+ try {
+ $stmt->execute($arr);
+ var_dump($stmt->fetch());
+ } catch (\Exception $e) {
+ echo $e->getMessage()."\n";
+ }
+};
+
+$test();
+
+$pdo->setAttribute(\PDO::ATTR_EMULATE_PREPARES, true);
+
+$test();
+
+?>
+--EXPECT--
+SQLSTATE[HY093]: Invalid parameter number: parameter was not defined
+SQLSTATE[HY093]: Invalid parameter number: parameter was not defined
+