Author: Armin Rigo <[email protected]>
Branch: 
Changeset: r89193:4dd7bdd90b9c
Date: 2016-12-20 10:20 +0100
http://bitbucket.org/pypy/pypy/changeset/4dd7bdd90b9c/

Log:    Backout 5d96f9ed88fe, 55980e9a374e, 2aa05052bb18

        We are getting SQLITE_MISUSE on Windows, which is documented as:

        """If SQLite ever returns SQLITE_MISUSE from any interface, that
        means that the application is incorrectly coded and needs to be
        fixed. Do not ship an application that sometimes returns
        SQLITE_MISUSE from a standard SQLite interface because that
        application contains potentially serious bugs."""

diff --git a/lib-python/2.7/sqlite3/test/regression.py 
b/lib-python/2.7/sqlite3/test/regression.py
--- a/lib-python/2.7/sqlite3/test/regression.py
+++ b/lib-python/2.7/sqlite3/test/regression.py
@@ -351,7 +351,10 @@
         self.assertRaises(ValueError, cur.execute, " \0select 2")
         self.assertRaises(ValueError, cur.execute, "select 2\0")
 
+    @test_support.impl_detail(pypy=False)
     def CheckCommitCursorReset(self):
+        # This test is for logic added in 2.7.13 which PyPy doesn't
+        # implement.  See http://bugs.python.org/issue29006
         """
         Connection.commit() did reset cursors, which made sqlite3
         to return rows multiple times when fetched from cursors
diff --git a/lib_pypy/_sqlite3.py b/lib_pypy/_sqlite3.py
--- a/lib_pypy/_sqlite3.py
+++ b/lib_pypy/_sqlite3.py
@@ -363,12 +363,6 @@
                 if cursor is not None:
                     cursor._reset = True
 
-    def _reset_other_statements(self, excepted):
-        for weakref in self.__statements:
-            statement = weakref()
-            if statement is not None and statement is not excepted:
-                statement._reset()
-
     @_check_thread_wrap
     @_check_closed_wrap
     def __call__(self, sql):
@@ -424,6 +418,16 @@
         if not self._in_transaction:
             return
 
+        # The following line is a KNOWN DIFFERENCE with CPython 2.7.13.
+        # More precisely, the corresponding line was removed in the
+        # version 2.7.13 of CPython, but this is causing troubles for
+        # PyPy (and potentially for CPython too):
+        #
+        #     http://bugs.python.org/issue29006
+        #
+        # So for now, we keep this line.
+        self.__do_all_statements(Statement._reset, False)
+
         statement_star = _ffi.new('sqlite3_stmt **')
         ret = _lib.sqlite3_prepare_v2(self._db, b"COMMIT", -1,
                                       statement_star, _ffi.NULL)
@@ -823,24 +827,7 @@
                 self.__statement._set_params(params)
 
                 # Actually execute the SQL statement
-
-                # NOTE: if we get SQLITE_LOCKED, it's probably because
-                # one of the cursors created previously is still alive
-                # and not reset and the operation we're trying to do
-                # makes Sqlite unhappy about that.  In that case, we
-                # automatically reset all cursors and try again.  This
-                # is not what CPython does!  It is a workaround for a
-                # new feature of 2.7.13.  Previously, all cursors would
-                # be reset at commit(), which makes it unlikely to have
-                # cursors lingering around.  Since 2.7.13, cursors stay
-                # around instead.  This causes problems here---at least:
-                # this is the only place shown by pysqlite tests, and I
-                # can only hope there is no other.
-
                 ret = _lib.sqlite3_step(self.__statement._statement)
-                if ret == _lib.SQLITE_LOCKED:
-                    self.__connection._reset_other_statements(self.__statement)
-                    ret = _lib.sqlite3_step(self.__statement._statement)
 
                 if ret == _lib.SQLITE_ROW:
                     if multiple:
diff --git a/pypy/doc/cpython_differences.rst b/pypy/doc/cpython_differences.rst
--- a/pypy/doc/cpython_differences.rst
+++ b/pypy/doc/cpython_differences.rst
@@ -488,6 +488,11 @@
   the rest is kept.  If you return an unexpected string from
   ``__hex__()`` you get an exception (or a crash before CPython 2.7.13).
 
+* The ``sqlite`` module was updated on 2.7.13 to no longer reset all
+  cursors when there is a commit.  This causes troubles for PyPy (and
+  potentially for CPython too), and so for now we didn't port this change:
+  see http://bugs.python.org/issue29006.
+
 .. _`is ignored in PyPy`: http://bugs.python.org/issue14621
 .. _`little point`: 
http://events.ccc.de/congress/2012/Fahrplan/events/5152.en.html
 .. _`#2072`: https://bitbucket.org/pypy/pypy/issue/2072/
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to