Commit Graph

108 Commits

Author SHA1 Message Date
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
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
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
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
TcMits
17c91c1fe2 resolve conflicts 2025-09-22 16:03:52 +07:00
Nikita Sivukhin
c63c820bb7 add busy_timeout pragma 2025-09-19 16:48:12 +04:00
TcMits
96e4c5d241 fix issue 3144 2025-09-16 18:39:45 +07:00
pedrocarlo
3d265489dc modify semantics of busy_timeout to be more on par with sqlite 2025-09-15 02:20:32 -03:00
pedrocarlo
0586b75fbe expose function to set busy timeout duration 2025-09-15 02:20:32 -03:00
Pekka Enberg
d6557db3ac bindings/rust: Return error if io_uring requested on non-Linux
Suggested by @sivukhin
2025-09-04 20:00:22 +03:00
Pekka Enberg
ed6d5fd3d7 bindings/rust: Add with_io() method to Builder 2025-09-04 19:14:45 +03:00
Nikita Sivukhin
4653f78356 fix compilation 2025-08-21 18:28:16 +04:00
Nikita Sivukhin
abe3404953 fix build 2025-08-21 15:15:23 +04:00
Pekka Enberg
2963ea7239 bindings/rust: Add Connection::last_insert_rowid() method
Fixes #2670
2025-08-19 17:49:24 +03:00
Nikita Sivukhin
0f1d954319 enable indices in Rust SDK 2025-08-13 16:28:45 +04:00
pedrocarlo
b6e200dbed adjust cacheflush calls outside of pager 2025-08-13 10:24:55 +03:00
Nikita Sivukhin
b612259a3a more friendly copmletely runtime agnostic turso-sync-engine crate 2025-08-06 19:26:55 +04:00
Pere Diaz Bou
2392ea1b55 bindings/rust: add with_mvcc option 2025-08-05 11:40:23 +02:00
Nikita Sivukhin
2e23230e79 extend raw WAL API with few more methods
- try_wal_watermark_read_page - try to read page from the DB with given WAL watermark value
- wal_changed_pages_after - return set of unique pages changed after watermark WAL position
2025-08-04 16:55:50 +04:00
Nikita Sivukhin
0adb40534c hind dangerous methods behind conn_raw_api feature 2025-08-04 12:40:28 +04:00
Diego Reis
8a47b9d5a4 Address PR's comments 2025-08-01 16:00:32 -03:00
Diego Reis
572d3bd4ce Simplify Rust API verbosity by implementing Row.get() and
Statement.query_row()
2025-08-01 16:00:32 -03:00
Diego Reis
adb81dd6ce Separate Row and Rows in its own file 2025-08-01 16:00:32 -03:00
pedrocarlo
543cdb3e2c underscoring completions and IOResult to avoid warning messages 2025-07-31 11:51:17 -03:00
Jussi Saurio
6e2218c3ed fix/bindings/rust: return errors instead of swallowing them and returning None 2025-07-31 11:57:17 +03:00
Pekka Enberg
2443b8db3c Merge 'bindings/rust: Add Connection::execute_batch()' from Rohith Suresh
Fixes #2184

Closes #2215
2025-07-30 10:19:03 +03:00
RS2007
282222a39f feat: execute_batch working 2025-07-29 21:24:33 +05:30
RS2007
8affc9d436 Prototyping execute_batch 2025-07-29 21:24:22 +05:30
Jussi Saurio
72bf4a714a bindings/rust: return errors instead of vibecoded numbers 2025-07-29 17:45:15 +03:00
Nikita Sivukhin
76cc8c05a5 add conversion method 2025-07-29 14:41:10 +04:00
pedrocarlo
3831e0db39 convert must_use compile warnings to unused_variables to track locations where we need to refactor in the future 2025-07-28 16:09:26 -03:00
Pekka Enberg
e2d4cbbe48 Merge 'core: Enforce shared database object per database file' from Pekka Enberg
We need to ensures that there is a single, shared `Database` object per
a database file. We need because it is not safe to have multiple
independent WAL files open because coordination happens at process-level
POSIX file advisory locks.
Fixes #2267

Reviewed-by: Pere Diaz Bou <pere-altea@homail.com>

Closes #2299
2025-07-28 19:34:35 +03:00
Nikita Sivukhin
976b67a408 fix clippy 2025-07-28 17:27:52 +04:00
Nikita Sivukhin
09b18f6b6e add WAL API methods to the rust bindings and extend result of wal_insert_frame method 2025-07-28 17:20:10 +04:00
Pekka Enberg
551df4ce0d bindings/rust: Fix test_database_persistence_many_frames()
We need to make sure database connection is closed to avoid reusing he
same `Database` object.
2025-07-28 13:04:22 +03:00
RS2007
adf70dc855 Return number of rows changed from Connection.execute 2025-07-20 07:27:38 +05:30
Diego Reis
b3c8255032 Fix clippy warnings 2025-07-18 11:26:10 -03:00
Diego Reis
f9d024b68a bind/rust: Use Rusqlite compatible consumer API
Methods like commit, rollback and finish should "consume" a transaction,
so it cannot be used after calling any of them (Pretty neat, rust!)
2025-07-18 11:25:24 -03:00
Diego Reis
92cddb6437 bind/rust: Add more tests for Transaction 2025-07-18 11:25:24 -03:00
Diego Reis
0b96c24196 wip: Basic support for Transaction in Rust binding 2025-07-18 11:25:24 -03:00
Diego Reis
5dd571483f Add cacheflush to Rust binding 2025-07-16 11:08:52 -03:00