Commit Graph

10455 Commits

Author SHA1 Message Date
Pekka Enberg
fbad158213 Turso 0.2.0-pre.4 2025-09-22 09:15:55 +03:00
Pekka Enberg
18c41b0f5a Merge 'sqlite3: Fix compatibility test error by canonicalizing path' from Samuel Marks
Use canonical path to fix temp path on macOS ; rename to resolve binding
connascence. Fixes:
```
---- tests::test_sqlite3_db_filename stdout ----

thread 'tests::test_sqlite3_db_filename' (62061) panicked at sqlite3/tests/compat/mod.rs:1251:13:
assertion `left == right` failed
  left: "/private/var/folders/w5/21g61wls7ksd3z8cxrj41s1c0000gn/T/.tmpNcCUO2.db"
 right: "/var/folders/w5/21g61wls7ksd3z8cxrj41s1c0000gn/T/.tmpNcCUO2.db"
```

Closes #3227
2025-09-22 09:15:00 +03:00
Pekka Enberg
46297acb31 Merge 'Sync improvements' from Nikita Sivukhin
This PR improves sync and database bindings for browser
List of changes:
- For node and browser database now run on main thread and only IO work
offloaded to the worker (web worker in browser)
- Simple locks are implemented for database access externally in order
to guard access to the same connection (when request is executed async -
main thread can try to start another request concurrently)
- parking_lot in the Wal replaced by spin-wait (by invoking
`parking_lot.try_read/try_write`) for WASM target because browser can't
park main thread
- js sync reworked in order to support few engine options
(`longPollTimeoutMs`) and introduce external locking which properly
guards concurrent access of sync methods

Closes #3218
2025-09-22 09:14:30 +03:00
Pekka Enberg
6280cfc59d Merge branch 'main' into sync-improvements 2025-09-22 07:35:39 +03:00
Pekka Enberg
54176d4548 Merge 'Add encryption throughput test' from Avinash Sajjanshetty
```
cargo run --release -- -b 100 -i 100000 --read-ratio 75

cargo run --release -- -b 100 -i 100000 --read-ratio 75 --encryption
```
```
Total time: 629.51s

Transaction throughput: 158.85 txns/sec
Operation throughput: 15885.37 ops/sec
  - Read operations: 7500165 (7500165 found, 0 not found)
  - Read throughput: 11914.29 reads/sec
  - Write operations: 2499835
  - Write throughput: 3971.08 writes/sec
```
vs
```
Total time: 665.05s

Transaction throughput: 150.36 txns/sec
Operation throughput: 15036.47 ops/sec
  - Read operations: 7500165 (7500165 found, 0 not found)
  - Read throughput: 11277.60 reads/sec
  - Write operations: 2499835
  - Write throughput: 3758.87 writes/sec
```

Closes #3230
2025-09-22 07:34:29 +03:00
Pekka Enberg
dae72a7418 Merge 'Remove some unnecessary unsafe impls' from Pedro Muniz
Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com>

Closes #3236
2025-09-22 07:33:50 +03:00
Glauber Costa
2627ad44de support union statements in the DBSP circuit compiler 2025-09-21 21:00:27 -03:00
Glauber Costa
b419db489a Implement the DBSP merge operator
The Merge operator is a stateless operator that merges two deltas.
There are two modes: Distinct, where we merge together values that
are the same, and All, where we preserve all values. We use the rowid of
the hashable row to guarantee that: In Distinct mode, the rowid is set
to 0 in both sides. If they values are the same, they will hash to the
same thing. For All, the rowids are different.

