-
Notifications
You must be signed in to change notification settings - Fork 636
Run statements to completion on reset #4042
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
base: main
Are you sure you want to change the base?
Run statements to completion on reset #4042
Conversation
819750b to
9de4011
Compare
|
Hi @nightscape , can you see if this change in |
|
@jussisaurio actually this PR builds on #4038 and applies a similar fix for the Rust bindings that the other PR does for the SQLite C-bindings. |
9de4011 to
de4a61f
Compare
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.
Pull request overview
This pull request implements a fix to ensure statements run to completion when reset or dropped, addressing issues with INSERT...RETURNING statements and transaction behavior in non-MVCC mode. The core change adds a completion loop in reset_internal() that steps through any remaining statement execution before cleanup. The PR includes comprehensive test coverage for the new behavior.
Key Changes
- Modified
reset_internal()to run statements to completion before aborting - Added integration tests for non-MVCC transaction commit/rollback behavior
- Added async tests for
INSERT...RETURNINGpartial consumption scenarios
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
core/lib.rs |
Adds completion loop in reset_internal() to ensure statements finish executing before cleanup |
tests/integration/query_processing/test_transactions.rs |
Adds synchronous tests for commit/rollback in non-MVCC mode |
bindings/rust/tests/integration_tests.rs |
Adds async tests for INSERT...RETURNING partial consumption and transaction interactions |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
3ce0ad0 to
95445b9
Compare
|
@jussisaurio your and copilot's comments should be addressed now. |
95445b9 to
911f791
Compare
911f791 to
5c38e93
Compare
Hi, while using Turso in an app I'm just developing, I ran into a few errors concerning statement lifecycle and transaction behaviour. Part of this fix is porting #4038 to the Rust bindings.
For full transparency: The fix was created by Opus 4.5 because I don't understand MVCC deeply enough.
I just gave it the failing code, had it create test cases and then implement a fix and verify that it works in my project.
I don't know if it's the right way to solve these issues.
Summary
When a prepared statement is reset or dropped, it now runs to completion first. This ensures
INSERT...RETURNINGand similar statements complete all their work even if the caller only consumed some of the returned rows.Problem
Previously, if you did:
Only the first row would be inserted because the statement wasn't run to completion.
Solution
In
reset_internal(), run the statement to completion before callingabort(). This matches SQLite's behavior and ensures all side effects complete.Uses
catch_unwindto handle panics gracefully (e.g., from corrupted databases).Tests
Added regression tests covering: