stephan [Wed, 26 Nov 2025 16:27:11 +0000 (16:27 +0000)]
Remove some dead code. Resolve the remaining kvvfs v1/v2 API compatibility confusion by eliding the v1 API from Workers like we've always done. Add some tests.
stephan [Wed, 26 Nov 2025 16:26:27 +0000 (16:26 +0000)]
Wasm speedtest1: replace some 'self' with 'globalThis' and expose the sqlite3 object to the global scope for inspection via the dev console (for inspecting resulting kvvfs storage objects).
stephan [Wed, 26 Nov 2025 13:55:20 +0000 (13:55 +0000)]
Internal kvvfs docs and cleanups. Wasm speedtest1: remove the hard-coded --size=2 limit for kvvfs and use a transient storage object instead of session storage (which is limited to --size=2). For small job sizes kvvfs is roughly 3x the speed of memdb and that gap grows as the --size increases, with kvvfs _really_ bogging down on the --size=50 jsonb tests.
stephan [Tue, 25 Nov 2025 19:05:13 +0000 (19:05 +0000)]
Remove the ostensible support for empty kvvfs names, as those names apparently never reach kvvfs.xOpen (the empty name is special). That actually simplifies things with regards to backwards compatibility.
stephan [Tue, 25 Nov 2025 16:41:56 +0000 (16:41 +0000)]
Add the sqlite3.kvvfs namespace for the new kvvfs APIs instead of adding more sqlite3_js_kvvfs_...() methods. Reinstate that clearing kvvfs storage is illegal when db handles are opened, solely for sanity's sake (they can actually recover from that but supporting such use feels ill-advised).
stephan [Tue, 25 Nov 2025 15:59:58 +0000 (15:59 +0000)]
A more compact formulation of [ac8af73c16ab821] which uncovered two remaining direct calls to kvrecordRead(), now replaced with calls through the thunk. Fix a typo which caused the storage object name to not be passed on to event listener.
stephan [Tue, 25 Nov 2025 15:35:53 +0000 (15:35 +0000)]
In wasm builds, #if out the impls for the 3 core kvvfs i/o routines which get overwritten from JS (and thus aren't used) to reduce dependencies on POSIX APIs.
stephan [Mon, 24 Nov 2025 20:43:14 +0000 (20:43 +0000)]
Do not allow the kvvfs transient flag to flag a previously-non-transient storage as transient. i.e. only applies when first opening a db. Rename the transient flag to delete-on-close to avoid confusion with other meanings of transient in that context.
stephan [Mon, 24 Nov 2025 20:14:23 +0000 (20:14 +0000)]
Add kvvfs URI flag transient=1 to cause the storage object to be removed when the last handle to the db is closed. By default it behaves like a filesystem would, retaining the storage objects.
stephan [Mon, 24 Nov 2025 15:17:52 +0000 (15:17 +0000)]
Get kvvfs v2 storage import working by disallowing it when there are opened db/journal handles. Move import/export out of the JsStorageDb class and into sqlite3_js_kvvfs_import/export_storage().
stephan [Sun, 23 Nov 2025 22:13:42 +0000 (22:13 +0000)]
More work on kvvfs v2. Db imports work, in the sense that the storage is properly replaced, but the native side is not yet able to recover from that (and how to make it able to do so is not clear).
stephan [Sun, 23 Nov 2025 16:35:18 +0000 (16:35 +0000)]
Eliminate the superfluous 'kvvfs-' part of keys for transient storage and cleanup their export a bit. Reminder for later: we could potentially use the dbpage vtab to serialize any db to this JSON-friendly form.
stephan [Sun, 23 Nov 2025 12:14:18 +0000 (12:14 +0000)]
Bump kvvfs's sqlite3_vfs::iVersion to 2 so that its xCurrentTimeInt64() can be used. Add JsStorageDb.exportToObject() to serialize a kvvfs to a JSON-friendly form.
stephan [Sat, 22 Nov 2025 19:21:25 +0000 (19:21 +0000)]
This combination of kvvfs callbacks seems to work okay for both persistent and transient storage, but it's unclear why/how, as xAccess() does not appear to be doing anything useful (and misbehaves when told to report that the storage object in question exists). These tests fail in 64-bit builds for as-yet-unknown reasons (other tests continue to pass in 64-bit).
stephan [Fri, 21 Nov 2025 22:13:35 +0000 (22:13 +0000)]
Get initial JS overrides of the kvvfs sqlite3_vfs and sqlite3_io_methods in place. It now tracks a distinct Storage-ish object per sqlite3_file instance.
stephan [Fri, 21 Nov 2025 15:23:52 +0000 (15:23 +0000)]
Initial restructuring of kvvfs working towards generic support of JS's Strorage interface as storage rather than hard-coding it to just window.localStorage and window.sessionStorage. The eventual goal of that is to have a storage solution which works without the POSIX I/O APIs, getting us one step closer to a wasi-sdk build. It would be transient, like Emscripten's virtual filesystem, and could hypothetically replace our dependency on that particular feature.
stephan [Thu, 20 Nov 2025 12:12:55 +0000 (12:12 +0000)]
Enable the SQLITE_EXPERIMENTAL_PRAGMA_20251114 in the WASM builds for the sake of VFS experimentors. The links in the comments describe what that does.
drh [Tue, 18 Nov 2025 17:49:48 +0000 (17:49 +0000)]
New subcomponent, the Query Result Formatter (QRF), that formats query
results for display to humans on a fixed-width font terminal. Rework the
CLI to make use of the QRF. Renovate the .mode command of the CLI. Also
incorporate the QRF into the TCL interface as the "format" method.
drh [Tue, 18 Nov 2025 17:27:46 +0000 (17:27 +0000)]
Add support for SQLITE_LIMIT_PARSER_DEPTH to limit the size of the stack
used by the parser. This can help prevent deeply nested parse trees that
then cause problems on machines with smaller CPU stacks. Modify the
%realloc and %free directives of Lemon and add the new %stack_size_limit
directive in support of this capability.
drh [Tue, 18 Nov 2025 15:40:02 +0000 (15:40 +0000)]
Modify the "%realloc" and "%free" commands in Lemon so that the functions
they specify take an extra parameter at the end, the %extra_context pointer.
This allows the implementation to distinguish between OOM errors and
failures to increase the stack size because of the stack size limit.
stephan [Mon, 17 Nov 2025 23:55:41 +0000 (23:55 +0000)]
Add api.oo1=0 flag to ext/wasm/GNUmakefile to strip out the sqlite3.oo1 pieces from the build. Part of the ongoing response to [forum:4b7d45433731d2e0|forum post 4b7d45433731d2e0].
drh [Mon, 17 Nov 2025 19:46:04 +0000 (19:46 +0000)]
If SQL is entered as additional command-line arguments to CLI, that counts
the same as getting input from a pipe or file for the purpose of determining
the default format mode.
drh [Mon, 17 Nov 2025 16:44:13 +0000 (16:44 +0000)]
CLI comes up in legacy "list" mode if neither stdin or stdout are a tty, or
if "--compat 20251114" or earlier is specified, or if "--batch" is used.
New modes "batch" and "tty" select either legacy "list" mode or the newer
"qbox" mode with limits.
Make CVS output compatible with legacy. Break out ".import" into a separate
subroutine in anticipation of forthcoming improvements. General code
cleanup.
drh [Sun, 16 Nov 2025 17:27:21 +0000 (17:27 +0000)]
Default .mode is now qbox with limits. New --compat YYYYMMDD command-line
option, and new -DCOMPATIBILITY_DATE=YYYYMMDD compile-time options can
override. Command ".mode YYYYMMDD" sets the mode to the default for the
date given.
stephan [Sat, 15 Nov 2025 15:30:45 +0000 (15:30 +0000)]
JNI: when validing the eTextRep argument in sqlite3_create_function(), only validate the lower four bits (the high bits are for other flags). Add flags to test functions to ensure this case is triggered.
stephan [Sat, 15 Nov 2025 15:09:04 +0000 (15:09 +0000)]
Replace the JNI binding's internal use of sqlite3ErrorWithMsg() with sqlite3_set_errmsg() and have it handle OOM in a way consistent with the rest of the JNI bindings.
stephan [Sat, 15 Nov 2025 13:30:13 +0000 (13:30 +0000)]
Random JS build cleanups and parallel build mkdir race fixes. Reinstate the recently-removed [a65bd978cbc646ec] after finding a reformulation which works on Emscripten 4.0.19 (and saves about 85kb on the JS deliverables).
stephan [Sat, 15 Nov 2025 11:53:30 +0000 (11:53 +0000)]
Reorder initialization of sqlite3ApiBootstrap()'s bownstrapped config object so that it's possible to inject the wasm memory and exports via that, to simplify plugging-in of sqlite3-api.js in other builds. Previously the build-provided wasm exports/memory overrode any which a client might want to use.
stephan [Sat, 15 Nov 2025 09:19:03 +0000 (09:19 +0000)]
Move sqlite3-api-cleanup.js into post-js-footer.js to remove the final direct Emscripten dependency from the intermediary build product sqlite3-api.js (the whole library, waiting to be bootstrapped). This is partly in response to [forum:4b7d45433731d2e0|forum post 4b7d45433731d2e0], which demonstrates a potential use case for a standalone sqlite3-api.js. This is a build/doc change, not a functional one.