Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge branch 'main' into sqlite-reset
  • Loading branch information
erlend-aasland committed Jun 20, 2022
commit 7d8cbe289f5722b72ed5156e66f028a64608dcf3
31 changes: 15 additions & 16 deletions Modules/_sqlite/cursor.c
Original file line number Diff line number Diff line change
Expand Up @@ -830,13 +830,13 @@ _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject* operation
}
}

/* reset description and rowcount */
/* reset description */
Py_INCREF(Py_None);
Py_SETREF(self->description, Py_None);

if (self->statement) {
// Reset pending statements on this cursor.
(void)pysqlite_statement_reset(self->statement);
(void)stmt_reset(self->statement);
}

PyObject *stmt = get_statement_from_cache(self, operation);
Expand Down Expand Up @@ -940,14 +940,11 @@ _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject* operation
}
}

if (self->statement->is_dml) {
self->rowcount += (long)sqlite3_changes(self->connection->db);
} else {
self->rowcount= -1L;
}

if (rc == SQLITE_DONE) {
(void)pysqlite_statement_reset(self->statement);
if (self->statement->is_dml) {
self->rowcount += (long)sqlite3_changes(self->connection->db);
}
stmt_reset(self->statement);
}
Py_XDECREF(parameters);
}
Expand Down Expand Up @@ -1118,15 +1115,17 @@ pysqlite_cursor_iternext(pysqlite_Cursor *self)
}
int rc = stmt_step(stmt);
if (rc == SQLITE_DONE) {
if (self->statement->is_dml) {
self->rowcount = (long)sqlite3_changes(self->connection->db);
}
(void)pysqlite_statement_reset(self->statement);
Py_CLEAR(self->statement);

if (rc != SQLITE_DONE) {
(void)_pysqlite_seterror(self->connection->state,
self->connection->db);
Py_DECREF(row);
return NULL;
}
}
else if (rc != SQLITE_ROW) {
(void)_pysqlite_seterror(self->connection->state,
self->connection->db);
Py_DECREF(row);
return NULL;
}
if (!Py_IsNone(self->row_factory)) {
PyObject *factory = self->row_factory;
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.