Commit Graph

10455 Commits

Author SHA1 Message Date
Pekka Enberg
eb835c39d4 Merge 'core/vdbe: fix ALTER COLUMN to propagate constraints to other table references' from Preston Thorpe
with fix to ensure `PRIMARY KEY` isn't written twice

Closes #3798
2025-10-21 20:05:41 +03:00
Nikita Sivukhin
792e0033ae fix tests and clippy 2025-10-21 21:03:45 +04:00
Pekka Enberg
177e4f39a8 Merge 'Move completion code to separate file' from Pedro Muniz
We have almost 1000 lines of code related to Completions the
`io/mod.rs`. My intention here is to declutter the file so that we can
focus more on what is relevant for the `IO` and `File` trait

Closes #3800
2025-10-21 20:03:40 +03:00
Pekka Enberg
edea108037 Merge 'avoid unnecessary allocations' from Nikita Sivukhin
Closes #3801
2025-10-21 20:03:25 +03:00
Pere Diaz Bou
128b426681 core/mvcc/cursor: imports 2025-10-21 18:22:37 +02:00
Pere Diaz Bou
92c0e74458 core/mvcc/cursor: implement seek_to_last 2025-10-21 18:22:37 +02:00
Pere Diaz Bou
8857604161 core/mvcc/cursor: fix rewind 2025-10-21 18:22:37 +02:00
Pere Diaz Bou
3f41a092f2 core/mvcc/cursor: add next rowid lock 2025-10-21 18:22:37 +02:00
Pere Diaz Bou
0fee588bca core/mvcc/cursor: add record cursor 2025-10-21 18:22:37 +02:00
Pere Diaz Bou
790859c62f core/mvcc/cursor: fix exists 2025-10-21 18:22:37 +02:00
Pere Diaz Bou
edac1ff256 core/mvcc/cursor: set null flag 2025-10-21 18:22:37 +02:00
Pere Diaz Bou
ea04e9033a core/mvcc: add btree_cursor under MVCC cursor 2025-10-21 18:22:37 +02:00
Nikita Sivukhin
00e382a7c7 avoid unnecessary allocations 2025-10-21 20:13:39 +04:00
Pekka Enberg
d2d995a9c0 Merge 'Make sure explicit column aliases have binding precedence in orderby' from Pavan Nambi
closes https://github.com/tursodatabase/turso/issues/3684

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

Closes #3709
2025-10-21 19:04:42 +03:00
pedrocarlo
a327747531 organize completion code in a separate file 2025-10-21 12:43:49 -03:00
Pekka Enberg
51c5d6a66c Merge 'tests/integration: Reduce collation fuzz test iterations' from Pekka Enberg
The collation fuzz test case takes up to 4 minutes to run, making it the
slowest of all the test cases. Let's reduce iteration count a bit to
make this more CI friendly.

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

Closes #3797
2025-10-21 18:41:10 +03:00
PThorpe92
08197e345a Fix cdc test to assert for correct schema output 2025-10-21 11:22:29 -04:00
PThorpe92
c48d7a0963 Add tcl tests for alter column fixes 2025-10-21 10:47:08 -04:00
PThorpe92
2fbd4b7cec Ensure op_alter_column and Func::AlterColumn are fixing table references to columns with fk's 2025-10-21 10:46:52 -04:00
PThorpe92
06e3b9611b Add helpers to rewrite REFERENCES from foriegn keys in ColumnDefinition 2025-10-21 10:40:31 -04:00
Pekka Enberg
05bd75275f tests/integration: Reduce collation fuzz test iterations
The collation fuzz test case takes up to 4 minutes to run, making it the
slowest of all the test cases. Let's reduce iteration count a bit to
make this more CI friendly.
2025-10-21 17:29:11 +03:00
PThorpe92
7c746e476c Fix to_sql method on BTreeTable to not double write primary keys 2025-10-21 09:45:42 -04:00
Pekka Enberg
16d1398586 Merge 'Switch random blob creation to get_random' from Pedro Muniz
Also added a benchmark for inserting randomblobs. On my machine, I get
something like a 20% increase in performance.

