diff options
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 |