Commit Graph

30927 Commits

Author SHA1 Message Date
stephan 4ad869aa3f 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.
FossilOrigin-Name: 450b4bcca6038be58a73ff15ff18b9d70df661fe0bd9777273e0db6fbce5f296
2025-11-26 16:27:11 +00:00
stephan 0e4ea1821f 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).
FossilOrigin-Name: c18154bc9a7cf07d3902d74d27b4ca696929aae9e1abe031679bd5a42d759046
2025-11-26 16:26:27 +00:00
stephan 0baab04f8b Minor optimization in kvvfs event notification.
FossilOrigin-Name: fd85b96b12d164f7700624dba478d35e886b23f5c31c853715f783639ea95f23
2025-11-26 14:22:51 +00:00
stephan a781caa9ad 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.
FossilOrigin-Name: 43173267849f7f4b77a9ee15ab586e9deb0e290071149857fe18421fb948a715
2025-11-26 13:55:20 +00:00
stephan 1da8e7ac4f Remove some debug output.
FossilOrigin-Name: 9fc6b811d6b0e268be18b768b6a69381606557a1702064b29f0ff4ca7c505cac
2025-11-25 19:06:05 +00:00
stephan 20e1f8a289 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.
FossilOrigin-Name: a5c61fa56770a6fffcb4c76db2256c71b2d5f0beee6fc2c4800c40bf7ef995c8
2025-11-25 19:05:13 +00:00
stephan f0ca498c61 Improve kvvfs file name validation. Add sqlite3.kvvfs.unlink().
FossilOrigin-Name: 0dfdf4681cf63541de971a20be21b33d0d3b38e8281f302d20aca9492df3da42
2025-11-25 18:52:08 +00:00
stephan e62055f274 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).
FossilOrigin-Name: 02793c5905e6b99379cd5ad6bfe1eb6cccf839da081fc174dce7b06245e212fb
2025-11-25 16:41:56 +00:00
stephan 27aec2d1c1 Add an explicit rollback test for kvvfs.
FossilOrigin-Name: 2bf31ef8027a3e15887d4dcd26fe09463b5f8852c5ce443f7d07c23d29c37311
2025-11-25 16:07:05 +00:00
stephan 30f9c25d9a 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.
FossilOrigin-Name: d391f1ce691fca4504c21a7e3e05a029f247da23d432ee34b0dae14be51d909c
2025-11-25 15:59:58 +00:00
stephan a63538027c 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.
FossilOrigin-Name: ac8af73c16ab821a7aa7d28a5fde8aeba0bc4d03c0af0dd2cff288c8fdabc49e
2025-11-25 15:35:53 +00:00
stephan 68230ef670 kvvfs internal cleanups. Experimentally add async event listeners to kvvfs to explore backing up a kvvfs a page at a time.
FossilOrigin-Name: f355fd484947a645206c9b9c2fd6fe691455dece7fb1aa5b72cb51a86b39474f
2025-11-25 05:44:03 +00:00
stephan 76dc170938 Factor out some now-superfluous JS-side kvvfs code. Factor out a superfluous allocation. Shorten the public API names of the new methods.
FossilOrigin-Name: be435b668f1aee56fc4965592c207de25283de238fe89002f1a68ba0567aca65
2025-11-25 04:07:50 +00:00
stephan c14460f466 Disallow a filename of '-journal' for db files in kvvfs, as that name has a special meaning there.
FossilOrigin-Name: 357cc42633efb85c3ca9bc3d6d46430e1ecaf2825e6bdd7d7b4e0f6865d0b599
2025-11-25 03:09:45 +00:00
stephan d3a0fc5473 Add xGetLastError() to kvvfs but it does not appear to be called for xOpen() failures.
FossilOrigin-Name: 7e7944f00792c5e7a9ea013f9c5d1f6bb6313070de20ec4ce262ff0b430f9801
2025-11-25 02:08:49 +00:00
stephan 45d8831cad Fix a 32-/64-bit incompatibility in opfs-sahpool.
FossilOrigin-Name: 256c1dd2c367dbc3b3df5028f2004bb1126851109efc71a1699f60f493514fcb
2025-11-25 02:08:11 +00:00
stephan b7ed25a86f 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.
FossilOrigin-Name: 46d6b636307d98d17344d995afd99204e16eb06b6b19021a824dab95267d5377
2025-11-24 20:43:14 +00:00
stephan 91c8b974e5 Add the sqlite3_db_filename() to the sqlite3.oo1.DB tracing output. Document an unfortunate design choice which was only recently recognized as such.
FossilOrigin-Name: dec0c6073cc130ba445ec68bc49a410001d778c4aa21624dcb0a68b88fce251f
2025-11-24 20:36:49 +00:00
stephan c4d6f31747 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.
FossilOrigin-Name: c6183261be77d03451aed563a5e4c19aa69706aa311cfdaf5db5e9b0a167d814
2025-11-24 20:14:23 +00:00
stephan d8b323f652 Fix a typeof check so that it works in Worker threads.
FossilOrigin-Name: 3f2ed39e40e9c76c7d035b819d06c316ec4fba4e112b8a293822a8648147594b
2025-11-24 18:17:07 +00:00
stephan c340a0f717 Have kvvfs enforce ASCII-only names to avoid truncating multibyte characters in kvvfs's key buffer.
FossilOrigin-Name: 03cb2a13c7f9081132390b5169cf22ffeced6ebdc5f01654360f951720310916
2025-11-24 18:08:25 +00:00
stephan 72b4d638a5 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().
FossilOrigin-Name: c9e0b32278290baf987b5a46bd47358439e3d0f190b2879a965d6e4262ea7baf
2025-11-24 15:17:52 +00:00
stephan 853335af49 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).
FossilOrigin-Name: 4857c9d2fe428c19319244bf0589eaf93c124f020a633d6b7d40d35aaf969d24
2025-11-23 22:13:42 +00:00
stephan 8679c33355 Add the long-missing sqlite3_next_stmt() binding to JS/WASM.
FossilOrigin-Name: 53a99ff4ed5ef5f8620bf324a4f7a1d0812f5c80311228eb820039430ca04bd5
2025-11-23 22:09:16 +00:00
stephan 606b1bd153 Docs, cleanups, and dead code removal.
FossilOrigin-Name: 49db59aa9c74e49d878adc8671b0d32db8f1f898bde29d046ce0e368d8987868
2025-11-23 20:05:21 +00:00
stephan da0d872270 Get the kvvfs v2 working in 64-bit wasm builds (a 0 vs null vs BigInt issue).
FossilOrigin-Name: 4811742688bd8ae847c0a13ca9b395b2d2edd24ce4e7760a5d1b0adf1c7f332d
2025-11-23 16:54:16 +00:00
stephan 274db1fd84 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.
FossilOrigin-Name: f63014f70febf82976a99f9f1ce6d793e2ca8d1dd2f72622152b64b2d65f8adc
2025-11-23 16:35:18 +00:00
stephan d855948547 Initial work on eliminating the superfluous-for-transient-storage kvvfs key prefixes and implementing kvvfs db import.
FossilOrigin-Name: 6bc64059410b1868b7a3576e16d03c02e7c007a2be8b313e386eeb2e2a35c258
2025-11-23 15:38:34 +00:00
stephan 56a4a2173e Add tests demonstrating basic concurrent use of kvvfs storage and that kvvfs still works after wiping the storage out from under it).
FossilOrigin-Name: cbbb9e61ae81097625488d78c5cbc0065c0acc3c8a7fd819490bc697f9d808c5
2025-11-23 13:33:56 +00:00
stephan ea375f1320 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.
FossilOrigin-Name: 393c1beee00ec3b3e98eb385cae0abeb1b34475140c0e8c3d57541d349904436
2025-11-23 12:14:18 +00:00
stephan 48c8405f99 Replace an alloc/free on every read of a JS kvvfs key with a one-time alloc and a long paragraph explaining why we have to leak it.
FossilOrigin-Name: 66fb9978f0a63887d214e895343adedfa46ee7aefccb8389d6d3af727e0a65ea
2025-11-23 11:28:27 +00:00
stephan 44fdf80c28 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).
FossilOrigin-Name: 69e591d0054218ead789cee199e5258f1c378a89e4b7b0e38fe74e834e23156b
2025-11-22 19:21:25 +00:00
stephan 05478c7149 Fix a misinteraction of CREATE/READONLY flags in the OPFS VFS.
FossilOrigin-Name: 0b53be562f1e1a5b20ffe8d72df64e753a8d759b580d949a0f32409144769bb0
2025-11-22 17:27:16 +00:00
stephan 7ae80c0bc1 Fix storage-size counting of non-local/non-session kvvfs storage. Rename the 'global' buildin kvvfs storage object to 'localThread'.
FossilOrigin-Name: 61606be2ae2b0d73cdcd7947a77c7ad87cdf850bba90b0c3e3cdf8c02177db73
2025-11-22 16:29:45 +00:00
stephan ec274603f1 Incremental work on kvvfs v2.
FossilOrigin-Name: 60d61cf383b63b25dcfbf8da9539aaec253b6618ec83403f6690b7a32c13363d
2025-11-22 07:35:36 +00:00
stephan 16d127eb45 Factor KVVfsFile::zName back out. Remove the extraneous part of the storage keys for non-local/non-session storage.
FossilOrigin-Name: d2bf96d68c6cb2ae68558722edb22192fb1dbbf08fefdb2fd0a4827688e082a8
2025-11-22 05:37:21 +00:00
stephan fc6096b013 Demonstrate completely transient and a semi-transient (until page reload) kvvfs instances.
FossilOrigin-Name: 3f9ff9873303c3900dd3cba6e922bfb8cdb1f595353b692796b62e3025013517
2025-11-22 02:43:56 +00:00
stephan 7845d312b1 Latest side-stream jaccwabyt/wasmutil.
FossilOrigin-Name: e0b33b51229a977cc3fa8a5a6c8ea59669f8bf566b2a6330fd24da1ad886a716
2025-11-22 02:23:02 +00:00
stephan 92fa31bc5f 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.
FossilOrigin-Name: 19a3349a2031e2b7fae67847b55643e4f70f8dae863ebc1ace3b09d1f482c8eb
2025-11-21 22:13:35 +00:00
stephan 7c07260353 More work towards using JS generic Storage objects as db page storage via kvvfs.
FossilOrigin-Name: 90a33941c69b3581feaed271542f0238ca81ee34fe5b353ca7da48b81ac73a5f
2025-11-21 18:55:33 +00:00
stephan 6690972855 Remove kvvfs-specific filename validation from the oo1.DB ctor.
FossilOrigin-Name: 206275292217be4ff317d4c9186ecaf863ca69295e2f995ed175aa65d9ad11dc
2025-11-21 18:49:58 +00:00
stephan 81b7e49d2d 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.
FossilOrigin-Name: 190ef4a94005b0feebe865a960d846a1b60ec1b267b15d5a24749f174a6169bc
2025-11-21 15:23:52 +00:00
stephan 794a9b48ac Add new file missing from [3c4061428544].
FossilOrigin-Name: 41f94eca01d8317364aa60ddd8e5fe3cd21a215040ef271a157d450a914139d0
2025-11-21 15:03:38 +00:00
drh 873cd21ec3 Enhance ALTER TABLE to support adding and removing NOT NULL and CHECK
constraints.

FossilOrigin-Name: 895498e4431e02cff65a5d96db22f0b0cb9c96aedf1e3cdcdeb3c34c6fec432b
2025-11-21 14:15:56 +00:00
drh ac16642cc4 Fix the QRF so that it omits the closing text from styles "json" and "jobject"
when the result set it empty.

FossilOrigin-Name: e1ba175124be83da4db6d5d4e583b9b3b7dcb82e983c6f185d590469dcdc3139
2025-11-21 11:00:29 +00:00
stephan 40ce52a4e5 Move the JS pieces of kvvfs into their own file to facilitate pending feature experimentation.
FossilOrigin-Name: 3c40614285449df259a3444e36f888cfb5e782ea58287914f97f496ea61e9e9f
2025-11-21 10:49:32 +00:00
drh 1073985be7 Test cases for the fix in the prior check-in.
FossilOrigin-Name: 4d41bee75eda51251121c8e3903f47941116e5182238a03f41a593c47efb6fcf
2025-11-20 22:46:27 +00:00
drh 980580efec Preserve auto-explain mode across mode changes, as has always been the
case before.

FossilOrigin-Name: 8896185ae0b0af8918aa8ce449f18759e6ae60358afbac1019397bae307b15d5
2025-11-20 21:08:46 +00:00
drh a68046e79d Fix hwtime.h (broken by [305bb022368bac9f]) so that unamalgamated windows
builds work again.

FossilOrigin-Name: 1245319257d03a00eddbc8ff4b43b5813f8a567a12a9957f923bef58c85c0c20
2025-11-20 12:41:26 +00:00
stephan 6d62ed4f87 Remove an extraneous loop level from the JS bootstrapping bits.
FossilOrigin-Name: 86817b4e9f011d296fb420be95269fecb54fb48a220bce84020e3af2d2c164a4
2025-11-20 12:14:03 +00:00