Method: SQLite3::Database#load_extension

Defined in:
ext/sqlite3/database.c

#load_extension(file) ⇒ Object

Loads an SQLite extension library from the named file. Extension loading must be enabled using db.enable_load_extension(1) prior to calling this API.



641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
# File 'ext/sqlite3/database.c', line 641

static VALUE load_extension(VALUE self, VALUE file)
{
  sqlite3RubyPtr ctx;
  int status;
  char *errMsg;
  VALUE errexp;
  Data_Get_Struct(self, sqlite3Ruby, ctx);
  REQUIRE_OPEN_DB(ctx);

  status = sqlite3_load_extension(ctx->db, RSTRING_PTR(file), 0, &errMsg);
  if (status != SQLITE_OK)
  {
    errexp = rb_exc_new2(rb_eRuntimeError, errMsg);
    sqlite3_free(errMsg);
    rb_exc_raise(errexp);
  }

  return self;
}