summaryrefslogtreecommitdiffstats
path: root/Modules/_sqlite/statement.c
diff options
context:
space:
mode:
authorErlend Egeberg Aasland <erlend.aasland@innova.no>2021-09-26 21:24:19 (GMT)
committerGitHub <noreply@github.com>2021-09-26 21:24:19 (GMT)
commit7b88f63e1dd4006b1a08b9c9f087dd13449ecc76 (patch)
treed747d53319ed936b6b391531da9cf6d8837d1d2c /Modules/_sqlite/statement.c
parentf56268a2cd38b3fe2be1e4361d3d8b581e73559b (diff)
downloadcpython-7b88f63e1dd4006b1a08b9c9f087dd13449ecc76.zip
cpython-7b88f63e1dd4006b1a08b9c9f087dd13449ecc76.tar.gz
cpython-7b88f63e1dd4006b1a08b9c9f087dd13449ecc76.tar.bz2
bpo-44958: Revert GH-27844 (GH-28574)
This reverts commit 050d1035957379d70e8601e6f5636637716a264b, but keeps the tests.
Diffstat (limited to 'Modules/_sqlite/statement.c')
-rw-r--r--Modules/_sqlite/statement.c32
1 files changed, 12 insertions, 20 deletions
diff --git a/Modules/_sqlite/statement.c b/Modules/_sqlite/statement.c
index 3016fe5..b20c91d 100644
--- a/Modules/_sqlite/statement.c
+++ b/Modules/_sqlite/statement.c
@@ -360,31 +360,23 @@ pysqlite_statement_bind_parameters(pysqlite_state *state,
}
}
-void
-pysqlite_statement_reset(pysqlite_Statement *self)
+int pysqlite_statement_reset(pysqlite_Statement* self)
{
- sqlite3_stmt *stmt = self->st;
- if (stmt == NULL || self->in_use == 0) {
- return;
- }
+ int rc;
-#if SQLITE_VERSION_NUMBER >= 3020000
- /* Check if the statement has been run (that is, sqlite3_step() has been
- * called at least once). Third parameter is non-zero in order to reset the
- * run count. */
- if (sqlite3_stmt_status(stmt, SQLITE_STMTSTATUS_RUN, 1) == 0) {
- return;
- }
-#endif
+ rc = SQLITE_OK;
- int rc;
- Py_BEGIN_ALLOW_THREADS
- rc = sqlite3_reset(stmt);
- Py_END_ALLOW_THREADS
+ if (self->in_use && self->st) {
+ Py_BEGIN_ALLOW_THREADS
+ rc = sqlite3_reset(self->st);
+ Py_END_ALLOW_THREADS
- if (rc == SQLITE_OK) {
- self->in_use = 0;
+ if (rc == SQLITE_OK) {
+ self->in_use = 0;
+ }
}
+
+ return rc;
}
void pysqlite_statement_mark_dirty(pysqlite_Statement* self)