]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-40810: Require SQLite 3.7.15 (GH-24106)
authorErlend Egeberg Aasland <erlend.aasland@innova.no>
Wed, 6 Jan 2021 00:02:43 +0000 (01:02 +0100)
committerGitHub <noreply@github.com>
Wed, 6 Jan 2021 00:02:43 +0000 (02:02 +0200)
Doc/library/sqlite3.rst
Doc/whatsnew/3.10.rst
Lib/sqlite3/test/dbapi.py
Lib/sqlite3/test/hooks.py
Misc/NEWS.d/next/Library/2021-01-05-00-52-30.bpo-40810.JxQqPe.rst [new file with mode: 0644]
Modules/_sqlite/connection.c
Modules/_sqlite/module.c
Modules/_sqlite/util.h
setup.py

index 950df60b2027defae00649020a6053936bfc1235..5f9a26a7bb16ca1599b1d06f8921077b0b0a9032 100644 (file)
@@ -19,7 +19,7 @@ PostgreSQL or Oracle.
 
 The sqlite3 module was written by Gerhard Häring.  It provides a SQL interface
 compliant with the DB-API 2.0 specification described by :pep:`249`, and
-requires SQLite 3.7.3 or newer.
+requires SQLite 3.7.15 or newer.
 
 To use the module, you must first create a :class:`Connection` object that
 represents the database.  Here the data will be stored in the
index 4181eba81cf13307d71e8879461d88dc5170d92e..444f1326e5bd2e696f9d6cfeefd5867f39cd7c44 100644 (file)
@@ -577,13 +577,12 @@ CPython bytecode changes
 Build Changes
 =============
 
-
 * The C99 functions :c:func:`snprintf` and :c:func:`vsnprintf` are now required
   to build Python.
   (Contributed by Victor Stinner in :issue:`36020`.)
 
-* :mod:`sqlite3` requires SQLite 3.7.3 or higher.
-  (Contributed by Sergey Fedoseev and Erlend E. Aasland :issue:`40744`.)
+* :mod:`sqlite3` requires SQLite 3.7.15 or higher. (Contributed by Sergey Fedoseev
+  and Erlend E. Aasland :issue:`40744` and :issue:`40810`.)
 
 * The :mod:`atexit` module must now always be built as a built-in module.
   (Contributed by Victor Stinner in :issue:`42639`.)
index 7867bf361e5ac6f659f7495e49b29ff63f9d7f99..2b85ef99f0233df8245d3df0c42c4b02bc374155 100644 (file)
@@ -172,10 +172,6 @@ class ConnectionTests(unittest.TestCase):
             cx.execute('create table test(id integer)')
 
     def CheckOpenUri(self):
-        if sqlite.sqlite_version_info < (3, 7, 7):
-            with self.assertRaises(sqlite.NotSupportedError):
-                sqlite.connect(':memory:', uri=True)
-            return
         self.addCleanup(unlink, TESTFN)
         with sqlite.connect(TESTFN) as cx:
             cx.execute('create table test(id integer)')
index 6c1aaa2d601617cf69ead077d91dcc35348d9867..2e620ecdf864cb91a577e9724108dbfdffe0a226 100644 (file)
@@ -260,14 +260,6 @@ class TraceCallbackTests(unittest.TestCase):
         cur.execute(queries[0])
         con2.execute("create table bar(x)")
         cur.execute(queries[1])
-
-        # Extract from SQLite 3.7.15 changelog:
-        # Avoid invoking the sqlite3_trace() callback multiple times when a
-        # statement is automatically reprepared due to SQLITE_SCHEMA errors.
-        #
-        # See bpo-40810
-        if sqlite.sqlite_version_info < (3, 7, 15):
-            queries.append(queries[-1])
         self.assertEqual(traced_statements, queries)
 
 
diff --git a/Misc/NEWS.d/next/Library/2021-01-05-00-52-30.bpo-40810.JxQqPe.rst b/Misc/NEWS.d/next/Library/2021-01-05-00-52-30.bpo-40810.JxQqPe.rst
new file mode 100644 (file)
index 0000000..61d8780
--- /dev/null
@@ -0,0 +1 @@
+Require SQLite 3.7.15 or newer. Patch by Erlend E. Aasland.
index 1e23daca445582ff00db28967af6329955fc4044..dbe5dd1ec13fae0e561e2aa722069e16c6018078 100644 (file)
@@ -233,7 +233,7 @@ void pysqlite_connection_dealloc(pysqlite_Connection* self)
 
     /* Clean up if user has not called .close() explicitly. */
     if (self->db) {
-        SQLITE3_CLOSE(self->db);
+        sqlite3_close_v2(self->db);
     }
 
     Py_XDECREF(self->isolation_level);
