Merge pull request #298 from shaxbee/master

Expose LoadExtension with entry point
This commit is contained in:
mattn 2016-04-18 19:38:27 +09:00
commit 22d73514b2
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
}