Commit graph

37 commits

Author SHA1 Message Date
pedrocarlo
2a449f8f6b revert change in index_scan_compound_key_fuzz 2025-12-10 23:38:41 -03:00
pedrocarlo
bc16588273 index and rowid fuzz should open a separate sqlite database for comparison 2025-12-10 15:38:02 -03:00
pedrocarlo
ffbbd4c270 add exec rows trait for more ergonomic testing in core_tester 2025-12-10 15:21:03 -03:00
pedrocarlo
c207eddd3f remove unused TempDatabase argument requirement for limbo_exec_rows 2025-12-10 15:21:03 -03:00
Nikita Sivukhin
8cc40949a5 fix clippy 2025-12-10 15:08:44 +04:00
Nikita Sivukhin
e70428e976 add explicit insert action to the fuzz test and disable it for now 2025-12-10 14:53:32 +04:00
Nikita Sivukhin
70b1e5716d add fuzz test which maintain sqlite3 and turso db and periodically switch them between each other in order to validate compatibility 2025-12-10 14:53:32 +04:00
Jussi Saurio
2e8b771f6f
Merge 'Fix descending index scan returning rows when seek key is NULL' from Jussi Saurio
Closes #4066
Closes #4129
## Problem
Take e.g.
CREATE TABLE t(x); CREATE INDEX txdesc ON t(x desc); INSERT INTO t
values (1),(2),(3);
SELECT * FROM t WHERE x > NULL;
--
Our plan, like Sqlite, was to start iterating the descending index from
the beginning (Rewind) and stop once we hit a row where x is <= than
NULL using `IdxGe` instruction (GE in descending indexes means LE).
However, `IdxGe` and other similar instructions use a sort comparison
where NULL is less than numbers/strings etc, so this would incorrectly
not jump.
## Fix
Fix: we need to emit an explicit NULL check after rewinding.
## Tests
Added TCL tests + improved `index_scan_compound_key_fuzz` to have NULL
seek keys sometimes.
## AI disclosure
I started debugging this with Claude Code thinking this is a much deeper
corruption issue, but Opus 4.5 noticed immediately that we are returning
rows from a `x > NULL` comparison which should never happen. Hence, the
fix was then fairly simple.

Closes #4132
2025-12-09 09:38:18 +02:00
Jussi Saurio
027ebe33fe Fix descending index scan returning rows when seek key is NULL
Take e.g.

CREATE TABLE t(x); CREATE INDEX txdesc ON t(x desc);
INSERT INTO t values (1),(2),(3);

SELECT * FROM t WHERE x > NULL;

--

Our plan, like Sqlite, was to start iterating the descending index
from the beginning (Rewind) and stop once we hit a row where x is
<= than NULL using `IdxGe` instruction (GE in descending indexes
means LE).

However, `IdxGe` and other similar instructions use a sort comparison
where NULL is less than numbers/strings etc, so this would incorrectly
not jump.

Fix: we need to emit an explicit NULL check after rewinding.
2025-12-08 13:19:58 +02:00
Jussi Saurio
826ca4d44d chore: remove experimental_indexes feature flags 2025-12-08 13:00:37 +02:00
Preston Thorpe
e7c7f232b4
Merge 'testing/fuzz: Add new fuzzer for joins' from Preston Thorpe
needed for #4063 to merge, currently passing on main but just want to
lower the already huge diff

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

