goto error;
}
- if (rc == SQLITE_ROW || rc == SQLITE_DONE) {
- Py_BEGIN_ALLOW_THREADS
- numcols = sqlite3_column_count(self->statement->st);
- Py_END_ALLOW_THREADS
- if (self->description == Py_None && numcols > 0) {
- Py_SETREF(self->description, PyTuple_New(numcols));
- if (!self->description) {
+ assert(rc == SQLITE_ROW || rc == SQLITE_DONE);
+ Py_BEGIN_ALLOW_THREADS
+ numcols = sqlite3_column_count(self->statement->st);
+ Py_END_ALLOW_THREADS
+
+ if (self->description == Py_None && numcols > 0) {
+ Py_SETREF(self->description, PyTuple_New(numcols));
+ if (!self->description) {
+ goto error;
+ }
+ for (i = 0; i < numcols; i++) {
+ descriptor = PyTuple_New(7);
+ if (!descriptor) {
goto error;
}
- for (i = 0; i < numcols; i++) {
- descriptor = PyTuple_New(7);
- if (!descriptor) {
- goto error;
- }
- PyTuple_SetItem(descriptor, 0, _pysqlite_build_column_name(sqlite3_column_name(self->statement->st, i)));
- Py_INCREF(Py_None); PyTuple_SetItem(descriptor, 1, Py_None);
- Py_INCREF(Py_None); PyTuple_SetItem(descriptor, 2, Py_None);
- Py_INCREF(Py_None); PyTuple_SetItem(descriptor, 3, Py_None);
- Py_INCREF(Py_None); PyTuple_SetItem(descriptor, 4, Py_None);
- Py_INCREF(Py_None); PyTuple_SetItem(descriptor, 5, Py_None);
- Py_INCREF(Py_None); PyTuple_SetItem(descriptor, 6, Py_None);
- PyTuple_SetItem(self->description, i, descriptor);
- }
+ PyTuple_SetItem(descriptor, 0, _pysqlite_build_column_name(sqlite3_column_name(self->statement->st, i)));
+ Py_INCREF(Py_None); PyTuple_SetItem(descriptor, 1, Py_None);
+ Py_INCREF(Py_None); PyTuple_SetItem(descriptor, 2, Py_None);
+ Py_INCREF(Py_None); PyTuple_SetItem(descriptor, 3, Py_None);
+ Py_INCREF(Py_None); PyTuple_SetItem(descriptor, 4, Py_None);
+ Py_INCREF(Py_None); PyTuple_SetItem(descriptor, 5, Py_None);
+ Py_INCREF(Py_None); PyTuple_SetItem(descriptor, 6, Py_None);
+ PyTuple_SetItem(self->description, i, descriptor);
}
}
}
}
-int pysqlite_statement_recompile(pysqlite_Statement* self, PyObject* params)
-{
- const char* tail;
- int rc;
- const char* sql_cstr;
- Py_ssize_t sql_len;
- sqlite3_stmt* new_st;
-
- sql_cstr = PyUnicode_AsUTF8AndSize(self->sql, &sql_len);
- if (sql_cstr == NULL) {
- rc = PYSQLITE_SQL_WRONG_TYPE;
- return rc;
- }
-
- Py_BEGIN_ALLOW_THREADS
- rc = sqlite3_prepare_v2(self->db,
- sql_cstr,
- -1,
- &new_st,
- &tail);
- Py_END_ALLOW_THREADS
-
- if (rc == SQLITE_OK) {
- /* The efficient sqlite3_transfer_bindings is only available in SQLite
- * version 3.2.2 or later. For older SQLite releases, that might not
- * even define SQLITE_VERSION_NUMBER, we do it the manual way.
- */
- #ifdef SQLITE_VERSION_NUMBER
- #if SQLITE_VERSION_NUMBER >= 3002002
- /* 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);
- #endif
-
- (void)sqlite3_finalize(self->st);
- self->st = new_st;
- }
-
- return rc;
-}
-
int pysqlite_statement_finalize(pysqlite_Statement* self)
{
int rc;
int pysqlite_statement_bind_parameter(pysqlite_Statement* self, int pos, PyObject* parameter);
void pysqlite_statement_bind_parameters(pysqlite_Statement* self, PyObject* parameters);
-int pysqlite_statement_recompile(pysqlite_Statement* self, PyObject* parameters);
int pysqlite_statement_finalize(pysqlite_Statement* self);
int pysqlite_statement_reset(pysqlite_Statement* self);
void pysqlite_statement_mark_dirty(pysqlite_Statement* self);