summaryrefslogtreecommitdiffstats
path: root/Modules/_sqlite/statement.c
diff options
context:
space:
mode:
authorGerhard Häring <gh@ghaering.de>2007-11-25 17:40:35 (GMT)
committerGerhard Häring <gh@ghaering.de>2007-11-25 17:40:35 (GMT)
commit14fbf29692ab4beaddca40fa39698e02bbf6aa08 (patch)
tree5bc988575b2409d16902fd376f8e25b3f3b6247c /Modules/_sqlite/statement.c
parent664ad76a347cfa798b7229286706edd155c6aaa3 (diff)
downloadcpython-14fbf29692ab4beaddca40fa39698e02bbf6aa08.zip
cpython-14fbf29692ab4beaddca40fa39698e02bbf6aa08.tar.gz
cpython-14fbf29692ab4beaddca40fa39698e02bbf6aa08.tar.bz2
- 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.
Diffstat (limited to 'Modules/_sqlite/statement.c')
-rw-r--r--Modules/_sqlite/statement.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/Modules/_sqlite/statement.c b/Modules/_sqlite/statement.c
index 55923e7..dee811f 100644
--- a/Modules/_sqlite/statement.c
+++ b/Modules/_sqlite/statement.c
@@ -237,7 +237,11 @@ int statement_recompile(Statement* self, PyObject* params)
*/
#ifdef SQLITE_VERSION_NUMBER
#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
#else
statement_bind_parameters(self, params);