Skip to content

Commit e846fe3

Browse files
gh-92206: Move pysqlite_step() to Modules/_sqlite/cursor.c (#92207)
1 parent 39e6b8a commit e846fe3

File tree

3 files changed

+14
-16
lines changed

3 files changed

+14
-16
lines changed

Modules/_sqlite/cursor.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,18 @@ get_statement_from_cache(pysqlite_Cursor *self, PyObject *operation)
454454
return PyObject_Vectorcall(cache, args + 1, nargsf, NULL);
455455
}
456456

457+
static inline int
458+
stmt_step(sqlite3_stmt *statement)
459+
{
460+
int rc;
461+
462+
Py_BEGIN_ALLOW_THREADS
463+
rc = sqlite3_step(statement);
464+
Py_END_ALLOW_THREADS
465+
466+
return rc;
467+
}
468+
457469
PyObject *
458470
_pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject* operation, PyObject* second_argument)
459471
{
@@ -570,7 +582,7 @@ _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject* operation
570582
goto error;
571583
}
572584

573-
rc = pysqlite_step(self->statement->st);
585+
rc = stmt_step(self->statement->st);
574586
if (rc != SQLITE_DONE && rc != SQLITE_ROW) {
575587
if (PyErr_Occurred()) {
576588
/* there was an error that occurred in a user-defined callback */
@@ -799,7 +811,7 @@ pysqlite_cursor_iternext(pysqlite_Cursor *self)
799811
if (row == NULL) {
800812
return NULL;
801813
}
802-
int rc = pysqlite_step(stmt);
814+
int rc = stmt_step(stmt);
803815
if (rc == SQLITE_DONE) {
804816
(void)pysqlite_statement_reset(self->statement);
805817
}

Modules/_sqlite/util.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,6 @@
2424
#include "module.h"
2525
#include "connection.h"
2626

27-
int
28-
pysqlite_step(sqlite3_stmt *statement)
29-
{
30-
int rc;
31-
32-
Py_BEGIN_ALLOW_THREADS
33-
rc = sqlite3_step(statement);
34-
Py_END_ALLOW_THREADS
35-
36-
return rc;
37-
}
38-
3927
// Returns non-NULL if a new exception should be raised
4028
static PyObject *
4129
get_exception_class(pysqlite_state *state, int errorcode)

Modules/_sqlite/util.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@
2929
#include "sqlite3.h"
3030
#include "connection.h"
3131

32-
int pysqlite_step(sqlite3_stmt *statement);
33-
3432
/**
3533
* Checks the SQLite error code and sets the appropriate DB-API exception.
3634
* Returns the error code (0 means no error occurred).

0 commit comments

Comments
 (0)