GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(sqlite): autocommit mode transaction handling to match CPython by ever0de · Pull Request #5918 · RustPython/RustPython

fix(sqlite): autocommit mode transaction handling to match CPython #5918

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.

Sign up for GitHub

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
youknowone merged 1 commit into RustPython:main from ever0de:fix/sqlite-autocommit-transaction-control
Jul 9, 2025

Uh oh!

There was an error while loading. Please reload this page.

Merged

fix(sqlite): autocommit mode transaction handling to match CPython #5918

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
1 commit
Select commit
142b263
fix(sqlite): autocommit mode transaction handling to match CPython
ever0de Jul 9, 2025
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view
fix(sqlite): autocommit mode transaction handling to match CPython
  • Loading branch information

Uh oh!

There was an error while loading. Please reload this page.

@ever0de
ever0de committed Jul 9, 2025
commit 142b2632356389f39a55cba32aa2623e36ee51ea

There are no files selected for viewing

2 changes: 0 additions & 2 deletions 2 Lib/test/test_sqlite3/test_transactions.py
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,6 @@ def test_replace_starts_transaction(self):
self.assertEqual(len(res), 1)
self.assertEqual(res[0][0], 5)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_toggle_auto_commit(self):
self.cur1.execute("create table test(i)")
self.cur1.execute("insert into test(i) values (5)")
Expand Down
20 changes: 18 additions & 2 deletions 20 stdlib/src/sqlite.rs
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -1346,6 +1346,16 @@ mod _sqlite {
if let Some(val) = &val {
begin_statement_ptr_from_isolation_level(val, vm)?;
}

// If setting isolation_level to None (auto-commit mode), commit any pending transaction
if val.is_none() {
let db = self.db_lock(vm)?;
if !db.is_autocommit() {
// Keep the lock and call implicit_commit directly to avoid race conditions
db.implicit_commit(vm)?;
}
}

let _ = unsafe { self.isolation_level.swap(val) };
Ok(())
}
Expand Down Expand Up @@ -1472,7 +1482,10 @@ mod _sqlite {

let db = zelf.connection.db_lock(vm)?;

if stmt.is_dml && db.is_autocommit() {
if stmt.is_dml
&& db.is_autocommit()
&& zelf.connection.isolation_level.deref().is_some()
Comment thread
Comment on lines +1485 to +1487

@gemini-code-assist gemini-code-assist Bot Jul 9, 2025

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The condition zelf.connection.isolation_level.deref().is_some() seems like it could be simplified. Consider extracting the deref() call to a local variable to improve readability and avoid dereferencing multiple times.

            let isolation_level = zelf.connection.isolation_level.deref();
            if stmt.is_dml
                && db.is_autocommit()
                && isolation_level.is_some()

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
{
db.begin_transaction(
zelf.connection
.isolation_level
Expand Down Expand Up @@ -1552,7 +1565,10 @@ mod _sqlite {

let db = zelf.connection.db_lock(vm)?;

if stmt.is_dml && db.is_autocommit() {
if stmt.is_dml
&& db.is_autocommit()
&& zelf.connection.isolation_level.deref().is_some()
Comment thread
Comment on lines +1568 to +1570

@gemini-code-assist gemini-code-assist Bot Jul 9, 2025

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The condition zelf.connection.isolation_level.deref().is_some() seems like it could be simplified. Consider extracting the deref() call to a local variable to improve readability and avoid dereferencing multiple times.

            let isolation_level = zelf.connection.isolation_level.deref();
            if stmt.is_dml
                && db.is_autocommit()
                && isolation_level.is_some()

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
{
db.begin_transaction(
zelf.connection
.isolation_level
Expand Down
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.