In the shell WASM build, call open_db() early so that we can get access to the global db handle from certain experimentation-only function without having to first run some SQL code.
FossilOrigin-Name: 31706ef851f7d55e2fe865933ec03f42dfa8b49e6d1f12b6c016b5c1d3460504
This commit is contained in:
+39
-1
@@ -12563,6 +12563,38 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){
|
||||
|
||||
|
||||
#ifdef SQLITE_SHELL_WASM_MODE
|
||||
/* Only for emcc experimentation purposes. */
|
||||
int fiddle_experiment(int a,int b){
|
||||
return a + b;
|
||||
}
|
||||
|
||||
/* Only for emcc experimentation purposes.
|
||||
|
||||
Define this function in JS using:
|
||||
|
||||
emcc ... --js-library somefile.js
|
||||
|
||||
containing:
|
||||
|
||||
mergeInto(LibraryManager.library, {
|
||||
my_foo: function(){
|
||||
console.debug("my_foo()",arguments);
|
||||
}
|
||||
});
|
||||
*/
|
||||
/*extern void my_foo(sqlite3 *);*/
|
||||
/* Only for emcc experimentation purposes. */
|
||||
sqlite3 * fiddle_the_db(){
|
||||
printf("fiddle_the_db(%p)\n", (const void*)globalDb);
|
||||
/*my_foo(globalDb);*/
|
||||
return globalDb;
|
||||
}
|
||||
/* Only for emcc experimentation purposes. */
|
||||
sqlite3 * fiddle_db_arg(sqlite3 *arg){
|
||||
printf("fiddle_db_arg(%p)\n", (const void*)arg);
|
||||
return arg;
|
||||
}
|
||||
|
||||
/*
|
||||
** Trivial exportable function for emscripten. Needs to be exported using:
|
||||
**
|
||||
@@ -12589,7 +12621,13 @@ void fiddle_exec(const char * zSql){
|
||||
);
|
||||
puts("WASM shell");
|
||||
puts("Enter \".help\" for usage hints.");
|
||||
puts("Connected to a transient in-memory database.");
|
||||
if(once>0) open_db(&shellState, 0);
|
||||
if(shellState.db){
|
||||
puts("Connected to a transient in-memory database.");
|
||||
}else{
|
||||
fprintf(stderr,"ERROR initializing db!\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(once<0){
|
||||
puts("DB init failed. Not executing SQL.");
|
||||
|
||||
Reference in New Issue
Block a user