Pavan-Nambi
8024bb3bde
add tests
2025-11-25 07:51:41 +05:30
Pavan-Nambi
06c06ac8d2
drop triggers if table drops
2025-11-23 10:56:14 +05:30
Preston Thorpe
a97081eafe
Merge 'translate/planner: Implement Index creation on arbitrary expressions' from Preston Thorpe
...
Build & publish @tursodatabase/database / db-bindings-x86_64-pc-windows-msvc - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / db-bindings-x86_64-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 / sync-bindings-aarch64-apple-darwin - 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-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
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
Python / configure-strategy (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 / macos-arm64 (aarch64) (push) Waiting to run
Python / sdist (push) Waiting to run
Python / Release (push) Blocked by required conditions
Rust / test-limbo (push) Waiting to run
Rust / test-sqlite (push) Waiting to run
Rust / simulator (push) Waiting to run
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 / clippy (push) Waiting to run
Rust Benchmarks+Nyrkiö / tpc-h (push) Waiting to run
Rust Benchmarks+Nyrkiö / vfs-bench-compile (push) Waiting to run
Rust Benchmarks+Nyrkiö / bench (push) Waiting to run
Rust Benchmarks+Nyrkiö / clickbench (push) Waiting to run
Rust Benchmarks+Nyrkiö / tpc-h-criterion (push) Waiting to run
This PR implements the functionality to create an index on an expression
instead of just a column, and makes an attempt for the planner to be
able to use these indexes.
https://sqlite.org/expridx.html
This adds the field:
`expr: Option<Box<Expr>>` to `IndexedColumn`
which is `None` for regular indexed columns.
This also adds the sentinel value `EXPR_INDEX_SENTINEL` for the
`position_in_table` field of indexed col expressions, since they are
not, actually in the table.. and similarly: `Constraint` now has the
`table_col_position` as an Option now, because it is no longer a
guarantee that it refers to a col expression.
Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com>
Closes #3990
2025-11-22 06:52:20 -05:00
Pekka Enberg
b5c5666a49
Turso 0.4.0-pre.3
2025-11-22 09:56:18 +02:00
Pekka Enberg
bb2df133ea
Merge 'Kill unwrap in incremental module' from Pekka Enberg
...
As preparation for #3992 which prohibits use of unwrap, remove uses of
it in the incremental module.
Closes #4001
2025-11-22 09:55:35 +02:00
Jussi Saurio
06a01c4366
Merge 'mvcc: refactor RowID.row_id to be either i64 or a record' from Jussi Saurio
...
Rust / test-limbo (push) Waiting to run
Build & publish @tursodatabase/database / db-bindings-x86_64-pc-windows-msvc - node@20 (push) Waiting to run
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-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 / 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
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
Python / configure-strategy (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 / macos-arm64 (aarch64) (push) Waiting to run
Python / sdist (push) Waiting to run
Python / Release (push) Blocked by required conditions
Rust / test-sqlite (push) Waiting to run
Rust / simulator (push) Waiting to run
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 / clippy (push) Waiting to run
Rust Benchmarks+Nyrkiö / bench (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ö / vfs-bench-compile (push) Waiting to run
to make interoperability with VDBE opcodes easier, we are going to store
versioned index rows (unlike in Hekaton). for this reason refactor
RowID.row_id to either be an i64 or an index key (record).
this lets us store a SkipMap from index key to a list of index row
versions like normal table row versions.
Reviewed-by: Pere Diaz Bou <pere-altea@homail.com>
Closes #4002
2025-11-21 22:07:15 +02:00
Jussi Saurio
c1a9f5c951
mvcc: refactor RowID.row_id to be either i64 or a record
...
to make interoperability with VDBE opcodes easier, we are going
to store versioned index rows (unlike in Hekaton). for this reason
refactor RowID.row_id to either be an i64 or an index key (record).
this lets us store a SkipMap from index key to a list of index row
versions like normal table row versions.
2025-11-21 17:05:56 +02:00
Pekka Enberg
f1401ab007
core/incremental: Improve error handling
2025-11-21 15:08:01 +02:00
Pekka Enberg
15f1619c42
Merge 'Kill unwrap() calls in extensions' from Pekka Enberg
...
Build & publish @tursodatabase/database / db-bindings-x86_64-pc-windows-msvc - node@20 (push) Waiting to run
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-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 / 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
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
Python / configure-strategy (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 / macos-arm64 (aarch64) (push) Waiting to run
Python / sdist (push) Waiting to run
Python / Release (push) Blocked by required conditions
Rust / cargo-fmt-check (push) Waiting to run
Rust / test-sqlite (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 / simulator (push) Waiting to run
Rust Benchmarks+Nyrkiö / bench (push) Waiting to run
Rust Benchmarks+Nyrkiö / tpc-h-criterion (push) Waiting to run
Rust Benchmarks+Nyrkiö / vfs-bench-compile (push) Waiting to run
Rust / build-native (windows-latest) (push) Waiting to run
Rust / clippy (push) Waiting to run
Rust / test-limbo (push) Waiting to run
Rust Benchmarks+Nyrkiö / tpc-h (push) Waiting to run
Rust Benchmarks+Nyrkiö / clickbench (push) Waiting to run
As preparation for #3992 that actually enforces no unwraps, remove them
from extensions.
Reviewed-by: Preston Thorpe <preston@turso.tech>
Closes #4000
2025-11-21 14:19:18 +02:00
Pekka Enberg
227c979882
extensions/tests: Allow use of unwrap()
...
They're tests, it's fine.
2025-11-21 14:11:53 +02:00
Pekka Enberg
dcaf6f88d0
extensions: Replace unwrap() with expect() in fuzzy extension
2025-11-21 14:11:53 +02:00
Pekka Enberg
f044e39d43
extensions: Eliminate unwrap() in fuzzy extension
2025-11-21 14:11:53 +02:00
Pekka Enberg
cae17e7a36
extensions: Eliminate unwrap() call in csv extension
2025-11-21 14:11:53 +02:00
Pekka Enberg
deeb79c80e
extensions: Eliminate unwrap() in crypto extension
2025-11-21 14:11:53 +02:00
Pekka Enberg
eb07a5164b
extensions: Improve error handling in percentile extension
...
Eliminate unwrap() where we can, replace with expect() where we can't.
2025-11-21 14:11:53 +02:00
Pekka Enberg
96e63b4556
extensions: Replace unwrap() with expect() in get_column_names()
...
...error handling would be better here.
2025-11-21 14:11:53 +02:00
Pekka Enberg
582cc057ce
extensions: Eliminate unwrap() in IndexInfo::to_ffi()
2025-11-21 14:11:53 +02:00
Pekka Enberg
23859ec6ef
extensions: Replace unwrap() with expect() in generate_random_number()
...
Propagating the error would be even better, of course.
2025-11-21 14:11:53 +02:00
Pekka Enberg
d2fc52834a
Merge 'SQLite C API improvements' from Nikita Sivukhin
...
Build & publish @tursodatabase/database / db-bindings-x86_64-pc-windows-msvc - node@20 (push) Waiting to run
Build & publish @tursodatabase/database / db-bindings-x86_64-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-aarch64-apple-darwin - 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-x86_64-pc-windows-msvc - 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
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
Python / sdist (push) Waiting to run
Python / Release (push) Blocked by required conditions
Python / configure-strategy (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 / macos-arm64 (aarch64) (push) Waiting to run
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 / clippy (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ö / bench (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ö / vfs-bench-compile (push) Waiting to run
This PR adds rich error codes for sqlite3 C bridge layer and also do few
minor adjustments:
1. Enable indices by default
2. Return debug logs to the stderr
Closes #3999
2025-11-21 13:20:44 +02:00
Nikita Sivukhin
cb3ae4d7fd
remove unnecessary constant
...
- it is not exported as a symbol - so no need to have it
2025-11-21 14:27:04 +04:00
Nikita Sivukhin
78b9fa54a5
fix clippy
2025-11-21 14:04:04 +04:00
Nikita Sivukhin
daaa91259b
remove debug logs
2025-11-21 13:58:20 +04:00
Nikita Sivukhin
228f2c1be9
return proper error code in case of certain LimboErrors
2025-11-21 13:58:07 +04:00
Nikita Sivukhin
f5e8eaa6c1
enable indices by default
2025-11-21 13:57:34 +04:00
Nikita Sivukhin
139ec0035e
copy errors codes from SQLite
2025-11-21 13:56:56 +04:00
Pekka Enberg
2f078f13e6
Merge 'simulator: only check all tables if we have any tables to check' from Pedro Muniz
...
Fixes : #3996
Closes #3997
2025-11-21 09:39:55 +02:00
pedrocarlo
03f38ae72c
simulator: only check all tables if we have any tables to check
2025-11-21 01:10:55 -03:00
Preston Thorpe
e40b07122d
Merge 'Support table xinfo' from Nikita Sivukhin
...
Build & publish @tursodatabase/database / db-bindings-x86_64-pc-windows-msvc - node@20 (push) Waiting to run
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-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 / 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
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
Python / sdist (push) Waiting to run
Python / Release (push) Blocked by required conditions
Python / configure-strategy (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 / macos-arm64 (aarch64) (push) Waiting to run
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 / clippy (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ö / bench (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ö / vfs-bench-compile (push) Waiting to run
Support extended pragma `table_xinfo` which in addition to all
`table_info` columns report extra column about if the column is
hidden/generated/dynamic (while usually all such columns filtered out
from the output of `table_info` pragma).
Reviewed-by: Preston Thorpe <preston@turso.tech>
Closes #3994
2025-11-20 19:51:52 -05:00
PThorpe92
5a801f5405
Fix clippy error
2025-11-20 17:38:18 -05:00
PThorpe92
9223dfdbff
Add integration test to ensure covering expr index is used
2025-11-20 12:47:50 -05:00
PThorpe92
94a0f7f17a
Use expression indexes as covering when possible
2025-11-20 12:47:50 -05:00
PThorpe92
2259e62fae
Add expression_index.rs to translate module with some helpers
2025-11-20 12:47:50 -05:00
PThorpe92
1719bbbc2f
Rewrite delete rowset_plan to replace covering idx cursor w/ table cursor for idx expressions
2025-11-20 12:47:49 -05:00
PThorpe92
a8e22d4253
Clippy fix
2025-11-20 12:47:49 -05:00
PThorpe92
b3b95f9e0f
Add comments and cleanups
2025-11-20 12:47:49 -05:00
PThorpe92
2688f8b9c3
Add tcl tests for expr indexes and collation
2025-11-20 12:47:49 -05:00
PThorpe92
e593028b0c
Respect collation in index DDL statements
2025-11-20 12:47:48 -05:00
PThorpe92
563b1d8b6d
Fix optimizer make useable constraint require column position for index
2025-11-20 12:47:48 -05:00
PThorpe92
8376f9e46d
Fix rewriting idx expression to existing registers in upsert
2025-11-20 12:47:48 -05:00
PThorpe92
67f3ed92f4
Fix expr index handling in upsert
2025-11-20 12:47:48 -05:00
PThorpe92
6c163f5202
Fix expr_to_column_order to return None when mask extraction fails or spans >1 table
2025-11-20 12:47:47 -05:00
PThorpe92
fae566b3e0
Cleanup expr indexes, use raw pointer for ColumnTarget::Expr
2025-11-20 12:47:47 -05:00
PThorpe92
b0ac042092
Add tests for using expr indexes in query plans for ORDER BY and WHERE predicates
2025-11-20 12:47:47 -05:00
PThorpe92
9f735feb10
add some comments in optimizer
2025-11-20 12:47:46 -05:00
PThorpe92
04629d4d7b
Add some expression indexes in our fuzz tests
2025-11-20 12:47:46 -05:00
PThorpe92
cd440e2684
Make ORDER BY expression aware and wire index exprs into optimizer
2025-11-20 12:47:46 -05:00
PThorpe92
420615c4de
Wire expression indexes plumbing into UPDATE emission
2025-11-20 12:47:46 -05:00
PThorpe92
1a417ef4dc
Begin to implement index creation on arbitrary expressions
2025-11-20 12:47:45 -05:00
Pere Diaz Bou
86119b0dba
Merge 'core/mvcc/cursor: implement prev and last ' from Pere Diaz Bou
...
Build & publish @tursodatabase/database / db-bindings-x86_64-pc-windows-msvc - node@20 (push) Waiting to run
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-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 / 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
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
Python / configure-strategy (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 / macos-arm64 (aarch64) (push) Waiting to run
Python / sdist (push) Waiting to run
Python / Release (push) Blocked by required conditions
Rust / test-limbo (push) Waiting to run
Rust / test-sqlite (push) Waiting to run
Rust / clippy (push) Waiting to run
Rust / simulator (push) Waiting to run
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 Benchmarks+Nyrkiö / bench (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ö / vfs-bench-compile (push) Waiting to run
Backward scan of a table wasn't implemented yet in MVCC so this achieves
that. I added simple test for mixed btree and mvcc backward scan but I
should add more intense testing for this.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Implements backward scanning and last() in MVCC lazy cursor and adds
directional rowid iteration in the MVCC store, with new tests for mixed
MVCC+B-Tree backward scans.
>
> - **MVCC Cursor (`core/mvcc/cursor.rs`)**:
> - Implement `prev()` and `last()` with mixed MVCC/B-Tree
coordination using `IterationDirection`.
> - Add `PrevState` and extend state machine to handle backward
iteration.
> - Update `get_new_position_from_mvcc_and_btree(...)` to choose
rowids based on direction.
> - Integrate B-Tree cursor calls (`last`, `prev`) and adjust
`rewind`/rowid selection; tweak next-rowid when at `End`.
> - **MVCC Store (`core/mvcc/database/mod.rs`)**:
> - Add `get_prev_row_id_for_table(...)` and generalized
`get_row_id_for_table_in_direction(...)` supporting forward/backward
scans.
> - Add tracing and minor refactors around next/prev rowid retrieval.
> - **Tests (`core/mvcc/database/tests.rs`)**:
> - Add test for backward scan combining B-Tree and MVCC and an
ignored test covering delete during backward scan.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot ) for commit
430bd457e6 . This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot ).</sup>
<!-- /CURSOR_SUMMARY -->
Closes #3980
2025-11-20 18:41:41 +01:00
Nikita Sivukhin
0c1e2a8a10
fix test
2025-11-20 18:03:32 +04:00