Repository navigation
fix(duckdb): prepare a statement only inside a transaction it runs in - #4364
Merged
Merged
Conversation
…ting-prepare # Conflicts: # core/docs/decisions/README.md
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
SET threads = nextval('seq')orSELECT * FROM range(nextval('seq')), then invalidated the whole database until it was reopened. Extracting the statements first prepares the same way (measured).duckdb_query, one statement at a time, which prepares nothing. A streamed read, and a statement with parameters, is prepared inside the session's transaction or one the plugin opens when the session holds none, and committed when its result ends; a failed COMMIT is the statement's error.duckdb_query.duckdb_queryagainst 450 µs prepared.duckdb_querypath.apple/scripts/probes/check-duckdb-side-effecting-prepare.shmeasures what it rests on.Test plan
DuckDBSideEffectingBindTests: a streamed read and an export whose table function takes a sequence value leave the database open; a read inside the user's transaction keeps it; a SET takes its value once; which statements stream.sessions: a binding that takes a sequence value leaves the database open; a script that ends its transaction reads the next binding outside one; a writing read cut at the row limit completes.range(nextval('seq'))fails with the internal error and every later statement with FATAL; here it reads 20 rows, the SET takes its value once, rows affected and RETURNING read as before, and the threads stay taken over.cargo test -p tablepro-driver-duckdband clippy,verify.sh plugins,lint,l10n. On macOSopen_semantics::an_attach_of_a_fifo_is_refusedfails on the/varagainst/private/varspelling of the temporary directory, in code this change does not touch; CI runs that test on Linux.