Closes #3787
2025-10-21 16:04:55 +03:00
Pekka Enberg
74d4dd53dc Merge 'Fix git directory resolution in simulator to support worktrees' from Jussi Saurio
sim cannot be run in a git worktree on main

Closes #3794
2025-10-21 16:03:58 +03:00
Pekka Enberg
6139dde081 Revert "Merge 'core/translate: fix ALTER COLUMN to propagate other constraint references' from Preston Thorpe"
This reverts commit 1151f49ff4, reversing
changes made to f4da2194f4.
2025-10-21 16:00:04 +03:00
Nikita Sivukhin
2483d08bca do not allocate if possible 2025-10-21 16:28:00 +04:00
Jussi Saurio
b67fabdd62 Fix git directory resolution in simulator to support worktrees
sim cannot be run in a git worktree on main
2025-10-21 14:34:27 +03:00
Nikita Sivukhin
948bd557cd use simsimd for dense operations 2025-10-21 14:59:01 +04:00
Pekka Enberg
f764f3061d Merge 'Add Miri support for turso_stress, with bash scripts to run' from Bob Peterson
It was mentioned in https://github.com/tursodatabase/turso/pull/3720
that adding Miri support for `turso_stress` would be useful. And, that a
bash script to start Miri with the right config would be a big help.
Notable changes:
- `antithesis_sdk`'s default features are disabled at the workspace
level, and only enabled as needed with the `antithesis` feature flag in
the various turso crates. Miri needs the noop version of
`antithesis_sdk` to run `turso_stress`, and feature unification
previously prevented this. I'm not able to ensure locally that all the
Antithesis stuff is still happy with these changes.
- Bash script to run `turso_stress` - this is barebones for now, see
below
- Bash script to run `simulator` - this passes any args to the `cargo
run` invocation inside, intercepting `--seed` if it's present, and
generating one from `/dev/random` if it's not. The seed is passed to
both Miri and the simulator to keep the overall execution reproducible.
(I checked this with a simple case)
- A `const fn`, `normal_or_miri` to supply different defaults in things
like CLI args for normal operation and Miri, since it's so slow. (An
idea I stole from tokio.) Right now the relevant values are 100x smaller
for Miri, although Miri is probably 1000 to 10,000x slower overall from
a rough estimation.
Caught UB from running `turso_stress` with Miri:
- An unsafe cast of a `*u8` to `*u32` inside the BTree implementation
resulted in the `*u32` making an unaligned read: `read()` ->
`read_unaligned()` fixes this
Future work - Making `turso_stress` reproducible under Miri:
- Right now `turso_stress` is plugged in to Antithesis, which is great!
But, `antithesis_sdk`'s noop mode (`default-features = false`) turns
`antithesis_sdk::random::get_random()` into `rand::random<u64>()`, which
isn't seedable/reproducible. It's more work than I wanted to take on in
this PR, but I'd like to instead conditionally replace `get_random` with
a seedable `ChaCha8Rng` like in the simulator, if Miri is being used.
Comment:
- On a machine without all necessary dependencies, running the bash
scripts fails in a way that cargo prompts you through installing the
nightly toolchain, Miri, etc. until it works
- Below is a snippet of the output from Miri on the Btree alignment
issue. Because turso_stress isn't yet deterministic/reproducible under
Miri, I can't always reproduce it. (It doesn't always happen like the
ones in my last MR)
```
error: Undefined Behavior: accessing memory based on pointer with alignment 1, but alignment 4 is required
    --> /home/rwp/git/turso/core/storage/btree.rs:2860:50
     |
2860 |                     let mut pgno: u32 = unsafe { right_pointer.cast::<u32>().read().swap_bytes() };
     |                                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Undefined Behavior occurred here
     |
     = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
     = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information

```

Closes #3790
2025-10-21 11:53:49 +03:00
Pekka Enberg
1151f49ff4 Merge 'core/translate: fix ALTER COLUMN to propagate other constraint references' from Preston Thorpe
closes #3666
and probably other issues i'll have to go digging through to see if
there is any others.
<img width="948" height="445" alt="image" src="https://github.com/user-
attachments/assets/2844e09b-109a-4a70-bd18-d8a814e49ea0" />
Any ALTER COLUMN stmt will now update the constraints on the table
(primary key, foreign key, unique)

Closes #3776
2025-10-21 11:53:42 +03:00
Pekka Enberg
f4da2194f4 Merge 'Shared WAL lock scoping' from Pedro Muniz
After https://github.com/tursodatabase/turso/pull/3759 was merged, I
went back to the code to see if we could try and avoid this problem in
the future. One way I tried to achieve this is with scoped locking by
forcing all operations on the `SharedWalFile` to go through
`with_shared` and `with_shared_mut`. Also, I noticed some functions
still held locks across IO calls, so I fixed that as well.
If Rust already had`negative_impls` or custom auto traits in stable, I
could try to create a marker trait where you can mark any closure that
contains a `Completion` as IO related and throw a compile error when you
try to execute IO inside it.

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

Closes #3781
2025-10-21 09:05:40 +03:00
Bob Peterson
b92f4cb9c4 Make Miri easier to run 2025-10-20 23:48:19 -05:00
pedrocarlo
a614b51ebf change randomblob generation to use thread_rng 2025-10-21 01:41:40 -03:00
Bob Peterson
2cb0a9b34b Use read_unaligned with *u8 cast to *u32
Avoids undefined behavior due to unaligned read caught with Miri
2025-10-20 22:50:57 -05: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
pedrocarlo
baf649affb add insert randomblob benchmark 2025-10-20 14:47:47 -03:00
pedrocarlo
ba9a1ebbef add mutable scoped locking for SharedWalFile 2025-10-20 10:45:14 -03:00
pedrocarlo
b00a276960 add scoped locking for SharedWalFile to avoid holding locks for longer than needed 2025-10-20 10:45:14 -03:00
Pekka Enberg
97991a1934 Merge 'Fix deferred FK violations check before committing to WAL' from Jussi Saurio
DEFERRED was a bit too deferred - it allowed the dirty pages to be
written out to WAL before checking for violations, resulting in the
violations effectively being committed even though the transaction ended
up aborting
Closes #3784

Closes #3785
2025-10-20 14:51:25 +03:00
Jussi Saurio
10532544dc Fix: check deferred FK violations before committing to WAL
DEFERRED was a bit too deferred - it allowed the dirty pages to be
written out to WAL before checking for violations, resulting in the
violations effectively being committed even though the transaction
ended up aborting
2025-10-20 14:00:49 +03:00
Jussi Saurio
bebe230b05 Regression test: deferred FK violations are checked before commit 2025-10-20 13:59:37 +03:00
Pekka Enberg
c81c062707 Merge 'Remove tests that alter testing.db from views.test' from Preston Thorpe
so we don't to have to `git restore` the database files every time tests
run

Closes #3772
2025-10-20 13:43:56 +03:00
Pekka Enberg
931a2a4127 Merge 'tests/integration: Disable rowid alias differential fuzz test case' from Pekka Enberg
The fuzz test seems to find something that causes the tests to hang.
Let's disable it for now.

Closes #3782
2025-10-20 13:38:57 +03:00
Pekka Enberg
591b43634e tests/integration: Disable rowid alias differential fuzz test case
The fuzz test seems to find something that causes the tests to hang.
Let's disable it for now.
2025-10-20 12:30:32 +03:00
Pekka Enberg
e6c70f2d55 Merge 'core/storage: Reduce logging level' from Pekka Enberg
Closes #3765
2025-10-20 11:52:53 +03:00
Pekka Enberg
583f2b3d48 Merge 'cli: Improve manual page display' from Pavan Nambi
opens manual page in seperate screen similar to man command in linux

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

Closes #3777
2025-10-20 11:51:59 +03:00
Pavan-Nambi
aad3c00e57 clippy 2025-10-19 13:25:40 +05:30
Pavan-Nambi
055b38787d more keybindings 2025-10-19 13:22:35 +05:30
Pavan-Nambi
3658a94f06 fmt 2025-10-19 13:20:40 +05:30
Pavan-Nambi
ba2570d0b8 cli:scrolling and enable suggestion for wrong commands 2025-10-19 13:20:03 +05:30