Skip to content

loadExtension() #316

Closed
Closed

Description

@baptistapedro

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.

Activity

  1. lovasoa commented on Dec 25, 2019

    @lovasoa
    Member

    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.

  2. mandel59 commented on Dec 26, 2019

    @mandel59

    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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions