Commit Graph

7806 Commits

Author SHA1 Message Date
Jussi Saurio
687e593361 Add pgno field to CacheError::Locked for debugging 2025-08-19 15:44:16 +03:00
Jussi Saurio
366281eeab Merge 'Do not begin or end transactions in nested statement' from Jussi Saurio
Closes #2657
Closes #2659
Closes #2660
Closes #2661
1. In simulator, do not assume every error that happens after fault
injection has the literal error message `"Injected fault"`. If an error
happened, all we need to do is not shadow the query into the in-memory
simulator environment -- in other words, we assume whatever the
statement did failed and was rolled back.
2. Do not begin or end transactions inside a nested statement. Nested
statements generally only occur when `ParseSchema` is invoked, which
runs the equivalent of `SELECT * FROM sqlite_schema`. This does not need
a new transaction nor does it need to end the transaction on error,
since the parent statement will handle it.

Reviewed-by: Pere Diaz Bou <pere-altea@homail.com>

Closes #2666
2025-08-19 14:25:33 +03:00
Pekka Enberg
7c2bdac7ca Merge 'bindings/javascript: Add TypeScript declarations to package' from Pekka Enberg
Fixes #2621

Closes #2665
2025-08-19 13:18:00 +03:00
Jussi Saurio
7f1eac9560 Do not start or end transaction in nested statement 2025-08-19 13:03:14 +03:00
Jussi Saurio
97657a86b3 Do not assume error message content in FaultyQuery 2025-08-19 12:49:01 +03:00
Pekka Enberg
976403b080 bindings/javascript: Add TypeScript declarations to package
Fixes #2621
2025-08-19 12:34:49 +03:00
Preston Thorpe
91cf63215f Merge 'add missing closing tag' from Glauber Costa
should have been added to the previous commit

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

Closes #2656
2025-08-18 21:21:31 -04:00
Glauber Costa
b66e90bf9a add missing closing tag
should have been added to the previous commit
2025-08-18 18:18:54 -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
Preston Thorpe
f912139817 Merge 'make the MCP server instructions more visible on the README' from Glauber Costa
Right now it is buried under "console".
We have also not updated the list of commands when we added two more,
and this is done in this PR.

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

Closes #2655
2025-08-18 20:13:55 -04:00
Preston Thorpe
b5538eb90c Merge 'Add bench-sqlite script and makefile command' from Preston Thorpe
<img width="436" height="480" alt="image" src="https://github.com/user-
attachments/assets/d95572cf-b775-43d9-b3fa-b6b1c9ecc64d" />
(cherry-picked example, yes on io_uring we do well with some write
workloads against sqlite)
adds:
`make bench-sqlite VFS=io_uring SQL="insert into products (name,price)
values (1,2);" N=10000`

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

Closes #2652
2025-08-18 20:00:25 -04:00
Glauber Costa
c6aadeafa2 make the MCP server instructions more visible on the README
Right now it is buried under "console".

We have also not updated the list of commands when we added two more,
and this is done in this PR.
2025-08-18 16:31:49 -07:00
PThorpe92
1f31903723 dont time the first iteration of sqlite benchmark 2025-08-18 17:39:50 -04:00
Jussi Saurio
9deedd917f Merge 'FaultyQuery enabled by default' from Pedro Muniz
FaultyQuery was disabled. We were not simulating faults.

Reviewed-by: Avinash Sajjanshetty (@avinassh)
Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com>

Closes #2594
2025-08-18 22:53:37 +03:00
PThorpe92
d8faae1b99 Make python linter happy 2025-08-18 15:46:30 -04:00
Pekka Enberg
ac7a7325fc Merge 'Fix simulator docker build by adding new sync directory' from Preston Thorpe
workspace changed

Closes #2653
2025-08-18 22:38:03 +03:00
PThorpe92
ef389db64b Fix simulator docker build by adding new sync directory 2025-08-18 15:32:22 -04:00
Preston Thorpe
b302951fd4 Merge 'hide our age' from Glauber Costa
This PR lets us pretend we are younger than our real age, by using uv
like all the cool kids.

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

Closes #2645
2025-08-18 15:14:03 -04:00
PThorpe92
4fab57767b Add bench-sqlite script and makefile command for benchmarking an I/O backend against sqlite3 2025-08-18 15:11:29 -04:00
pedrocarlo
d96a26aef9 Property TableHasExpectedContent should just check the expected
content on runtime, not generation time
2025-08-18 16:00:59 -03:00
pedrocarlo
aa7f8fbfc4 Tripwire for Wal Syncing + set syncing to true before calling sync 2025-08-18 15:34:20 -03:00
Pekka Enberg
077247ad52 Merge ' core/mvcc: schema_did_change support and find last valid version ' from Pere Diaz Bou
1. Find latest version available of a row for a specific transaction.
For that we need to keep track which txid is finding a row.
2. Support for schema_did_change on commit txn
3. Extract the connection transaction state from non mvcc transactions
to
mvcc too.

Closes #2642
2025-08-18 19:22:24 +03:00
Pekka Enberg
e6804feb52 Merge 'make sure our responses are compliant with MCP' from Glauber Costa
There is an inconsistency now on how we are handling IDs and
notifications. Claude Code doesn't complain (good boi), but Claude
Desktop does.

Closes #2649
2025-08-18 19:21:50 +03:00
Pekka Enberg
2b7355d126 Merge 'Move sync code to own directory' from Pekka Enberg
Reviewed-by: Nikita Sivukhin (@sivukhin)

Closes #2643
2025-08-18 19:21:34 +03:00
pedrocarlo
2954e2e7bf shrinking: remove table assertions for non-dependent tables 2025-08-18 12:44:49 -03:00
pedrocarlo
59da828362 do not shadow FaultyQuery's immediately. Only shadow them later 2025-08-18 12:40:02 -03:00
pedrocarlo
c5dc26f542 reset more pager state machines in rollback 2025-08-18 12:01:10 -03:00
pedrocarlo
7fb14cfc76 add File path to SimulatorFile 2025-08-18 11:52:10 -03:00
pedrocarlo
6388ed2017 FaultyQuery enabled by default 2025-08-18 11:52:10 -03: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
Pere Diaz Bou
94cd504d4c core/mvcc: support schema_did change on commit_txn
This not only changes schema_did_change on commit_txn for mvcc, but also
extracts the connection transaction state from non mvcc transactions to
mvcc too.
2025-08-18 15:52:10 +02: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
Pekka Enberg
69e8f7fa31 Move sync engine to sync/engine 2025-08-18 15:41:54 +03:00
Glauber Costa
fc385a0be2 hide our age
This PR lets us pretend we are younger than our real age, by using uv
like all the cool kids.
2025-08-18 07:24:33 -05:00
Pere Diaz Bou
f8c110e664 core/mvcc: find latest valid version for row for every operation
Previously we only checked first version of row...
2025-08-18 13:54:10 +02:00
Pekka Enberg
13b805a992 Move @tursodatabase/sync code to sync/javascript 2025-08-18 14:23:20 +03:00
Pekka Enberg
33ddae1877 Fix JavaScript API reference 2025-08-18 14:00:46 +03:00
Jussi Saurio
3ee2be6750 Merge 'Refactor: use regular save/restore context mechanism for delete balancing' from Jussi Saurio
This is the first in a series of PRs whose end goal is to close the
#2004 issue, but I don't want to make that PR too bloated.
- Removes special `DeleteSavepoint` and uses the existing cursor
restoration mechanism.
- This required some restructuring of `DeleteState` to avoid cloning it,
i.e. some negotations with the borrow checker.
- CursorContext now takes a SeekOp as well to allow retaining the
behavior that we use LT for seeking after a delete-induced rebalancing.
This behavior will probably be removed as part of fixing #2004, but here
I am trying to preserve the current semantics.

Reviewed-by: Pere Diaz Bou <pere-altea@homail.com>

Closes #2638
2025-08-18 13:38:48 +03:00
Jussi Saurio
9abc63d853 Add a bit of abstraction for creating EQ cursorcontexts 2025-08-18 13:13:02 +03:00
Pekka Enberg
3a72b478d2 Turso 0.1.4-pre.9 2025-08-18 12:55:45 +03:00
Jussi Saurio
3eb89982ba Remove obsolete FIXME 2025-08-18 12:08:40 +03:00
Jussi Saurio
50fd7ec58b Refactor: use regular save/restore context mechanism for delete balancing
- Removes special `DeleteSavepoint` and uses the existing cursor restoration
  mechanism.
- This required some restructuring of `DeleteState` to avoid cloning it, i.e.
  some negotations with the borrow checker.
- CursorContext now takes a SeekOp as well to allow retaining the behavior
  that we use LT for seeking after a delete-induced rebalancing. This behavior
  will probably be removed as part of fixing #2004, but here I am trying to
  preserve the current semantics.
2025-08-18 11:58:00 +03:00
Pekka Enberg
568737ec88 Merge 'Add list databases and open database commands to the MCP server' from Glauber Costa
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.

Closes #2628
2025-08-18 08:30:34 +03:00
Jussi Saurio
b69709d9bc Merge 'fix/sim: prevent sim from trying to create an existing table or index' from Jussi Saurio
We recently merged a change that panics the sim on parse errors, because
not doing so has masked many scenarios where the sim unintentionally
creates incorrect sql and we just ignore it.
The aforementioned change also surfaced that the sim can try to create a
table that already exists, which now makes us panic and fail the sim. So
in this PR, we make sure that doesn't happen.
We already have Property::DoubleCreateFailure to assert that the same
table cannot be created twice, so this should not hide any bugs.

Closes #2634
2025-08-17 18:36:43 +03:00
Jussi Saurio
6c17fa2a5e fix/sim: prevent sim from trying to create an existing table or index
We recently merged a change that panics the sim on parse errors, because
not doing so has masked many scenarios where the sim unintentionally
creates incorrect sql and we just ignore it.

We already have Property::DoubleCreateFailure to assert that the same table
cannot be created twice, so this should not hide any bugs.
2025-08-17 18:13:05 +03:00
Jussi Saurio
6e8822792a Merge 'Improve handling of inserts with column names' from Wallys Ferreira
Closes #2495
Return error on inserts with qualified expressions to emulate same
functionality as SQLite.

Closes #2592
2025-08-17 14:41:48 +03:00
Jussi Saurio
5fc967c41d Merge 'Fail simulator on parse errors' from Jussi Saurio
Closes #2618 (sufficiently for now, IMO)
Prevents simulator from creating malformed queries which we don't notice
(ref e.g. #2609 , #2611, #2616)

Closes #2624
2025-08-17 14:40:38 +03:00
Jussi Saurio
c21d9871db Merge 'fix pragma table_info for views' from Glauber Costa
We were not generating table_info for views. This PR fixes it.  We were
so far storing columns as strings with just their names - since this is
all we needed - but we will move now to store Columns. We need to
convert the names to Column anyway for table_info to work.

Closes #2625
2025-08-17 14:40:21 +03:00
Jussi Saurio
cf9851ea9b Merge 'emit SetCookie when creating a view' from Glauber Costa
SetCookie is necessary to invalidate prepared statements in the
connection after DDL expressions.

Closes #2632
2025-08-17 14:39:58 +03:00
Jussi Saurio
c4f530d8f5 Merge 'unify halts' from Glauber Costa
We have halt and op_halt, doing essentially the same thing.
This PR unifies them. There is a minor difference between them now in
the way halt() handles auto-commit. My current understanding of the code
is that what we have in halt *is a bug*, which is already one bad
consequence of the duplication.

Closes #2631
2025-08-17 14:39:30 +03:00