allow NOMUTEX|READONLY

This commit is contained in:
Ian Chiles 2017-09-13 11:59:37 -05:00
parent 05548ff555
commit 6455f61179
1 changed files with 11 additions and 5 deletions

View File

@ -712,11 +712,17 @@ func (d *SQLiteDriver) Open(dsn string) (driver.Conn, error) {
var db *C.sqlite3
name := C.CString(dsn)
defer C.free(unsafe.Pointer(name))
rv := C._sqlite3_open_v2(name, &db,
C.SQLITE_OPEN_FULLMUTEX|
C.SQLITE_OPEN_READWRITE|
C.SQLITE_OPEN_CREATE,
nil)
var rv C.int
if strings.Contains(dsn, "immutable") {
rv = C._sqlite3_open_v2(name, &db, C.SQLITE_OPEN_NOMUTEX|C.SQLITE_OPEN_READONLY, nil)
} else {
rv = C._sqlite3_open_v2(name, &db,
C.SQLITE_OPEN_FULLMUTEX|
C.SQLITE_OPEN_READWRITE|
C.SQLITE_OPEN_CREATE,
nil)
}
if rv != 0 {
return nil, Error{Code: ErrNo(rv)}
}