Add subcursor() for interleaved streaming + DML#397
Open
rustyconover wants to merge 1 commit intoduckdb:mainfrom
Open
Add subcursor() for interleaved streaming + DML#397rustyconover wants to merge 1 commit intoduckdb:mainfrom
rustyconover wants to merge 1 commit intoduckdb:mainfrom
Conversation
Adds subcursor() method that creates a cursor sharing the same underlying Connection and transaction as the parent. This enables interleaved streaming SELECT + UPDATE/INSERT/DELETE within an explicit transaction without destroying the streaming result. Requires the companion duckdb core PR that adds the enable_suspended_queries setting and suspend/resume mechanics. Key changes: - ConnectionGuard: unique_ptr<Connection> to shared_ptr<Connection> - Add ShareConnection/GetSharedConnection accessors - Add Subcursor() method that shares the parent's Connection - Add is_subcursor flag with transaction management guard - Subcursors cannot call begin/commit/rollback - Closing a subcursor cleans up any suspended query state
0e11a3c to
3be0986
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
subcursor()method that creates a cursor sharing the sameConnectionand transaction as the parentbegin/commit/rollbackthrowInvalidInputException)Dependencies
This PR requires the companion core DuckDB PR: duckdb/duckdb#21569 — which adds the
enable_suspended_queriessetting and the suspend/resume mechanics inClientContext. Without that PR,subcursor()will create a shared connection but suspension won't activate.Usage
Changes
ConnectionGuard:unique_ptr<Connection>→shared_ptr<Connection>withShareConnection()/GetSharedConnection()accessorsDuckDBPyConnection::Subcursor(): creates a cursor sharing the parent'sConnectionis_subcursorflag guardsBegin()/Commit()/Rollback()subcursormethodTest plan
🤖 Generated with Claude Code