Skip to content

Commit

Permalink
func: add libsql_initialize_wasm_func_table
Browse files Browse the repository at this point in the history
The routine creates the libsql_wasm_func_table table,
responsible for storing WebAssembly source code for dynamically
added Wasm functions.
  • Loading branch information
psarna committed Nov 18, 2022
1 parent 3e300a7 commit 45e4bd5
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/func.c
Original file line number Diff line number Diff line change
Expand Up @@ -2590,3 +2590,16 @@ void sqlite3RegisterBuiltinFunctions(void){
}
#endif
}

#ifdef LIBSQL_ENABLE_WASM_RUNTIME
int libsql_initialize_wasm_func_table(sqlite3 *db) {
int rc = sqlite3_exec(db, "CREATE TABLE IF NOT EXISTS libsql_wasm_func_table (name text PRIMARY KEY, body text)", NULL, NULL, NULL);
if (rc == SQLITE_READONLY) {
sqlite3_exec(db, "CREATE TEMP TABLE IF NOT EXISTS libsql_wasm_func_table (name text PRIMARY KEY, body text)", NULL, NULL, NULL);
}
// This initialization is best-effort: failing to initialize a Wasm func table
// does not prevent users from using this database
db->errCode = SQLITE_OK;
return SQLITE_OK;
}
#endif

0 comments on commit 45e4bd5

Please sign in to comment.