1
0
mirror of https://github.com/sqlite/sqlite.git synced 2026-10-23 21:49:02 +03:00
Commit Graph

755 Commits

Author SHA1 Message Date
stephan
40f8f74946 OPFS SAHPool VFS: fix an improbable corner case in which the VFS's in-memory state and its on-disk state could differ with regards to availability of a given SAH if a write failure happens at one very specific point during de-registration of the SAH. Addresses [bugs:432f260aa7|bug report 2026-10-05T17:51:35Z].
FossilOrigin-Name: 837fee6e45464bd3fcb5064cfdb91ec15d7cf0c010106797e28e744c3cb39bbc
2026-10-05 20:26:24 +00:00
stephan
0caf6b532d SAHPool VFS tweaks contributed off-list by Jure Rotar: hardening against malicious inputs and I/O errors. Truncate to the shorter length when overwriting a db file with a shorter one via importDb(). Correct xOpen() to honor the combination of CREATE/EXCLUSIVE flags.
FossilOrigin-Name: 7af745868b873daacdbb57621201887f80782cef4e10ef24243a15ae88897f0d
2026-10-01 08:13:58 +00:00
stephan
ca9a8adfa4 Add tests demonstrating kvvfs locking errors across multiple connections to the same storage. Add sqlite3.oo1.Stmt.resetNoThrow() for reasons described in its API docs.
FossilOrigin-Name: 0fed9bcbe2c33d8db5b3500b506bcdfa6a2c718a65bfef4f1d2d21951f6341a8
2026-09-30 19:26:14 +00:00
stephan
c15f5adadb Rework the JS kvvfs xLock(), xUnlock(), xCheckReserved(), and xSleep() analog to the recent opfs-sahpool changes to make it more robust when a given kvvfs store is accessed via multiple handles (all necessarily from the same thread). This does not break anything but also does not prove anything - tests are pending.
FossilOrigin-Name: d0e27fa55b05832dc2ad52d5bdb56e74dae2d95984e0f8f8d1831015c5fcd781
2026-09-30 18:40:09 +00:00
stephan
519e4c23a5 [fa44643f65d6] inadvertently removed its circular-cleanup protection by fixing the finalizer ordering. This check-in fixes that. Spotted in [forum:ba4cb328a7|forum post 2026-09-30T14:59:13Z].
FossilOrigin-Name: 771faec269d786f01fc8d9155fd546d09ea6ca2eba0f0c97e34e795f64719454
2026-09-30 15:46:02 +00:00
stephan
cdbfe6a938 Do not inherit the OPFS SAHPool's xSleep method from the default VFS, as doing so can cause the thread to freeze. This VFS only deals with contention originating in the same thread, so xSleep() needs to be a no-op. Addresses [forum:3f0794c5d8|bug report 2026-09-30T12:52:54Z].
FossilOrigin-Name: c9dd4d88e44a9eae4ea11d0ce5491c7ac2ac2d60a3bc83ed485812234be374da
2026-09-30 13:23:56 +00:00
stephan
3b28aa1ce7 Fix the OPFS SAHPool VFS's xLock/xUnlock to properly deal with multiple handles to the same underlying file within the same JS thread. Addresses [forum:5e66a600ba6e57de|bug report 2026-09-30T10:49:15Z]. Also (unrelated but code-adjacent) make sure that the VFS releases all of its internal mappings when it's paused.
FossilOrigin-Name: 9e2caaa382cee5d5df26ad3af7d727ab3f68a912e39655ffcc52f592d5a08a8d
2026-09-30 11:48:29 +00:00
stephan
737c12a04c Minor JS doc correction.
FossilOrigin-Name: 6b470917b2c9ab25d1e7fed56f19f37b5c2fc3f2a3d504a752a7bb2db14a3ee6
2026-09-30 10:36:27 +00:00
stephan
9fd5a0bc55 Correct the xCheckReserveLock() impl of the OPFS SAHPool VFS to fix a corruption case involving multiple handles in the same JS thread to the same filename when one leaves a journal behind. Addresses [forum:b2fbb61642|bug report 2026-09-29T18:25:28Z].
FossilOrigin-Name: 9168a6f1bedba87117169d096f9a6fcadaac65249d707193e4bcbc25e59ccb54
2026-09-30 09:53:09 +00:00
stephan
226a2c0d6a Generic internal JS cleanups. No functional changes. Update the preprocessor for the ability to use C-style comments in directive arguments.
FossilOrigin-Name: b2699eb9676e6f5459b8279661c264ba2c803ae133f85c703984deb7afa4fe60
2026-09-30 09:17:12 +00:00
stephan
ad1bbfc2bd OPFS SAHPool: more cleanly handle an init failure. Add an init option which tells it not to wipe the storage if initialization fails. Based on the discussion and patch in [forum:5664cd4baee50236|forum post 5664cd4b]. Minor doc updates in unrelated code.
FossilOrigin-Name: 0560c3cc20f60caee42492e4d2063aed8d8d44b0a544a8c3aae56ee67da2e4a7
2026-09-29 08:31:55 +00:00
stephan
998173efcd Update some long-dormant JS test code for refactoring-/renaming breakage induced since it was last used. Remove a separate long-dormant JS demo which cannot work with the current code.
FossilOrigin-Name: fc4e246dc26f3e3872dde42ceefcea70ba4158a92ba94361656b2ca0f4e3ef92
2026-09-26 06:23:08 +00:00
stephan
a8d1f1ff12 Fix a small potential buffer overwrite in the JS impl of kvvfs to resolve [bugs:8d4fe4cc4c|bug report 2026-09-23T10:50:46Z]. Remove some adjacent dead code.
FossilOrigin-Name: c43287d8855b3f9a4621545793ecb2a89ef456d563d8377f2b243812e6acb2b3
2026-09-23 14:00:07 +00:00
stephan
ae9c436852 User new, more compare JS syntax in a couple of places. No functional changes.
FossilOrigin-Name: 0d747adadf56a0aa3bd5666954a9f7c75c394254dbb938f28ddcd987ffff01b2
2026-09-19 08:13:27 +00:00
stephan
46c7da50b3 Minor internal API doc update.
FossilOrigin-Name: 346c56e02c39858b4364e4c8b8e4c88237e64470066ebb2687ae06d2b0e978b8
2026-09-18 08:00:34 +00:00
stephan
d457639847 Performance improvements in some of the JS sqlite3.oo1 APIs, based on analysis and suggestions from Jure Rotar.
FossilOrigin-Name: 8c6c586c3e42dd1d0af4f374b01a660bfc6afb47fd3b34cd7ef16c198ec66d0a
2026-09-18 07:56:22 +00:00
stephan
3d0687bade Disable Module.instantiateWasm() in node builds to match branch-3.53's behavior. Fix a sqlite3_backup test (duplicate finalize). The aforementioned world-breaking bug was caused by my browser having gotten into a funky state and needing a restart.
FossilOrigin-Name: 7d77bb088641881fca7a625d9828503d269d0ca1e245583a2dcf24a4f09390f5
2026-08-10 12:35:49 +00:00
stephan
961cc1ec09 Add tests for the sqlite3_backup JS bindings but they are disabled while tracking down an unrelated problem which prevents those tests from working (most of the sqlite3.capi methods are being mis-mapped to the sqlite3InitModule function for reasons unimaginable).
FossilOrigin-Name: cb610a8a87cfd29d70ab6b825b4a43d44fd801feecfda1bf4fb7ae181806d84b
2026-08-10 12:18:07 +00:00
stephan
46441db7e8 Merge trunk into the js-backup-bindings branch.
FossilOrigin-Name: 692c4e8ad81f142a454c2038fcdc83317dbaeb71dd6d0497edb4621297c2e35c
2026-08-10 11:23:29 +00:00
stephan
d0afe9c60b Lower the range of inputs accepted by the pstack allocator to address [bugs:4dbd096fe335f974dbd096fe3|/bugs/4dbd096fe335].
FossilOrigin-Name: fafefb59481530255a881f22b1f75b587731867d00eabea39eaec7da2199fdff
2026-08-07 05:31:08 +00:00
stephan
77ef17960c Add long-missing sqlite3_backup bindings to JS/WASM, in response to [forum:dc96ed27b3fdb202|forum thread dc96ed27b3]. This does not yet include tests.
FossilOrigin-Name: 90e599757416059044c643121631fc56eab2b6eea76d04b2d99eae49b8adef44
2026-07-29 12:51:52 +00:00
stephan
76a15f2b95 Factor an extranous local var out of the previous check-in.
FossilOrigin-Name: 422b4303dae214e23a53b181e5cdf7888d159da33e1675fd8317cbe66834b78e
2026-07-26 15:56:06 +00:00
stephan
bdde38eb0c Remove some extraneous I/O in kvvfs. Reported off-list by Jure Rotar.
FossilOrigin-Name: ce09bfe406728312761a9f227b3f82cbee7cc176dddac1a499e10480a7ee2c1c
2026-07-26 15:47:56 +00:00
stephan
fdb802581c Fix a JS container API misuse in sqlite3.oo1.DB.close() which caused its fallback cleanup of still-open statements to not actually do so. Reported off-list by Jure Rotar.
FossilOrigin-Name: d5d8ee76d337820f765cea7b279f2e5644a24d4f0e76d53b35b4d52277edb767
2026-07-26 15:39:18 +00:00
stephan
7d1796e488 Add (#base64 -f filename) support to the preprocessor and slightly simplify the wasm embedding with it. Fix a bug in the preprocessor's @token@ call expansion when the length of the configured @ is greater than 1 byte.
FossilOrigin-Name: 1e90bedec99054f4856bfb89efc4d676486504db67bd1304c45d14c638ddfc7e
2026-07-22 14:06:41 +00:00
stephan
093ca6b1af Consolidate a duplicated code block and ensure that the new filtering of the final JS files makes them read/write so that rebuilds without a clean between them work.
FossilOrigin-Name: 8b013184e42dbd7cd47c07bbb1edbb1f088dfb4efe540bfbc52a2e3c472c7b2d
2026-07-21 16:12:06 +00:00
stephan
1f2bc0ea64 Add support for (make base64.wasm=1), which embeds sqlite3.wasm into its corresponding JS file as base64. A very expensive calculator which was fed the resulting file sizes assures me that the two-file approach is, in the aggregate, more efficient both in terms of overall network bandwidth (+~20% bigger for base64) and client-side memory usage (streaming vs non-streaming wasm compilation), so we'll shelve this as an interesting experiment or maybe for use by custom builds.
FossilOrigin-Name: a167aee75198ff08b20b448fecd3267ed4a70af2472c02605318a5613f446fc6
2026-07-21 16:04:10 +00:00
stephan
bee0db8c60 This embeds sqlite3.wasm into sqlite3.js/mjs as base64 but is applied globally - it still needs to be made configurable.
FossilOrigin-Name: 0467a0f826b5b7bb65d9c74df80c7443f01824c1cc8184417849a74791f491b7
2026-07-21 13:28:52 +00:00
stephan
379e111bff An initial attempt at embedding sqlite3.wasm into sqlite3.js using base64. This produces a chicken-egg situation in the build because the input file where the blob belongs is injested by emscripten (which generates the wasm file from which that blob is to be generated), so it does not work as-is but is being set aside for later. We'll need to add a second preprocessing step which uses a different #directive delimiter to keep it hidden inside the first pass, then squeeze the wasm file in through there.
FossilOrigin-Name: 538199cf62f07a2fe7ee5775c9f01aff1644d638bc0916cf631d61376462b5cb
2026-07-21 12:57:48 +00:00
stephan
886d2c743e Add worker1 to the list of omit-api=X values, per downstream request. Add omit-api=all shorthand.
FossilOrigin-Name: 97ab248b4dd30de76bfbc74ab5cf087df9cd14fd38eb4369a3eadc75953b8c73
2026-06-29 11:36:44 +00:00
stephan
bf98a1f6b6 Teach the JS build to filter out various APIs/VFSes when passed omit-api='api names...'. Fully trimmed this saves just shy of 300kb from the JS. Make loud=1 mode distinctly louder when preprocessing.
FossilOrigin-Name: 2603c855795fc9466522b1e10433efd5e30975e68ee891680f27f06f3189390b
2026-06-24 09:09:02 +00:00
stephan
3fa3e3942e Add preprocessor guards to various JS files working towards the ability to build, e.g., with only one of various VFSes included. The makefile does not yet integrate these - this is an incremental step towards addressing the discussion in [https://github.com/sqlite/sqlite-wasm/pull/168|the downstream npm project's PR#168].
FossilOrigin-Name: f6618a693b7b71f4b846fac257100d3a516dcda687b039d24bcaf29dd1c7454b
2026-06-23 20:42:48 +00:00
stephan
190034d268 Correct misuse of a loop control variable in writing of a kvvfs journal. Bug report [bugs:20e208fe17|2026-06-20T08:49:41Z]. Remove a snippet of dead code in the JS kvvfs side.
FossilOrigin-Name: a396d7c54c5f251daaaac1e68321c2a54d3b6969599027c29b7ca7abe7fb8c4e
2026-06-20 11:07:04 +00:00
stephan
b1bbff20a0 Revert the native impl of kvvfs's xOpen() (as distinct from the JS impl which the wasm build uses) to the historical db name restrictions of 'local' or 'session', failing with SQLITE_CANTOPEN if passed another name. [ec866b04d088e53b] overhauled support for kvvfs db names in JS but it turns out that the native impl still relies on those names in order to match journals to databases. Correct a related too-lenient assert() in the WASM pieces.
FossilOrigin-Name: 4b3ec30c63e3824163a2e6cacceb9630301b61f3ffd2b80f8a7b234f09bc251b
2026-06-15 12:36:24 +00:00
stephan
6f842b8da4 For the various OPFS VFS db-import routines, in SEE builds (only) relax the is-this-a-db check to allow for SEE dbs not having the usual header string in cleartext. Addresses [https://sqlite.org/see/forumpost/f84bef3552|SEE forum post f84bef3552].
FossilOrigin-Name: a5a9ac7ad6622b5b07193aa279deefde7d59ca17f81aba9dd78ee90718446993
2026-05-05 08:51:10 +00:00
stephan
d3abfd77f5 Reformulate how the OPFS async proxy Worker is loaded for the bundler-friendly builds to work around a bug in Vite in which it incompatibly rewrites the Worker's URL arguments. Addresses the discussion at [https://github.com/sqlite/sqlite-wasm/pull/159|npm package PR 159] and patch validated by Jure Rotar.
FossilOrigin-Name: ec877a30f5c5db30b9154745140744c5cc80d89673d79e50901d7377599cf2b4
2026-04-21 10:19:38 +00:00
stephan
9d950aa13b A protype of .prompt support in fiddle but its utility there is in doubt because .open does not work there, so there's very little dynamic info worth showing in a prompt. Also, ANSI colorization can't work there, nor can we colorize the prompts using HTML because of limitations in jquery.terminal.
FossilOrigin-Name: 3b17500dc6338df23d1ed0572cd71593da5a9b048731f73242e27b9a76553a27
2026-04-10 23:05:41 +00:00
stephan
35f8abcfd0 API doc correction for sqlite3_js_retry_busy(). No code changes.
FossilOrigin-Name: 749c537812b907164b7e7ad1fddc1aee8106c59875d2686fe83d602cd0e07611
2026-04-10 17:55:31 +00:00
stephan
d4b74b9fac Add some comments to the OPFS async proxy about potential future experimentation. No code changes.
FossilOrigin-Name: 9c14ee74305a5db3be95dbd9ae8d1db0abf39b323001be4e2f02b7226e6ca0d3
2026-04-04 08:07:25 +00:00
stephan
eb8edc0bac Doc cleanups in opfs-wl. No code changes.
FossilOrigin-Name: 009b576dcd5fccaaa52459dbfaa1b2a6fcf6d372e4b8d63553dfa88aab9a759c
2026-04-01 11:39:13 +00:00
stephan
46a692c08b Upgrade ext/wasm/c-pp-lite.c to its newer sibling because we've reached the older one's limits. This renames c-pp-lite.c to libcmpp.c to maintain both the SCM- and code lineage but that may end up looking a bit weird because the diff between the two is vast.
FossilOrigin-Name: 2e2339bd9e4293bad04ece7673a3048b99c2143cf9573ade2ec082d95744b981
2026-03-08 16:03:08 +00:00
stephan
02cbc96d09 JS doc updates.
FossilOrigin-Name: 699295f84ef2c4da363f13126abde6af07697d0959896cd868b14513d4278964
2026-03-08 12:42:34 +00:00
stephan
976b50620a Merge opfs-wl into trunk, not so much for the "opfs-wl" VFS, which is stil tentative (working fine but with little perceived benefit), but for the "opfs" VFS cleanups which necessarily happened around it.
FossilOrigin-Name: bcaa876c6dafee0995d239f59b6ce7810b6f5faa219b9c392966211ae3dec17a
2026-03-08 08:32:22 +00:00
stephan
9358070cb3 Expose sqlite3_bind_zeroblob() to JS/WASM.
FossilOrigin-Name: 0c5d4fe0bd322b4c8dbd0800001317a21cd511b00244de74b4db3fd051153879
2026-03-08 05:53:47 +00:00
stephan
237fce8205 Extend the JS pre-bootstrapping configuration to include an option to disable inclusion of any given extension VFS (not the default VFSes, like memdb). The primary motivation for this is to give people who don't use OPFS to a way to keep the OPFS VFSes from loading their proxy workers, which are expensive.
FossilOrigin-Name: 9a07eb7a941479510891d1444aacbeb440efaad3e9a13f186833618d8b60a8da
2026-03-07 06:10:29 +00:00
stephan
78649bb421 Fix the mangling of the opfs async proxy script's URI caused by both OPFS VFSes modifying it to accound for sqlite3.dir. Add a link to speedtest1 with opfw-wl to index.html.
FossilOrigin-Name: c1cb61f473a11a325ef421ba8edfb20257203688565f7db62309044be183af5f
2026-03-07 04:19:08 +00:00
stephan
7d10030d75 Cleanups and docs in the opfs vfs and its concurrency tester. Experimentally add sqlite3.capi.sqlite3_js_retry_busy(), which runs a callback repeatedly until it _stops_ returning (or throwing) an SQLITE_BUSY error.
FossilOrigin-Name: 45c02ed21635f7ef45214ab5ec6230b6b8bd89e35ef5889db318523e1c679fea
2026-03-07 03:32:17 +00:00
stephan
9be458e611 Cleanups and docs in the new opfs code structure.
FossilOrigin-Name: 3b470c4c7a1fcc710e6b9eae32134c7f6c3f6008b24c7351257f66f5e8f70311
2026-03-07 02:19:23 +00:00
stephan
57d0fe254a For backwards compatibility, ensure that the "opfs" VFS does not specifically require Atomics.waitAsync() (a new requirement of "opfs-wl"), but make use of it if available. Only apply jitter to the concurrency test runs at random intervals.
FossilOrigin-Name: f2175f526c00cfe562e8f332eb197b5ef2c3d6be1fff2aab1566c2c533a293ac
2026-03-07 01:01:13 +00:00
stephan
ac63b524ac Add some jitter and duration info to the opfs concurrency tester. Ensure that Atomics.waitAsync() is available for opfs-wl. Further testing has shown that Web opfs-wl is consistently fairer about doling out contested locks but it's dog slow compared to the original VFS under moderate concurrency. In single-connection use they're effectively on par.
FossilOrigin-Name: a9aecc987512d60f2663973f43c769cf086fc14149edfbcb18c0aec9f5aa3dbf
2026-03-06 23:50:44 +00:00