Extend [0e69b2c379e618] to support uninstalling stale JS-to-WASM function pointers added on behalf of UDFs.
FossilOrigin-Name: 7a46e629dcbf97ae037c5abb39306af7ad55f1910c1e962373e09d88d8bd5a33
This commit is contained in:
parent
7197f0a8f2
commit
171aa209fa
@ -760,6 +760,26 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
|
||||
m.collation.add(__argStr(name).toLowerCase());
|
||||
};
|
||||
|
||||
__dbCleanupMap._addUDF = function(pDb, name, arity, map){
|
||||
/* Map UDF name to a Set of arity values */
|
||||
name = __argStr(name).toLowerCase();
|
||||
let u = map.get(name);
|
||||
if(!u) map.set(name, (u = new Set));
|
||||
u.add((arity<0) ? -1 : arity);
|
||||
};
|
||||
|
||||
__dbCleanupMap.addFunction = function(pDb, name, arity){
|
||||
const m = __dbCleanupMap(pDb, 1);
|
||||
if(!m.udf) m.udf = new Map;
|
||||
this._addUDF(pDb, name, arity, m.udf);
|
||||
};
|
||||
|
||||
__dbCleanupMap.addWindowFunc = function(pDb, name, arity){
|
||||
const m = __dbCleanupMap(pDb, 1);
|
||||
if(!m.wudf) m.wudf = new Map;
|
||||
this._addUDF(pDb, name, arity, m.wudf);
|
||||
};
|
||||
|
||||
/**
|
||||
Intended to be called _only_ from sqlite3_close_v2(),
|
||||
passed its non-0 db argument.
|
||||
@ -783,7 +803,7 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
|
||||
*/
|
||||
__dbCleanupMap.cleanup = function(pDb){
|
||||
pDb = __argPDb(pDb);
|
||||
//wasm.xWrap.FuncPtrAdapter.debugFuncInstall = true;
|
||||
wasm.xWrap.FuncPtrAdapter.debugFuncInstall = true;
|
||||
/**
|
||||
Installing NULL functions in the C API will remove those
|
||||
bindings. The FuncPtrAdapter which sits between us and the C
|
||||
@ -809,10 +829,28 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
|
||||
}
|
||||
delete m.collation;
|
||||
}
|
||||
if(m.udf){
|
||||
//TODO: map and clean up UDFs.
|
||||
let i;
|
||||
for(i = 0; i < 2; ++i){ /* Clean up UDFs... */
|
||||
const fmap = i ? m.wudf : m.udf;
|
||||
if(!fmap) continue;
|
||||
const func = i
|
||||
? capi.sqlite3_create_window_function
|
||||
: capi.sqlite3_create_function_v2;
|
||||
for(const e of fmap){
|
||||
const name = e[0], arities = e[1];
|
||||
const fargs = [pDb, name, 0/*arity*/, capi.SQLITE_UTF8, 0, 0, 0, 0, 0];
|
||||
if(i) fargs.push(0);
|
||||
for(const arity of arities){
|
||||
try{ fargs[2] = arity; func.apply(null, fargs); }
|
||||
catch(e){/*ignored*/}
|
||||
}
|
||||
arities.clear();
|
||||
}
|
||||
fmap.clear();
|
||||
}
|
||||
};
|
||||
delete m.udf;
|
||||
delete m.wudf;
|
||||
}/*__dbCleanupMap.cleanup()*/;
|
||||
|
||||
{/* Binding of sqlite3_close_v2() */
|
||||
const __sqlite3CloseV2 = wasm.xWrap("sqlite3_close_v2", "int", "sqlite3*");
|
||||
@ -1015,8 +1053,15 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
|
||||
return __errEncoding(pDb);
|
||||
}
|
||||
try{
|
||||
return __sqlite3CreateFunction(pDb, funcName, nArg, eTextRep,
|
||||
pApp, xFunc, xStep, xFinal, xDestroy);
|
||||
const rc = __sqlite3CreateFunction(pDb, funcName, nArg, eTextRep,
|
||||
pApp, xFunc, xStep, xFinal, xDestroy);
|
||||
if(0===rc && (xFunc instanceof Function
|
||||
|| xStep instanceof Function
|
||||
|| xFinal instanceof Function
|
||||
|| xDestroy instanceof Function)){
|
||||
__dbCleanupMap.addFunction(pDb, funcName, nArg);
|
||||
}
|
||||
return rc;
|
||||
}catch(e){
|
||||
console.error("sqlite3_create_function_v2() setup threw:",e);
|
||||
return util.sqlite3_wasm_db_error(pDb, e, "Creation of UDF threw: "+e);
|
||||
@ -1051,9 +1096,17 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
|
||||
return __errEncoding(pDb);
|
||||
}
|
||||
try{
|
||||
return __sqlite3CreateWindowFunction(pDb, funcName, nArg, eTextRep,
|
||||
pApp, xStep, xFinal, xValue,
|
||||
xInverse, xDestroy);
|
||||
const rc = __sqlite3CreateWindowFunction(pDb, funcName, nArg, eTextRep,
|
||||
pApp, xStep, xFinal, xValue,
|
||||
xInverse, xDestroy);
|
||||
if(0===rc && (xStep instanceof Function
|
||||
|| xFinal instanceof Function
|
||||
|| xValue instanceof Function
|
||||
|| xInverse instanceof Function
|
||||
|| xDestroy instanceof Function)){
|
||||
__dbCleanupMap.addWindowFunc(pDb, funcName, nArg);
|
||||
}
|
||||
return rc;
|
||||
}catch(e){
|
||||
console.error("sqlite3_create_window_function() setup threw:",e);
|
||||
return util.sqlite3_wasm_db_error(pDb, e, "Creation of UDF threw: "+e);
|
||||
|
@ -1659,8 +1659,9 @@ self.WhWasmUtilInstaller = function(target){
|
||||
static warnOnUse = false;
|
||||
|
||||
/** If true, convertArg() will FuncPtrAdapter.debugOut() when it
|
||||
(un)installs a function binding to/from WASM.
|
||||
*/
|
||||
(un)installs a function binding to/from WASM. Note that
|
||||
deinstallation of bindScope=transient bindings happens
|
||||
via scopedAllocPop() so will not be output. */
|
||||
static debugFuncInstall = false;
|
||||
|
||||
/** Function used for debug output. */
|
||||
|
14
manifest
14
manifest
@ -1,5 +1,5 @@
|
||||
C Add\sJS\sinfrastructure\swhich\senables\ssqlite3.capi.sqlite3_close_v2()\sto\sclean\sup\sstale\sJS-to-WASM\scollation\sfunction\sconversions\sinstalled\son\sbehalf\sof\sa\sgiven\sdb\shandle.\sThe\ssame\sfor\sUDF\smappings\sis\sTODO.
|
||||
D 2022-12-26T13:00:58.115
|
||||
C Extend\s[0e69b2c379e618]\sto\ssupport\suninstalling\sstale\sJS-to-WASM\sfunction\spointers\sadded\son\sbehalf\sof\sUDFs.
|
||||
D 2022-12-26T13:45:10.544
|
||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
|
||||
@ -503,7 +503,7 @@ F ext/wasm/api/post-js-footer.js cd0a8ec768501d9bd45d325ab0442037fb0e33d1f3b4f08
|
||||
F ext/wasm/api/post-js-header.js 47b6b281f39ad59fa6e8b658308cd98ea292c286a68407b35ff3ed9cfd281a62
|
||||
F ext/wasm/api/pre-js.c-pp.js b88499dc303c21fc3f55f2c364a0f814f587b60a95784303881169f9e91c1d5f
|
||||
F ext/wasm/api/sqlite3-api-cleanup.js 680d5ccfff54459db136a49b2199d9f879c8405d9c99af1dda0cc5e7c29056f4
|
||||
F ext/wasm/api/sqlite3-api-glue.js 8e6336cd5c6e404b1460a196196eb6362b13de4ec24544ef1a3a1a4132245d9c
|
||||
F ext/wasm/api/sqlite3-api-glue.js 859180a5cea4e33d18c3a129d41e4068d5330846efa3287f152ac063859055a6
|
||||
F ext/wasm/api/sqlite3-api-oo1.js 959be9a922d1f012b4a25e7b763c112220bb0efb989f56b82a776ab1ccebe72d
|
||||
F ext/wasm/api/sqlite3-api-prologue.js 3792a703ea15be8d4393a99992862c285d62732d760cec95226dc5ec2781d920
|
||||
F ext/wasm/api/sqlite3-api-worker1.js c9ef8865f072e61251260b218aa4ed614a21a25e9e3cc6f22acf81794d32fc0b
|
||||
@ -521,7 +521,7 @@ F ext/wasm/c-pp.c 92285f7bce67ed7b7020b40fde8ed0982c442b63dc33df9dfd4b658d4a6c07
|
||||
F ext/wasm/common/SqliteTestUtil.js d8bf97ecb0705a2299765c8fc9e11b1a5ac7f10988bbf375a6558b7ca287067b
|
||||
F ext/wasm/common/emscripten.css 11bd104b6c0d597c67d40cc8ecc0a60dae2b965151e3b6a37fa5708bac3acd15
|
||||
F ext/wasm/common/testing.css 0ff15602a3ab2bad8aef2c3bd120c7ee3fd1c2054ad2ace7e214187ae68d926f
|
||||
F ext/wasm/common/whwasmutil.js 8014d4559b723a0f34f480c1962ad8625994cb17e7f71e9027732f0c16f3a70d
|
||||
F ext/wasm/common/whwasmutil.js 63188a5b90de3c17a2fdf3f1a90321ffdeaa2c34f6ca9d76f830fb0800867854
|
||||
F ext/wasm/demo-123-worker.html a0b58d9caef098a626a1a1db567076fca4245e8d60ba94557ede8684350a81ed
|
||||
F ext/wasm/demo-123.html 8c70a412ce386bd3796534257935eb1e3ea5c581e5d5aea0490b8232e570a508
|
||||
F ext/wasm/demo-123.js ebae30756585bca655b4ab2553ec9236a87c23ad24fc8652115dcedb06d28df6
|
||||
@ -2067,8 +2067,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
|
||||
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
||||
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
||||
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
||||
P 60b262ef0f57b162c2566b12e70685a92afb00b441332ea7a6540fcb188cc7af
|
||||
R ad57ccb8cecad2b9daaaef2f36f544d6
|
||||
P 0e69b2c379e61893c7db8a9c9d270650f2bd63b6cea30811d41136392a2e4f04
|
||||
R 45aeadabb85c467b62debc379d9a6901
|
||||
U stephan
|
||||
Z 7341e7115e45a0f5c9a909c3a65ff344
|
||||
Z eea54b677b9aecae6309be4e3e0e63e0
|
||||
# Remove this line to create a well-formed Fossil manifest.
|
||||
|
@ -1 +1 @@
|
||||
0e69b2c379e61893c7db8a9c9d270650f2bd63b6cea30811d41136392a2e4f04
|
||||
7a46e629dcbf97ae037c5abb39306af7ad55f1910c1e962373e09d88d8bd5a33
|
Loading…
x
Reference in New Issue
Block a user