Merge pull request #747 from azavorotnii/open_journal_mode

Fix Open() journal mode regression
noncgo
mattn 2019-09-24 10:39:45 +09:00 committed by GitHub
commit 4396a38886
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 6 deletions

View File

@ -1000,7 +1000,7 @@ func (d *SQLiteDriver) Open(dsn string) (driver.Conn, error) {
deferForeignKeys := -1 deferForeignKeys := -1
foreignKeys := -1 foreignKeys := -1
ignoreCheckConstraints := -1 ignoreCheckConstraints := -1
journalMode := "DELETE" var journalMode string
lockingMode := "NORMAL" lockingMode := "NORMAL"
queryOnly := -1 queryOnly := -1
recursiveTriggers := -1 recursiveTriggers := -1
@ -1232,7 +1232,7 @@ func (d *SQLiteDriver) Open(dsn string) (driver.Conn, error) {
if _, ok := params["_locking"]; ok { if _, ok := params["_locking"]; ok {
pkey = "_locking" pkey = "_locking"
} }
if val := params.Get("_locking"); val != "" { if val := params.Get(pkey); val != "" {
switch strings.ToUpper(val) { switch strings.ToUpper(val) {
case "NORMAL", "EXCLUSIVE": case "NORMAL", "EXCLUSIVE":
lockingMode = strings.ToUpper(val) lockingMode = strings.ToUpper(val)
@ -1571,10 +1571,11 @@ func (d *SQLiteDriver) Open(dsn string) (driver.Conn, error) {
} }
// Journal Mode // Journal Mode
// Because default Journal Mode is DELETE this PRAGMA can always be executed. if journalMode != "" {
if err := exec(fmt.Sprintf("PRAGMA journal_mode = %s;", journalMode)); err != nil { if err := exec(fmt.Sprintf("PRAGMA journal_mode = %s;", journalMode)); err != nil {
C.sqlite3_close_v2(db) C.sqlite3_close_v2(db)
return nil, err return nil, err
}
} }
// Locking Mode // Locking Mode