Commit graph

169 commits

Author SHA1 Message Date
Pekka Enberg
b4a331da38
Merge 'SDK tweaks' from Nikita Sivukhin
Few small tweaks in SDKs:
1. Export `ConnectionSync` type from Python SDK
2. Remove dependency on `conn_raw_api` and corresponding methods from
rust bindings - no one use them so let's drop support for this feature
completely
3. Add Waker dependency in the sdk-kit in order to integrate it later to
rust bindings
4. Add io_uring feature to the sdk-kit

Closes #4284
2025-12-22 11:59:02 +02:00
pedrocarlo
06326e6d16 for now use the _io() for rust bindings for implementing future. But in the future we would remove this and the let the user advance io 2025-12-19 17:20:46 -03:00
Pekka Enberg
edd45ff7b8 Improve MVCC DX by dropping --experimental-mvcc flag
The DX is right now pretty terrible:

```
penberg@vonneumann turso % cargo run -- hello.db
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.15s
     Running `target/debug/tursodb hello.db`
Turso v0.4.0-pre.18
Enter ".help" for usage hints.
Did you know that Turso supports live materialized views? Type .manual materialized-views to learn more.
This software is in BETA, use caution with production data and ensure you have backups.
turso> PRAGMA journal_mode = 'experimental_mvcc';
  × Invalid argument supplied: MVCC is not enabled. Enable it with `--experimental-mvcc` flag in the CLI or by setting the MVCC option in `DatabaseOpts`

turso>
```

To add insult to the injury, many SDKs don't even have a way to enable
MVCC via database options. Therefore, let's remove the flag altogether.
2025-12-19 12:59:42 +02:00
Nikita Sivukhin
e5e7f68681 Merge branch 'main' into sdk-tweaks 2025-12-18 12:30:09 +04:00
Nikita Sivukhin
2b8020226a remove methods 2025-12-18 12:25:43 +04:00
Nikita Sivukhin
f4a1a91ba2 remove unnecessary dependencies 2025-12-18 12:22:06 +04:00
Dave Warnock
123b0cfdb0 Remove mut from connection clone test 2025-12-12 23:07:10 +00:00
Dave Warnock
24622d35a7 Fix clippy warning
Use .to_string instead of format!
2025-12-12 22:32:18 +00:00
Dave Warnock
7c4994b7a7
Clean up commented-out code in connection.rs
Removed commented-out code for clarity.
2025-12-12 19:41:25 +00:00
Dave Warnock
b5c76b9e46 Test Connection.clone
I wanted to be sure I hadn't broken clone
2025-12-12 08:44:25 +00:00
Dave Warnock
38598591ec Make the inner turson::core::Connection an option
This is needed for the Connection pool so that when a Connection is
dropped we can take the inner connection and put it back into
ConnectionPool
2025-12-12 08:43:57 +00:00
Dave Warnock
9ef9b5ba24 Refactor get_inner_connection
Instead of manually getting the inner connection everytime with locking
and error handling add a new function and call it.
Also replaces the one instance of an unwrap with an expect as per
project preferences
2025-12-12 07:53:57 +00:00
Dave Warnock
fc56a433c5 Refactor Connection to separate module
Makes further refactoring easier given the code length
2025-12-12 06:21:12 +00:00
Dave Warnock
f3f8fe9b97 Added transaction.prepare test
This should check that ypou can call prepare on a transaction, execute,
commit and read back
2025-12-09 23:50:09 +00:00
Dave Warnock
9718c1f876
Merge branch 'tursodatabase:main' into Rust-Binding-add-prepare-to-transaction 2025-12-09 22:28:22 +00:00
Jussi Saurio
826ca4d44d chore: remove experimental_indexes feature flags 2025-12-08 13:00:37 +02:00
Dave Warnock
aa55cba1db Improve Transaction.prepare
Moved to clearer position, improved comment.
2025-12-05 21:56:25 +00:00
Dave Warnock
f4c1d350c3
Merge branch 'tursodatabase:main' into More-rusqlite-style-example 2025-12-05 19:22:00 +00:00
pedrocarlo
a311c966a2 set encryption context for page and wal in init_pager 2025-12-05 02:04:06 -03:00
pedrocarlo
889322f6b5 do not call pragmas related to encryption on connect or open 2025-12-05 02:04:06 -03:00
Dave Warnock
357a24580b Improved transaction example
It is more realistic to begin and commit the transaction outside the
update function.
2025-12-01 01:07:29 +00:00
Dave Warnock
9f7fc532b9 Pass a transation to the insert_users function
Needed to add prepare to impl Transaction
2025-12-01 00:47:27 +00:00
Dave Warnock
bd07a32083 Clearer for idiomatic
NB This highlights an issue around Connection/Transaction/Prepare
2025-11-30 23:24:20 +00:00
Dave Warnock
1b66d718ec Moving closer to rusqlite using a struct
Read the query results using a struct as the rusqlite example does
2025-11-23 21:53:40 +00:00
Dave Warnock
a7d56be2da Tidied import
I noticed that I should have tidied the imports
2025-11-23 16:32:38 +00:00
Dave Warnock
1e5723e05a Removed unwrap from the rust binding example
Refactor to remove unwrap, also added:

