aboutsummaryrefslogtreecommitdiff
path: root/ext/wasm/tester1.c-pp.js
diff options
context:
space:
mode:
authorstephan <stephan@noemail.net>2024-10-17 11:12:57 +0000
committerstephan <stephan@noemail.net>2024-10-17 11:12:57 +0000
commit6031de92c6e06e014323cab81e4c0ac77123fa27 (patch)
tree457d3483d7f3f557b872d6a94545989fad37cb52 /ext/wasm/tester1.c-pp.js
parent88282af521692b398b0d0cc58a8bdb220a8ff58c (diff)
downloadsqlite-6031de92c6e06e014323cab81e4c0ac77123fa27.tar.gz
sqlite-6031de92c6e06e014323cab81e4c0ac77123fa27.zip
When calling OpfsSAHPoolUtil.removeVfs(), ensure that the cached result the VFS init is also removed so that the VFS may later be registered again with the same name. Set up test code for the regression reported in [forum:cf37d5ff11 | forum post cf37d5ff11] (which uncovered the removeVfs() shortcoming) but that test is currently only known to fail with the "opfs" VFS and is not currently set up to fail.
FossilOrigin-Name: b7f7a5deeae61920dbfec7606cf9014de711f959a285b29e12673abfd2f88646
Diffstat (limited to 'ext/wasm/tester1.c-pp.js')
-rw-r--r--ext/wasm/tester1.c-pp.js41
1 files changed, 41 insertions, 0 deletions
diff --git a/ext/wasm/tester1.c-pp.js b/ext/wasm/tester1.c-pp.js
index fd67dc01c..74596b9ba 100644
--- a/ext/wasm/tester1.c-pp.js
+++ b/ext/wasm/tester1.c-pp.js
@@ -3355,6 +3355,47 @@ globalThis.sqlite3InitModule = sqlite3InitModule;
db.close();
}
})
+ .t({
+ name: 'r/o connection recovery from write op error',
+ predicate: ()=>hasOpfs() || "Requires OPFS to reproduce",
+ //predicate: ()=>false,
+ test: async function(sqlite3){
+ /* https://sqlite.org/forum/forumpost/cf37d5ff11 */
+ 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*/);
+ try{
+ db.exec('select a from t');
+ }finally{
+ db.close();
+ }
+ if( poolUtil ) await poolUtil.removeVfs();
+ }
+ })
;/*end of Bug Reports group*/;
////////////////////////////////////////////////////////////////////////