Closes #4103
2025-12-05 13:13:44 -05:00
PThorpe92
c9a6827011
Extract out join fuzzer to an additional test on indexed columns 2025-12-05 12:03:23 -05:00
Jussi Saurio
a90087bcf6 Enable compound_select_fuzz for mvcc because it works as a regression test for #4108 2025-12-05 17:19:05 +02:00
Nikita Sivukhin
d5f58de801 fix clippy 2025-12-05 15:29:17 +04:00
Nikita Sivukhin
e839eb499b make fuzzer to generate SELECT COUNT(*) OR SELECT * statements
- this is important for IN operation translation bug because in case of COUNT(*) there is constant assignment instruction right after last instruction translated from IN condition
2025-12-05 14:48:59 +04:00
Jussi Saurio
eb782ce2d4 fix/mvcc: seek() must seek from both mv store and btree
for example, upon opening an existing database, all the rows are in
the btree, so if we seek only from MV store, we won't find anything.
ergo: we must look from both the mv store and the btree. if we are
iterating forwards, the smallest of the two results is where we land,
and vice versa for backwards iteration.

initially this implementation used blocking IO but was refactored to
use state machines after the rest of the Cursor methods in the MVCC cursor
module were refactored to do that too.

---

this PR was initially almost entirely written using Claude Code + Opus 4.5,
but heavily manually cleaned up as the AI made the state machine refactor
far too complicated.
2025-12-05 11:53:16 +02:00
PThorpe92
16a1940d3a
Reduce iteration count in join fuzzer to 2000 2025-12-04 16:23:46 -05:00
PThorpe92
bf6038f0ba
Add join fuzzer for non-indexed columns 2025-12-04 16:19:19 -05:00
Jussi Saurio
3eccee731e Remove todo comment from test 2025-12-03 16:32:20 +02:00
Jussi Saurio
fd067912dc tests/fuzz/mvcc: enable table_index_mutation_fuzz for mvcc
special cases: do not use triggers or expression indexes for the
mvcc version of the test.
2025-12-03 16:28:53 +02:00
Jussi Saurio
ea905d276c
Merge 'Add #[turso_macros::test] to automatically create tests that can run MVCC with minimal code changes' from Pedro Muniz
- added procedural macro that creates Rust tests and with just a flag,
creates a new test that runs the same with MVCC enabled
- migrated almost all tests to use this new macro and added the mvcc
flag to the tests that were not failing
- added a `TempDatabase` builder to facilitate the proc_macro to
generate the correct database options

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

