[Python-checkins] r59184 - python/branches/release25-maint/Modules/_sqlite/statement.c python/branches/release25-maint/Modules/_sqlite/util.c
gerhard.haering
python-checkins at python.org
Sun Nov 25 18:40:35 CET 2007
Author: gerhard.haering
Date: Sun Nov 25 18:40:35 2007
New Revision: 59184
Modified:
python/branches/release25-maint/Modules/_sqlite/statement.c
python/branches/release25-maint/Modules/_sqlite/util.c
Log:
- 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.
Modified: python/branches/release25-maint/Modules/_sqlite/statement.c
==============================================================================
--- python/branches/release25-maint/Modules/_sqlite/statement.c (original)
+++ python/branches/release25-maint/Modules/_sqlite/statement.c Sun Nov 25 18:40:35 2007
@@ -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);
Modified: python/branches/release25-maint/Modules/_sqlite/util.c
==============================================================================
--- python/branches/release25-maint/Modules/_sqlite/util.c (original)
+++ python/branches/release25-maint/Modules/_sqlite/util.c Sun Nov 25 18:40:35 2007
@@ -29,9 +29,15 @@
{
int rc;
- Py_BEGIN_ALLOW_THREADS
- rc = sqlite3_step(statement);
- Py_END_ALLOW_THREADS
+ if (statement == NULL) {
+ /* this is a workaround for SQLite 3.5 and later. it now apparently
+ * returns NULL for "no-operation" statements */
+ rc = SQLITE_OK;
+ } else {
+ Py_BEGIN_ALLOW_THREADS
+ rc = sqlite3_step(statement);
+ Py_END_ALLOW_THREADS
+ }
return rc;
}
More information about the Python-checkins
mailing list