]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-92206: Move pysqlite_step() to Modules/_sqlite/cursor.c (#92207)
authorErlend Egeberg Aasland <erlend.aasland@protonmail.com>
Tue, 3 May 2022 03:45:04 +0000 (21:45 -0600)
committerGitHub <noreply@github.com>
Tue, 3 May 2022 03:45:04 +0000 (21:45 -0600)
Modules/_sqlite/cursor.c
Modules/_sqlite/util.c
Modules/_sqlite/util.h

index e48a95867298bcfaccd04c6318ec3637858e0bbf..861704f95cc83c96e7c6818a0c449106293c3345 100644 (file)
@@ -454,6 +454,18 @@ get_statement_from_cache(pysqlite_Cursor *self, PyObject *operation)
     return PyObject_Vectorcall(cache, args + 1, nargsf, NULL);
 }
 
+static inline int
+stmt_step(sqlite3_stmt *statement)
+{
+    int rc;
+
+    Py_BEGIN_ALLOW_THREADS
+    rc = sqlite3_step(statement);
+    Py_END_ALLOW_THREADS
+
+    return rc;
+}
+
 PyObject *
 _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject* operation, PyObject* second_argument)
 {
@@ -570,7 +582,7 @@ _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject* operation
             goto error;
         }
 
-        rc = pysqlite_step(self->statement->st);
+        rc = stmt_step(self->statement->st);
         if (rc != SQLITE_DONE && rc != SQLITE_ROW) {
             if (PyErr_Occurred()) {
                 /* there was an error that occurred in a user-defined callback */
@@ -799,7 +811,7 @@ pysqlite_cursor_iternext(pysqlite_Cursor *self)
     if (row == NULL) {
         return NULL;
     }
-    int rc = pysqlite_step(stmt);
+    int rc = stmt_step(stmt);
     if (rc == SQLITE_DONE) {
         (void)pysqlite_statement_reset(self->statement);
     }
index 113b581bfac7351295e7260307050a508106e73b..37b2dd6cb29f4e4874bdc26177a5dec4b99ac628 100644 (file)
 #include "module.h"
 #include "connection.h"
 
-int
-pysqlite_step(sqlite3_stmt *statement)
-{
-    int rc;
-
-    Py_BEGIN_ALLOW_THREADS
-    rc = sqlite3_step(statement);
-    Py_END_ALLOW_THREADS
-
-    return rc;
-}
-
 // Returns non-NULL if a new exception should be raised
 static PyObject *
 get_exception_class(pysqlite_state *state, int errorcode)
index 5eee3fac6f114e2171ee53e3ab9af2612fd8cfcf..a22bcd82d2a05bbd7581a187f0b8a0ae746cde77 100644 (file)
@@ -29,8 +29,6 @@
 #include "sqlite3.h"
 #include "connection.h"
 
-int pysqlite_step(sqlite3_stmt *statement);
-
 /**
  * Checks the SQLite error code and sets the appropriate DB-API exception.
  * Returns the error code (0 means no error occurred).