gh-92206: Improve scoping of sqlite3 statement helper (#92260)

This commit is contained in:
Erlend Egeberg Aasland 2022-05-03 16:07:11 -06:00 committed by GitHub
parent 27e3665715
commit 6b7dcc5607
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 9 deletions

View file

@ -754,6 +754,12 @@ bind_parameters(pysqlite_state *state, pysqlite_Statement *self,
} }
} }
static inline void
stmt_mark_dirty(pysqlite_Statement *self)
{
self->in_use = 1;
}
PyObject * PyObject *
_pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject* operation, PyObject* second_argument) _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject* operation, PyObject* second_argument)
{ {
@ -844,7 +850,7 @@ _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject* operation
} }
stmt_reset(self->statement); stmt_reset(self->statement);
pysqlite_statement_mark_dirty(self->statement); stmt_mark_dirty(self->statement);
/* We start a transaction implicitly before a DML statement. /* We start a transaction implicitly before a DML statement.
SELECT is the only exception. See #9924. */ SELECT is the only exception. See #9924. */
@ -863,7 +869,7 @@ _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject* operation
break; break;
} }
pysqlite_statement_mark_dirty(self->statement); stmt_mark_dirty(self->statement);
bind_parameters(state, self->statement, parameters); bind_parameters(state, self->statement, parameters);
if (PyErr_Occurred()) { if (PyErr_Occurred()) {

View file

@ -116,11 +116,6 @@ error:
return NULL; return NULL;
} }
void pysqlite_statement_mark_dirty(pysqlite_Statement* self)
{
self->in_use = 1;
}
static void static void
stmt_dealloc(pysqlite_Statement *self) stmt_dealloc(pysqlite_Statement *self)
{ {

View file

@ -39,8 +39,6 @@ typedef struct
pysqlite_Statement *pysqlite_statement_create(pysqlite_Connection *connection, PyObject *sql); pysqlite_Statement *pysqlite_statement_create(pysqlite_Connection *connection, PyObject *sql);
void pysqlite_statement_mark_dirty(pysqlite_Statement* self);
int pysqlite_statement_setup_types(PyObject *module); int pysqlite_statement_setup_types(PyObject *module);
#endif #endif