Commit Graph

70 Commits

Author SHA1 Message Date
sonhmai
75f0cf9e20 chore: make clippy happy 2025-01-20 13:29:23 +07:00
Elijah Morgan
f20a2d1334 Reorg to single package
Handle commonjs and esm module entry points

tests works
2025-01-16 21:29:19 -05:00
Elijah Morgan
02e4104932 reorg package structure
src moved under web/ to make it cleaner
build does less moving of files, mostly just moves the wasm-pack
into dist for node and web
2025-01-16 21:29:19 -05:00
Pekka Enberg
a369329988 Merge 'Add OPFS support to Wasm bindings' from Elijah Morgan
Lots of cleanup still left to do. Draft PR for adding support for OPFS
for WASM build (add support for limbo in browser).
Overall explanation of the architecture: this follows the sqlite wasm
architecture for OPFS.
main <> (limbo-worker.js) limbo (VFS - opfs.js) <> opfs-sync-proxy
The main thread loads limbo-worker.js which bootstraps the opfs.js and
opfs-sync-proxy.js and then launches the limbo-wasm.js.
At that point it can be used with worker.postmessage and
worker.onmessage interactions from the main thread.
The VFS provided by opfs.js provides a sync API by offloading async
operations to opfs-sync-proxy.js. This is done through SharedArrayBuffer
and Atomic.wait() to make the actual async operations appear synchronous
for limbo.
resolves #531

Closes #594
2025-01-07 10:36:18 +02:00
Pekka Enberg
daee7f8458 s/RowResult/StepResult/ 2025-01-05 20:24:26 +02:00
Pekka Enberg
5681603750 Merge 'Make iterate() lazily evaluated on wasm' from Diego Reis
#514
Introduces a new feature for lazy evaluation in the
`Statement.raw().iterate()` method and includes related changes in both
the test and implementation files. The most important changes include
adding a test case for lazy evaluation, creating a `RowIterator` struct,
and modifying the `iterate` method to use this new struct.
Everything seems to works fine, but suggestions on code improvement and
test use cases are welcoming.

Closes #527
2025-01-05 20:23:06 +02:00
Elijah Morgan
d51ca2150c Cleanup logging, move html files
General cleanup of cruft, deleted dead code, moved html files to clean
up dir.
2025-01-03 14:38:34 -05:00
Elijah Morgan
4bda7803c3 Add build for nodejs or web
Change how VFS gets loaded based on feature flags
2025-01-01 16:54:31 -05:00
Elijah Morgan
058ca89561 feat add basic opfs support and tests 2025-01-01 10:31:26 -05:00
PThorpe92
f6cd707544 Add clippy CI, fix or ignore warnings where appropriate 2024-12-29 10:25:41 -05:00
adamnemecek
97647ff056 Clean up code to use Self
Closes #556
2024-12-29 10:07:38 +02:00
Pekka Enberg
f2ecebc357 Rename RowResult to StepResult
The name "row result" is confusing because it really *is* a result from
a step() call. The only difference is how a row is represented as we
return from VDBE or from a statement.

Therefore, rename RowResult to StepResult.
2024-12-27 10:20:41 +02:00
Diego Reis
67c6409412 Add handling to busy row on RowIterator::next() 2024-12-26 15:40:04 -03:00
Diego Reis
d7be6f91cd Fix formating and pass on tests 2024-12-26 15:40:04 -03:00
Diego Reis
979115ee59 Remove unused variable on RowIterator 2024-12-26 15:40:04 -03:00
Diego Reis
77c2b6f1a0 Make iterate() lazily evaluated on wasm 2024-12-26 15:40:04 -03:00
Pere Diaz Bou
aed14117c9 core: transaction support 2024-12-24 18:04:30 +01:00
Ziyak Jehangir
99d1b0e5a3 cleanup: replace &(*x) with x.as_ref() for smart pointer derefs 2024-12-19 19:36:04 +05:30
Pekka Enberg
e93ac38e55 Add statement interruption support
This adds an interrupt() method to Statement that allows apps to
interrupt a running statement. Please note that this is different from
`sqlite3_interrupt()` which interrupts all ongoing operations in a
database. Although we want to support that too, per statement interrupt
is much more useful to apps.
2024-12-19 12:30:32 +02:00
Pere Diaz Bou
39a75147d4 Page cache by page_number and frame_number
Since page cache is now shared by default, we need to cache pages by
page number and something else. I chose to go with max_frame of
connection, because this connection will have a max_frame set until from
the start of a transaction until the end of it.

With key pairs of (pgno, max_frame) we make sure each connection is
caching based on the snapshot it is at as two different connections
might have the same pageno being using but a different frame. If both
have same max_frame then they will share same page.
2024-12-13 21:57:27 +01:00
Pere Diaz Bou
3fda2d09b9 Extract multi threaded part from WalFile to WalFileShared
Since we expect to ensure thread safety between multiple threads in the
future, we extract what is important to be shared between multiple
connections with regards to WAL.

This is WIP so I just put whatever feels like important behind a RwLock
but expect this to change to Atomics in the future as needed. Maybe even
these locks might disappear because they will be better served with
transaction locks.
2024-12-13 13:09:13 +01:00
Pere Diaz Bou
a4297702bd extract page cache to be multi threaded 2024-12-13 13:09:13 +01:00
Pekka Enberg
36f9565910 Merge 'feat(wasm): add get and iterate func' from Jean Arhancet
Add `get` and `iterate` functions to the wasm module

Closes #421
2024-12-09 17:28:43 +02:00
JeanArhancet
5693cd1ae0 feat(wasm): add get and iterate func 2024-11-29 21:48:20 +01:00
Lauri Virtanen
a7100d8e9b Autofix clippy issues with cargo fix --clippy 2024-11-24 20:24:47 +02:00
Pekka Enberg
bfce49c7eb bindings/wasm: Fix conversion to JsValue 2024-11-20 11:54:34 +02:00
Pekka Enberg
b65d0a72ba bindings/wasm: Implement Statement.raw() 2024-11-20 11:47:28 +02:00
Pere Diaz Bou
2cc89f712e open file in append mode 2024-11-18 18:06:01 +01:00
Pekka Enberg
82ec900b07 bindings/wasm: Fix VFS.sync() function signature
We don't expect any return value from the underlying `fsync()` so fix
the function signature accordingly.

Fixes the following obscure error:

```
TypeError: Cannot convert undefined to a BigInt
    at wasm://wasm/00942492:wasm-function[1501]:0x1c4dc1
    at wasm://wasm/00942492:wasm-function[694]:0x189586
    at wasm://wasm/00942492:wasm-function[50]:0x143d7
    at wasm://wasm/00942492:wasm-function[60]:0x3f91a
    at new Database (/Users/penberg/src/penberg/limbo/bindings/wasm/pkg/limbo_wasm.js:162:26)
    at file:///Users/penberg/src/penberg/limbo/bindings/wasm/perf/perf-limbo.js:5:12
    at ModuleJob.run (node:internal/modules/esm/module_job:195:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:336:24)
    at async loadESM (node:internal/process/esm_loader:34:7)
    at async handleMainPromise (node:internal/modules/run_main:106:12)
```
2024-11-16 13:07:32 +02:00
Pere Diaz Bou
6cd0f03643 core: create databases from limbo 2024-11-15 12:09:07 +01:00
Pere Diaz Bou
87c80b2a07 use core wal file for wasm 2024-11-14 17:54:20 +01:00
Pere Diaz Bou
71ac1eacb7 Merge 'btree: cursor with lineal stack structure' from Pere Diaz Bou
Removed MemPage from the code in favor of an array to encode the stack
of the cursor. This is both simpler and better in terms of memory
access.
O_DIRECT was removed from WAL file as it introduces alignment
constraints that are too hard to follow in regular appends. Maybe in the
future?

Closes #378
2024-11-13 18:23:31 +01:00
Pere Diaz Bou
e2276c2e9d O_DIRECT disable on WAL 2024-11-13 13:45:42 +00:00
Pekka Enberg
b7ca2c9823 bindings/wasm: Add Database.prepare() and Statement.all()
This adds `Database.prepare()` and `Statement.all()` APIs to the Wasm
bindings so that you can actually get something useful out of the
library.
2024-11-13 12:22:35 +02:00
Pere Diaz Bou
ce8378793e btree: run until finished or IO + bug fixes 2024-11-11 17:03:15 +01:00
Pere Diaz Bou
ce1367b76a move wal creation 2024-11-07 13:51:02 +01:00
Pere Diaz Bou
0b46648c0e write wal header on init 2024-11-07 13:29:57 +01:00
Pere Diaz Bou
8eb3c89227 wasm,sim fixes 2024-11-05 15:41:30 +01:00
Pere Diaz Bou
f43e53a815 fix wasm and simulator wal impl 2024-11-05 15:29:54 +01:00
Pere Diaz Bou
f66e3925f3 fix imports 2024-11-05 15:29:54 +01:00
Pere Diaz Bou
f009eb35c6 suspendable checkpoint 2024-11-05 15:29:54 +01:00
Pere Diaz Bou
c0e51c4ca6 wip wal 2024-11-05 15:29:53 +01:00
김선우
28884181be Fix clippy 2024-09-15 16:23:27 +09:00
mazchew
671b61ba19 add time querying to io trait 2024-08-25 22:55:15 +08:00
mazchew
156005694a added rng to io trait for simulation 2024-08-22 23:24:02 +08:00
Pekka Enberg
933bf89bb9 wasm: VFS interface to use Node filesystem API
This adds a basic VFS interface to use Node filesystem API from Rust
code. Not a lot, but parses the SQLite database file header and
completes database open without errors.
2024-08-04 11:12:21 +03:00
Pekka Enberg
7df979cd3a wasm: Enable console.error() panic hook
Makes debugging a little bit easier...
2024-08-04 09:45:27 +03:00
Pekka Enberg
ed4116e7c2 core: Introduce Wal trait
We're going to need it for WebAssembly anyway, which does not have
standard filesystem support.
2024-08-03 12:34:10 +03:00
Pekka Enberg
3f7c788e5b core: Rename DatabaseStorage methods
Let's call them read_page() and write_page().
2024-08-03 10:35:14 +03:00
Pekka Enberg
8a54e31803 core: Rename PageIO to DatabaseStorage 2024-08-03 10:33:52 +03:00