Commit Graph

7840 Commits

Author SHA1 Message Date
pedrocarlo
46c756b130 clear locked on pages when completion errors 2025-08-19 17:29:57 -03:00
Jussi Saurio
1614b0e0fa Merge 'Remove assertions from Completion::complete() and Completion::error()' from Jussi Saurio
The completion callback can be invoked only once via `OnceLock`, let's
not crash if we e.g. call `Completion::abort()` on an already finished
completion.
Closes #2673

Closes #2674
2025-08-19 22:28:19 +03:00
Jussi Saurio
b5439dd068 Remove assertions from Completion::complete() and Completion::error()
The completion callback can be invoked only once via `OnceLock`, let's not
crash if we e.g. call `Completion::abort()` on an already finished completion.

Closes #2673
2025-08-19 22:02:02 +03:00
Pekka Enberg
8d7ab52471 Turso 0.1.4-pre.10 2025-08-19 19:32:47 +03:00
Pekka Enberg
da80e6f760 Add links to JavaScript packages 2025-08-19 19:31:32 +03:00
Jussi Saurio
a82930d641 Merge 'Completion Error' from Pedro Muniz
Completions can now carry errors inside of them. This allows us to wait
for a completion to complete or to error. When it errors we can properly
tell the caller of `wait_for_completion` that we errored. This will also
allow us to abort completions.
Currently, this just creates the scaffold for us to store the error in
the completion. But to correctly achieve this, it will require some
refactor of our IO implementations to store the `run_once` error for a
particular completion inside of it instead of short circuiting. This
would also allow us to check for an error in `program.step` and properly
rollback.
Also, creates default impls for some common IO methods, this is
important specially for `wait_for_completion` as we want to check the
error in the `Completion` before returning `Ok`.
Maybe we could also accept a Result type in the completion callback so
that we can execute some sort of compensating action on error, like
unlocking a page so it can be evicted by the page cache later.
**EDIT:** actually implemented this in this PR. We store a `Result`
object inside `CompletionInner` behind a `OnceLock` for thread-safety.
We also pass a result object to Completion callbacks to execute
compensating actions.

Reviewed-by: Avinash Sajjanshetty (@avinassh)

Closes #2589
2025-08-19 19:07:57 +03:00
Pekka Enberg
6be1f67714 Merge 'JavaScript improvements' from Pekka Enberg
This pull request brings the JavaScript APIs to almost feature parity
with libSQL. Some corner cases like error messages still need some more
work.

Closes #2669
2025-08-19 18:27:51 +03:00
Pekka Enberg
945089d792 Merge 'bindings/rust: Add method' from Pekka Enberg
Fixes #2670

Closes #2671
2025-08-19 18:26:18 +03:00
Pekka Enberg
2963ea7239 bindings/rust: Add Connection::last_insert_rowid() method
Fixes #2670
2025-08-19 17:49:24 +03:00
pedrocarlo
b1399f6e8c fix merge conflicts 2025-08-19 10:48:21 -03:00
pedrocarlo
66171527b4 thread safely store the result of completion 2025-08-19 10:48:21 -03:00
pedrocarlo
de1811dea7 abort completions on error 2025-08-19 10:48:21 -03:00
pedrocarlo
4dca1c00db fix merge conflict 2025-08-19 10:48:21 -03:00
pedrocarlo
ab3b68e360 change completion callbacks to take a Result param + create separate functions to declare a completion errored 2025-08-19 10:48:21 -03:00
pedrocarlo
71ca221390 clippy 2025-08-19 10:48:21 -03:00
pedrocarlo
2d6fad5ea3 nit: adjust order of struct completions 2025-08-19 10:48:21 -03:00
pedrocarlo
fadf78fe67 use a dedicated Error enum for Completion Error 2025-08-19 10:48:21 -03:00
pedrocarlo
7bc0545442 default impl for get_memory_io 2025-08-19 10:48:21 -03:00
pedrocarlo
d5a59c6bee default impl for generate_random_number 2025-08-19 10:48:21 -03:00
pedrocarlo
f72bcbc5da default impl for wait_for_completion + check for errors in completion there 2025-08-19 10:48:21 -03:00
pedrocarlo
002390b5a5 store error inside Completion 2025-08-19 10:48:21 -03:00
pedrocarlo
d0c13f0104 remove IOError from Parser + store only ErrorKind in LimboError 2025-08-19 10:48:21 -03:00
Pekka Enberg
54b4fdaa7d javascript: Implement transactions API 2025-08-19 16:35:44 +03:00
Pekka Enberg
387d384394 javascript: Implement Statement.columns() 2025-08-19 16:35:44 +03:00
Pekka Enberg
5002539b04 javascript: Implement safe integers 2025-08-19 16:35:44 +03:00
Pekka Enberg
6b59bcd51e javascript: Fix Statement.get() for boundary values 2025-08-19 16:35:44 +03:00
Pekka Enberg
e99f189344 javascript: Implement Statement.pluck() 2025-08-19 16:35:44 +03:00
Pekka Enberg
54c02b6ae0 Merge 'bindings/javascript: Rename to ' from Pekka Enberg
We already have a `@tursodatabase/sync` package so let's make the name
of the better-sqlite3 compatibility API package stand out.

Closes #2667
2025-08-19 16:35:23 +03:00
Jussi Saurio
1200a1dd44 Merge 'Small pager cleanups' from Jussi Saurio
Reviewed-by: Preston Thorpe <preston@turso.tech>

Closes #2668
2025-08-19 16:04:11 +03:00
Jussi Saurio
ac37e89fe1 remove unused PAGE_ERROR flag 2025-08-19 15:44:16 +03:00
Jussi Saurio
33eb730ef8 finish_read_page() never fails, so it does not need to return Result 2025-08-19 15:44:16 +03:00
Jussi Saurio
687e593361 Add pgno field to CacheError::Locked for debugging 2025-08-19 15:44:16 +03:00
Preston Thorpe
ea5896b4ea Merge 'Add helper to convert io::clock::Instant to useable format ' from Preston Thorpe
I needed this for another PR

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

Closes #2654
2025-08-19 08:18:52 -04: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
692323ae9b bindings/javascript: Rename @tursodatabase/database/sync to compat
We already have a `@tursodatabase/sync` package so let's make the name of the
better-sqlite3 compatibility API package stand out.
2025-08-19 13:20:34 +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
d3d01cefc8 Add to_system_time for our io::clock::Instant type 2025-08-18 19:27:37 -04: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