bpo-45040: Simplify sqlite3 transaction control functions (GH-28019)

This commit is contained in:
Erlend Egeberg Aasland 2021-09-20 00:51:36 +02:00 committed by GitHub
parent 1d42408495
commit 771a546713
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 63 deletions

View file

@ -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;
}