Commit Graph

10673 Commits

Author SHA1 Message Date
Jussi Saurio
4de36d28e6 deps: add tracing to rust bindings 2025-10-16 14:00:26 +03:00
Jussi Saurio
56d5702176 Fix: rolling back tx should set autocommit to true
Rolling back a transaction should result in `connection.auto_commit` being set
back to true.

Added a regression test for this where a UNIQUE constraint violation rolls back
the transaction and trying to COMMIT will fail.

Currently, our default conflict resolution strategy is ROLLBACK,
which ends the transaction. In SQLite, the default is ABORT, which rolls back
the current statement but allows the transaction to continue.

We should migrate to default ABORT once we support subtransactions.
2025-10-16 12:05:53 +03:00
Pekka Enberg
e9c0fdcb4b Turso 0.3.0-pre.2 2025-10-16 11:31:30 +03:00
Pekka Enberg
a450a43d6d dist: Add Linux/arm64 target for install package 2025-10-16 11:30:30 +03:00
Pekka Enberg
bf5de920f2 core: Unsafe Send and Sync pushdown
This patch pushes unsafe Send and Sync to individual components instead
of doing it at Database level. This makes it easier for us to
incrementally fix thread-safety, but avoid developers adding more thread
unsafe code.
2025-10-16 11:26:50 +03:00
Pekka Enberg
b64ce77e47 Merge 'core: Don't run build.rs in debug mode' from Pedro Muniz
Hopefully this will help a bit with compile times when developing and
with `cargo check`

Closes #3744
2025-10-16 10:52:03 +03:00
Pekka Enberg
f8e8ed6228 Merge 'Run SQLite integrity check after stress test run' from Pedro Muniz
Closes #2916

Closes #3730
2025-10-16 10:07:09 +03:00
Jussi Saurio
95f375791b refactor: move condition outside init_autoincrement 2025-10-16 09:34:13 +03:00
Jussi Saurio
25339a5200 rename: CheckConstraints -> ConstraintsToCheck
CHECK constraints is a separate SQL concept, so let's remove some
potential confusion from the naming.
2025-10-16 09:30:41 +03:00
Pekka Enberg
012ac00e46 Merge 'Document ThreadSanitizer in CONTRIBUTING.md' from Pekka Enberg
Closes #3739
2025-10-16 08:43:33 +03:00
pedrocarlo
2a1be48f3a do not run build.rs on debug mode 2025-10-16 01:22:54 -03:00
PThorpe92
3112f55e05 Add TCL tests for INSERT OR IGNORE handling 2025-10-15 22:51:10 -04:00
PThorpe92
41d2a0af77 Add INSERT OR IGNORE handling and refactor INSERT further 2025-10-15 22:51:10 -04:00
Preston Thorpe
0ae53e6270 Merge 'tests/fuzz: Accept SEED env var for all fuzz tests' from Preston Thorpe
Closes #3741
2025-10-15 22:50:57 -04:00
PThorpe92
48eb456a12 Accept SEED env var for all fuzz tests 2025-10-15 20:08:13 -04:00
Preston Thorpe
4873103660 Merge 'Fix: outer CTEs should be available in subqueries' from Jussi Saurio
Closes #3670

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

Closes #3737
2025-10-15 19:07:42 -04:00
Pekka Enberg
6fe9ea0925 Merge 'Make Rust bindings actually async' from Pedro Muniz
This PR introduces a `Context` object that is stored in the `Completion`
that currently only stores a `Waker`. In the future, I want to add some
sort of abort signal so that we can abort tasks that share the same
Context. To pass the Waker, I introduced a `step_with_waker` function in
`Statement` that delegates to an internal `_step` function. `_step` is
the previous `step` but just with the `Option<&Waker>` argument.
I was going to try and have the BusyHandler by truly async as well, but
I decided to not do it here, because it will be slightly complicated to
achieve.

