8000 bpo-27334: roll back transaction if sqlite3 context manager fails to commit by erlend-aasland · Pull Request #26202 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content
8000

bpo-27334: roll back transaction if sqlite3 context manager fails to commit #26202

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 26 commits into from
Aug 25, 2021
Merged
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
a1361e6
bpo-27334: sqlite3 context manager now rolls back if commit fails
May 15, 2021
7111bba
Add NEWS
May 17, 2021
0b63628
Add explanatory comments to test
May 17, 2021
fce98f1
PEP 8
May 17, 2021
3edde50
Prevent accidentally clearing the current exception
May 19, 2021
99c4157
... and clean up
May 19, 2021
581bc44
Use test.support.SHORT_TIMEOUT to wait for sub-process
May 19, 2021
31f43fa
Adjust comment
May 19, 2021
a66828b
Make rollback thread friendly, and use _pysqlite_seterror to check th…
May 20, 2021
cdb0d50
Remove unused variable
May 22, 2021
e5fdaf7
Dedent test script using if 1 trick
May 22, 2021
f67591c
Use test.support.TIMEOUT to adjust connection timeout
May 25, 2021
4e654d0
Address review: make news entry less low level-ish
Jun 2, 2021
98d3ada
Chain exceptions if rollback also fails
Jun 2, 2021
195edbe
Address review
Jun 2, 2021
da26486
Add managed connection helper
Jun 3, 2021
e5f9e16
Merge branch 'main' into sqlite-ctx-rollback
Jun 3, 2021
43ea594
Fix tests (cannot use managed_connect() bco. shared access
Jun 3, 2021
1d4bcf9
Revert "Fix tests (cannot use managed_connect() bco. shared access"
Jun 3, 2021
a4b388e
Fix tests (cannot use managed_connect() bco. shared access
Jun 3, 2021
b03ee62
Merge branch 'main' into sqlite-ctx-rollback
Jun 17, 2021
b4c8d39
Merge branch 'main' into sqlite-ctx-rollback
Jun 20, 2021
da65db8
Merge branch 'main' into sqlite-ctx-rollback
Jun 24, 2021
1c93e9f
Rewrite test
Jun 25, 2021
a32943c
Restore comments
Jun 27, 2021
175d4a0
Merge branch 'main' into sqlite-ctx-rollback
Aug 8, 2021
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
Make rollback thread friendly, and use _pysqlite_seterror to check th…
…e return value
  • Loading branch information
Erlend E. Aasland committed May 20, 2021
commit a66828be335f91d69e73fe6cd5189042000f30a9
11 changes: 6 additions & 5 deletions Modules/_sqlite/connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -1856,11 +1856,12 @@ pysqlite_connection_exit_impl(pysqlite_Connection *self, PyObject *exc_type,
* sqlite3_exec() to avoid accidentally clearing the current
* exception when rolling back. */
char *errmsg = NULL;
int rc = sqlite3_exec(self->db, "rollback;", NULL, NULL, &errmsg);
if (rc != SQLITE_OK) {
assert(errmsg != NULL);
PyErr_SetString(pysqlite_OperationalError, errmsg);
sqlite3_free(errmsg);
int rc;
Py_BEGIN_ALLOW_THREADS
rc = sqlite3_exec(self->db, "rollback;", NULL, NULL, NULL);
Py_END_ALLOW_THREADS
if (rc != SQLITE_OK && !PyErr_Occurred()) {
_pysqlite_seterror(self->db);
}
}
return NULL;
Expand Down
0