summaryrefslogtreecommitdiffstats
path: root/Modules/_sqlite
diff options
context:
space:
mode:
authorErlend E. Aasland <erlend.aasland@protonmail.com>2023-06-18 22:29:08 (GMT)
committerGitHub <noreply@github.com>2023-06-18 22:29:08 (GMT)
commit6849acb3feacda63ee43f1dc9be28fac1075ca7d (patch)
tree6d188e17bbf6563945a32860ae11e5c47a55941b /Modules/_sqlite
parentbc07c8f096791d678ca5c1e3486cb9648f7a027b (diff)
downloadcpython-6849acb3feacda63ee43f1dc9be28fac1075ca7d.zip
cpython-6849acb3feacda63ee43f1dc9be28fac1075ca7d.tar.gz
cpython-6849acb3feacda63ee43f1dc9be28fac1075ca7d.tar.bz2
gh-105875: Require SQLite 3.15.2 or newer (#105876)
SQLite 3.15.2 was released 2016-11-28.
Diffstat (limited to 'Modules/_sqlite')
-rw-r--r--Modules/_sqlite/blob.c8
-rw-r--r--Modules/_sqlite/connection.c59
-rw-r--r--Modules/_sqlite/module.c44
3 files changed, 4 insertions, 107 deletions
diff --git a/Modules/_sqlite/blob.c b/Modules/_sqlite/blob.c
index 76d261b..3096fb0 100644
--- a/Modules/_sqlite/blob.c
+++ b/Modules/_sqlite/blob.c
@@ -108,14 +108,6 @@ static void
blob_seterror(pysqlite_Blob *self, int rc)
{
assert(self->connection != NULL);
-#if SQLITE_VERSION_NUMBER < 3008008
- // SQLite pre 3.8.8 does not set this blob error on the connection
- if (rc == SQLITE_ABORT) {
- PyErr_SetString(self->connection->OperationalError,
- "Cannot operate on an expired blob handle");
- return;
- }
-#endif
_pysqlite_seterror(self->connection->state, self->connection->db);
}
diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c
index 82d23c2..d12d655 100644
--- a/Modules/_sqlite/connection.c
+++ b/Modules/_sqlite/connection.c
@@ -32,10 +32,6 @@
#include <stdbool.h>
-#if SQLITE_VERSION_NUMBER >= 3014000
-#define HAVE_TRACE_V2
-#endif
-
#if SQLITE_VERSION_NUMBER >= 3025000
#define HAVE_WINDOW_FUNCTIONS
#endif
@@ -401,11 +397,7 @@ free_callback_contexts(pysqlite_Connection *self)
static void
remove_callbacks(sqlite3 *db)
{
-#ifdef HAVE_TRACE_V2
sqlite3_trace_v2(db, SQLITE_TRACE_STMT, 0, 0);
-#else
- sqlite3_trace(db, 0, (void*)0);
-#endif
sqlite3_progress_handler(db, 0, 0, (void *)0);
(void)sqlite3_set_authorizer(db, NULL, NULL);
}
@@ -1086,18 +1078,7 @@ pysqlite_connection_create_function_impl(pysqlite_Connection *self,
}
if (deterministic) {
-#if SQLITE_VERSION_NUMBER < 3008003
- PyErr_SetString(self->NotSupportedError,
- "deterministic=True requires SQLite 3.8.3 or higher");
- return NULL;
-#else
- if (sqlite3_libversion_number() < 3008003) {
- PyErr_SetString(self->NotSupportedError,
- "deterministic=True requires SQLite 3.8.3 or higher");
- return NULL;
- }
flags |= SQLITE_DETERMINISTIC;
-#endif
}
callback_context *ctx = create_callback_context(cls, func);
if (ctx == NULL) {
@@ -1376,7 +1357,6 @@ progress_callback(void *ctx)
return rc;
}
-#ifdef HAVE_TRACE_V2
/*
* From https://sqlite.org/c3ref/trace_v2.html:
* The integer return value from the callback is currently ignored, though this
@@ -1385,16 +1365,10 @@ progress_callback(void *ctx)
*/
static int
trace_callback(unsigned int type, void *ctx, void *stmt, void *sql)
-#else
-static void
-trace_callback(void *ctx, const char *sql)
-#endif
{
-#ifdef HAVE_TRACE_V2
if (type != SQLITE_TRACE_STMT) {
return 0;
}
-#endif
PyGILState_STATE gilstate = PyGILState_Ensure();
@@ -1403,7 +1377,6 @@ trace_callback(void *ctx, const char *sql)
assert(state != NULL);
PyObject *py_statement = NULL;
-#ifdef HAVE_TRACE_V2
const char *expanded_sql = sqlite3_expanded_sql((sqlite3_stmt *)stmt);
if (expanded_sql == NULL) {
sqlite3 *db = sqlite3_db_handle((sqlite3_stmt *)stmt);
@@ -1423,15 +1396,6 @@ trace_callback(void *ctx, const char *sql)
py_statement = PyUnicode_FromString(expanded_sql);
sqlite3_free((void *)expanded_sql);
}
-#else
- if (sql == NULL) {
- PyErr_SetString(state->DataError,
- "Expanded SQL string exceeds the maximum string length");
- print_or_clear_traceback((callback_context *)ctx);
- goto exit;
- }
- py_statement = PyUnicode_FromString(sql);
-#endif
if (py_statement) {
PyObject *callable = ((callback_context *)ctx)->callable;
PyObject *ret = PyObject_CallOneArg(callable, py_statement);
@@ -1444,9 +1408,7 @@ trace_callback(void *ctx, const char *sql)
exit:
PyGILState_Release(gilstate);
-#ifdef HAVE_TRACE_V2
return 0;
-#endif
}
/*[clinic input]
@@ -1556,11 +1518,7 @@ pysqlite_connection_set_trace_callback_impl(pysqlite_Connection *self,
* - https://sqlite.org/c3ref/c_trace.html
* - https://sqlite.org/c3ref/trace_v2.html
*/
-#ifdef HAVE_TRACE_V2
sqlite3_trace_v2(self->db, SQLITE_TRACE_STMT, 0, 0);
-#else
- sqlite3_trace(self->db, 0, (void*)0);
-#endif
set_callback_context(&self->trace_ctx, NULL);
}
else {
@@ -1568,11 +1526,7 @@ pysqlite_connection_set_trace_callback_impl(pysqlite_Connection *self,
if (ctx == NULL) {
return NULL;
}
-#ifdef HAVE_TRACE_V2
sqlite3_trace_v2(self->db, SQLITE_TRACE_STMT, trace_callback, ctx);
-#else
- sqlite3_trace(self->db, trace_callback, ctx);
-#endif
set_callback_context(&self->trace_ctx, ctx);
}
@@ -2000,15 +1954,6 @@ pysqlite_connection_backup_impl(pysqlite_Connection *self,
return NULL;
}
-#if SQLITE_VERSION_NUMBER < 3008008
- /* Since 3.8.8 this is already done, per commit
- https://www.sqlite.org/src/info/169b5505498c0a7e */
- if (!sqlite3_get_autocommit(target->db)) {
- PyErr_SetString(self->OperationalError, "target is in transaction");
- return NULL;
- }
-#endif
-
if (progress != Py_None && !PyCallable_Check(progress)) {
PyErr_SetString(PyExc_TypeError, "progress argument must be a callable");
return NULL;
@@ -2371,12 +2316,8 @@ is_int_config(const int op)
switch (op) {
case SQLITE_DBCONFIG_ENABLE_FKEY:
case SQLITE_DBCONFIG_ENABLE_TRIGGER:
-#if SQLITE_VERSION_NUMBER >= 3012002
case SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER:
-#endif
-#if SQLITE_VERSION_NUMBER >= 3013000
case SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION:
-#endif
#if SQLITE_VERSION_NUMBER >= 3016000
case SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE:
#endif
diff --git a/Modules/_sqlite/module.c b/Modules/_sqlite/module.c
index 27bd42f..ea4d8c5 100644
--- a/Modules/_sqlite/module.c
+++ b/Modules/_sqlite/module.c
@@ -29,8 +29,8 @@
#include "row.h"
#include "blob.h"
-#if SQLITE_VERSION_NUMBER < 3007015
-#error "SQLite 3.7.15 or higher required"
+#if SQLITE_VERSION_NUMBER < 3015002
+#error "SQLite 3.15.2 or higher required"
#endif
#define clinic_state() (pysqlite_get_state(module))
@@ -245,12 +245,6 @@ static PyMethodDef module_methods[] = {
/* SQLite C API result codes. See also:
* - https://www.sqlite.org/c3ref/c_abort_rollback.html
- * - https://sqlite.org/changes.html#version_3_3_8
- * - https://sqlite.org/changes.html#version_3_7_16
- * - https://sqlite.org/changes.html#version_3_7_17
- * - https://sqlite.org/changes.html#version_3_8_0
- * - https://sqlite.org/changes.html#version_3_8_3
- * - https://sqlite.org/changes.html#version_3_14
*
* Note: the SQLite changelogs rarely mention new result codes, so in order to
* keep the 'error_codes' table in sync with SQLite, we must manually inspect
@@ -294,10 +288,8 @@ static const struct {
DECLARE_ERROR_CODE(SQLITE_ROW),
DECLARE_ERROR_CODE(SQLITE_SCHEMA),
DECLARE_ERROR_CODE(SQLITE_TOOBIG),
-#if SQLITE_VERSION_NUMBER >= 3007017
DECLARE_ERROR_CODE(SQLITE_NOTICE),
DECLARE_ERROR_CODE(SQLITE_WARNING),
-#endif
// Extended result code list
DECLARE_ERROR_CODE(SQLITE_ABORT_ROLLBACK),
DECLARE_ERROR_CODE(SQLITE_BUSY_RECOVERY),
@@ -331,7 +323,6 @@ static const struct {
DECLARE_ERROR_CODE(SQLITE_LOCKED_SHAREDCACHE),
DECLARE_ERROR_CODE(SQLITE_READONLY_CANTLOCK),
DECLARE_ERROR_CODE(SQLITE_READONLY_RECOVERY),
-#if SQLITE_VERSION_NUMBER >= 3007016
DECLARE_ERROR_CODE(SQLITE_CONSTRAINT_CHECK),
DECLARE_ERROR_CODE(SQLITE_CONSTRAINT_COMMITHOOK),
DECLARE_ERROR_CODE(SQLITE_CONSTRAINT_FOREIGNKEY),
@@ -342,39 +333,20 @@ static const struct {
DECLARE_ERROR_CODE(SQLITE_CONSTRAINT_UNIQUE),
DECLARE_ERROR_CODE(SQLITE_CONSTRAINT_VTAB),
DECLARE_ERROR_CODE(SQLITE_READONLY_ROLLBACK),
-#endif
-#if SQLITE_VERSION_NUMBER >= 3007017
DECLARE_ERROR_CODE(SQLITE_IOERR_MMAP),
DECLARE_ERROR_CODE(SQLITE_NOTICE_RECOVER_ROLLBACK),
DECLARE_ERROR_CODE(SQLITE_NOTICE_RECOVER_WAL),
-#endif
-#if SQLITE_VERSION_NUMBER >= 3008000
DECLARE_ERROR_CODE(SQLITE_BUSY_SNAPSHOT),
DECLARE_ERROR_CODE(SQLITE_IOERR_GETTEMPPATH),
DECLARE_ERROR_CODE(SQLITE_WARNING_AUTOINDEX),
-#endif
-#if SQLITE_VERSION_NUMBER >= 3008001
DECLARE_ERROR_CODE(SQLITE_CANTOPEN_CONVPATH),
DECLARE_ERROR_CODE(SQLITE_IOERR_CONVPATH),
-#endif
-#if SQLITE_VERSION_NUMBER >= 3008002
DECLARE_ERROR_CODE(SQLITE_CONSTRAINT_ROWID),
-#endif
-#if SQLITE_VERSION_NUMBER >= 3008003
DECLARE_ERROR_CODE(SQLITE_READONLY_DBMOVED),
-#endif
-#if SQLITE_VERSION_NUMBER >= 3008007
DECLARE_ERROR_CODE(SQLITE_AUTH_USER),
-#endif
-#if SQLITE_VERSION_NUMBER >= 3009000
DECLARE_ERROR_CODE(SQLITE_IOERR_VNODE),
-#endif
-#if SQLITE_VERSION_NUMBER >= 3010000
DECLARE_ERROR_CODE(SQLITE_IOERR_AUTH),
-#endif
-#if SQLITE_VERSION_NUMBER >= 3014001
DECLARE_ERROR_CODE(SQLITE_OK_LOAD_PERMANENTLY),
-#endif
#if SQLITE_VERSION_NUMBER >= 3021000
DECLARE_ERROR_CODE(SQLITE_IOERR_BEGIN_ATOMIC),
DECLARE_ERROR_CODE(SQLITE_IOERR_COMMIT_ATOMIC),
@@ -481,9 +453,7 @@ add_integer_constants(PyObject *module) {
ADD_INT(SQLITE_DROP_VTABLE);
ADD_INT(SQLITE_FUNCTION);
ADD_INT(SQLITE_SAVEPOINT);
-#if SQLITE_VERSION_NUMBER >= 3008003
ADD_INT(SQLITE_RECURSIVE);
-#endif
// Run-time limit categories
ADD_INT(SQLITE_LIMIT_LENGTH);
ADD_INT(SQLITE_LIMIT_SQL_LENGTH);
@@ -496,9 +466,7 @@ add_integer_constants(PyObject *module) {
ADD_INT(SQLITE_LIMIT_LIKE_PATTERN_LENGTH);
ADD_INT(SQLITE_LIMIT_VARIABLE_NUMBER);
ADD_INT(SQLITE_LIMIT_TRIGGER_DEPTH);
-#if SQLITE_VERSION_NUMBER >= 3008007
ADD_INT(SQLITE_LIMIT_WORKER_THREADS);
-#endif
/*
* Database connection configuration options.
@@ -506,12 +474,8 @@ add_integer_constants(PyObject *module) {
*/
ADD_INT(SQLITE_DBCONFIG_ENABLE_FKEY);
ADD_INT(SQLITE_DBCONFIG_ENABLE_TRIGGER);
-#if SQLITE_VERSION_NUMBER >= 3012002
ADD_INT(SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER);
-#endif
-#if SQLITE_VERSION_NUMBER >= 3013000
ADD_INT(SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION);
-#endif
#if SQLITE_VERSION_NUMBER >= 3016000
ADD_INT(SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE);
#endif
@@ -678,8 +642,8 @@ do { \
static int
module_exec(PyObject *module)
{
- if (sqlite3_libversion_number() < 3007015) {
- PyErr_SetString(PyExc_ImportError, MODULE_NAME ": SQLite 3.7.15 or higher required");
+ if (sqlite3_libversion_number() < 3015002) {
+ PyErr_SetString(PyExc_ImportError, MODULE_NAME ": SQLite 3.15.2 or higher required");
return -1;
}