]> granicus.if.org Git - python/commitdiff
revert dd13098a5dc2 (#29006, #10513)
authorBenjamin Peterson <benjamin@python.org>
Mon, 16 Jan 2017 08:07:27 +0000 (00:07 -0800)
committerBenjamin Peterson <benjamin@python.org>
Mon, 16 Jan 2017 08:07:27 +0000 (00:07 -0800)
Lib/sqlite3/test/regression.py
Misc/NEWS
Modules/_sqlite/connection.c

index 6ac40167dee7dc8160d1dca1d224072ed08f6d91..36fec59f1131d857e7a9253c1f1364aae53465b8 100644 (file)
@@ -328,6 +328,36 @@ class RegressionTests(unittest.TestCase):
         self.assertRaises(ValueError, cur.execute, " \0select 2")
         self.assertRaises(ValueError, cur.execute, "select 2\0")
 
+    def CheckCommitCursorReset(self):
+        """
+        Connection.commit() did reset cursors, which made sqlite3
+        to return rows multiple times when fetched from cursors
+        after commit. See issues 10513 and 23129 for details.
+        """
+        con = sqlite.connect(":memory:")
+        con.executescript("""
+        create table t(c);
+        create table t2(c);
+        insert into t values(0);
+        insert into t values(1);
+        insert into t values(2);
+        """)
+
+        self.assertEqual(con.isolation_level, "")
+
+        counter = 0
+        for i, row in enumerate(con.execute("select c from t")):
+            con.execute("insert into t2(c) values (?)", (i,))
+            con.commit()
+            if counter == 0:
+                self.assertEqual(row[0], 0)
+            elif counter == 1:
+                self.assertEqual(row[0], 1)
+            elif counter == 2:
+                self.assertEqual(row[0], 2)
+            counter += 1
+        self.assertEqual(counter, 3, "should have returned exactly three rows")
+
 
 def suite():
     regression_suite = unittest.makeSuite(RegressionTests, "Check")
index b1d35670dbde890a557b6cc51ad2ef7797e80047..155ec8e06651454b714c071b69b6c1eac8ae76a9 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -29,9 +29,6 @@ Library
 - Issue #29082: Fixed loading libraries in ctypes by unicode names on Windows.
   Original patch by Chi Hsuan Yen.
 
-- Issue #29006: Revert change from issue #10513 for making sqlite more liable to
-  emit "database table is locked" errors.
-
 - Issue #29188: Support glibc 2.24 on Linux: don't use getentropy() function
   but read from /dev/urandom to get random bytes, for example in os.urandom().
   On Linux, getentropy() is implemented which getrandom() is blocking mode,
@@ -257,6 +254,9 @@ Library
 
 - Issue #19884: Avoid spurious output on OS X with Gnu Readline.
 
+- Issue #10513: Fix a regression in Connection.commit().  Statements should
+  not be reset after a commit.
+
 - Issue #2466: posixpath.ismount now correctly recognizes mount points which
   the user does not have permission to access.
 
index 4e28289125061c54a0f742bbe2eb49d1e3c8c006..237d6e419a975c737a446d242fec3f4d871d6777 100644 (file)
@@ -467,7 +467,6 @@ PyObject* pysqlite_connection_commit(pysqlite_Connection* self, PyObject* args)
     }
 
     if (self->inTransaction) {
-        pysqlite_do_all_statements(self, ACTION_RESET, 0);
 
         Py_BEGIN_ALLOW_THREADS
         rc = sqlite3_prepare(self->db, "COMMIT", -1, &statement, &tail);