mirror of https://github.com/mattn/go-sqlite3.git
allow NOMUTEX|READONLY
This commit is contained in:
parent
05548ff555
commit
6455f61179
16
sqlite3.go
16
sqlite3.go
|
@ -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
|
||||||
C.SQLITE_OPEN_FULLMUTEX|
|
if strings.Contains(dsn, "immutable") {
|
||||||
C.SQLITE_OPEN_READWRITE|
|
rv = C._sqlite3_open_v2(name, &db, C.SQLITE_OPEN_NOMUTEX|C.SQLITE_OPEN_READONLY, nil)
|
||||||
C.SQLITE_OPEN_CREATE,
|
} else {
|
||||||
nil)
|
rv = C._sqlite3_open_v2(name, &db,
|
||||||
|
C.SQLITE_OPEN_FULLMUTEX|
|
||||||
|
C.SQLITE_OPEN_READWRITE|
|
||||||
|
C.SQLITE_OPEN_CREATE,
|
||||||
|
nil)
|
||||||
|
}
|
||||||
|
|
||||||
if rv != 0 {
|
if rv != 0 {
|
||||||
return nil, Error{Code: ErrNo(rv)}
|
return nil, Error{Code: ErrNo(rv)}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue