diff options
author | Erlend Egeberg Aasland <erlend.aasland@protonmail.com> | 2022-05-03 03:45:04 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-03 03:45:04 (GMT) |
commit | e846fe3fc189ff54413382611ee36e41c2f0776b (patch) | |
tree | fb1e7e50be75b993c875a2f09442a24d072aafd7 /Modules | |
parent | 39e6b8ae6a5b49bb23746fdcc354d148ff2d98e3 (diff) | |
download | cpython-e846fe3fc189ff54413382611ee36e41c2f0776b.zip cpython-e846fe3fc189ff54413382611ee36e41c2f0776b.tar.gz cpython-e846fe3fc189ff54413382611ee36e41c2f0776b.tar.bz2 |
gh-92206: Move pysqlite_step() to Modules/_sqlite/cursor.c (#92207)
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_sqlite/cursor.c | 16 | ||||
-rw-r--r-- | Modules/_sqlite/util.c | 12 | ||||
-rw-r--r-- | Modules/_sqlite/util.h | 2 |
3 files changed, 14 insertions, 16 deletions
diff --git a/Modules/_sqlite/cursor.c b/Modules/_sqlite/cursor.c index e48a958..861704f 100644 --- a/Modules/_sqlite/cursor.c +++ b/Modules/_sqlite/cursor.c @@ -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); } diff --git a/Modules/_sqlite/util.c b/Modules/_sqlite/util.c index 113b581..37b2dd6 100644 --- a/Modules/_sqlite/util.c +++ b/Modules/_sqlite/util.c @@ -24,18 +24,6 @@ #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) diff --git a/Modules/_sqlite/util.h b/Modules/_sqlite/util.h index 5eee3fa..a22bcd8 100644 --- a/Modules/_sqlite/util.h +++ b/Modules/_sqlite/util.h @@ -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). |