-
Notifications
You must be signed in to change notification settings - Fork 1.4k
fix(sqlite): Raise ProgrammingError when operating on a closed cursor #6339
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
fix(sqlite): Raise ProgrammingError when operating on a closed cursor #6339
Conversation
WalkthroughThis change enhances SQLite cursor state management by introducing eager initialization in Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Actionable comments posted: 0
🧹 Nitpick comments (2)
crates/stdlib/src/sqlite.rs (2)
1768-1791: Executescript now correctly respects closed/unninitialized cursor stateCalling
inner(vm)?up front makesCursor::executescriptfail withProgrammingErrorwhen the cursor is closed or not initialized, consistent withexecute/executemanyand fetch methods.As a small nit, the
clone()is not needed here; this is equivalent and a bit cleaner:// Just validate initialization / closed state zelf.inner(vm)?;
1831-1848: Closed flag wiring inCursor::closecorrectly enforces “closed cursor” errorsThis implementation makes
close()mark the inner state as closed and reset any active statement, so all later operations that route throughinner(vm)?will now raiseProgrammingErroras intended. The method stays idempotent and still distinguishes the “Base Cursor.init not called.” case.If you want to go further (not required for fixing #6336), you could also clear
inner.statementafter resetting to drop theStatementeagerly and free its underlying SQLite resources sooner:if let Some(stmt) = &inner.statement { stmt.lock().reset(); } inner.statement = None; inner.closed = true;But as-is this change looks correct for the PR’s closed‑cursor behavior goals.
📜 Review details
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
Lib/test/test_sqlite3/test_dbapi.pyis excluded by!Lib/**
📒 Files selected for processing (1)
crates/stdlib/src/sqlite.rs(2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rs
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.rs: Follow the default rustfmt code style by runningcargo fmtto format Rust code
Always run clippy to lint Rust code (cargo clippy) before completing tasks and fix any warnings or lints introduced by changes
Follow Rust best practices for error handling and memory management
Use the macro system (pyclass,pymodule,pyfunction, etc.) when implementing Python functionality in Rust
Files:
crates/stdlib/src/sqlite.rs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
- GitHub Check: Run snippets and cpython tests on wasm-wasi
- GitHub Check: Check the WASM package and demo
- GitHub Check: Run rust tests (windows-latest)
- GitHub Check: Run snippets and cpython tests (windows-latest)
- GitHub Check: Run rust tests (ubuntu-latest)
- GitHub Check: Run rust tests (macos-latest)
- GitHub Check: Ensure compilation on various targets
- GitHub Check: Run snippets and cpython tests (ubuntu-latest)
- GitHub Check: Run snippets and cpython tests (macos-latest)
- GitHub Check: Check Rust code with clippy
youknowone
left a comment
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.
👍
fixed #6336
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.