Skip to content

loadExtension() #316

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
baptistapedro opened this issue Dec 25, 2019 · 2 comments
Closed

loadExtension() #316

baptistapedro opened this issue Dec 25, 2019 · 2 comments

Comments

@baptistapedro
Copy link

Hello,
I amusing sql.js on browser on my emscripten project.
I am trying to load an .wasm extension but it doesnt seem to support loadExtension()

config = {
    locateFile: filename => `/dist/${filename}`
}

initSqlJs(config).then(function(SQL){
    var db = new SQL.Database();
    db.loadExtension('myout.wasm');
    db.run("SELECT TESTFUNC('CREATE TABLE foo (bar TEXT)')");
});

Can you tell me what's the right way to load it?

Thanks.

@lovasoa
Copy link
Member

lovasoa commented Dec 25, 2019

Hello,
There is no way to load an extension, and this feature is not trivial to implement at all. If you are interested in implementing it, let me know and I'll reopen this issue.

@lovasoa lovasoa closed this as completed Dec 25, 2019
@mandel59
Copy link

Emscripten supports dynamic linking. (https://github.com/emscripten-core/emscripten/wiki/Linking) SQLite's run-time extension is just loaded by dlopen, so it will work if

  • the main module (sqlite) is compiled with -s MAIN_MODULE=1 option, and
  • extensions are compiled with -s SIDE_MODULE=1.

SQLite disables run-time extension by default, so calling sqlite3_db_config is also needed.

I confirmed that WASM version of SQLite can load run-time extensions with code of my repository https://github.com/mandel59/sqlite-wasm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants