Commit Graph

7447 Commits

Author SHA1 Message Date
Pekka Enberg
2fa501158c Merge 'turso-cdc: add updates column for cdc table' from Nikita Sivukhin
This PR adds new `updates` column to the CDC table. This column holds
updated fields of the row in the following format:
```
[C boolean values where true set for changed columns]
[C values with updates where NULL is set for not-changed columns]
```
For example:
```
turso> UPDATE t SET y = 'turso', q = 'db' WHERE rowid = 1;
turso> SELECT bin_record_json_object('["x","y","z","q","x","y","z","q"]', updates) as updates FROM turso_cdc;
┌──────────────────────────────────────────────────────────────────┐
│ updates                                                          │
├──────────────────────────────────────────────────────────────────┤
│ {"x":0,"y":1,"z":0,"q":1,"x":null,"y":"turso","z":null,"q":"db"} │
└──────────────────────────────────────────────────────────────────┘
```
Also, this column works differently for `ALTER TABLE` statements where
update value for `sql` will be equal to the original `ALTER TABLE`:
```
turso> ALTER TABLE t ADD COLUMN t;
turso> SELECT bin_record_json_object('["type","name","tbl_name","rootpage","sql","type","name","tbl_name","rootpage","sql"]', updates) as updates FROM turso_cdc WHERE rowid = 2;
┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ updates                                                                                                                                           │
├───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ {"type":0,"name":0,"tbl_name":0,"rootpage":0,"sql":1,"type":null,"name":null,"tbl_name":null,"rootpage":null,"sql":"ALTER TABLE t ADD COLUMN t;"} │
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
```
This will help turso-db to implement logical replication which supports
both column-level updates and schema changes

Closes #2538
2025-08-12 09:50:16 +03:00
Pekka Enberg
1349c051f8 Merge 'Fix view processing in the VDBE' from Jussi Saurio
1. Introduce state machines to insert and delete to make sure IO is
handled properly
2. When `rowid` is changed in `UPDATE`, it is handled as a combination
of delete and insert, so `op_insert` doesn't need to update the
incremental view with the deleted old column since the preceding
`op_delete` instruction should already do it.

Closes #2542
2025-08-12 09:49:11 +03:00
Preston Thorpe
9a595d6ffa Merge 'Update PERF.md with mobibench instructions' from Preston Thorpe
Closes #2550
2025-08-11 19:56:56 -04:00
PThorpe92
4c876547f0 Add Mobibench to .gitignore 2025-08-11 19:56:26 -04:00
PThorpe92
d2df8bf1a3 Update PERF.md 2025-08-11 19:44:12 -04:00
Jussi Saurio
909c096579 Merge 'docs: improve README initialization section clarity' from Braden Wong
Improves the clarity of the README's "Getting Started" → "Command Line"
section by adding explicit `$ tursodb` command example so users know
exactly what to type.

Closes #2534
2025-08-11 21:11:01 +03:00
Jussi Saurio
f598c86fa4 Merge 'Handle single, double and unquoted strings in values clause' from Mikaël Francoeur
I'm not sure how much this will clash with @TcMits's parser rewrite,
hopefully not too much. If it does and we eventually have to remove it,
at least we'll have two new regression tests.
Closes https://github.com/tursodatabase/turso/issues/2484

