diff options
author | stephan <stephan@noemail.net> | 2022-10-20 05:14:37 +0000 |
---|---|---|
committer | stephan <stephan@noemail.net> | 2022-10-20 05:14:37 +0000 |
commit | 842c5ee84951da8524221e0546d41e4f3a1a18f0 (patch) | |
tree | 69fe682e0d6d57c46478a0c4d34510bb0df729cb /ext/wasm/api/sqlite3-wasm.c | |
parent | d89a66ec36491c1d98a1bbeb04dac4e74d66f754 (diff) | |
download | sqlite-842c5ee84951da8524221e0546d41e4f3a1a18f0.tar.gz sqlite-842c5ee84951da8524221e0546d41e4f3a1a18f0.zip |
Rework sqlite3_wasm_vfs_unlink(), add sqlite3_wasm_db_vfs(), update some docs.
FossilOrigin-Name: cdd46858f0e63bc7bfce8e339b3db9efdec43b6443ee76563a847f53d0176831
Diffstat (limited to 'ext/wasm/api/sqlite3-wasm.c')
-rw-r--r-- | ext/wasm/api/sqlite3-wasm.c | 36 |
1 files changed, 23 insertions, 13 deletions
diff --git a/ext/wasm/api/sqlite3-wasm.c b/ext/wasm/api/sqlite3-wasm.c index cda4e7ae2..1decf0593 100644 --- a/ext/wasm/api/sqlite3-wasm.c +++ b/ext/wasm/api/sqlite3-wasm.c @@ -809,22 +809,16 @@ const char * sqlite3_wasm_enum_json(void){ ** This function is NOT part of the sqlite3 public API. It is strictly ** for use by the sqlite project's own JS/WASM bindings. ** -** Do not use this function, even for internal use: it was -** ill-conceived and will be removed once the JS code which still -** calls it has been weeded out. -** -** This function invokes the xDelete method of the default VFS, -** passing on the given filename. If zName is NULL, no default VFS is -** found, or it has no xDelete method, SQLITE_MISUSE is returned, else -** the result of the xDelete() call is returned. +** This function invokes the xDelete method of the given VFS (or the +** default VFS if pVfs is NULL), passing on the given filename. If +** zName is NULL, no default VFS is found, or it has no xDelete +** method, SQLITE_MISUSE is returned, else the result of the xDelete() +** call is returned. */ SQLITE_WASM_KEEP -int sqlite3_wasm_vfs_unlink(const char * zName){ +int sqlite3_wasm_vfs_unlink(sqlite3_vfs *pVfs, const char * zName){ int rc = SQLITE_MISUSE /* ??? */; - sqlite3_vfs * const pVfs = sqlite3_vfs_find(0); -#if defined(__EMSCRIPTEN__) - emscripten_console_warn("sqlite3_wasm_vfs_unlink() will be removed."); -#endif + if( 0==pVfs && 0!=zName ) pVfs = sqlite3_vfs_find(0); if( zName && pVfs && pVfs->xDelete ){ rc = pVfs->xDelete(pVfs, zName, 1); } @@ -835,6 +829,22 @@ int sqlite3_wasm_vfs_unlink(const char * zName){ ** This function is NOT part of the sqlite3 public API. It is strictly ** for use by the sqlite project's own JS/WASM bindings. ** +** Returns a pointer to the given DB's VFS for the given DB name, +** defaulting to "main" if zDbName is 0. Returns 0 if no db with the +** given name is open. +*/ +SQLITE_WASM_KEEP +sqlite3_vfs * sqlite3_wasm_db_vfs(sqlite3 *pDb, const char *zDbName){ + sqlite3_vfs * pVfs = 0; + sqlite3_file_control(pDb, zDbName ? zDbName : "main", + SQLITE_FCNTL_VFS_POINTER, &pVfs); + return pVfs; +} + +/* +** This function is NOT part of the sqlite3 public API. It is strictly +** for use by the sqlite project's own JS/WASM bindings. +** ** This function resets the given db pointer's database as described at ** ** https://www.sqlite.org/c3ref/c_dbconfig_defensive.html#sqlitedbconfigresetdatabase |