worker due to an Emscripten limitation.</li>
<li><a href='scratchpad-opfs-worker.html'>scratchpad-opfs-worker</a>:
experimenting with OPFS from a Worker thread (without WASMFS).</li>
- <li><a href='x-sync-async.html?opfs-sanity-check&opfs-verbose'>x-sync-async</a> is an
+ <li><a href='test-opfs-vfs.html'>test-opfs-vfs</a>
+ (<a href='test-opfs-vfs.html?opfs-sanity-check&opfs-verbose'>same
+ with verbose output and sanity-checking tests</a>) is an
experiment in implementing a syncronous sqlite3 VFS proxy
- for a fully synchronous backend interface (namely OPFS), using SharedArrayBuffer
- and the Atomics APIs to regulate communication between the synchronous
- interface and the async impl.
+ for a fully asynchronous backend interface (namely OPFS),
+ using SharedArrayBuffer and the Atomics APIs to regulate
+ communication between the synchronous interface and the
+ async impl.
</li>
<!--li><a href='x.html'></a></li-->
</ul>
const fh = __openFiles[fid];
try{
const aRead = new Uint8Array(fh.sab, 0, n);
- const nRead = fh.accessHandle.read(aRead, {at: offset});
+ const nRead = fh.accessHandle.read(aRead, {at: Number(offset)});
if(nRead < n){/* Zero-fill remaining bytes */
new Uint8Array(fh.sab).fill(0, nRead, n);
rc = state.sq3Codes.SQLITE_IOERR_SHORT_READ;
const fh = __openFiles[fid];
try{
affirmNotRO('xWrite', fh);
- const nOut = fh.accessHandle.write(new Uint8Array(fh.sab, 0, n), {at: offset});
+ const nOut = fh.accessHandle.write(new Uint8Array(fh.sab, 0, n),
+ {at: Number(offset)});
rc = (nOut===n) ? 0 : state.sq3Codes.SQLITE_IOERR_WRITE;
}catch(e){
error("xWrite():",e,fh);
</div>
<div id='test-output'>
</div>
- <script>new Worker("x-sync-async.js"+self.location.search);</script>
+ <script>new Worker("test-opfs-vfs.js"+self.location.search);</script>
</body>
</html>
const tryOpfsVfs = function(sqlite3){
const toss = function(...args){throw new Error(args.join(' '))};
const logPrefix = "OPFS tester:";
- const log = (...args)=>{
- console.log(logPrefix,...args);
- };
- const warn = (...args)=>{
- console.warn(logPrefix,...args);
- };
- const error = (...args)=>{
- console.error(logPrefix,...args);
- };
+ const log = (...args)=>console.log(logPrefix,...args);
+ const warn = (...args)=>console.warn(logPrefix,...args);
+ const error = (...args)=>console.error(logPrefix,...args);
log("tryOpfsVfs()");
const capi = sqlite3.capi;
const pVfs = capi.sqlite3_vfs_find("opfs") || toss("Unexpectedly missing 'opfs' VFS.");
- const oVfs = capi.sqlite3_vfs.instanceForPointer(pVfs);
+ const oVfs = capi.sqlite3_vfs.instanceForPointer(pVfs) || toss("Unexpected instanceForPointer() result.");;
log("OPFS VFS:",pVfs, oVfs);
+
+ const dbFile = "my-persistent.db";
+ const db = new sqlite3.oo1.DB(dbFile, "c", "opfs");
+ log("db file:",db.filename);
+ try{
+ let n = db.selectValue("select count(*) from sqlite_schema");
+ if(n){
+ log("Persistent data found. sqlite_schema entry count =",n);
+ }
+ db.transaction((db)=>{
+ db.exec({
+ sql:[
+ "create table if not exists t(a);",
+ "insert into t(a) values(?),(?),(?);",
+ ],
+ bind: [performance.now() | 0,
+ (performance.now() |0) / 2,
+ (performance.now() |0) / 4]
+ });
+ });
+ log("count(*) from t =",db.selectValue("select count(*) from t"));
+ }finally{
+ db.close();
+ }
+
log("Done!");
}/*tryOpfsVfs()*/;
.then((sqlite3)=>tryOpfsVfs(sqlite3))
.catch((e)=>{
console.error("Error initializing OPFS VFS:",e);
- throw e;
});
});
-C Move\sthe\sOPFS\sVFS\sbits\sback\sinto\sapi/sqlite3-api-opfs.js.\sRefactor\sthe\sOPFS\sVFS\sinit\sprocess\sto\suse\sa\sPromise-returning\sfunction\swhich\sthe\sclient\smust\scall,\sas\sthat\seliminates\sany\suncertainty\sabout\swhen\sthe\sVFS\s(necessarily\sactivated\sasynchronously)\sactually\sbecomes\savailable\sto\sthe\sclient.
-D 2022-09-18T02:35:30.998
+C Move\sthe\sOPFS\sVFS\sbits\sback\sinto\sapi/sqlite3-api-opfs.js.\sRefactor\sthe\sOPFS\sVFS\sinit\sprocess\sto\suse\sa\sPromise-returning\sfunction\swhich\sthe\sclient\smust\scall,\sas\sthat\seliminates\sany\suncertainty\sabout\swhen\sthe\sVFS\s(necessarily\sactivated\sasynchronously)\sactually\sbecomes\savailable\sto\sthe\sclient.\sRename\sx-sync-async.*\sto\stest-opfs-vfs.*\sMilestone:\sfirst\ssuccessful\stest\sof\sOPFS\swithout\sWASMFS.
+D 2022-09-18T03:05:55.278
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
F ext/wasm/fiddle/fiddle-worker.js bccf46045be8824752876f3eec01c223be0616ccac184bffd0024cfe7a3262b8
F ext/wasm/fiddle/fiddle.html 550c5aafce40bd218de9bf26192749f69f9b10bc379423ecd2e162bcef885c08
F ext/wasm/fiddle/fiddle.js 4ffcfc9a235beebaddec689a549e9e0dfad6dca5c1f0b41f03468d7e76480686
-F ext/wasm/index.html b8a47afa96d0c7ac3081c6d469e1fd7be6b87c64b94e4fb62e26984a1564cac4
+F ext/wasm/index.html 492eb6c9023c9cda391c61702a28bd18e6c986ca2588ec3f384275bb77275285
F ext/wasm/jaccwabyt/jaccwabyt.js 0d7f32817456a0f3937fcfd934afeb32154ca33580ab264dab6c285e6dbbd215
F ext/wasm/jaccwabyt/jaccwabyt.md 447cc02b598f7792edaa8ae6853a7847b8178a18ed356afacbdbf312b2588106
F ext/wasm/jaccwabyt/jaccwabyt_test.c 39e4b865a33548f943e2eb9dd0dc8d619a80de05d5300668e9960fff30d0d36f
F ext/wasm/split-speedtest1-script.sh a3e271938d4d14ee49105eb05567c6a69ba4c1f1293583ad5af0cd3a3779e205 x
F ext/wasm/sql/000-mandelbrot.sql 775337a4b80938ac8146aedf88808282f04d02d983d82675bd63d9c2d97a15f0
F ext/wasm/sql/001-sudoku.sql 35b7cb7239ba5d5f193bc05ec379bcf66891bce6f2a5b3879f2f78d0917299b5
-F ext/wasm/sqlite3-opfs-async-proxy.js ef012be0a77d3e34dc699de2e430b6d26a58c69dbebdd75248d8f41540996c71
+F ext/wasm/sqlite3-opfs-async-proxy.js 456bef1253fd4732f133b601a4450b7f8461e67af6e8d30bf8a239ad775c77a2
F ext/wasm/sqlite3-worker1-promiser.js 92b8da5f38439ffec459a8215775d30fa498bc0f1ab929ff341fc3dd479660b9
F ext/wasm/sqlite3-worker1.js 0c1e7626304543969c3846573e080c082bf43bcaa47e87d416458af84f340a9e
+F ext/wasm/test-opfs-vfs.html 3e11c875c28f041891deeea6b2375121845ee1269cac6747df957ec0c7d4d37a w ext/wasm/x-sync-async.html
+F ext/wasm/test-opfs-vfs.js bf70cd553a443b4eda63b577787ef73144f879fa062a20a73bb44e3242c81a15 w ext/wasm/x-sync-async.js
F ext/wasm/testing-worker1-promiser.html 6eaec6e04a56cf24cf4fa8ef49d78ce8905dde1354235c9125dca6885f7ce893
F ext/wasm/testing-worker1-promiser.js 63448fddfd3b8c89ff667d17c8b31c6c2259dd4647ebbbd28f3a921c48e924da
F ext/wasm/testing1.html 50575755e43232dbe4c2f97c9086b3118eb91ec2ee1fae931e6d7669fb17fcae
F ext/wasm/testing2.html a66951c38137ff1d687df79466351f3c734fa9c6d9cce71d3cf97c291b2167e3
F ext/wasm/testing2.js 25584bcc30f19673ce13a6f301f89f8820a59dfe044e0c4f2913941f4097fe3c
F ext/wasm/wasmfs.make 21a5cf297954a689e0dc2a95299ae158f681cae5e90c10b99d986097815fd42d
-F ext/wasm/x-sync-async.html d85cb9b1ab398ef5a20ce64a689ce4bf9a347ffe69edd46c2d3dc57b869a8925
-F ext/wasm/x-sync-async.js 95142516c0e467480fb87e71d7aab5b8ecee07fe7bd4babb5f5aa9b5b6ace4d0
F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x
F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8
F magic.txt 8273bf49ba3b0c8559cb2774495390c31fd61c60
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P a0e93ed20b2463606a63b03ce8ca41ec1fb22886db5c5c898ace86ba24636f70
-R 088ef11f22396ef93f0589b73a5e4797
+P 1c660970d0f62bcfd6e698a72b050d99972a1e39f45a5ac24194a190f8f78ab3
+R 039a2cd7ec4da87358ad6184da91bc68
U stephan
-Z 0f7cc3e7ea750e2836a1d35bc86649c9
+Z 58e9ce410c47c756bc153984b857c4cf
# Remove this line to create a well-formed Fossil manifest.
-1c660970d0f62bcfd6e698a72b050d99972a1e39f45a5ac24194a190f8f78ab3
\ No newline at end of file
+b2abf60dbfa6648f671a3932cb65feb28d05a0d5b7f792351d14f9c13d9798c5
\ No newline at end of file