Commit Graph

9834 Commits

Author SHA1 Message Date
pedrocarlo
dc0d4e2dcb print diffs in assert tables 2025-10-03 02:01:14 -03:00
Pekka Enberg
b11246278f Merge 'Enable encryption properly in Rust bindings, whopper, and throughput tests' from Avinash Sajjanshetty
This is a follow up from PR - #3457 which requires users to opt in to
enable encryption. This patch
- Makes appropriate changes to Whopper and Encryption throughput tests
- Updated Rust bindings to pass the encryption options properly
- Added a test for rust bindings
To use encryption in Rust bindings, one needs to do:
```rust
let opts = EncryptionOpts {
    hexkey: "b1bbfda...02a5669fc76327".to_string(),
    cipher: "aegis256".to_string(),
};

let builder = Builder::new_local(&db_file).experimental_encryption(true).with_encryption(opts.clone());
let db = builder.build().await.unwrap();
```
We will remove the `experimental_encryption` once the feature is stable.

Closes #3532
2025-10-02 18:32:06 +03:00
Pekka Enberg
d3b6adfb2d Merge 'Enable checksums only if its opted in via feature flag' from Avinash Sajjanshetty
Reviewed-by: Nikita Sivukhin (@sivukhin)
Reviewed-by: bit-aloo (@Shourya742)

Closes #3523
2025-10-02 17:26:14 +03:00
Pekka Enberg
3378afe8c6 Merge 'Fix MVCC drop table' from Jussi Saurio
MVCC shuoldn't try to destroy btrees in pager because pager operations
are only done in checkpoint

Closes #3524
2025-10-02 17:26:00 +03:00
Pekka Enberg
78e3311c3b Merge 'Sync engine defered sync' from Nikita Sivukhin
This PR makes sync client completely autonomous as now it can defer
initial sync.
This can open possibility to asynchronously create DB in the Turso Cloud
while giving user ability to interact with local DB straight away.

Closes #3531
2025-10-02 17:25:11 +03:00
Avinash Sajjanshetty
3653c1a853 clear page cache when the encryption context is set 2025-10-02 19:50:12 +05:30
Avinash Sajjanshetty
306f681966 Add an encryption test in rust bindings 2025-10-02 19:50:10 +05:30
Avinash Sajjanshetty
36d4b09830 Use the updated bindings for encryption throughput tests 2025-10-02 19:04:15 +05:30
Nikita Sivukhin
649fddedf6 remove unnecessary clone 2025-10-02 17:31:30 +04:00
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
Nikita Sivukhin
cff23c80cb fix wasm client 2025-10-02 16:56:54 +04:00
Nikita Sivukhin
39bf35abe9 adjust native sync client 2025-10-02 16:51:08 +04:00
Nikita Sivukhin
c0b6210756 add missed method in the core 2025-10-02 16:19:52 +04:00
Nikita Sivukhin
863e3fe94e make url parameter to accept either string or function 2025-10-02 16:17:36 +04:00
Nikita Sivukhin
64389447e3 support defered sync in the bindings core 2025-10-02 16:17:36 +04:00
Nikita Sivukhin
5ec2d96bc1 support defered sync in the engine 2025-10-02 16:17:36 +04:00
Nikita Sivukhin
7016d9456e fix test in the database tape 2025-10-02 16:17:36 +04:00
Nikita Sivukhin
91aeadd940 apply create DDL operation with IF NOT EXISTS clause in order to make them idempotent 2025-10-02 15:56:34 +04:00
Pekka Enberg
a44f965a45 Turso 0.2.0-pre.14 2025-10-02 14:29:22 +03:00
Pekka Enberg
7bfb4dc203 Merge 'Fix MVCC startup infinite loop when using existing DB' from Jussi Saurio
MVCC bootstrap connection got stuck into an infinite statement reparsing
loop because the bootstrap procedure happened before the on-disk schema
was deserialized.
closes #3518

