]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-92206: Improve scoping of sqlite3 statement helper (#92260)
authorErlend Egeberg Aasland <erlend.aasland@protonmail.com>
Tue, 3 May 2022 22:07:11 +0000 (16:07 -0600)
committerGitHub <noreply@github.com>
Tue, 3 May 2022 22:07:11 +0000 (16:07 -0600)
Modules/_sqlite/cursor.c
Modules/_sqlite/statement.c
Modules/_sqlite/statement.h

index 16bceef2e50242df5757eaf2175fdaeec34e3128..87fed2e46e10e436b8a7652c929491190832b1e3 100644 (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 *
 _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);
-    pysqlite_statement_mark_dirty(self->statement);
+    stmt_mark_dirty(self->statement);
 
     /* We start a transaction implicitly before a DML statement.
        SELECT is the only exception. See #9924. */
@@ -863,7 +869,7 @@ _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject* operation
             break;
         }
 
-        pysqlite_statement_mark_dirty(self->statement);
+        stmt_mark_dirty(self->statement);
 
         bind_parameters(state, self->statement, parameters);
         if (PyErr_Occurred()) {
index d0a404f13b200ab4d1e03386e92b5d5da42339da..f9cb70f0ef146c57762296bb71241f9c860af788 100644 (file)
@@ -116,11 +116,6 @@ error:
     return NULL;
 }
 
-void pysqlite_statement_mark_dirty(pysqlite_Statement* self)
-{
-    self->in_use = 1;
-}
-
 static void
 stmt_dealloc(pysqlite_Statement *self)
 {
index 88d56779854beb904a1cdc6c54ec2a4fe90ebc71..5e61227424bafaf0b7587860a9153313e09eb26d 100644 (file)
@@ -39,8 +39,6 @@ typedef struct
 
 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);
 
 #endif