Closes #2499
2025-08-11 21:08:15 +03:00
Jussi Saurio
a7c1c8b7d4 Merge 'Use rusqlite 0.37 with bundled SQLite everywhere' from Jussi Saurio
Use the same rusqlite version in every crate and use a bundled up-to-
date sqlite version
(the impetus for this PR is still me trying to figure out why sqlite in
the insert benchmark doesn't seem to be fsyncing, even when instructed)

Closes #2507
2025-08-11 21:07:24 +03:00
Preston Thorpe
cb59877821 Merge 'Feat/pragma module list' from Lucas Forato
Implementation of the module_list pragma

Reviewed-by: Diego Reis (@el-yawd)
Reviewed-by: Preston Thorpe <preston@turso.tech>

Closes #2430
2025-08-11 13:54:24 -04:00
PThorpe92
4dbf69545e try_borrow.unwrap -> borrow 2025-08-11 13:54:00 -04:00
Jussi Saurio
7339b207e3 add assert 2025-08-11 19:25:25 +03:00
Jussi Saurio
28d6c2b673 fix flags again 2025-08-11 19:22:22 +03:00
Braden Wong
51d2824b6e fix: tursodb insteada of turso for shell command in README 2025-08-11 12:17:33 -04:00
Braden Wong
5751fb6d4c Merge branch 'tursodatabase:main' into improve-readme-initialization 2025-08-11 09:17:07 -07:00
PThorpe92
ae22af29cd Fix pragma module list tests 2025-08-11 12:13:47 -04:00
Jussi Saurio
d6abc252b2 remove double nchanges 2025-08-11 19:07:29 +03:00
Jussi Saurio
1bdc8b6002 fix resetting to default state 2025-08-11 19:07:29 +03:00
Jussi Saurio
44c91f6752 fix/vdbe: fix state handling for incremental views in op_delete 2025-08-11 19:07:29 +03:00
Jussi Saurio
f38333b373 fix/vdbe: fix state handling for incremental views
- When the rowid is changed in UPDATE, it is handled as a combination of DELETE + INSERT,
so we dont need to delete the old values in that case
- We should only update the views after the operation on the btree is done
- A proper state machine is needed to handle IO yielding points
2025-08-11 19:02:15 +03:00
Lucas Forato
e07ab423e6 feat: removed module_name from VirtualTable, instead looking only at symbol tables 2025-08-11 11:43:32 -03:00
Pekka Enberg
9ae6a57980 Merge 'remove turso-sync as now we have turso-sync-engine' from Nikita Sivukhin
Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com>

Closes #2539
2025-08-11 17:00:13 +03:00
Pekka Enberg
9a35d76c55 Merge 'Add support for Full checkpoint mode in the WAL' from Preston Thorpe
Closes #2519

Closes #2521
2025-08-11 16:59:26 +03:00
Nikita Sivukhin
eb40d4aff6 remove turso-sync as now we have turso-sync-engine 2025-08-11 16:53:39 +04:00
Jussi Saurio
ec7bded092 Merge 'Sorter IO Completions' from Pedro Muniz
Convert Sorter code to use state machines and not ignore completions.
Also simplifies some logic that seemed redundant to me. Also, I was
getting some IO errors because we were opening one file per Chunk, so I
fixed this by using only one file per sorter, and just using offsets in
the file for each chunk.
Builds on top of #2520

Closes #2473
2025-08-11 15:42:58 +03:00
Jussi Saurio
c25e8c685d let fuzz still have its own workspace 2025-08-11 15:13:58 +03:00
Jussi Saurio
87bf488bbc chore: use rusqlite 0.37 with bundled sqlite everywhere 2025-08-11 15:13:57 +03:00
Pekka Enberg
909338fad1 Merge 'Simulator should delete files after a successful run' from Pedro Muniz
I was getting IO errors for too many files when running the simulator
locally. It seemed that the simulator did not delete files after a
successful run. After this change, I did not get anymore errors

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

Closes #2520
2025-08-11 15:09:32 +03:00
Pekka Enberg
221e030d98 Merge 'Fix performance regression in prepare' from Piotr Rżysko
Attempt at fixing https://github.com/tursodatabase/turso/issues/2527.

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

Closes #2532
2025-08-11 15:08:10 +03:00
Pekka Enberg
4a53c44466 Merge 'Add support for PRAGMA freelist_count' from bit-aloo
Implements `PRAGMA freelist_count` to return the current number of free
pages in the database.

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

Closes #2531
2025-08-11 15:07:58 +03:00
Lucas Forato
9fe20a178a fix: formatting 2025-08-11 09:01:27 -03:00
Lucas Forato
76838bb46a fix: issues from rebase 2025-08-11 08:54:42 -03:00
Lucas Forato
562076fdb8 fix: close method 2025-08-11 08:42:19 -03:00
Lucas Forato
673cfdbc0f test: include tests in extensions.py 2025-08-11 08:42:08 -03:00
Lucas Forato
19c445f8b1 feat: listing both used and non-used modules 2025-08-11 08:42:08 -03:00
Lucas Forato
c2a5b43c68 fix: revert changes on testing dbs 2025-08-11 08:42:08 -03:00
Lucas Forato
adb69f21f9 feat: remove mods 2025-08-11 08:42:08 -03:00
Lucas Forato
8b1b79bc93 fix: broken file after merge 2025-08-11 08:42:08 -03:00
Lucas Forato
4161f68774 Update core/lib.rs
Co-authored-by: bit-aloo <84662239+Shourya742@users.noreply.github.com>
2025-08-11 08:42:03 -03:00
Lucas Forato
804df8dd7a feat: changed to non-empty test 2025-08-11 08:42:03 -03:00
Lucas Forato
c37ccd49e1 feat: included tests 2025-08-11 08:42:03 -03:00
Lucas Forato
6b1ae89426 chore: remove todo comment 2025-08-11 08:42:03 -03:00
Lucas Forato
27fd6aa13a chore: updated comment 2025-08-11 08:42:03 -03:00
Lucas Forato
5aa99f6743 feat: listing all modules 2025-08-11 08:42:03 -03:00
Lucas Forato
ff157e10e5 feat: included ModuleList in PragmaName 2025-08-11 08:41:53 -03:00
Pekka Enberg
08ab998404 Merge 'Initial pass on incremental view maintenance with DBSP' from Glauber Costa
Implement very basic views using DBSP
This is just the bare minimum that I needed to convince myself that this
 approach will work. The only views that we support are slices of the
 main table: no aggregations, no joins, no projections.
 * drop view is implemented.
 * view population is implemented.
 * deletes, inserts and updates are implemented.
 much like indexes before, a flag must be passed to enable views.

Closes #2530
2025-08-11 14:09:35 +03:00
Pekka Enberg
fb023ac62d Merge 'SQLite C API improvements: add bind_text and bind_blob' from Danawan Bimantoro
Add support for more of the SQLite C API.
Bind functions:
- sqlite3_bind_text (with destructor callback)
- sqlite3_bind_blob
Column functions:
- sqlite3_column_text
- sqlite3_column_blob
- sqlite3_column_bytes

Closes #2528
2025-08-11 12:32:46 +03:00
Pekka Enberg
f65a12a699 Merge 'perf/clickbench: enable rest of queries since we support DISTINCT and REGEXP_REPLACE' from Jussi Saurio
Closes #2537
2025-08-11 12:32:02 +03:00
Pekka Enberg
cdaea7f274 core/vdbe: Make apply_view_deltas() return early if views are disabled
Currently, we have a borrow problem because parse_schema_rows() already
borrows `schema`, but then `apply_view_deltas` does the same:

```
thread 'main' panicked at core/vdbe/mod.rs:450:49:
already mutably borrowed: BorrowError
stack backtrace:
   0: __rustc::rust_begin_unwind
             at /rustc/6b00bc3880198600130e1cf62b8f8a93494488cc/library/std/src/panicking.rs:697:5
   1: core::panicking::panic_fmt
             at /rustc/6b00bc3880198600130e1cf62b8f8a93494488cc/library/core/src/panicking.rs:75:14
   2: core::cell::panic_already_mutably_borrowed
             at /rustc/6b00bc3880198600130e1cf62b8f8a93494488cc/library/core/src/cell.rs:799:5
   3: core::cell::RefCell<T>::borrow
             at /rustc/6b00bc3880198600130e1cf62b8f8a93494488cc/library/core/src/cell.rs:987:25
   4: turso_core::vdbe::Program::apply_view_deltas
             at ./core/vdbe/mod.rs:450:26
   5: turso_core::vdbe::Program::commit_txn
             at ./core/vdbe/mod.rs:468:9
   6: turso_core::vdbe::execute::op_halt
             at ./core/vdbe/execute.rs:1954:15
   7: turso_core::vdbe::Program::step
             at ./core/vdbe/mod.rs:430:19
   8: turso_core::Statement::step
             at ./core/lib.rs:1914:23
   9: turso_core::util::parse_schema_rows
             at ./core/util.rs:91:15
  10: turso_core::Connection::parse_schema_rows::{{closure}}
             at ./core/lib.rs:1518:17
  11: turso_core::Connection::with_schema_mut
             at ./core/lib.rs:1625:9
  12: turso_core::Connection::parse_schema_rows
             at ./core/lib.rs:1515:9
```

However, this is a read transaction and views are not even enabled,
let's just make `apply_view_deltas()` return early if there's no
processing needed, to skip the schema borrow altogether.
2025-08-11 12:26:11 +03:00
Nikita Sivukhin
8749a66217 remove test from another branch 2025-08-11 13:18:01 +04:00
Pekka Enberg
e829201fdd cli: Fix .schema SQL statement some more
We need to fetch name and type too, but also sort in both places
consistently.
2025-08-11 11:52:57 +03:00