summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierrick Charron <pierrick@php.net>2009-12-03 15:24:43 +0000
committerPierrick Charron <pierrick@php.net>2009-12-03 15:24:43 +0000
commit5a64467cba799befcfd7ccc1a6f0aeb1961328ba (patch)
tree37e139e9acb3b3c6763b4a4306d5eb4bdce769f9
parent553191ea5c5aacd37b2817bcea31ee77dedead51 (diff)
downloadphp-git-5a64467cba799befcfd7ccc1a6f0aeb1961328ba.tar.gz
Fixed bug #45120 (PDOStatement->execute() returns true then false for same statement).
-rw-r--r--NEWS3
-rwxr-xr-xext/pdo/pdo_stmt.c1
-rw-r--r--ext/pdo_mysql/tests/bug_45120.phpt48
3 files changed, 51 insertions, 1 deletions
diff --git a/NEWS b/NEWS
index 0c5153ce29..b57138c264 100644
--- a/NEWS
+++ b/NEWS
@@ -14,7 +14,8 @@ PHP NEWS
- Fixed bug #49660 (libxml 2.7.3+ limits text nodes to 10MB). (Felipe)
- Fixed bug #49472 (Constants defined in Interfaces can be overridden).
(Felipe)
-
+- Fixed bug #45120 (PDOStatement->execute() returns true then false for same
+ statement). (Pierrick)
27 Nov 2009, PHP 5.2.12RC3
- Fixed break in the build chain introduced in 5.2.12RC2 (Jani)
diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c
index ad38c36fe4..5fb0179994 100755
--- a/ext/pdo/pdo_stmt.c
+++ b/ext/pdo/pdo_stmt.c
@@ -509,6 +509,7 @@ static PHP_METHOD(PDOStatement, execute)
/* no changes were made */
stmt->active_query_string = stmt->query_string;
stmt->active_query_stringlen = stmt->query_stringlen;
+ ret = 1;
} else if (ret == -1) {
/* something broke */
PDO_HANDLE_STMT_ERR();
diff --git a/ext/pdo_mysql/tests/bug_45120.phpt b/ext/pdo_mysql/tests/bug_45120.phpt
new file mode 100644
index 0000000000..db5da823f7
--- /dev/null
+++ b/ext/pdo_mysql/tests/bug_45120.phpt
@@ -0,0 +1,48 @@
+--TEST--
+Bug #45120 (PDOStatement->execute() returns true then false for same statement)
+--SKIPIF--
+<?php
+if (!extension_loaded('pdo') || !extension_loaded('pdo_mysql')) die('skip not loaded');
+require dirname(__FILE__) . '/config.inc';
+require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
+PDOTest::skip();
+?>
+--FILE--
+<?php
+require dirname(__FILE__) . '/config.inc';
+require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
+$db = PDOTest::test_factory(dirname(__FILE__) . '/common.phpt');
+
+function bug_45120($db) {
+
+ $stmt = $db->prepare("SELECT 1 AS 'one'");
+ if (true !== $stmt->execute())
+ printf("[001] Execute has failed: %s\n", var_export($stmt->errorInfo(), true));
+
+ $res = $stmt->fetch(PDO::FETCH_ASSOC);
+ if ($res['one'] != 1)
+ printf("[002] Wrong results: %s\n", var_export($res, true));
+
+ if (true !== $stmt->execute())
+ printf("[003] Execute has failed: %s\n", var_export($stmt->errorInfo(), true));
+
+ $res = $stmt->fetch(PDO::FETCH_ASSOC);
+ if ($res['one'] != 1)
+ printf("[004] Wrong results: %s\n", var_export($res, true));
+
+}
+
+print "Emulated Prepared Statements\n";
+$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 1);
+bug_45120($db);
+
+print "Native Prepared Statements\n";
+$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0);
+bug_45120($db);
+
+print "done!";
+?>
+--EXPECT--
+Emulated Prepared Statements
+Native Prepared Statements
+done!