Mercurial > cpython-lru_cache-weakref
diff Modules/_sqlite/statement.c @ 44274:a6d1059f22e2 legacy-trunk
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
| author | Gerhard Häring <gh@ghaering.de> |
|---|---|
| date | Tue, 11 Dec 2007 21:07:40 +0000 |
| parents | 6620a510e9a9 |
| children | 26384b8180c7 |
line wrap: on
line diff
--- a/Modules/_sqlite/statement.c Tue Dec 11 19:35:12 2007 +0000 +++ b/Modules/_sqlite/statement.c Tue Dec 11 21:07:40 2007 +0000 @@ -237,7 +237,11 @@ */ #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);
