mirror of https://github.com/mattn/go-sqlite3.git
allow NOMUTEX|READONLY
This commit is contained in:
parent
05548ff555
commit
6455f61179
|
@ -712,11 +712,17 @@ func (d *SQLiteDriver) Open(dsn string) (driver.Conn, error) {
|
||||||
var db *C.sqlite3
|
var db *C.sqlite3
|
||||||
name := C.CString(dsn)
|
name := C.CString(dsn)
|
||||||
defer C.free(unsafe.Pointer(name))
|
defer C.free(unsafe.Pointer(name))
|
||||||
rv := C._sqlite3_open_v2(name, &db,
|
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_FULLMUTEX|
|
||||||
C.SQLITE_OPEN_READWRITE|
|
C.SQLITE_OPEN_READWRITE|
|
||||||
C.SQLITE_OPEN_CREATE,
|
C.SQLITE_OPEN_CREATE,
|
||||||
nil)
|
nil)
|
||||||
|
}
|
||||||
|
|
||||||
if rv != 0 {
|
if rv != 0 {
|
||||||
return nil, Error{Code: ErrNo(rv)}
|
return nil, Error{Code: ErrNo(rv)}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue