aboutsummaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorstephan <stephan@noemail.net>2023-07-18 19:27:11 +0000
committerstephan <stephan@noemail.net>2023-07-18 19:27:11 +0000
commit0649a1a05d9ae4e67cf7484ff7cbee06901b39c5 (patch)
tree820dc20010fadee154e95d7b0f4227d80d64fc69 /ext
parentb0dd9d427faac25681ba2cd4ba45b11fb7071ef5 (diff)
downloadsqlite-0649a1a05d9ae4e67cf7484ff7cbee06901b39c5.tar.gz
sqlite-0649a1a05d9ae4e67cf7484ff7cbee06901b39c5.zip
Fix a shadowed var in opfs-sahpool and add more tests.
FossilOrigin-Name: 9c8a73aff0f291e0c18072372e0d8961d3a05910489598d0d342227d99871954
Diffstat (limited to 'ext')
-rw-r--r--ext/wasm/api/sqlite3-vfs-opfs-sahpool.js14
-rw-r--r--ext/wasm/tester1.c-pp.js23
2 files changed, 26 insertions, 11 deletions
diff --git a/ext/wasm/api/sqlite3-vfs-opfs-sahpool.js b/ext/wasm/api/sqlite3-vfs-opfs-sahpool.js
index 1f026c7cc..fc088c419 100644
--- a/ext/wasm/api/sqlite3-vfs-opfs-sahpool.js
+++ b/ext/wasm/api/sqlite3-vfs-opfs-sahpool.js
@@ -999,18 +999,18 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
//log("vfs list:",capi.sqlite3_js_vfs_list());
if(sqlite3.oo1){
const oo1 = sqlite3.oo1;
- const OpfsthePoolDb = function(...args){
+ const OpfsSAHPoolDb = function(...args){
const opt = oo1.DB.dbCtorHelper.normalizeArgs(...args);
opt.vfs = opfsVfs.$zName;
oo1.DB.dbCtorHelper.call(this, opt);
};
- OpfsthePoolDb.prototype = Object.create(oo1.DB.prototype);
- OpfsthePoolDb.PoolUtil = poolUtil;
- if(!oo1.OpfsthePoolDb){
- oo1.OpfsthePoolDb = Object.create(null);
- oo1.OpfsthePoolDb.default = OpfsthePoolDb;
+ OpfsSAHPoolDb.prototype = Object.create(oo1.DB.prototype);
+ OpfsSAHPoolDb.PoolUtil = poolUtil;
+ if(!oo1.OpfsSAHPool){
+ oo1.OpfsSAHPool = Object.create(null);
+ oo1.OpfsSAHPool.default = OpfsSAHPoolDb;
}
- oo1.OpfsthePoolDb[vfsName] = OpfsthePoolDb;
+ oo1.OpfsSAHPool[vfsName] = OpfsSAHPoolDb;
oo1.DB.dbCtorHelper.setVfsPostOpenSql(
opfsVfs.pointer,
function(oo1Db, sqlite3){
diff --git a/ext/wasm/tester1.c-pp.js b/ext/wasm/tester1.c-pp.js
index ed0e5c3c7..e63d8440c 100644
--- a/ext/wasm/tester1.c-pp.js
+++ b/ext/wasm/tester1.c-pp.js
@@ -2779,10 +2779,25 @@ globalThis.sqlite3InitModule = sqlite3InitModule;
T.assert(u1 === u2)
.assert(sahPoolConfig.name === u1.vfsName)
.assert(sqlite3.capi.sqlite3_vfs_find(sahPoolConfig.name))
- .assert(u1.getCapacity() === sahPoolConfig.initialCapacity)
- .assert(5 === (await u2.addCapacity(2)))
- .assert(sqlite3.capi.sqlite3_js_vfs_list().indexOf(sahPoolConfig.name) >= 0)
- .assert(true === await u2.removeVfs())
+ .assert(u1.getCapacity() >= sahPoolConfig.initialCapacity
+ /* If a test fails before we get to nuke the VFS, we
+ can have more than the initial capacity on the next
+ run. */)
+ .assert(u1.getCapacity() + 2 === (await u2.addCapacity(2)))
+ .assert(sqlite3.oo1.OpfsSAHPool.default instanceof Function)
+ .assert(sqlite3.oo1.OpfsSAHPool.default ===
+ sqlite3.oo1.OpfsSAHPool[sahPoolConfig.name])
+ .assert(sqlite3.capi.sqlite3_js_vfs_list().indexOf(sahPoolConfig.name) >= 0);
+
+ const db = new sqlite3.oo1.OpfsSAHPool.default("foo.db");
+ db.exec([
+ 'create table t(a);',
+ 'insert into t(a) values(1),(2),(3)'
+ ]);
+ T.assert(3 === db.selectValue('select count(*) from t'));
+ db.close();
+
+ T.assert(true === await u2.removeVfs())
.assert(false === await u1.removeVfs())
.assert(!sqlite3.capi.sqlite3_vfs_find(sahPoolConfig.name));