Closes #3535
2025-10-15 19:38:24 +03:00
Pavan-Nambi
2df3d3ee0c add more tests 2025-10-15 21:51:52 +05:30
Pekka Enberg
08f010b969 Document ThreadSanitizer in CONTRIBUTING.md 2025-10-15 18:16:31 +03:00
Nikita Sivukhin
4b3689e9e7 avoid doing work in case of heap-sort optimization 2025-10-15 17:27:22 +04:00
Nikita Sivukhin
dd34f7fd50 wip 2025-10-15 17:27:22 +04:00
Nikita Sivukhin
af4c1e8bd4 use proper register for limit 2025-10-15 17:27:22 +04:00
Nikita Sivukhin
a2dbaafe69 add explicit test for multiple rows heap-sort bug 2025-10-15 17:27:22 +04:00
Nikita Sivukhin
a1260ca8c7 implement Sequence opcodes for any type of cursors 2025-10-15 17:27:22 +04:00
Nikita Sivukhin
b065e7d380 emit Sequence column for heap-sort in order to distinguish between rows with same order by key and result columns 2025-10-15 17:27:22 +04:00
Nikita Sivukhin
5868270b06 fix clippy 2025-10-15 17:27:22 +04:00
Nikita Sivukhin
1a24139359 fix limit for order by queries with heap-sort style execution 2025-10-15 17:27:22 +04:00
Nikita Sivukhin
7c919314a9 use heap-sort style algorithm for order by ... limit k queries 2025-10-15 17:27:22 +04:00
Nikita Sivukhin
68650cf594 alternative read_variant implementation
- it faster in benchmark (who knows why)
- also seems bit faster for some my query
- let's test on CI
2025-10-15 17:27:22 +04:00
Nikita Sivukhin
c0fdaeb475 move more possible option higher 2025-10-15 17:27:22 +04:00
Nikita Sivukhin
f19c73822e simplify serial_type size calculation 2025-10-15 17:27:22 +04:00
Nikita Sivukhin
a6a5ffd821 move read_varint_fast closer to the read_varint impl 2025-10-15 17:27:22 +04:00
Nikita Sivukhin
dba195bdfa avoid allocations 2025-10-15 17:27:22 +04:00
Nikita Sivukhin
ae8adc0449 faster extend_from_slice 2025-10-15 17:27:22 +04:00
Nikita Sivukhin
8e107ab18e slight reorder of operations 2025-10-15 17:27:22 +04:00
Jussi Saurio
d7a719418e Fix: outer CTEs should be available in subqueries 2025-10-15 15:15:55 +03:00
Pekka Enberg
af3a90bf4b core: Kill Many variant from IOCompletions enum 2025-10-15 11:48:24 +03:00
Pekka Enberg
5fb93b8780 core: Kill io_yield_many macro 2025-10-15 11:48:24 +03:00
Pekka Enberg
ff7f462981 core/vdbe/sorter: Replace IOCompletions::Many with completion group 2025-10-15 11:48:24 +03:00
Pekka Enberg
840d6a0df5 core/storage/btree: Replace io_yield_many with completion group in B-Tree 2025-10-15 11:48:24 +03:00
Pekka Enberg
986faa42da core/storage/pager: Replace io_yield_many with completion groups 2025-10-15 11:48:24 +03:00
Pekka Enberg
07ba7276b2 core/vdbe/sorter: Replace io_yield_many with completion groups 2025-10-15 11:48:24 +03:00
Pekka Enberg
80876148cf core/io: Add cancel() method to CompletionGroup 2025-10-15 11:48:24 +03:00
Pekka Enberg
7ff427f9d4 core/io: Fix completion group callback invocation for empty groups
Spotted by @pedrocarlo.
2025-10-15 11:48:24 +03:00
Pekka Enberg
cdd6f6a45d core/io: Fix completion group parent notification
The previous implementation of CompletionGroup would call the group's
callback function directly when the last completion finished:

    if prev == 1 {
        let group_result = group.result.get().and_then(|e| *e);
        (group.complete)(group_result.map_or(Ok(0), Err));
    }

This broke nested completion groups because parent groups track their
children via the Completion::callback() method. By calling the function
pointer directly, we bypassed the completion chain and parent groups
never received notification that their child had completed.

The fix stores a reference to the group's own Completion object in
self_completion during build(). When the last child finishes, we call
group_completion.callback() instead of invoking the function directly.
This properly propagates through the completion hierarchy, ensuring
parent groups decrement their outstanding count and eventually complete.

This matches the behavior of individual completions and maintains the
invariant that all completions notify their parents through the unified
callback() mechanism.
2025-10-15 10:47:16 +03:00
Pekka Enberg
d3e8285d93 core/io: Never skip a completion in CompletionGroup::add()
The previous implementation of CompletionGroup::add() would filter out
successfully-finished completions:

    if !completion.finished() || completion.failed() {
        self.completions.push(completion.clone());
    }

This caused a problem when combined with drain() in the calling code.
Completions that were already finished would be removed from the source
vector by drain() but not added to the group, effectively losing track
of them.

This breaks the invariant that all completions passed to a group must
be tracked, regardless of their state. The build() method already
handles finished completions correctly by not including them in the
outstanding count.

The fix is to always add all completions and let build() handle their
state appropriately, matching the behavior of the old io_yield_many!()
macro.
2025-10-15 10:47:16 +03:00
Jussi Saurio
4e6f373e3d Merge 'Fix: Evaluating expression in LIMIT and OFFSET clauses.' from
Closes #3687 .
Previously, the `try_fold_expr_to_i64` function casted `NULL` as `0`
when evaluating expressions in `LIMIT` or `OFFSET` clauses. I removed
this function since evaluating the expression directly and relying on
the MustBeInt operation for casting seems to handle everything.

Closes #3695
2025-10-15 10:36:36 +03:00
Pekka Enberg
d3aad90820 Merge 'perf/throughput: force sqlite to use fullfsync' from Pedro Muniz
I was sampling our performance and noticed that In the throughput test,
we were only setting the `PRAGMA synchronous = full` in `setup_database`
and not in the connection. Also we were not setting `PRAGMA fullfsync =
true`.
Now SQLite numbers and Turso numbers are much closer:
`Turso,1,1000,0,215095.94`
vs
`SQLite,1,1000,0,219748.39`
Specs: M2 Air 8gb
related: #3027

Closes #3734
2025-10-15 10:24:13 +03:00
Jussi Saurio
bae33cb52c Avoid unwrapping failed f64 parsing attempts 2025-10-15 09:47:47 +03:00
Jussi Saurio
25cf56b8e8 Fix expected error message 2025-10-15 09:41:44 +03:00