mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-29 08:01:23 +03:00
Remove some dead JS code and tweak some docs.
FossilOrigin-Name: 0ee495452c014680697aa9035c245024df127a52d1820ab0e02580a015d96ecb
This commit is contained in:
@ -13,7 +13,7 @@
|
||||
A Worker which manages asynchronous OPFS handles on behalf of a
|
||||
synchronous API which controls it via a combination of Worker
|
||||
messages, SharedArrayBuffer, and Atomics. It is the asynchronous
|
||||
counterpart of the API defined in sqlite3-api-opfs.js.
|
||||
counterpart of the API defined in sqlite3-vfs-opfs.js.
|
||||
|
||||
Highly indebted to:
|
||||
|
||||
@ -343,16 +343,6 @@ const installAsyncProxy = function(self){
|
||||
const affirmNotRO = function(opName,fh){
|
||||
if(fh.readOnly) toss(opName+"(): File is read-only: "+fh.filenameAbs);
|
||||
};
|
||||
const affirmLocked = function(opName,fh){
|
||||
//if(!fh.syncHandle) toss(opName+"(): File does not have a lock: "+fh.filenameAbs);
|
||||
/**
|
||||
Currently a no-op, as speedtest1 triggers xRead() without a
|
||||
lock (that seems like a bug but it's currently uninvestigated).
|
||||
This means, however, that some OPFS VFS routines may trigger
|
||||
acquisition of a lock but never let it go until xUnlock() is
|
||||
called (which it likely won't be if xLock() was not called).
|
||||
*/
|
||||
};
|
||||
|
||||
/**
|
||||
We track 2 different timers: the "metrics" timer records how much
|
||||
@ -393,7 +383,6 @@ const installAsyncProxy = function(self){
|
||||
*/
|
||||
let flagAsyncShutdown = false;
|
||||
|
||||
|
||||
/**
|
||||
Asynchronous wrappers for sqlite3_vfs and sqlite3_io_methods
|
||||
methods, as well as helpers like mkdir(). Maintenance reminder:
|
||||
@ -427,11 +416,11 @@ const installAsyncProxy = function(self){
|
||||
},
|
||||
xAccess: async (filename)=>{
|
||||
mTimeStart('xAccess');
|
||||
/* OPFS cannot support the full range of xAccess() queries sqlite3
|
||||
calls for. We can essentially just tell if the file is
|
||||
accessible, but if it is it's automatically writable (unless
|
||||
it's locked, which we cannot(?) know without trying to open
|
||||
it). OPFS does not have the notion of read-only.
|
||||
/* OPFS cannot support the full range of xAccess() queries
|
||||
sqlite3 calls for. We can essentially just tell if the file
|
||||
is accessible, but if it is then it's automatically writable
|
||||
(unless it's locked, which we cannot(?) know without trying
|
||||
to open it). OPFS does not have the notion of read-only.
|
||||
|
||||
The return semantics of this function differ from sqlite3's
|
||||
xAccess semantics because we are limited in what we can
|
||||
@ -519,7 +508,6 @@ const installAsyncProxy = function(self){
|
||||
let rc = 0;
|
||||
wTimeStart('xFileSize');
|
||||
try{
|
||||
affirmLocked('xFileSize',fh);
|
||||
const sz = await (await getSyncHandle(fh,'xFileSize')).getSize();
|
||||
state.s11n.serialize(Number(sz));
|
||||
}catch(e){
|
||||
@ -615,7 +603,6 @@ const installAsyncProxy = function(self){
|
||||
let rc = 0, nRead;
|
||||
const fh = __openFiles[fid];
|
||||
try{
|
||||
affirmLocked('xRead',fh);
|
||||
wTimeStart('xRead');
|
||||
nRead = (await getSyncHandle(fh,'xRead')).read(
|
||||
fh.sabView.subarray(0, n),
|
||||
@ -659,7 +646,6 @@ const installAsyncProxy = function(self){
|
||||
const fh = __openFiles[fid];
|
||||
wTimeStart('xTruncate');
|
||||
try{
|
||||
affirmLocked('xTruncate',fh);
|
||||
affirmNotRO('xTruncate', fh);
|
||||
await (await getSyncHandle(fh,'xTruncate')).truncate(size);
|
||||
}catch(e){
|
||||
@ -696,7 +682,6 @@ const installAsyncProxy = function(self){
|
||||
const fh = __openFiles[fid];
|
||||
wTimeStart('xWrite');
|
||||
try{
|
||||
affirmLocked('xWrite',fh);
|
||||
affirmNotRO('xWrite', fh);
|
||||
rc = (
|
||||
n === (await getSyncHandle(fh,'xWrite'))
|
||||
|
@ -538,6 +538,7 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
|
||||
try{return func(...arguments) || 0;}
|
||||
catch(e){
|
||||
if(!(e instanceof sqlite3.WasmAllocError)){
|
||||
wasm.dealloc(wasm.getPtrValue(pzErr));
|
||||
wasm.setPtrValue(pzErr, wasm.allocCString(e.message));
|
||||
}
|
||||
return vt.xError(methodName, e);
|
||||
|
@ -75,7 +75,7 @@
|
||||
</li>
|
||||
<li>The easiest way to try different optimization levels is,
|
||||
from this directory:
|
||||
<pre>$ rm -f speedtest1.js; make -e emcc_opt='-O2' speedtest1.js</pre>
|
||||
<pre>$ rm -f jswasm/speedtest1.js; make -e emcc_opt='-O2' speedtest1</pre>
|
||||
Then reload this page. -O2 seems to consistently produce the fastest results.
|
||||
</li>
|
||||
</ul>
|
||||
|
@ -40,9 +40,9 @@
|
||||
<script src="jswasm/speedtest1.js"></script>
|
||||
<script>(function(){
|
||||
/**
|
||||
If this environment contains OPFS, this function initializes it and
|
||||
returns the name of the dir on which OPFS is mounted, else it returns
|
||||
an empty string.
|
||||
If this environment contains WASMFS with OPFS, this function
|
||||
initializes it and returns the name of the dir on which OPFS is
|
||||
mounted, else it returns an empty string.
|
||||
*/
|
||||
const wasmfsDir = function f(wasmUtil){
|
||||
if(undefined !== f._) return f._;
|
||||
|
@ -22,12 +22,14 @@
|
||||
groups and individual tests can be assigned a predicate function
|
||||
which determines whether to run them or not, and this is
|
||||
specifically intended to be used to toggle certain tests on or off
|
||||
for the main/worker threads.
|
||||
for the main/worker threads or the availability (or not) of
|
||||
optional features such as int64 support.
|
||||
|
||||
Each test group defines a state object which gets applied as each
|
||||
test function's `this`. Test functions can use that to, e.g., set up
|
||||
a db in an early test and close it in a later test. Each test gets
|
||||
passed the sqlite3 namespace object as its only argument.
|
||||
Each test group defines a single state object which gets applied as
|
||||
the test functions' `this` for all tests in that group. Test
|
||||
functions can use that to, e.g., set up a db in an early test and
|
||||
close it in a later test. Each test gets passed the sqlite3
|
||||
namespace object as its only argument.
|
||||
*/
|
||||
/*
|
||||
This file is intended to be processed by c-pp to inject (or not)
|
||||
@ -1680,6 +1682,7 @@ self.sqlite3InitModule = sqlite3InitModule;
|
||||
return rc;
|
||||
}catch(e){
|
||||
if(!(e instanceof sqlite3.WasmAllocError)){
|
||||
wasm.dealloc(wasm.getPtrValue, pzErr);
|
||||
wasm.setPtrValue(pzErr, wasm.allocCString(e.message));
|
||||
}
|
||||
return vth.xError('xConnect',e);
|
||||
@ -1883,10 +1886,10 @@ self.sqlite3InitModule = sqlite3InitModule;
|
||||
callback sets an error string. */;
|
||||
const modConfig = {
|
||||
/* catchExceptions changes how the methods are wrapped */
|
||||
catchExceptions: false,
|
||||
catchExceptions: true,
|
||||
name: "vtab2test",
|
||||
methods:{
|
||||
xConnect: function(pDb, pAux, argc, argv, ppVtab, pzErr){
|
||||
xCreate: function(pDb, pAux, argc, argv, ppVtab, pzErr){
|
||||
if(throwOnConnect){
|
||||
sqlite3.SQLite3Error.toss(
|
||||
throwOnConnect,
|
||||
@ -1967,7 +1970,7 @@ self.sqlite3InitModule = sqlite3InitModule;
|
||||
}
|
||||
}/*methods*/
|
||||
};
|
||||
const doEponymous =
|
||||
const doEponymousOnly =
|
||||
/* Bug (somewhere): non-eponymous is behaving as is
|
||||
the call to sqlite3_create_module() is missing
|
||||
or failed:
|
||||
@ -1976,29 +1979,36 @@ self.sqlite3InitModule = sqlite3InitModule;
|
||||
|
||||
=> sqlite3 result code 1: no such module: vtab2test
|
||||
*/ true;
|
||||
if(doEponymous){
|
||||
modConfig.methods.xConnect =
|
||||
modConfig.methods.xCreate;
|
||||
if(doEponymousOnly){
|
||||
warn("Reminder: non-eponymous mode is still not working here.",
|
||||
"Details are in the code comments.");
|
||||
"Details are in the code comments.");
|
||||
modConfig.methods.xCreate = 0;
|
||||
}else{
|
||||
modConfig.methods.xCreate = (...args)=>0;
|
||||
/*(...args)=>{
|
||||
try{return modConfig.methods.xConnect(...args)}
|
||||
catch(e){return vth.xError('xConnect',e)}
|
||||
};*/
|
||||
}
|
||||
const tmplMod = vth.setupModule(modConfig);
|
||||
T.assert(tmplMod instanceof capi.sqlite3_module)
|
||||
.assert(1===tmplMod.$iVersion);
|
||||
if(doEponymous){
|
||||
if(doEponymousOnly){
|
||||
if(modConfig.methods.xCreate !== 0){
|
||||
T.assert(modConfig.methods.xCreate === modConfig.methods.xConnect)
|
||||
.assert(tmplMod.$xCreate === tmplMod.$xConnect);
|
||||
}else{
|
||||
T.assert(0 === tmplMod.$xCreate);
|
||||
}
|
||||
}else{
|
||||
//T.assert(tmplMod.$xCreate !== tmplMod.$xConnect);
|
||||
}
|
||||
this.db.onclose.disposeThese.push(tmplMod);
|
||||
this.db.checkRc(capi.sqlite3_create_module(
|
||||
this.db, modConfig.name, tmplMod, 0
|
||||
this.db.pointer, modConfig.name, tmplMod.pointer, 0
|
||||
));
|
||||
if(!doEponymous){
|
||||
if(!doEponymousOnly){
|
||||
this.db.exec([
|
||||
"create virtual table testvtab2 using ",
|
||||
modConfig.name,
|
||||
@ -2007,7 +2017,7 @@ self.sqlite3InitModule = sqlite3InitModule;
|
||||
}
|
||||
const list = this.db.selectArrays(
|
||||
["SELECT a,b FROM ",
|
||||
(doEponymous ? modConfig.name : "testvtab2"),
|
||||
(doEponymousOnly ? modConfig.name : "testvtab2"),
|
||||
" where a<9999 and b>1 order by a, b"
|
||||
]/* Query is shaped so that it will ensure that some
|
||||
constraints end up in xBestIndex(). */
|
||||
@ -2041,7 +2051,8 @@ self.sqlite3InitModule = sqlite3InitModule;
|
||||
})
|
||||
.t({
|
||||
name: 'kvvfs in main thread',
|
||||
predicate: ()=>(isUIThread() ? true : "No local/sessionStorage in Worker"),
|
||||
predicate: ()=>(isUIThread()
|
||||
|| "local/sessionStorage are unavailable in a Worker"),
|
||||
test: function(sqlite3){
|
||||
const filename = this.kvvfsDbFile = 'session';
|
||||
const pVfs = capi.sqlite3_vfs_find('kvvfs');
|
||||
@ -2086,7 +2097,7 @@ self.sqlite3InitModule = sqlite3InitModule;
|
||||
delete this.kvvfsUnlink;
|
||||
delete this.JDb;
|
||||
}
|
||||
}/*kvvfs sqlite3_js_vfs_create_file()*/)
|
||||
}/*kvvfs sqlite3_js_vfs_create_file()*/)
|
||||
;/* end kvvfs tests */
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
Reference in New Issue
Block a user