summaryrefslogtreecommitdiffstats
path: root/Modules/_sqlite/connection.c
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/connection.c
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/connection.c')
-rw-r--r--Modules/_sqlite/connection.c59
1 files changed, 0 insertions, 59 deletions
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