Skip to content

Commit

Permalink
Merge pull request mattn#298 from shaxbee/master
Browse files Browse the repository at this point in the history
Expose LoadExtension with entry point
  • Loading branch information
mattn committed Apr 18, 2016
2 parents 0d70831 + da9decb commit 22d7351
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions sqlite3_load_extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,27 @@ func (c *SQLiteConn) loadExtensions(extensions []string) error {
}
return nil
}

func (c *SQLiteConn) LoadExtension(lib string, entry string) error {
rv := C.sqlite3_enable_load_extension(c.db, 1)
if rv != C.SQLITE_OK {
return errors.New(C.GoString(C.sqlite3_errmsg(c.db)))
}

clib := C.CString(lib)
defer C.free(unsafe.Pointer(clib))
centry := C.CString(entry)
defer C.free(unsafe.Pointer(centry))

rv = C.sqlite3_load_extension(c.db, clib, centry, nil)
if rv != C.SQLITE_OK {
return errors.New(C.GoString(C.sqlite3_errmsg(c.db)))
}

rv = C.sqlite3_enable_load_extension(c.db, 0)
if rv != C.SQLITE_OK {
return errors.New(C.GoString(C.sqlite3_errmsg(c.db)))
}

return nil
}

0 comments on commit 22d7351

Please sign in to comment.