The merge operator is used for the UNION statement, which is a
cornerstone of Recursive CTEs.
2025-09-21 21:00:27 -03:00
Glauber Costa
9f54f60d45 make sure that complex select statements are captured by MV populate
The population code extracts table information from the select statement
so it can populate the materialized view. But the code, as written
today, is naive. It doesn't capture table information correctly if there
is more than one select statement (such in the case of a union query).
2025-09-21 21:00:27 -03:00
PThorpe92
7def22ef3c Add DO UPDATE SET case to partial index/upsert fuzzing 2025-09-21 14:47:59 -04:00
pedrocarlo
ffeb26b24a only ever call callbacks once 2025-09-21 14:36:18 -03:00
PThorpe92
4867999381 Add partial_index_mutation_and_upsert_fuzz test 2025-09-21 13:29:30 -04:00
PThorpe92
a1ca56620a Add SQLITE_CONSTRAINT_UNIQUE constraint to op_halt handling 2025-09-21 13:29:01 -04:00
PThorpe92
6fb4b03801 Fix UPSERT handling, properly rebuild indexes only based on what columns they touch 2025-09-21 13:28:36 -04:00
PThorpe92
0ea6e5714d Separate UPSERT behavior into preflight and commit state to prevent inserting idx before violating unique constraint 2025-09-21 13:27:50 -04:00
PThorpe92
e545e75e31 Emit Affinity instruction for unique index, and use no_constant_opt 2025-09-21 13:24:48 -04:00
PThorpe92
63177c42e4 Add SQLITE_CONSTRAINT_UNIQUE error constant 2025-09-21 13:22:31 -04:00
pedrocarlo
6e2b0c901e remove PanicGenerationContext and instead just pass the connection context directly 2025-09-21 14:16:46 -03:00
pedrocarlo
e5dfc942b1 remove some unnecessary unsafe impls 2025-09-21 13:29:59 -03:00
Pavan-Nambi
51cf410b56 add has_autoincrement to all test tables from main branch 2025-09-21 16:10:45 +05:30
Pavan Nambi
47194d7658 Merge branch 'tursodatabase:main' into cdc_fail_autoincrement 2025-09-21 16:03:38 +05:30
Glauber Costa
13260349b0 Return a parse error for a non-equality join
We currently don't handle non equality, but end up just returning a
bogus result. Let's parse error.
2025-09-20 20:35:10 -03:00
PThorpe92
33538a1ebf Add some tests for UPSERT with partial indexes 2025-09-20 18:32:50 -04:00
PThorpe92
03149bc92d Remove unused imports 2025-09-20 18:32:37 -04:00
PThorpe92
62ee68e4dd Fix INSERT/UPSERT to properly handle and/or reject partial indexes 2025-09-20 18:32:03 -04:00
PThorpe92
51fb801d87 Fix partial index handling in insert to properly map rowid to insertion key 2025-09-20 17:44:28 -04:00
PThorpe92
93d24d2b50 Use new bind_where_expr helper method in emitter 2025-09-20 17:43:50 -04:00
PThorpe92
421b5b7bae Use new index.validate_where_expr and bind_where_expr methods on index create 2025-09-20 17:42:50 -04:00
PThorpe92
1ed3fc52f7 Add method to validate the Where Expr from a partial index 2025-09-20 17:41:56 -04:00
PThorpe92
0f771ecb5d Fix tests to assert for UNIQUE constraint failed: table.col_name instead of idx name 2025-09-20 15:02:38 -04:00
PThorpe92
6dc7d04c5a Replace translate_epxr with translate_condition_expr and fix constraint error 2025-09-20 15:02:06 -04:00
PThorpe92
281344434f Remove unused import 2025-09-20 14:38:50 -04:00
PThorpe92
340b95aa8b Apply PR review suggestions, add comments to partial indexes 2025-09-20 14:38:50 -04:00
PThorpe92
21f6455190 Fix clippy warnings and tests 2025-09-20 14:38:50 -04:00
PThorpe92
f4258b8b08 Just use raw pointer instead of cloning JoinedTable in emitter 2025-09-20 14:38:49 -04:00
PThorpe92
6d8bf009f1 Add some comments 2025-09-20 14:38:49 -04:00
PThorpe92
67cb59d9a7 Add UPDATE tests for partial index behavior 2025-09-20 14:38:49 -04:00
PThorpe92
2d952feae3 Add DELETE behavior tests for partial indexes 2025-09-20 14:38:49 -04:00
PThorpe92
635273f782 Prevent using a partial index as a scan driver 2025-09-20 14:38:48 -04:00
PThorpe92
4c6917f849 Add testing for partial indexes 2025-09-20 14:38:48 -04:00
PThorpe92
51f970a263 Support partial indexes in INSERT/UPDATE/DELETE 2025-09-20 14:38:48 -04:00
PThorpe92
a0f574d279 Add where_clause expr field to Index 2025-09-20 14:38:47 -04:00
PThorpe92
864d113037 Remove dumb comment 2025-09-20 14:38:47 -04:00
Preston Thorpe
25754cb0e4 Merge 'Pragma busy timeout' from Nikita Sivukhin
Expose busy_timeout added in #3067 as a `PRAGMA busy_timeout=<ms
duration>`
https://www.sqlite.org/pragma.html#pragma_busy_timeout

Reviewed-by: Avinash Sajjanshetty (@avinassh)
Reviewed-by: Pere Diaz Bou <pere-altea@homail.com>

Closes #3224
2025-09-20 14:36:29 -04:00
Avinash Sajjanshetty
0597ea722a Add encryption throughput test 2025-09-20 21:56:58 +05:30
pedrocarlo
0e702fbec2 check FaultyQuery depending tables when shrinking 2025-09-20 12:01:07 -03:00
pedrocarlo
021d5d272a refactor shadowing code to take into account snapshot isolation 2025-09-20 12:01:07 -03:00
pedrocarlo
6b0011f477 in shriking remove unnecessary begin commit queries 2025-09-20 11:52:15 -03:00
pedrocarlo
0293c32616 disable integrity check and indexes when using mvcc 2025-09-20 11:52:15 -03:00
pedrocarlo
850dbc75a2 adjust shrinking to keep previous interactions if there are no depending tables 2025-09-20 11:52:15 -03:00