mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-45040: Simplify sqlite3 transaction control functions (GH-28019)
This commit is contained in:
parent
1d42408495
commit
771a546713
2 changed files with 28 additions and 63 deletions
|
@ -431,31 +431,22 @@ static int
|
|||
begin_transaction(pysqlite_Connection *self)
|
||||
{
|
||||
int rc;
|
||||
sqlite3_stmt *statement;
|
||||
|
||||
Py_BEGIN_ALLOW_THREADS
|
||||
sqlite3_stmt *statement;
|
||||
rc = sqlite3_prepare_v2(self->db, self->begin_statement, -1, &statement,
|
||||
NULL);
|
||||
if (rc == SQLITE_OK) {
|
||||
(void)sqlite3_step(statement);
|
||||
rc = sqlite3_finalize(statement);
|
||||
}
|
||||
Py_END_ALLOW_THREADS
|
||||
|
||||
if (rc != SQLITE_OK) {
|
||||
_pysqlite_seterror(self->state, self->db);
|
||||
goto error;
|
||||
}
|
||||
|
||||
Py_BEGIN_ALLOW_THREADS
|
||||
sqlite3_step(statement);
|
||||
rc = sqlite3_finalize(statement);
|
||||
Py_END_ALLOW_THREADS
|
||||
|
||||
if (rc != SQLITE_OK && !PyErr_Occurred()) {
|
||||
_pysqlite_seterror(self->state, self->db);
|
||||
}
|
||||
|
||||
error:
|
||||
if (PyErr_Occurred()) {
|
||||
(void)_pysqlite_seterror(self->state, self->db);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue