Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions Modules/_sqlite/cursor.c
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject* operation
goto error;
}

if (self->statement->in_use) {
if (sqlite3_stmt_busy(self->statement->st)) {
Py_SETREF(self->statement,
pysqlite_statement_create(self->connection, operation));
if (self->statement == NULL) {
Expand All @@ -542,7 +542,6 @@ _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject* operation
}

pysqlite_statement_reset(self->statement);
pysqlite_statement_mark_dirty(self->statement);

/* We start a transaction implicitly before a DML statement.
SELECT is the only exception. See #9924. */
Expand All @@ -561,8 +560,6 @@ _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject* operation
break;
}

pysqlite_statement_mark_dirty(self->statement);

pysqlite_statement_bind_parameters(self->statement, parameters);
if (PyErr_Occurred()) {
goto error;
Expand Down
14 changes: 1 addition & 13 deletions Modules/_sqlite/statement.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ pysqlite_statement_create(pysqlite_Connection *connection, PyObject *sql)
self->db = connection->db;
self->st = NULL;
self->sql = Py_NewRef(sql);
self->in_use = 0;
self->is_dml = 0;
self->in_weakreflist = NULL;

Expand Down Expand Up @@ -366,8 +365,6 @@ int pysqlite_statement_finalize(pysqlite_Statement* self)
self->st = NULL;
}

self->in_use = 0;

return rc;
}

Expand All @@ -377,24 +374,15 @@ int pysqlite_statement_reset(pysqlite_Statement* self)

rc = SQLITE_OK;

if (self->in_use && self->st) {
if (self->st) {
Py_BEGIN_ALLOW_THREADS
rc = sqlite3_reset(self->st);
Py_END_ALLOW_THREADS

if (rc == SQLITE_OK) {
self->in_use = 0;
}
}

return rc;
}

void pysqlite_statement_mark_dirty(pysqlite_Statement* self)
{
self->in_use = 1;
}

static void
stmt_dealloc(pysqlite_Statement *self)
{
Expand Down
2 changes: 0 additions & 2 deletions Modules/_sqlite/statement.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ typedef struct
sqlite3* db;
sqlite3_stmt* st;
PyObject* sql;
int in_use;
int is_dml;
PyObject* in_weakreflist; /* List of weak references */
} pysqlite_Statement;
Expand All @@ -49,7 +48,6 @@ void pysqlite_statement_bind_parameters(pysqlite_Statement* self, PyObject* para

int pysqlite_statement_finalize(pysqlite_Statement* self);
int pysqlite_statement_reset(pysqlite_Statement* self);
void pysqlite_statement_mark_dirty(pysqlite_Statement* self);

int pysqlite_statement_setup_types(PyObject *module);

Expand Down