Pere Diaz Bou
0eb2aa123d
cli/app: add mvcc mode
2025-09-18 18:21:04 +02:00
Pere Diaz Bou
de8a975a0b
core/mvcc: introduce MvccMode Logical Log
2025-09-18 18:21:04 +02:00
rajajisai
e605aff31b
Merge branch 'main' into enc-page-1
2025-09-16 10:06:00 -04:00
rajajisai
89caa868f9
Encryption support for database header page
2025-09-16 10:04:30 -04:00
Pekka Enberg
ae25a0f088
Merge 'Implement Min/Max aggregators' from Glauber Costa
...
We have not implemented them before because they require the raw
elements to be kept. It is easy to see why in the following example:
```
current_min = 3;
insert(2) => current_min = 2 // can be done without state
delete(2) => needs to look at the state to determine new min!
```
The aggregator state was a very simple key-value structure. To
accomodate for min/max, we will make it into a more complex table, where
we can encode a more complex structure.
The key insight is that we can use a primary key composed of:
```
1) storage_id
2) zset_id,
3) element
```
The storage_id and zset_id are our previous key, except they are now
exploded to support a larger range of storage_id. With more bits
available in the storage_id, we can encode information about which
column we are storing. For aggregations in multiple columns, we will
need to keep a different list of values for min/max!
The element is just the values of the columns.
Because this is a primary key, the data will be sorted in the btree. We
can then just do a prefix search in the first two components of the key
and easily find the min/max when needed.
This new format is also adequate for joins. Joins will just have a new
storage_id which encodes two "columns" (left side, right side).
Closes #3143
2025-09-16 16:19:59 +03:00
Glauber Costa
3e9a5d93b5
hide internal tables from .schema
2025-09-15 22:30:48 -05:00
pedrocarlo
3c91ae206b
move as many dependencies as possible to workspace to avoid multiple versions of the same dependency
2025-09-15 17:19:36 -03:00
TcMits
9dac467b40
support EXPLAIN QUERY PLAN
2025-09-12 19:58:45 +07:00
TcMits
830e10da8f
resolve merge conflict
2025-09-11 18:13:29 +07:00
TcMits
b574b4bcea
finish EXPLAIN
2025-09-11 18:04:59 +07:00
Jussi Saurio
7ac18a6952
Merge 'Remove some traces in super hot paths in btree' from Preston Thorpe
...
Particularly we were tracing `ImmutableRecord` / `BTreeKey` which would
then trace the bytes of records. These are super super hot paths and I
think we can probably remove even more to under debug assertions so we
dont eat those atomics/branches all the time.
This PR also introduces the `tracing_release` feature, which turns all
`trace!` and `debug!` macro invocations to noops at compile time, and
makes that feature available for all bindings.
it also removes the unused `lru` dependency, and cleans up the makefile
a bit
Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com >
Closes #2995
2025-09-11 13:33:25 +03:00
TcMits
5caf9a2640
make it more safe + clippy
2025-09-11 00:14:38 +07:00
PThorpe92
ba1ed72ed8
Add tracing_release feature for benchmarks to compile tracing macros to noops
2025-09-10 09:56:12 -04:00
TcMits
eeef8b85fa
always use consume instead of run_query, handle_dot_command
2025-09-10 16:54:51 +07:00
TcMits
688dc6dde3
minor
2025-09-10 16:31:57 +07:00
TcMits
65f5fbd1f6
no errors in consume
2025-09-10 16:31:12 +07:00
TcMits
ddf0df0aea
merge main
2025-09-10 15:59:56 +07:00
TcMits
dbcd01bf8b
make consume safer
2025-09-10 15:56:20 +07:00
Jussi Saurio
b6d99cd188
Merge 'clean print_query_result' from Lâm Hoàng Phúc
...
different between output modes is how we handle `Ok(StepResult::Row)` so
let introduce `row_step_result_query` macro to reduce duplicated code.
Closes #2979
2025-09-10 11:08:40 +03:00
TcMits
e8b853ed25
pretty mode's table need a line break
2025-09-10 12:03:59 +07:00
TcMits
28f23973a4
fix logic
2025-09-09 18:38:33 +07:00
TcMits
463fd75f0b
no need QueryStatistics
2025-09-09 18:35:27 +07:00
TcMits
8a72b24c0e
add writeln_fmt
2025-09-09 17:57:58 +07:00
TcMits
036235a518
clean 'print_query_result'
2025-09-09 17:41:08 +07:00
TcMits
048e72abf5
consume remaining
2025-09-09 16:27:31 +07:00
TcMits
8a6667a829
refactor cli: will write to
2025-09-09 16:23:08 +07:00
Pekka Enberg
80a4358272
cli: Fix dump compatibility in "PRAGMA foreign_keys"
...
SQLite emits a semicolon after "PRAGMA foreign_keys=OFF" so let's do th
same.
2025-09-08 12:55:29 +03:00
TcMits
f518291522
infinite loop when query starts with '--'
2025-09-05 16:36:14 +07:00
Pekka Enberg
12cf4d2e72
core: Make strict schema support experimental
...
It's not tested properly so let's mark it as experimental for now.
Fixes #2775
2025-09-02 16:40:02 +03:00
Arkoniak
2c0e3cf593
feat: consistent interrupt event processing ( #2801 )
2025-08-30 06:57:14 +03:00
Arkoniak
cb602d960d
feat: records output ( #2801 )
2025-08-30 06:57:14 +03:00
PThorpe92
959bc6ba74
Remove unused argument from handle_row fn
2025-08-29 10:18:49 -04:00
PThorpe92
5b73fad5d4
Remove some code duplication in the CLI
2025-08-29 10:15:07 -04:00
Alex Miller
327936fb51
Highlight the EXPLAIN keyword
2025-08-22 22:49:58 -07:00
Alex Miller
f1250a6c86
Add syntax highlighting for ANALYZE
2025-08-22 22:47:46 -07:00
Preston Thorpe
82fe508609
Merge 'add metrics and implement the .stats command' from Glauber Costa
...
This adds basic statement and connection metrics like SQLite (and
libSQL) have.
This is particularly useful to show that materialized views are working:
turso> create table t(a);
turso> insert into t(a) values (1) , (2), (3), (4), (5), (6), (7), (8),
(9), (10); turso> create materialized view v as select count(*) from t;
turso> .stats on
Stats display enabled.
turso> select count(*) from t;
┌───────────┐
│ count (*) │
├───────────┤
│ 10 │
└───────────┘
Statement Metrics:
Row Operations:
Rows read: 10
Rows written: 0
[ ... other metrics ... ]
turso> select * from v;
┌───────────┐
│ count (*) │
├───────────┤
│ 10 │
└───────────┘
Statement Metrics:
Row Operations:
Rows read: 1
Rows written: 0
[ ... other metrics ... ]
Reviewed-by: Preston Thorpe <preston@turso.tech >
Closes #2651
2025-08-18 20:26:48 -04:00
Glauber Costa
36fc8e8fdb
add metrics and implement the .stats command
...
This adds basic statement and connection metrics like SQLite (and
libSQL) have.
This is particularly useful to show that materialized views are working:
turso> create table t(a);
turso> insert into t(a) values (1) , (2), (3), (4), (5), (6), (7), (8), (9), (10);
turso> create materialized view v as select count(*) from t;
turso> .stats on
Stats display enabled.
turso> select count(*) from t;
┌───────────┐
│ count (*) │
├───────────┤
│ 10 │
└───────────┘
Statement Metrics:
Row Operations:
Rows read: 10
Rows written: 0
[ ... other metrics ... ]
turso> select * from v;
┌───────────┐
│ count (*) │
├───────────┤
│ 10 │
└───────────┘
Statement Metrics:
Row Operations:
Rows read: 1
Rows written: 0
[ ... other metrics ... ]
2025-08-18 09:11:06 -05:00
Glauber Costa
40efaab382
make sure our responses are compliant with MCP
...
There is an inconsistency now on how we are handling IDs and
notifications. Claude Code doesn't complain (good boi), but Claude
Desktop does.
2025-08-18 08:02:30 -05:00
Glauber Costa
841296a39d
add new commands to the MCP server
...
When playing with our MCP server with Claude Code, I realized that
having the agent pre-configured to a specific path is just not very
useful.
I am now adding two new commands, to open a database and to list
the current database. Those make our server more useful.
2025-08-16 11:00:28 -05:00
Nikita Sivukhin
6280d33b02
init tracing in CLI early
...
- now we miss logs from DB initialization phase
2025-08-15 13:11:38 +04:00
PThorpe92
9ccf79111a
Support non-utf8 blobs in .clone command
2025-08-14 21:31:14 -04:00
PThorpe92
2b289157d0
Properly quote sequence value
2025-08-14 21:31:14 -04:00
PThorpe92
7abf071128
Conditionally emit pragma foreign_keys=off when not .cloning
2025-08-14 21:31:14 -04:00
PThorpe92
4a612c1586
Properly implement .clone method safely
2025-08-14 21:31:13 -04:00
Jussi Saurio
69d8a73028
Merge 'use virtual root page for sqlite_schema' from Mikaël Francoeur
...
This PR fixes a problem where `sqlite_schema` could be read before page
1 was allocated.
The fix is similar to that in SQLite. In SQLite, if `btreeCursor()` sees
that the root page is 1 and that the b-tree is empty, it sets the page
to 0 ([here](https://github.com/sqlite/sqlite/blob/master/src/btree.c#L4
691-L4696)). SQLite's `moveToRoot()` then uses this special value to
return `CURSOR_INVALID` with no rows ([here](https://github.com/sqlite/s
qlite/blob/master/src/btree.c#L5538-L5540)).
Fixes https://github.com/tursodatabase/turso/issues/2449
Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com >
Closes #2551
2025-08-14 11:08:11 +03:00
Mikaël Francoeur
07ef47924c
use virtual root page for sqlite_schema
2025-08-13 16:31:21 -04:00
PThorpe92
614a0a45a6
Relax and fix memory ordering
2025-08-13 10:09:37 -04:00
Pekka Enberg
b82d850f7a
Merge 'Reset interrupt count each time a new line is entered in CLI' from
...
Resolves issue #1833 .
**Before:**
<img width="581" height="92" alt="Screenshot 2025-08-11 at 9 07 21 PM"
src="https://github.com/user-
attachments/assets/eff4c919-ad54-4379-bbee-28eb3e4a375f" />
**After:**
<img width="563" height="118" alt="Screenshot 2025-08-11 at 9 07 27 PM"
src="https://github.com/user-
attachments/assets/f99f84a0-f5d3-4d70-9e08-1c3871fddda3" />
Closes #2554
2025-08-12 11:50:03 +03:00
rajajisai
5cc5b0bca1
Reset interrupt count each time a new line is entered in CLI
2025-08-11 21:16:43 -07: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