Repository navigation
libsql: add Statement::raw_bind_parameter() - #2338
Open
AbdeldjalilChougui wants to merge 1 commit into
Open
AbdeldjalilChougui wants to merge 1 commit into
AbdeldjalilChougui wants to merge 1 commit into
Conversation
Add the rusqlite-style low-level binding API: raw_bind_parameter() binds one value by its 1-based index, raw_execute() and raw_query() run the statement with those values, and clear_bindings() drops them. The values live in the Statement wrapper and are passed to the backend as positional params, so the API works the same for local, remote, replica and sync connections. Every reported parameter is bound on each run, unbound ones as NULL, so a value from an earlier run never stays in the underlying SQLite statement. Statements are now built through Statement::new(). Closes tursodatabase#1696
AbdeldjalilChougui
marked this pull request as ready for review
November 24, 2026 22:29
Author
|
The 4 failing checks (CR SQLite C/Rust Tests, Extensions Tests, golang-bindings) are the runner bitrot described in #2337: the cr-sqlite bindgen build and the Go LTO link fail on current ubuntu-latest. This PR only touches libsql/src and libsql/tests; the Rust checks pass. |
This branch has not been deployed
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.
Closes #1696.
Adds rusqlite's low-level binding API to
libsql::Statement, as requested in the issue, for language bindings that receive parameters one at a time:Design
The 2024 attempt stalled on how to bind values for hrana and replication connections, since only the local backend has a real
sqlite3_bind_*. This PR avoids that: the values are stored in theStatementwrapper (raw_params: Vec<Value>) and passed to the backend asParams::Positionalbyraw_execute()/raw_query(). So it works the same on local, remote (hrana), replica and sync connections, with no backend-specific code.:id,@id,$id) are bound by index, as in rusqlite.parameter_name()maps an index to its name.NULL. On each run, every parameter the statement reports is bound, unbound ones asNULL. Without that, a value from an earlier run would stay in the local SQLite statement afterclear_bindings(), becausebind()withParams::Nonedoesn't touch existing bindings.0→Error::Misuse. An index aboveparameter_count()→Error::Misuse, but only when the statement reports its parameters. Remote hrana statements reportparameter_count()from bound args, which is 0 right afterprepare, so only the lower bound can be checked there.crate::Statementgained a field, so the 6 places that built it with a struct literal now callStatement::new(inner).Tests
There are four new tests in
tests/integration_tests.rs:NULL;clear_bindings().cargo test -p libsql --test integration_tests: 35 passed, 1 ignored.cargo fmt --checkis clean. Thecore-only build also compiles.