mirror of
https://github.com/python/cpython.git
synced 2025-10-17 12:18:23 +00:00
gh-105875: Require SQLite 3.15.2 or newer (#105876)
SQLite 3.15.2 was released 2016-11-28.
This commit is contained in:
parent
bc07c8f096
commit
6849acb3fe
13 changed files with 61 additions and 202 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue