mirror of
https://github.com/python/cpython.git
synced 2025-12-11 03:20:01 +00:00
bpo-46249: Move set lastrowid out of the sqlite3 query loop (GH-30489)
This commit is contained in:
parent
82c53229e1
commit
38afeb1a33
1 changed files with 11 additions and 11 deletions
|
|
@ -465,7 +465,6 @@ _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject* operation
|
||||||
int rc;
|
int rc;
|
||||||
int numcols;
|
int numcols;
|
||||||
PyObject* column_name;
|
PyObject* column_name;
|
||||||
sqlite_int64 lastrowid;
|
|
||||||
|
|
||||||
if (!check_cursor(self)) {
|
if (!check_cursor(self)) {
|
||||||
goto error;
|
goto error;
|
||||||
|
|
@ -630,16 +629,6 @@ _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject* operation
|
||||||
self->rowcount= -1L;
|
self->rowcount= -1L;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!multiple) {
|
|
||||||
Py_BEGIN_ALLOW_THREADS
|
|
||||||
lastrowid = sqlite3_last_insert_rowid(self->connection->db);
|
|
||||||
Py_END_ALLOW_THREADS
|
|
||||||
Py_SETREF(self->lastrowid, PyLong_FromLongLong(lastrowid));
|
|
||||||
if (self->lastrowid == NULL) {
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rc == SQLITE_DONE && !multiple) {
|
if (rc == SQLITE_DONE && !multiple) {
|
||||||
pysqlite_statement_reset(self->statement);
|
pysqlite_statement_reset(self->statement);
|
||||||
Py_CLEAR(self->statement);
|
Py_CLEAR(self->statement);
|
||||||
|
|
@ -651,6 +640,17 @@ _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject* operation
|
||||||
Py_XDECREF(parameters);
|
Py_XDECREF(parameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!multiple) {
|
||||||
|
sqlite_int64 lastrowid;
|
||||||
|
|
||||||
|
Py_BEGIN_ALLOW_THREADS
|
||||||
|
lastrowid = sqlite3_last_insert_rowid(self->connection->db);
|
||||||
|
Py_END_ALLOW_THREADS
|
||||||
|
|
||||||
|
Py_SETREF(self->lastrowid, PyLong_FromLongLong(lastrowid));
|
||||||
|
// Fall through on error.
|
||||||
|
}
|
||||||
|
|
||||||
error:
|
error:
|
||||||
Py_XDECREF(parameters);
|
Py_XDECREF(parameters);
|
||||||
Py_XDECREF(parameters_iter);
|
Py_XDECREF(parameters_iter);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue