diff --git a/ext/wasm/api/sqlite3-opfs-async-proxy.js b/ext/wasm/api/sqlite3-opfs-async-proxy.js index ca5583971e..0028c1025f 100644 --- a/ext/wasm/api/sqlite3-opfs-async-proxy.js +++ b/ext/wasm/api/sqlite3-opfs-async-proxy.js @@ -506,8 +506,7 @@ const installAsyncProxy = function(){ dirHandle: hDir, fileHandle: hFile, sabView: state.sabFileBufView, - readOnly: create - ? false : (state.sq3Codes.SQLITE_OPEN_READONLY & flags), + readOnly: !create && !!(state.sq3Codes.SQLITE_OPEN_READONLY & flags), deleteOnClose: !!(state.sq3Codes.SQLITE_OPEN_DELETEONCLOSE & flags) }); fh.releaseImplicitLocks = diff --git a/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js b/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js index 2d11b35831..27f1bfae7c 100644 --- a/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js +++ b/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js @@ -922,6 +922,8 @@ const installOpfsVfs = function callee(options){ fh.filename = zName; fh.sab = new SharedArrayBuffer(state.fileBufferSize); fh.flags = flags; + fh.readOnly = !(sqlite3.SQLITE_OPEN_CREATE & flags) + && !!(flags & capi.SQLITE_OPEN_READONLY); const rc = opRun('xOpen', pFile, zName, flags, opfsFlags); if(!rc){ /* Recall that sqlite3_vfs::xClose() will be called, even on diff --git a/ext/wasm/tester1.c-pp.js b/ext/wasm/tester1.c-pp.js index 74596b9ba7..4347c8fd79 100644 --- a/ext/wasm/tester1.c-pp.js +++ b/ext/wasm/tester1.c-pp.js @@ -3360,40 +3360,48 @@ globalThis.sqlite3InitModule = sqlite3InitModule; predicate: ()=>hasOpfs() || "Requires OPFS to reproduce", //predicate: ()=>false, test: async function(sqlite3){ - /* https://sqlite.org/forum/forumpost/cf37d5ff11 */ + /* https://sqlite.org/forum/forumpost/cf37d5ff1182c31081 + + The "opfs" VFS (but not SAHPool) was formerly misbehaving + after a write attempt was made on a db opened with + mode=ro. This test ensures that that behavior is fixed and + compares that behavior with other VFSes. */ + const tryOne = function(vfsName,descr){ + const uri = 'file:///foo.db'; + let db = new sqlite3.oo1.DB(uri + (vfsName ? '?vfs='+vfsName : '')); + db.exec([ + "drop table if exists t;", + "create table t(a);", + "insert into t(a) values('abc'),('def'),('ghi');" + ]); + db.close(); + db = new sqlite3.oo1.DB(uri+'?mode=ro'+ + (vfsName ? '&vfs='+vfsName : '')); + let err; + try { + db.exec('insert into t(a) values(1)'); + }catch(e){ + err = e; + } + T.assert(err && (err.message.indexOf('SQLITE_READONLY')===0)); + try{ + db.exec('select a from t'); + }finally{ + db.close(); + } + }; const poolConfig = JSON.parse(JSON.stringify(sahPoolConfig)); poolConfig.name = 'opfs-sahpool-cf37d5ff11'; - const vfsName = 0 ? poolConfig.name : (1 ? undefined : 'opfs'); let poolUtil; - const uri = 'file:///foo.db'; - //log('poolConfig =',poolConfig); - if( poolConfig.name === vfsName ){ - await sqlite3.installOpfsSAHPoolVfs(poolConfig).then(p=>poolUtil=p); - T.assert(!!sqlite3.capi.sqlite3_vfs_find(poolConfig.name), "Expecting to find just-registered VFS"); - } - let db = new sqlite3.oo1.DB(uri + (vfsName ? '?vfs='+vfsName : '')); - db.exec([ - "drop table if exists t;", - "create table t(a);", - "insert into t(a) values('abc'),('def'),('ghi');" - ]); - db.close(); - db = new sqlite3.oo1.DB(uri+'?mode=ro'+(vfsName ? '&vfs='+vfsName : '')); - let err; - try { - db.exec('insert into t(a) values(1)'); - }catch(e){ - err = e; - } - //log("err =",err); - T.assert(err && (err.message.indexOf('SQLITE_IOERR_WRITE')===0/*opfs*/ - || err.message.indexOf('readonly')>0)/*Emscripten FS*/); + await sqlite3.installOpfsSAHPoolVfs(poolConfig).then(p=>poolUtil=p); + T.assert(!!sqlite3.capi.sqlite3_vfs_find(poolConfig.name), "Expecting to find just-registered VFS"); try{ - db.exec('select a from t'); + tryOne(false, "Emscripten filesystem"); + tryOne(poolConfig.name); + tryOne('opfs'); }finally{ - db.close(); + await poolUtil.removeVfs(); } - if( poolUtil ) await poolUtil.removeVfs(); } }) ;/*end of Bug Reports group*/; diff --git a/manifest b/manifest index f1e4a85871..e88c2cb981 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C When\scalling\sOpfsSAHPoolUtil.removeVfs(),\sensure\sthat\sthe\scached\sresult\sthe\sVFS\sinit\sis\salso\sremoved\sso\sthat\sthe\sVFS\smay\slater\sbe\sregistered\sagain\swith\sthe\ssame\sname.\sSet\sup\stest\scode\sfor\sthe\sregression\sreported\sin\s[forum:cf37d5ff11\s|\sforum\spost\scf37d5ff11]\s(which\suncovered\sthe\sremoveVfs()\sshortcoming)\sbut\sthat\stest\sis\scurrently\sonly\sknown\sto\sfail\swith\sthe\s"opfs"\sVFS\sand\sis\snot\scurrently\sset\sup\sto\sfail. -D 2024-10-17T11:12:57.140 +C Ensure\sthat\sthe\sOPFS\sVFS's\sxOpen()\swrites\sback\sthe\sread-only\sflag\sto\sthe\soutput\sflags.\sResolves\sthe\sproblem\sreported\sin\s[forum:cf37d5ff1182c31081\s|\sforum\spost\scf37d5ff1182c31081]. +D 2024-10-17T12:14:34.534 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -630,10 +630,10 @@ F ext/wasm/api/sqlite3-api-oo1.c-pp.js f3a8e2004c6625d17946c11f2fb32008be78bc520 F ext/wasm/api/sqlite3-api-prologue.js 6f1257e04885632ed9f44d43aba200b86e0bc16709ffdba29abbbeb1bc8e8b76 F ext/wasm/api/sqlite3-api-worker1.c-pp.js 5cc22a3c0d52828cb32aad8691488719f47d27567e63e8bc8b832d74371c352d F ext/wasm/api/sqlite3-license-version-header.js 0c807a421f0187e778dc1078f10d2994b915123c1223fe752b60afdcd1263f89 -F ext/wasm/api/sqlite3-opfs-async-proxy.js e8f1df56e97a29004a95a2eddd26778f52c33b3e797d32d4b1b668a38e6493dd +F ext/wasm/api/sqlite3-opfs-async-proxy.js 3774befd97cd1a5e2895c8225a894aad946848c6d9b4028acc988b5d123475af F ext/wasm/api/sqlite3-vfs-helper.c-pp.js 3f828cc66758acb40e9c5b4dcfd87fd478a14c8fb7f0630264e6c7fa0e57515d F ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js bb5e96cd0fd6e1e54538256433f1c60a4e3095063c4d1a79a8a022fc59be9571 -F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js e99e3d99f736937914527070f00ab13e9391d3f1cef884ab99a64cbcbee8d675 +F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js 9b86ca2d8276cf919fbc9ba2a10e9786033b64f92c2db844d951804dee6c4b4e F ext/wasm/api/sqlite3-vtab-helper.c-pp.js e809739d71e8b35dfe1b55d24d91f02d04239e6aef7ca1ea92a15a29e704f616 F ext/wasm/api/sqlite3-wasm.c 83f5e9f998e9fa4261eb84e9f092210e3ffe03895119f5ded0429eb34ab9d2be F ext/wasm/api/sqlite3-worker1-promiser.c-pp.js 46f303ba8ddd1b2f0a391798837beddfa72e8c897038c8047eda49ce7d5ed46b @@ -682,7 +682,7 @@ F ext/wasm/test-opfs-vfs.html 1f2d672f3f3fce810dfd48a8d56914aba22e45c6834e262555 F ext/wasm/test-opfs-vfs.js 1618670e466f424aa289859fe0ec8ded223e42e9e69b5c851f809baaaca1a00c F ext/wasm/tester1-worker.html ebc4b820a128963afce328ecf63ab200bd923309eb939f4110510ab449e9814c F ext/wasm/tester1.c-pp.html 1c1bc78b858af2019e663b1a31e76657b73dc24bede28ca92fbe917c3a972af2 -F ext/wasm/tester1.c-pp.js ec786f62874173ab247d7d2d5cf7333500421763747260ca978e34ca174a0f48 +F ext/wasm/tester1.c-pp.js b683e64f776e03dc7cb81cf4737b991c644b0a59e3ca52dcdc606d851a95475e F ext/wasm/tests/opfs/concurrency/index.html 657578a6e9ce1e9b8be951549ed93a6a471f4520a99e5b545928668f4285fb5e F ext/wasm/tests/opfs/concurrency/test.js d08889a5bb6e61937d0b8cbb78c9efbefbf65ad09f510589c779b7cc6a803a88 F ext/wasm/tests/opfs/concurrency/worker.js 0a8c1a3e6ebb38aabbee24f122693f1fb29d599948915c76906681bb7da1d3d2 @@ -2217,8 +2217,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 309e6d6f07d4169fbd6ea1d8b3d4809186ad9b7a2e69bbd33eedb9a55e831d68 -R eb8ec29843014ddd8d81b820c9bb8816 +P b7f7a5deeae61920dbfec7606cf9014de711f959a285b29e12673abfd2f88646 +R 556651a7ceaf11a031d680d31500bcba U stephan -Z 64184ea5787410cb5f4f479477f5b63b +Z c682d4ab99e571cd5091abebe964c27a # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 0c7e81ffa9..8b47ea3fc2 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b7f7a5deeae61920dbfec7606cf9014de711f959a285b29e12673abfd2f88646 +0a32624015f16fd881a4ecbb56b7833391028d327a95f4c899eee864ed7fe00d