@@ -338,7 +338,7 @@ pysqlite_connection_close_impl(pysqlite_Connection *self)
     pysqlite_do_all_statements(self, ACTION_FINALIZE, 1);
 
     if (self->db) {
-        rc = SQLITE3_CLOSE(self->db);
+        rc = sqlite3_close_v2(self->db);
 
         if (rc != SQLITE_OK) {
             _pysqlite_seterror(self->db, NULL);
@@ -1687,33 +1687,7 @@ pysqlite_connection_backup_impl(pysqlite_Connection *self,
         if (rc == SQLITE_NOMEM) {
             (void)PyErr_NoMemory();
         } else {
-#if SQLITE_VERSION_NUMBER > 3007015
             PyErr_SetString(pysqlite_OperationalError, sqlite3_errstr(rc));
-#else
-            switch (rc) {
-                case SQLITE_ERROR:
-                    /* Description of SQLITE_ERROR in SQLite 3.7.14 and older
-                       releases. */
-                    PyErr_SetString(pysqlite_OperationalError,
-                                    "SQL logic error or missing database");
-                    break;
-                case SQLITE_READONLY:
-                    PyErr_SetString(pysqlite_OperationalError,
-                                    "attempt to write a readonly database");
-                    break;
-                case SQLITE_BUSY:
-                    PyErr_SetString(pysqlite_OperationalError, "database is locked");
-                    break;
-                case SQLITE_LOCKED:
-                    PyErr_SetString(pysqlite_OperationalError,
-                                    "database table is locked");
-                    break;
-                default:
-                    PyErr_Format(pysqlite_OperationalError,
-                                 "unrecognized error code: %d", rc);
-                    break;
-            }
-#endif
         }
     }
 
index cd2eb576c7b214a6914cb237a6b8592054a75fac..6bfb1b73f823911c7abfe0d055d017e3794c4f6c 100644 (file)
@@ -29,8 +29,8 @@
 #include "microprotocols.h"
 #include "row.h"
 
-#if SQLITE_VERSION_NUMBER < 3007003
-#error "SQLite 3.7.3 or higher required"
+#if SQLITE_VERSION_NUMBER < 3007015
+#error "SQLite 3.7.15 or higher required"
 #endif
 
 #include "clinic/module.c.h"
@@ -365,8 +365,8 @@ PyMODINIT_FUNC PyInit__sqlite3(void)
 {
     PyObject *module;
 
-    if (sqlite3_libversion_number() < 3007003) {
-        PyErr_SetString(PyExc_ImportError, MODULE_NAME ": SQLite 3.7.3 or higher required");
+    if (sqlite3_libversion_number() < 3007015) {
+        PyErr_SetString(PyExc_ImportError, MODULE_NAME ": SQLite 3.7.15 or higher required");
         return NULL;
     }
 
index c5a220e9b0aa7206e4c91a1f15b2a6eafb6260ea..cff31cda9578a068fedd430aaa6ec8f719cadbff 100644 (file)
@@ -39,10 +39,4 @@ int _pysqlite_seterror(sqlite3* db, sqlite3_stmt* st);
 
 sqlite_int64 _pysqlite_long_as_int64(PyObject * value);
 
-#if SQLITE_VERSION_NUMBER >= 3007014
-#define SQLITE3_CLOSE sqlite3_close_v2
-#else
-#define SQLITE3_CLOSE sqlite3_close
-#endif
-
 #endif
index 8598d2aa5dbceb0837e5135095b58267d9decec9..ddc0bd067d4e4fce9db237f9f254aba2035f9765 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -1444,8 +1444,7 @@ class PyBuildExt(build_ext):
                              ]
         if CROSS_COMPILING:
             sqlite_inc_paths = []
-        # We need to find >= sqlite version 3.7.3, for sqlite3_create_function_v2()
-        MIN_SQLITE_VERSION_NUMBER = (3, 7, 3)
+        MIN_SQLITE_VERSION_NUMBER = (3, 7, 15)  # Issue 40810
         MIN_SQLITE_VERSION = ".".join([str(x)
                                     for x in MIN_SQLITE_VERSION_NUMBER])