- an assertion to catch database failure
- an integer column to make the example a little more informative on how
to use binding
2025-11-23 15:45:15 +00:00
pedrocarlo
1db13889e3 Change Value::Text to use a Cow<'static, str> instead of Vec<u8> 2025-11-11 16:11:46 -03:00
Pekka Enberg
0217588d13 Make mimalloc dependency optional 2025-11-01 11:43:32 +02:00
Pekka Enberg
2429159e5d bindings/rust: Enable mimalloc as global allocator
This improves performance by using mimalloc for memory allocation in the
Rust bindings.
2025-10-26 16:55:33 +02:00
Bob Peterson
5d7b057b8a Enable turso_stress to run in Miri
antithesis_sdk needs to have default features disabled in the workspace
so turso_stress is free to select the noop implementation for Miri
2025-10-20 22:50:44 -05:00
Jussi Saurio
44fa0a4f6e
Merge 'bindings/rust: propagate the DropBehavior of a dropped tx to next access of DB, instead of panicing' from Jussi Saurio
Closes #3748
Right now if any error happens during an interactive tx that causes the
`Transaction` to drop, the program will panic.
To prevent this, we store the `DropBehavior` of the transaction on the
`Connection` when it drops and issue the corresponding action (ROLLBACK
/ COMMIT / IGNORE / PANIC) the next time `Connection` is used to access
the database. This defaults to `IGNORE`.
I don't know how good this solution is, but we can at least prevent a
panic by storing whether the connection has a dangling transaction and
roll it back automatically the next time the connection tries to do
something.

Reviewed-by: Preston Thorpe <preston@turso.tech>

Closes #3750
2025-10-16 17:18:31 +03:00
Jussi Saurio
7728f3ab58 Update DropBehavior related documentation to reflect reality 2025-10-16 16:40:02 +03:00
Jussi Saurio
3929322061 Propagate DropBehavior to dangling_tx so DropBehavior makes sense 2025-10-16 16:38:42 +03:00
Jussi Saurio
455f0fbc46 Set in_progress to false AFTER executing the statement 2025-10-16 15:53:58 +03:00
Jussi Saurio
d77dd8400d bindings/rust: rollback dangling tx on next access of DB, instead of panicing
Closes #3748

Right now if any error happens during an interactive tx that causes the
`Transaction` to drop, the program will panic.

