Add new driver name 'sqlite3_with_extensions'

systemlib
mattn 2013-08-23 09:57:22 +09:00
parent 34a33cffaa
commit f6dadd82d8
1 changed files with 12 additions and 1 deletions

View File

@ -72,11 +72,13 @@ var SQLiteTimestampFormats = []string{
}
func init() {
sql.Register("sqlite3", &SQLiteDriver{})
sql.Register("sqlite3", &SQLiteDriver{false})
sql.Register("sqlite3_with_extensions", &SQLiteDriver{true})
}
// Driver struct.
type SQLiteDriver struct {
enableLoadExtentions bool
}
// Conn struct.
@ -176,6 +178,15 @@ func (d *SQLiteDriver) Open(dsn string) (driver.Conn, error) {
return nil, errors.New(C.GoString(C.sqlite3_errmsg(db)))
}
enableLoadExtentions := 0
if d.enableLoadExtentions {
enableLoadExtentions = 1
}
rv = C.sqlite3_enable_load_extension(db, C.int(enableLoadExtentions))
if rv != C.SQLITE_OK {
return nil, errors.New(C.GoString(C.sqlite3_errmsg(db)))
}
return &SQLiteConn{db}, nil
}