summaryrefslogtreecommitdiff
path: root/ext/sqlite3/tests
diff options
context:
space:
mode:
authorChristoph M. Becker <cmbecker69@gmx.de>2016-11-16 11:49:04 +0100
committerChristoph M. Becker <cmbecker69@gmx.de>2016-11-16 11:49:04 +0100
commiteb570294a289b45d0dd38efc71065d6b0d314c4b (patch)
treecfa73c5288dcfeff8a5b16070e11eabc127e5082 /ext/sqlite3/tests
parentecba563f2fa1e027ea91b9ee0d50611273852995 (diff)
downloadphp-git-eb570294a289b45d0dd38efc71065d6b0d314c4b.tar.gz
Fix #73530: Unsetting result set may reset other result set
Calling sqlite3_reset() when a result set object is freed can cause undesired and maybe even hard to track interference with other result sets. Furthermore, there is no need to call sqlite3_reset(), because that is implicitly called on SQLite3Stmt::execute(), and users are encouraged to explicitly call either SQLite3Result::finalize() or SQLite3Stmt::reset() anyway.
Diffstat (limited to 'ext/sqlite3/tests')
-rw-r--r--ext/sqlite3/tests/bug73530.phpt32
1 files changed, 32 insertions, 0 deletions
diff --git a/ext/sqlite3/tests/bug73530.phpt b/ext/sqlite3/tests/bug73530.phpt
new file mode 100644
index 0000000000..7e17dfecd3
--- /dev/null
+++ b/ext/sqlite3/tests/bug73530.phpt
@@ -0,0 +1,32 @@
+--TEST--
+Bug #73530 (Unsetting result set may reset other result set)
+--SKIPIF--
+<?php
+if (!extension_loaded('sqlite3')) die('skip sqlite3 extension not available');
+?>
+--FILE--
+<?php
+$db = new SQLite3(':memory:');
+$db->exec("CREATE TABLE foo (num int)");
+$db->exec("INSERT INTO foo VALUES (0)");
+$db->exec("INSERT INTO foo VALUES (1)");
+$stmt = $db->prepare("SELECT * FROM foo WHERE NUM = ?");
+$stmt->bindValue(1, 0, SQLITE3_INTEGER);
+$res1 = $stmt->execute();
+$res1->finalize();
+$stmt->clear();
+$stmt->reset();
+$stmt->bindValue(1, 1, SQLITE3_INTEGER);
+$res2 = $stmt->execute();
+while ($row = $res2->fetchArray(SQLITE3_ASSOC)) {
+ var_dump($row);
+ unset($res1);
+}
+?>
+===DONE===
+--EXPECT--
+array(1) {
+ ["num"]=>
+ int(1)
+}
+===DONE===