I don't know how good this solution is, but we can at least prevent a panic
by storing whether the connection has a dangling transaction and roll it back
automatically the next time the connection tries to do something.
2025-10-16 15:44:44 +03:00
Jussi Saurio
213af28cf3 rust bindings: make Statement::query:row() finish execution
otherwise the statement will be considered to be in progress,
and its Drop implementation will roll back the transaction it
is in.
2025-10-16 14:03:17 +03:00
Jussi Saurio
6f1bda1438 Instrument test_drop() with tracing 2025-10-16 14:01:54 +03:00
Jussi Saurio
4de36d28e6 deps: add tracing to rust bindings 2025-10-16 14:00:26 +03:00
pedrocarlo
818a68b3dd ignore busy errors for test_concurrent_unique_constraint_regression 2025-10-14 12:33:36 -03:00
pedrocarlo
23380a58d7 make next truly async and non blocking 2025-10-14 12:33:36 -03:00
pedrocarlo
943ade7293 pass waker to completion for more efficient task scheduling 2025-10-14 12:33:36 -03:00
Kyle Kelley
f7ba978701
Recommend 0.2 in rust bindings
Bump version number for crate docs starter setup
2025-10-13 09:33:58 -07:00
Pekka Enberg
17a578a496 bindings/rust: Tokio is not required
Some checks are pending
Build & publish @tursodatabase/database / db-bindings-x86_64-pc-windows-msvc - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / db-bindings-x86_64-unknown-linux-gnu - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / sync-bindings-x86_64-pc-windows-msvc - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / sync-bindings-x86_64-unknown-linux-gnu - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / sync-bindings-aarch64-apple-darwin - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / sync-bindings-aarch64-unknown-linux-gnu - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / sync-bindings-wasm32-wasip1-threads - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / Test DB bindings on Linux-x64-gnu - node@20 (push) Blocked by required conditions
Build & publish @tursodatabase/database / Test DB bindings on browser@20 (push) Blocked by required conditions
Build & publish @tursodatabase/database / Publish (push) Blocked by required conditions
Python / linux (x86_64) (push) Waiting to run
Python / configure-strategy (push) Waiting to run
Python / test (push) Blocked by required conditions
Python / lint (push) Waiting to run
Python / macos-arm64 (aarch64) (push) Waiting to run
Python / sdist (push) Waiting to run
Python / Release (push) Blocked by required conditions
Rust / cargo-fmt-check (push) Waiting to run
Rust / build-native (blacksmith-4vcpu-ubuntu-2404) (push) Waiting to run
Rust / build-native (macos-latest) (push) Waiting to run
Rust / build-native (windows-latest) (push) Waiting to run
Rust / clippy (push) Waiting to run
Rust / simulator (push) Waiting to run
Rust / test-limbo (push) Waiting to run
Rust / test-sqlite (push) Waiting to run
Rust Benchmarks+Nyrkiö / bench (push) Waiting to run
Rust Benchmarks+Nyrkiö / clickbench (push) Waiting to run
Rust Benchmarks+Nyrkiö / tpc-h-criterion (push) Waiting to run
Rust Benchmarks+Nyrkiö / tpc-h (push) Waiting to run
Rust Benchmarks+Nyrkiö / vfs-bench-compile (push) Waiting to run
The bindings use just async Rust so any async runtime should work.
2025-10-08 11:47:39 +03:00
Dave Warnock
e28ece6950 Update Doc regarding rusqlite compatibility
Make it clear that it's not a drop in replacement for rusqlite as that
isn't async
2025-10-08 08:03:43 +01:00
Avinash Sajjanshetty
306f681966 Add an encryption test in rust bindings 2025-10-02 19:50:10 +05:30
Avinash Sajjanshetty
4ee6bdac1b update Rust bindings to pass encryption options 2025-10-02 18:51:44 +05:30
Avinash Sajjanshetty
593fd5fb88 update Rust bindings to enable experimental encryption 2025-10-02 18:50:57 +05:30
Pekka Enberg
17e07e620a
Merge 'fix/vdbe: reset op_transaction state properly' from Jussi Saurio
Some checks failed
Build & publish @tursodatabase/database / db-bindings-x86_64-unknown-linux-gnu - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / sync-bindings-aarch64-apple-darwin - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / sync-bindings-aarch64-unknown-linux-gnu - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / sync-bindings-wasm32-wasip1-threads - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / sync-bindings-x86_64-pc-windows-msvc - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / sync-bindings-x86_64-unknown-linux-gnu - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / Test DB bindings on Linux-x64-gnu - node@20 (push) Blocked by required conditions
Build & publish @tursodatabase/database / Test DB bindings on browser@20 (push) Blocked by required conditions
Build & publish @tursodatabase/database / Publish (push) Blocked by required conditions
Python / configure-strategy (push) Waiting to run
Python / test (push) Blocked by required conditions
Python / lint (push) Waiting to run
Python / linux (x86_64) (push) Waiting to run
Python / macos-arm64 (aarch64) (push) Waiting to run
Python / sdist (push) Waiting to run
Python / Release (push) Blocked by required conditions
Rust / cargo-fmt-check (push) Waiting to run
Rust / build-native (blacksmith-4vcpu-ubuntu-2404) (push) Waiting to run
Rust / build-native (macos-latest) (push) Waiting to run
Rust / build-native (windows-latest) (push) Waiting to run
Rust / clippy (push) Waiting to run
Rust / simulator (push) Waiting to run
Rust / test-limbo (push) Waiting to run
Rust / test-sqlite (push) Waiting to run
Rust Benchmarks+Nyrkiö / bench (push) Waiting to run
Rust Benchmarks+Nyrkiö / clickbench (push) Waiting to run
Rust Benchmarks+Nyrkiö / tpc-h-criterion (push) Waiting to run
Rust Benchmarks+Nyrkiö / tpc-h (push) Waiting to run
Rust Benchmarks+Nyrkiö / vfs-bench-compile (push) Waiting to run
turso-serverless / build (push) Has been cancelled
essentially after the first runthrough of `op_transaction` per a given
`ProgramState`, we weren't resetting the instruction state to `Start´ at
all, which means we didn't do any transaction state checking/updating
after that.
PR includes a rust bindings regression test that used to panic before
this change, and I bet it also fixes this issue in turso-go:
https://github.com/tursodatabase/turso-go/issues/28

Closes #3516
2025-10-02 09:25:23 +03:00
Jussi Saurio
f48165eb72 fix/vdbe: reset op_transaction state properly
essentially after the first runthrough of `op_transaction` per a
given `ProgramState`, we weren't resetting the instruction state
to `Start´ at all, which means we didn't do any transaction state
checking/updating.

PR includes a rust bindings regression test that used to panic before
this change, and I bet it also fixes this issue in turso-go:

https://github.com/tursodatabase/turso-go/issues/28
2025-10-02 08:40:41 +03:00
Jussi Saurio
f06aac6192 bindings/rust: don't panic if user provides invalid parameter
Now returns e.g.:

```rust
SqlExecutionFailure(
  "Invalid argument supplied: Unknown parameter ':email' for query 'INSERT INTO users (email, created_at) VALUES (?, ?)'.
  Make sure you're using the correct parameter syntax - named: (:foo), positional: (?, ?)"
)
```

instead of unwrapping a None value and panicing
2025-10-02 07:42:52 +03:00