Commit 2b702713 authored by Gerhard Häring's avatar Gerhard Häring

Forward-port of commit 59184.

- Backported a workaround for a bug in SQLite 3.2.x/3.3.x versions where a
  statement recompilation with no bound parameters lead to a segfault
- Backported a fix necessary because of an SQLite API change in version
  3.5.
  This prevents segfaults when executing empty queries, like our test suite
  does
parent 7587210f
...@@ -237,7 +237,11 @@ int pysqlite_statement_recompile(pysqlite_Statement* self, PyObject* params) ...@@ -237,7 +237,11 @@ int pysqlite_statement_recompile(pysqlite_Statement* self, PyObject* params)
*/ */
#ifdef SQLITE_VERSION_NUMBER #ifdef SQLITE_VERSION_NUMBER
#if SQLITE_VERSION_NUMBER >= 3002002 #if SQLITE_VERSION_NUMBER >= 3002002
(void)sqlite3_transfer_bindings(self->st, new_st); /* The check for the number of parameters is necessary to not trigger a
* bug in certain SQLite versions (experienced in 3.2.8 and 3.3.4). */
if (sqlite3_bind_parameter_count(self->st) > 0) {
(void)sqlite3_transfer_bindings(self->st, new_st);
}
#endif #endif
#else #else
statement_bind_parameters(self, params); statement_bind_parameters(self, params);
......
...@@ -28,9 +28,15 @@ int _sqlite_step_with_busyhandler(sqlite3_stmt* statement, pysqlite_Connection* ...@@ -28,9 +28,15 @@ int _sqlite_step_with_busyhandler(sqlite3_stmt* statement, pysqlite_Connection*
{ {
int rc; int rc;
Py_BEGIN_ALLOW_THREADS if (statement == NULL) {
rc = sqlite3_step(statement); /* this is a workaround for SQLite 3.5 and later. it now apparently
Py_END_ALLOW_THREADS * returns NULL for "no-operation" statements */
rc = SQLITE_OK;
} else {
Py_BEGIN_ALLOW_THREADS
rc = sqlite3_step(statement);
Py_END_ALLOW_THREADS
}
return rc; return rc;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment