. Fixed bug #62889 (LOAD DATA INFILE broken). (Nikita)
. Fixed bug #67004 (Executing PDOStatement::fetch() more than once prevents
releasing resultset). (Nikita)
+ . Fixed bug #79132 (PDO re-uses parameter values from earlier calls to
+ execute()). (Nikita)
- Phar:
. Fixed bug #73809 (Phar Zip parse crash - mmap fail). (cmb)
strcpy(stmt->error_code, "HY093");
PDO_DBG_RETURN(0);
}
- S->params_given++;
#ifndef PDO_USE_MYSQLND
b = &S->params[param->paramno];
PDO_DBG_RETURN(1);
case PDO_PARAM_EVT_EXEC_PRE:
- if (S->params_given < (unsigned int) S->num_params) {
+ if (zend_hash_num_elements(stmt->bound_params) < (unsigned int) S->num_params) {
/* too few parameter bound */
PDO_DBG_ERR("too few parameters bound");
strcpy(stmt->error_code, "HY093");
PDO_MYSQL_PARAM_BIND *bound_result;
my_bool *out_null;
zend_ulong *out_length;
- unsigned int params_given;
unsigned max_length:1;
/* Whether all result sets have been fully consumed.
* If this flag is not set, they need to be consumed during destruction. */
--- /dev/null
+--TEST--
+Bug #79132: PDO re-uses parameter values from earlier calls to execute()
+--SKIPIF--
+<?php
+require_once(__DIR__ . DIRECTORY_SEPARATOR . 'skipif.inc');
+require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
+MySQLPDOTest::skip();
+?>
+--FILE--
+<?php
+require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
+
+$pdo = MySQLPDOTest::factory();
+$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
+
+$pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
+test($pdo);
+echo "\n";
+$pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
+test($pdo);
+
+function test($pdo) {
+ $stmt = $pdo->prepare('select ? a, ? b');
+
+ $set = [
+ ['a', 'b'],
+ ['x'], /* second parameter is missing */
+ [1 => 'y'], /* first parameter is missing */
+ ];
+
+ foreach ($set as $params) {
+ try {
+ var_dump($stmt->execute($params), $stmt->fetchAll(PDO::FETCH_ASSOC));
+ } catch (PDOException $error) {
+ echo $error->getMessage() . "\n";
+ }
+ }
+}
+
+?>
+--EXPECT--
+bool(true)
+array(1) {
+ [0]=>
+ array(2) {
+ ["a"]=>
+ string(1) "a"
+ ["b"]=>
+ string(1) "b"
+ }
+}
+SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens
+SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens
+
+bool(true)
+array(1) {
+ [0]=>
+ array(2) {
+ ["a"]=>
+ string(1) "a"
+ ["b"]=>
+ string(1) "b"
+ }
+}
+SQLSTATE[HY093]: Invalid parameter number
+SQLSTATE[HY093]: Invalid parameter number