aboutsummaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js3
-rw-r--r--ext/wasm/tester1.c-pp.js41
2 files changed, 43 insertions, 1 deletions
diff --git a/ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js b/ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js
index d423bb0bb..6551b5c89 100644
--- a/ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js
+++ b/ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js
@@ -57,7 +57,7 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
'use strict';
const toss = sqlite3.util.toss;
const toss3 = sqlite3.util.toss3;
- const initPromises = Object.create(null);
+ const initPromises = Object.create(null) /* cache of (name:result) of VFS init results */;
const capi = sqlite3.capi;
const util = sqlite3.util;
const wasm = sqlite3.wasm;
@@ -843,6 +843,7 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
if(!this.#cVfs.pointer || !this.#dhOpaque) return false;
capi.sqlite3_vfs_unregister(this.#cVfs.pointer);
this.#cVfs.dispose();
+ delete initPromises[this.vfsName];
try{
this.releaseAccessHandles();
await this.#dhVfsRoot.removeEntry(OPAQUE_DIR_NAME, {recursive: true});
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*/;
////////////////////////////////////////////////////////////////////////