mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-27 20:41:58 +03:00
Merge trunk into the sahpool-digest branch.
FossilOrigin-Name: fc1eeb7d1f2880907b0fe71a8c572dd7cd74a5d65ec0177332976ad2f8c2b216
This commit is contained in:
@ -3189,8 +3189,25 @@ globalThis.sqlite3InitModule = sqlite3InitModule;
|
||||
db.close();
|
||||
T.assert(1 === u1.getFileCount());
|
||||
db = new u2.OpfsSAHPoolDb(dbName);
|
||||
T.assert(1 === u1.getFileCount());
|
||||
T.assert(1 === u1.getFileCount())
|
||||
.mustThrowMatching(
|
||||
()=>u1.pauseVfs(),
|
||||
(err)=>{
|
||||
return capi.SQLITE_MISUSE===err.resultCode
|
||||
&& /^SQLITE_MISUSE: Cannot pause VFS /.test(err.message);
|
||||
},
|
||||
"Cannot pause VFS with opened db."
|
||||
);
|
||||
db.close();
|
||||
T.assert( u2===u2.pauseVfs() )
|
||||
.assert( u2.isPaused() )
|
||||
.assert( 0===capi.sqlite3_vfs_find(u2.vfsName) )
|
||||
.mustThrowMatching(()=>new u2.OpfsSAHPoolDb(dbName),
|
||||
/.+no such vfs: .+/,
|
||||
"VFS is not available")
|
||||
.assert( u2===await u2.unpauseVfs() )
|
||||
.assert( u2===await u1.unpauseVfs(), "unpause is a no-op if the VFS is not paused" )
|
||||
.assert( 0!==capi.sqlite3_vfs_find(u2.vfsName) );
|
||||
const fileNames = u1.getFileNames();
|
||||
T.assert(1 === fileNames.length)
|
||||
.assert(dbName === fileNames[0])
|
||||
@ -3445,7 +3462,6 @@ globalThis.sqlite3InitModule = sqlite3InitModule;
|
||||
const stack = wasm.pstack.pointer;
|
||||
const pAux = wasm.pstack.alloc(4);
|
||||
let pAuxDestructed = 0;
|
||||
const args = [];
|
||||
const pAuxDtor = wasm.installFunction('v(p)', function(ptr){
|
||||
//log("freeing auxdata");
|
||||
++pAuxDestructed;
|
||||
@ -3457,10 +3473,11 @@ globalThis.sqlite3InitModule = sqlite3InitModule;
|
||||
wasm.uninstallFunction(pAuxDtor);
|
||||
}
|
||||
};
|
||||
let nAuxSet = 0 /* how many times we set aux data */;
|
||||
let nAuxReused = 0 /* how many times we reused aux data */;
|
||||
try{
|
||||
db.createFunction("auxtest",{
|
||||
xFunc: function(pCx, x, y){
|
||||
args.push(x);
|
||||
T.assert(wasm.isPtr(pCx));
|
||||
const localAux = capi.sqlite3_get_auxdata(pCx, 0);
|
||||
if( !localAux ){
|
||||
@ -3469,23 +3486,20 @@ globalThis.sqlite3InitModule = sqlite3InitModule;
|
||||
We do not currently an automated way to clean up
|
||||
auxdata finalizer functions (the 4th argument to
|
||||
sqlite3_set_auxdata()) which get automatically
|
||||
converted from JS to WASM. Because of that, relying
|
||||
on automated conversions for those is not
|
||||
recommended. Instead, follow the pattern show in
|
||||
converted from JS to WASM. Because of that, enabling
|
||||
automated conversions here would lead to leaks more
|
||||
often than not. Instead, follow the pattern show in
|
||||
this function: use wasm.installFunction() to create
|
||||
the function, then pass the resulting function
|
||||
pointer this function, and cleanup (at some point)
|
||||
using wasm.uninstallFunction().
|
||||
*/
|
||||
++nAuxSet;
|
||||
capi.sqlite3_set_auxdata(pCx, 0, pAux, pAuxDtor);
|
||||
}else{
|
||||
/* This is never actually hit in this example and it's
|
||||
not entirely clear how to cause it to. The point of
|
||||
this test, however, is to demonstrate that the
|
||||
finalizer impl gets triggered, so we're not going to
|
||||
fret over this at the moment. */
|
||||
//log("seen auxdata",localAux);
|
||||
//log("reusing auxdata",localAux);
|
||||
T.assert(pAux===localAux);
|
||||
++nAuxReused;
|
||||
}
|
||||
return x;
|
||||
}
|
||||
@ -3493,13 +3507,14 @@ globalThis.sqlite3InitModule = sqlite3InitModule;
|
||||
db.exec([
|
||||
"create table t(a);",
|
||||
"insert into t(a) values(1),(2),(1);",
|
||||
"select auxtest(a,a), auxtest(a,a) from t order by a"
|
||||
"select auxtest(1,a), auxtest(1,a) from t order by a"
|
||||
]);
|
||||
}finally{
|
||||
db.close();
|
||||
wasm.pstack.restore(stack);
|
||||
}
|
||||
T.assert(6===args.length);
|
||||
T.assert(nAuxSet>0).assert(nAuxReused>0)
|
||||
.assert(6===nAuxReused+nAuxSet);
|
||||
T.assert(pAuxDestructed>0);
|
||||
T.assert(pAuxDtorDestructed);
|
||||
}
|
||||
|
Reference in New Issue
Block a user