Expose LoadExtension with entry point

This commit is contained in:
Zbigniew Mandziejewicz 2016-04-18 17:05:24 +08:00
parent 0d708316a6
commit da9decb965
1 changed files with 24 additions and 0 deletions

View File

@ -37,3 +37,27 @@ func (c *SQLiteConn) loadExtensions(extensions []string) error {
} }
return nil 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
}