diff --git a/database/gdb/gdb_driver_mssql.go b/database/gdb/gdb_driver_mssql.go index 520582156..59f12426a 100644 --- a/database/gdb/gdb_driver_mssql.go +++ b/database/gdb/gdb_driver_mssql.go @@ -64,10 +64,10 @@ func (d *DriverMssql) GetChars() (charLeft string, charRight string) { // HandleSqlBeforeCommit deals with the sql string before commits it to underlying sql driver. func (d *DriverMssql) HandleSqlBeforeCommit(link Link, sql string, args []interface{}) (string, []interface{}) { var index int - // Convert place holder char '?' to string "@vx". + // Convert place holder char '?' to string "@px". str, _ := gregex.ReplaceStringFunc("\\?", sql, func(s string) string { index++ - return fmt.Sprintf("@v%d", index) + return fmt.Sprintf("@p%d", index) }) str, _ = gregex.ReplaceString("\"", "", str) return d.parseSql(str), args diff --git a/database/gdb/gdb_func.go b/database/gdb/gdb_func.go index e30508a2c..206bad1e3 100644 --- a/database/gdb/gdb_func.go +++ b/database/gdb/gdb_func.go @@ -553,7 +553,7 @@ func formatError(err error, sql string, args ...interface{}) error { func FormatSqlWithArgs(sql string, args []interface{}) string { index := -1 newQuery, _ := gregex.ReplaceStringFunc( - `(\?|:v\d+|\$\d+|@v\d+)`, sql, func(s string) string { + `(\?|:v\d+|\$\d+|@p\d+)`, sql, func(s string) string { index++ if len(args) > index { if args[index] == nil { diff --git a/database/gdb/gdb_z_mysql_internal_test.go b/database/gdb/gdb_z_mysql_internal_test.go index 251a61a6d..b010bb3db 100644 --- a/database/gdb/gdb_z_mysql_internal_test.go +++ b/database/gdb/gdb_z_mysql_internal_test.go @@ -75,7 +75,7 @@ func Test_Func_FormatSqlWithArgs(t *testing.T) { // mssql gtest.C(t, func(t *gtest.T) { var s string - s = FormatSqlWithArgs("select * from table where id>=@v1 and sex=@v2", []interface{}{100, 1}) + s = FormatSqlWithArgs("select * from table where id>=@p1 and sex=@p2", []interface{}{100, 1}) t.Assert(s, "select * from table where id>=100 and sex=1") }) // pgsql diff --git a/os/glog/glog_logger.go b/os/glog/glog_logger.go index 6178c22d8..68a449851 100644 --- a/os/glog/glog_logger.go +++ b/os/glog/glog_logger.go @@ -229,22 +229,23 @@ func (l *Logger) printToFile(now time.Time, buffer *bytes.Buffer) { gmlock.Lock(memoryLockKey) defer gmlock.Unlock(memoryLockKey) file := l.getFilePointer(logFilePath) - defer file.Close() // Rotation file size checks. if l.config.RotateSize > 0 { stat, err := file.Stat() if err != nil { + file.Close() panic(err) } if stat.Size() > l.config.RotateSize { l.rotateFileBySize(now) file = l.getFilePointer(logFilePath) - defer file.Close() } } if _, err := file.Write(buffer.Bytes()); err != nil { + file.Close() panic(err) } + file.Close() } // getFilePointer retrieves and returns a file pointer from file pool.