Closes #3522
2025-10-02 14:20:42 +03:00
Jussi Saurio
0e3132d24b Dont try to destroy btree in mvcc mode 2025-10-02 14:12:12 +03:00
Jussi Saurio
bb82f26440 Modify DDL fuzz test to support MVCC too 2025-10-02 14:12:12 +03:00
Avinash Sajjanshetty
09ba4615ba return appropriate error if checksum was not compiled 2025-10-02 16:11:18 +05:30
Pekka Enberg
aa37d279ca Merge 'core/vdbe: Avoid cloning Arc<MvStore> on every VDBE step' from Pekka Enberg
The VDBE step() function was taking Arc<MvStore> by value, causing it to
be cloned on every single step of query execution. This resulted in
thousands of atomic reference count increments/decrements per query,
showing up as a major hotspot in profiling.
Changed step() and related functions to take Option<&Arc<MvStore>>
instead, passing a reference rather than cloning the Arc. This
eliminates the unnecessary atomic operations while maintaining the same
semantics.

Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com>

Closes #3520
2025-10-02 13:41:14 +03:00
Avinash Sajjanshetty
6d7dc6d183 enable checksums only if its opted in via feature flag 2025-10-02 16:01:56 +05:30
Jussi Saurio
3a1851ec06 Fix MVCC startup infinite loop when using existing DB
MVCC bootstrap connection got stuck into an infinite statement
reparsing loop because the bootstrap procedure happened before the
on-disk schema was deserialized.
2025-10-02 13:21:44 +03:00
Avinash Sajjanshetty
68425fbe92 Fix whopper to work with encryption flag 2025-10-02 15:26:35 +05:30
Pekka Enberg
4c5a7cda08 core/vdbe: Avoid cloning Arc<MvStore> on every VDBE step
The VDBE step() function was taking Arc<MvStore> by value, causing it to
be cloned on every single step of query execution. This resulted in
thousands of atomic reference count increments/decrements per query,
showing up as a major hotspot in profiling.

Changed step() and related functions to take Option<&Arc<MvStore>>
instead, passing a reference rather than cloning the Arc. This eliminates
the unnecessary atomic operations while maintaining the same semantics.
2025-10-02 12:28:11 +03:00
Pekka Enberg
641c3a73d0 Merge 'sim: add Profile::SimpleMvcc' from Jussi Saurio
- max 2 connections
- max 1 table
- no faults
- no indexes
Makes discovering very basic bugs in MVCC much easier

Closes #3517
2025-10-02 12:12:15 +03:00
Jussi Saurio
fa6ee6b850 Merge 'Fix: JOIN USING should pick columns from left table, not right' from Jussi Saurio
Closes #3468
Closes #3479

Closes #3485
2025-10-02 10:16:38 +03:00
Jussi Saurio
d3c9ef3a5c sim: add Profile::SimpleMvcc
- max 2 connections
- max 1 table
- no faults
- no indexes

Makes discovering very basic bugs in MVCC much easier
2025-10-02 10:14:31 +03:00
Jussi Saurio
7360edc169 Merge 'mvcc: dont try to end pager tx on connection close' from Jussi Saurio
closes #3487

Closes #3491
2025-10-02 10:06:23 +03:00
Pekka Enberg
17e07e620a Merge 'fix/vdbe: reset op_transaction state properly' from Jussi Saurio
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
Pekka Enberg
f4bb9f1a66 Merge 'bindings/rust: don't panic if user provides invalid parameter' from Jussi Saurio
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

Closes #3515
2025-10-02 08:32:52 +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
Jussi Saurio
a9d782e319 Merge 'Add encryption internals docs' from Avinash Sajjanshetty
preview - https://github.com/tursodatabase/turso/blob/8d2ef700c9b087a7e2
904c25052e4365395b33b3/docs/manual.md#encryption-1