Closes #3991
2025-11-27 21:53:09 +02:00
PThorpe92
04629d4d7b
Add some expression indexes in our fuzz tests 2025-11-20 12:47:46 -05:00
pedrocarlo
2ef2b13278 pending byte page cannot run at the same time with mvcc test 2025-11-19 23:52:22 -03:00
pedrocarlo
963b37f6ee change fuzz test to use new test macros 2025-11-19 23:28:23 -03:00
Jussi Saurio
e1dee4a072 triggers: add a lot of different kinds of tests 2025-11-18 15:19:01 +02:00
PThorpe92
0bc56d3f28
Sprinkle some OR REPLACE into INSERT statements in fuzzing 2025-11-17 08:23:16 -05:00
Jussi Saurio
6cf2072b51 translate: disallow correlated subqueries in HAVING and ORDER BY
These are supported by SQLite, but we cannot handle them correctly yet.
2025-10-29 15:37:19 +02:00
Jussi Saurio
ec1eac2943 Include subqueries in all positions in subquery fuzz test 2025-10-28 14:32:55 +02:00
Jussi Saurio
f593fd1a8d remove deprecated flag from TempDatabase::new_empty() usage in fuzz test
Some checks are pending
Build & publish @tursodatabase/database / db-bindings-x86_64-pc-windows-msvc - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / sync-bindings-aarch64-unknown-linux-gnu - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / sync-bindings-wasm32-wasip1-threads - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / sync-bindings-x86_64-pc-windows-msvc - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / Test DB bindings on browser@20 (push) Blocked by required conditions
Build & publish @tursodatabase/database / Publish (push) Blocked by required conditions
Build & publish @tursodatabase/database / db-bindings-x86_64-unknown-linux-gnu - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / sync-bindings-aarch64-apple-darwin - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / sync-bindings-x86_64-unknown-linux-gnu - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / Test DB bindings on Linux-x64-gnu - node@20 (push) Blocked by required conditions
Python / configure-strategy (push) Waiting to run
Python / macos-arm64 (aarch64) (push) Waiting to run
Python / test (push) Blocked by required conditions
Python / lint (push) Waiting to run
Python / linux (x86_64) (push) Waiting to run
Python / sdist (push) Waiting to run
Rust / clippy (push) Waiting to run
Python / Release (push) Blocked by required conditions
Rust / cargo-fmt-check (push) Waiting to run
Rust / build-native (blacksmith-4vcpu-ubuntu-2404) (push) Waiting to run
Rust / build-native (macos-latest) (push) Waiting to run
Rust / build-native (windows-latest) (push) Waiting to run
Rust / simulator (push) Waiting to run
Rust / test-limbo (push) Waiting to run
Rust / test-sqlite (push) Waiting to run
Rust Benchmarks+Nyrkiö / clickbench (push) Waiting to run
Rust Benchmarks+Nyrkiö / tpc-h-criterion (push) Waiting to run
Rust Benchmarks+Nyrkiö / tpc-h (push) Waiting to run
Rust Benchmarks+Nyrkiö / bench (push) Waiting to run
Rust Benchmarks+Nyrkiö / vfs-bench-compile (push) Waiting to run
2025-10-28 09:10:05 +02:00
Jussi Saurio
d993ac8157
Merge 'index_method: implement basic trait and simple toy index' from Nikita Sivukhin
This PR adds `index_method` trait and implementation of toy sparse
vector index.
In order to make PR more lightweight - for now index methods are not
deeply integrated into the query planner and only necessary components
are added in order to make integration tests which uses `index_method`
API directly to work.
Primary changes introduced in this PR are:
1. `SymbolTable` extended with `index_methods` field and builtin
extensions populated with 2 native indices: `backing_btree` and
`toy_vector_sparse_ivf`
2. `Index` struct extended with `index_method` field which holds
`IndexMethodAttachment` constructed for the table with given parameters
from `IndexMethod` "factory" trait
The toy index implementation store inverted index pairs `(dimension,
rowid)` in the auxilary BTree index. This index uses special
`backing_btree` index_method which marked as `backing_btree: true` and
treated in a special way by the db core: this is real BTree index which
is not managed by the tursodb core and must be managed by index_method
created it (so it responsible for data population, creation, destruction
of this btree).

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

Closes #3846
2025-10-28 07:01:36 +02:00
Jussi Saurio
0b08f006d3 Add subquery fuzz test 2025-10-27 16:23:38 +02:00
Nikita Sivukhin
22fe9452ac remove unnecessary parameter from integration tests 2025-10-27 15:16:12 +04:00
Jussi Saurio
18e6a23f23 Fix foreign key constraint enforcement on UNIQUE indexes
Closes #3648

Co-authored-by: Pavan-Nambi <pavannambi999@gmail.com>
2025-10-24 11:03:55 +03:00
Jussi Saurio
c2b84f7484 Randomly inject txn control statements into index_mutation_upsert_fuzz 2025-10-22 23:40:45 +03:00
Jussi Saurio
2d3ac79fe9 Modify fk_deferred_constraints_fuzz
- Add more statements per iteration
- Allow interactive transaction to contain multiple statements
- add VERBOSE flag to print all statements executed in a successful
  iteration
2025-10-22 23:40:45 +03:00
Jussi Saurio
1fdc0258cd Unignore fk_deferred_constraints_fuzz because it doesnt fail anymore 2025-10-22 23:40:45 +03:00
Pekka Enberg
29b400c6ac tests: Separate integration and fuzz tests
This separates fuzz tests from integration tests so that you can run the
fast test cases with:

```
cargo test --test integration_tests
```

and the longer fuzz cases with:

```
cargo test --test fuzz_tests
```
2025-10-22 13:05:29 +03:00