1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-29 08:01:23 +03:00

Add sqlite3.version object. Add more state to the Worker #1 config-get response, including sqlite3.version.

FossilOrigin-Name: 711f458d188a0dbe6612069c856ade29323ab426dfa4f80e7b82757ccc474cb8
This commit is contained in:
stephan
2022-09-30 16:49:03 +00:00
parent 07c0b72253
commit d18f1bbfe0
5 changed files with 45 additions and 26 deletions

View File

@ -202,4 +202,9 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
capi[s.name] = sqlite3.StructBinder(s);
}
}/*end C constant imports*/
sqlite3.version = Object.assign(Object.create(null),{
library: sqlite3.capi.sqlite3_libversion(),
sourceId: sqlite3.capi.sqlite3_sourceid()
});
});

View File

@ -927,13 +927,16 @@ self.sqlite3ApiBootstrap = function sqlite3ApiBootstrap(
subsequent calls are no-ops which return a pre-resolved
Promise.
If called at all, this function must be called by client-level
code, which must not use the library until the returned promise
resolves.
Ideally this function is called as part of the Promise chain
which handles the loading and bootstrapping of the API. If not
then it must be called by client-level code, which must not use
the library until the returned promise resolves.
Bug: if called while a prior call is still resolving, the 2nd
call will resolve prematurely, before the 1st call has finished
resolving.
resolving. The current build setup precludes that possibility,
so it's only a hypothetical problem if/when this function
ever needs to be invoked by clients.
In Emscripten-based builds, this function is called
automatically and deleted from this object.

View File

@ -154,15 +154,20 @@
messageId: ...as above...,
result: {
wasmfsOpfsDir: path prefix, if any, of persistent storage.
An empty string denotes that no persistent storage is available.
version: sqlite3.version object
bigIntEnabled: bool. True if BigInt support is enabled.
wasmfsOpfsEnabled: true if persistent storage is enabled in the
current environment. Only files stored under persistentDirName
will persist, however.
wasmfsOpfsDir: path prefix, if any, _intended_ for use with
OPFS persistent storage.
wasmfsOpfsEnabled: true if persistent storage is enabled in the
current environment. Only files stored under wasmfsOpfsDir
will persist using that mechanism, however. It is legal to use
the non-WASMFS OPFS VFS to open a database via a URI-style
db filename.
vfses: result of sqlite3.capi.sqlite3_web_vfs_list()
}
}
```
@ -180,7 +185,8 @@
args:{
filename [=":memory:" or "" (unspecified)]: the db filename.
See the sqlite3.oo1.DB constructor for peculiarities and transformations,
See the sqlite3.oo1.DB constructor for peculiarities and
transformations,
persistent [=false]: if true and filename is not one of ("",
":memory:"), prepend sqlite3.capi.sqlite3_wasmfs_opfs_dir()
@ -188,6 +194,9 @@
_if_ the environment supports it. If persistent storage is not
supported, the filename is used as-is.
// TODO?: ^^^^ maybe rework that, now that we have the non-WASMFS
// OFPS.
}
}
```
@ -211,6 +220,7 @@
persistent: true if the given filename resides in the
known-persistent storage, else false. This determination is
independent of the `persistent` input argument.
}
}
```
@ -448,7 +458,8 @@ sqlite3.initWorker1API = function(){
}
const db = wState.open(oargs);
rc.filename = db.filename;
rc.persistent = !!pDir && db.filename.startsWith(pDir);
rc.persistent = (!!pDir && db.filename.startsWith(pDir))
|| sqlite3.capi.sqlite3_web_db_uses_vfs(db.pointer, "opfs");
rc.dbId = getDbId(db);
return rc;
},
@ -526,6 +537,8 @@ sqlite3.initWorker1API = function(){
if(Object.getOwnPropertyDescriptor(src, k)) rc[k] = src[k];
});
rc.wasmfsOpfsEnabled = !!sqlite3.capi.sqlite3_wasmfs_opfs_dir();
rc.version = sqlite3.version;
rc.vfses = sqlite3.capi.sqlite3_web_vfs_list();
return rc;
},
@ -542,12 +555,10 @@ sqlite3.initWorker1API = function(){
mimetype: 'application/x-sqlite3'
}
TODO is to determine how/whether this feature can support
exports of ":memory:" and "" (temp file) DBs. The latter is
ostensibly easy because the file is (potentially) on disk, but
the former does not have a structure which maps directly to a
db file image. We can VACUUM INTO a :memory:/temp db into a
file for that purpose, though.
2022-09-30: we have shell.c:fiddle_export_db() which works fine
for disk-based databases (even if it's a virtual disk like an
Emscripten VFS). sqlite3_serialize() can return this for
:memory: and temp databases.
*/
export: function(ev){
toss("export() requires reimplementing for portability reasons.");

View File

@ -1,5 +1,5 @@
C Add\soo1.JsStorageDb.clearStorage/storageSize()\smethods,\scopies\sof\scapi.sqlite3_web_kvvfs_clear/size().
D 2022-09-30T15:46:08.196
C Add\ssqlite3.version\sobject.\sAdd\smore\sstate\sto\sthe\sWorker\s#1\sconfig-get\sresponse,\sincluding\ssqlite3.version.
D 2022-09-30T16:49:03.804
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@ -485,11 +485,11 @@ F ext/wasm/api/post-js-footer.js b64319261d920211b8700004d08b956a6c285f3b0bba814
F ext/wasm/api/post-js-header.js 2e5c886398013ba2af88028ecbced1e4b22dc96a86467f1ecc5ba9e64ef90a8b
F ext/wasm/api/pre-js.js 2db711eb637991b383fc6b5c0f3df65ec48a7201e5730e304beba8de2d3f9b0b
F ext/wasm/api/sqlite3-api-cleanup.js 98905936119a555659b5cf43844211809ab9f436c52a569004e5585d2842b5c2
F ext/wasm/api/sqlite3-api-glue.js 81b06946223181727b9a1d731b4f3c2ba97a33ae43bc0bbda7e8fa02400a207e
F ext/wasm/api/sqlite3-api-glue.js 90206acd5cf556bd8a7a9275619aa680c9075ad8072ed1e18f47fc1d5cfbcf26
F ext/wasm/api/sqlite3-api-oo1.js 9caed0757a5e039ed92467e827fd3ca347fa08f19fe086fcbdd14a4ebe9c2f01
F ext/wasm/api/sqlite3-api-opfs.js 1b097808b7b081b0f0700cf97d49ef19760e401706168edff9cd45cf9169f541
F ext/wasm/api/sqlite3-api-prologue.js 304e883ff1b06f668ebb7bbdc80152b0a9f395bbd34acfd5f7a8ef84e8f17466
F ext/wasm/api/sqlite3-api-worker1.js d5d5b7fac4c4731c38c7e03f4f404b2a95c388a2a1d8bcf361caada572f107e0
F ext/wasm/api/sqlite3-api-prologue.js 3a93497a9bc542c7202f32063cd070aa9c4cd03171a5e354cf99dd4357585b7a
F ext/wasm/api/sqlite3-api-worker1.js 2e8a037a76d20c7653e5a392d9830f17a22ce6736ffd0597aa39b69d1c01ad2c
F ext/wasm/api/sqlite3-wasi.h 25356084cfe0d40458a902afb465df8c21fc4152c1d0a59b563a3fba59a068f9
F ext/wasm/api/sqlite3-wasm.c 336389b23c9b83763177499e49a0967949c392b2f7d84fbbb52ad6678e159f18
F ext/wasm/batch-runner.html c363032aba7a525920f61f8be112a29459f73f07e46f0ba3b7730081a617826e
@ -2029,8 +2029,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 60f0c5cb04d2baf8431e523434d8753e39377f4b2c6bad225c2e5487a4be419b
R 2f56b5a6214af7809c3a763a0bc16b9d
P 1e09efe7fa15b8908f8b8353164a8361de778e27ea6c0b11c402bf4e1c56333d
R 4c776ad1a7aec6f0bcde0b14554ad6b2
U stephan
Z 221cd5b9b95b0e9d6b36653a70003bd2
Z 125edfcbc5b4725eac67cee184f7f0b1
# Remove this line to create a well-formed Fossil manifest.

View File

@ -1 +1 @@
1e09efe7fa15b8908f8b8353164a8361de778e27ea6c0b11c402bf4e1c56333d
711f458d188a0dbe6612069c856ade29323ab426dfa4f80e7b82757ccc474cb8