Closes #3461
2025-10-02 07:04:16 +03:00
Jussi Saurio
3c9a6993e3 Merge 'core/storage: Apple platforms support' from Charly Delaroche
Closes #3507
2025-10-02 07:01:56 +03:00
Jussi Saurio
0e1a0e34a6 Merge 'Allow workflow_dispatch for all CI to allow for re-running jobs' from Preston Thorpe
Currently it is mad annoying when 1 job fails and you want a green
check, you have to force push and run them all over again -_-

Closes #3511
2025-10-02 07:01:04 +03:00
Jussi Saurio
e65eae764c Merge 'Resolve appropriate column name for rowid alias/PK' from Preston Thorpe
closes https://github.com/tursodatabase/turso/issues/3512

Closes #3513
2025-10-02 06:59:18 +03:00
Jussi Saurio
9e4ea6ea34 Merge 'core/mvcc/logical-log: fail in read_more_data if couldn't read enough' from Pere Diaz Bou
Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com>

Closes #3500
2025-10-02 06:58:28 +03:00
Jussi Saurio
bb4e54ca73 Merge 'fix/mvcc: deserialize table_id as i64' from Jussi Saurio
Reviewed-by: Nikita Sivukhin (@sivukhin)

Closes #3492
2025-10-02 06:58:01 +03:00
Jussi Saurio
30e6524c4e Fix: JOIN USING should pick columns from left table, not right
Closes #3468
Closes #3479
2025-10-02 06:56:52 +03:00
Jussi Saurio
c0da38e24a Merge 'Clear WhereTerm 'from_outer_join' state when LEFT JOIN is optimized to INNER JOIN' from Jussi Saurio
Closes #3470
## Background
In a query like `SELECT * FROM t LEFT JOIN s ON t.a=s.a WHERE s.a =
'foo'` we can remove the LEFT JOIN and replace it with an `INNER JOIN`
because NULL values will never be equal to 'foo'. Rewriting as `INNER
JOIN` allows the optimizer to also reorder the table join order to come
up with a more efficient query plan. In fact, we have this optimization
already.
## Problem
However, there is a dumb bug where `WhereTerm`s involving this join
still retain their `from_outer_join` state, resulting in forcing the
evaluation of those terms at the original join index, which results in
completely wrong bytecode if the join optimizer decides to reorder the
join as `s JOIN t` instead. Effectively it will evaluate `t.a=s.a` after
table `s` is open but table `t` is not open yet.
## Fix
This PR fixes that issue by clearing `from_outer_join` properly from the
relevant `WhereTerm`s.

Closes #3475
2025-10-02 06:56:07 +03:00
Jussi Saurio
78cccdd87a Merge 'Substr fix UTF-8' from Pedro Muniz
Fixes:
- `start_value` and `length_value` should be casted to integers
- proper handling of utf-8 characters
- do not need to cast blob to string, as substr in blobs refers to byte
indexes and not char-indexes

Closes #3465
2025-10-02 06:55:38 +03:00
PThorpe92
efac598232 Resolve appropriate column name for rowid alias/PK 2025-10-01 21:49:42 -04:00
Preston Thorpe
b310411997 Merge 'printf should truncates floats' from Pavan Nambi
closes https://github.com/tursodatabase/turso/issues/3308

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

Closes #3415
2025-10-01 19:31:39 -04:00
PThorpe92
a35f8a427f Allow workflow_dispatch for all CI to allow for re-running individual jobs 2025-10-01 19:01:10 -04:00
Preston Thorpe
4066718979 Merge 'Reject unsupported FROM clauses in UPDATE' from Mikaël Francoeur
Before, FROM clauses were simply ignored:
```
turso> update t set a = b from (select random() as b);
  × Parse error: no such column: b
```
Now, they will be rejected with a clear message. It also makes it
clearer that they need to be implemented:
```
turso> update t set a = b from (select random() as b);
  × Parse error: FROM clause is not supported in UPDATE
```

Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com>

Closes #3509
2025-10-01 17:17:39 -04:00