Skip to content

Commit

Permalink
Fix fmt issues
Browse files Browse the repository at this point in the history
  • Loading branch information
espresso98 committed Apr 28, 2022
1 parent f788a6a commit 4a2586e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion executor/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -932,7 +932,7 @@ func FormatSQL(sql string) stringutil.StringerFunc {
length := len(sql)
maxQueryLen := variable.QueryLogMaxLen.Load()
if maxQueryLen <= 0 {
return QueryReplacer.Replace(sql) // no limit
return QueryReplacer.Replace(sql) // no limit
}
if int32(length) > maxQueryLen {
sql = fmt.Sprintf("%.*q(len:%d)", maxQueryLen, sql, length)
Expand Down
4 changes: 2 additions & 2 deletions executor/adapter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ func TestFormatSQL(t *testing.T) {
require.Equal(t, "aaaa", val.String())
variable.QueryLogMaxLen.Store(0)
val = executor.FormatSQL("aaaaaaaaaaaaaaaaaaaa")
require.Equal(t, "aaaaaaaaaaaaaaaaaaaa", val.String())
require.Equal(t, "aaaaaaaaaaaaaaaaaaaa", val.String())
variable.QueryLogMaxLen.Store(5)
val = executor.FormatSQL("aaaaaaaaaaaaaaaaaaaa")
require.Equal(t, "\"aaaaa\"(len:20)", val.String())
}
}
8 changes: 4 additions & 4 deletions sessionctx/variable/sysvar.go
Original file line number Diff line number Diff line change
Expand Up @@ -678,10 +678,10 @@ var defaultSysVars = []*SysVar{
},
},
{Scope: ScopeGlobal, Name: TiDBQueryLogMaxLen, Value: strconv.Itoa(DefTiDBQueryLogMaxLen), Type: TypeInt, MinValue: 0, MaxValue: 1073741824, SetGlobal: func(s *SessionVars, val string) error {
QueryLogMaxLen.Store(int32(TidbOptInt64(val, DefTiDBQueryLogMaxLen)))
return nil
}, GetGlobal: func(s *SessionVars) (string, error) {
return fmt.Sprint(QueryLogMaxLen.Load()), nil
QueryLogMaxLen.Store(int32(TidbOptInt64(val, DefTiDBQueryLogMaxLen)))
return nil
}, GetGlobal: func(s *SessionVars) (string, error) {
return fmt.Sprint(QueryLogMaxLen.Load()), nil
}},

/* The system variables below have GLOBAL and SESSION scope */
Expand Down
4 changes: 2 additions & 2 deletions sessionctx/variable/sysvar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -964,7 +964,7 @@ func TestTiDBQueryLogMaxLen(t *testing.T) {
newVal = -2
expected = 0
val, err = sv.Validate(vars, fmt.Sprintf("%d", newVal), ScopeGlobal)
// expected to set to min value
// expected to set to min value
require.Equal(t, val, fmt.Sprintf("%d", expected))
require.NoError(t, err)
}
}

0 comments on commit 4a2586e

Please sign in to comment.