From 934c3f788266b32ef4e85b116c6686d1a08d76d7 Mon Sep 17 00:00:00 2001 From: chenshijun <csj_sky@126.com> Date: 星期五, 06 九月 2019 14:22:11 +0800 Subject: [PATCH] 完善一些业务处里 --- dbself.go | 11 +++++++---- 1 files changed, 7 insertions(+), 4 deletions(-) diff --git a/dbself.go b/dbself.go index 848eba7..5156b2b 100644 --- a/dbself.go +++ b/dbself.go @@ -1,4 +1,4 @@ -package main +package syncdb import ( "errors" @@ -64,6 +64,8 @@ } defer tmpconn.Close() + syncMut.Lock() + defer syncMut.Unlock() err = SerfDbConn.Backup(tmpconn) if err != nil { return "", err @@ -72,10 +74,10 @@ } // do exet when get querystring. -func ExecuteWriteSql(sqlString []string) ([]*Result, error) { +func ExecuteWriteSql(sqlString []string, tx bool) ([]*Result, error) { syncMut.Lock() defer syncMut.Unlock() - allResults, err := SerfDbConn.Execute(sqlString, false, false) + allResults, err := SerfDbConn.Execute(sqlString, tx, false) if err != nil { fmt.Println("execute error!", err) return nil, err @@ -96,7 +98,8 @@ } func Dumpdb() { - + syncMut.Lock() + defer syncMut.Unlock() var b strings.Builder if err := SerfDbConn.Dump(&b); err != nil { fmt.Println("dump file ", err.Error()) -- Gitblit v1.8.0