From 4fd9f789e54ac1525f540370a1950223bb8961c9 Mon Sep 17 00:00:00 2001 From: Weizhen Wang Date: Mon, 17 Jan 2022 17:11:44 +0800 Subject: [PATCH] *: remove useless else (#31715) ref pingcap/tidb#31716 --- config/config.go | 6 ++---- expression/builtin_json.go | 2 -- server/driver_tidb.go | 4 +--- sessionctx/variable/session.go | 5 +---- 4 files changed, 4 insertions(+), 13 deletions(-) diff --git a/config/config.go b/config/config.go index bed34b44cfe20..a335dcb18a633 100644 --- a/config/config.go +++ b/config/config.go @@ -229,11 +229,9 @@ func (c *Config) getTiKVConfig() *tikvcfg.Config { func encodeDefTempStorageDir(tempDir string, host, statusHost string, port, statusPort uint) string { dirName := base64.URLEncoding.EncodeToString([]byte(fmt.Sprintf("%v:%v/%v:%v", host, port, statusHost, statusPort))) - var osUID string + osUID := "" currentUser, err := user.Current() - if err != nil { - osUID = "" - } else { + if err == nil { osUID = currentUser.Uid } return filepath.Join(tempDir, osUID+"_tidb", dirName, "tmp-storage") diff --git a/expression/builtin_json.go b/expression/builtin_json.go index 92e427d1b883a..378f00149da9c 100644 --- a/expression/builtin_json.go +++ b/expression/builtin_json.go @@ -848,8 +848,6 @@ func (b *builtinJSONValidStringSig) evalInt(row chunk.Row) (res int64, isNull bo data := hack.Slice(val) if goJSON.Valid(data) { res = 1 - } else { - res = 0 } return res, false, nil } diff --git a/server/driver_tidb.go b/server/driver_tidb.go index 0840cceb86c0a..2922b9e3c4ef6 100644 --- a/server/driver_tidb.go +++ b/server/driver_tidb.go @@ -372,9 +372,7 @@ func convertColumnInfo(fld *ast.ResultField) (ci *ColumnInfo) { if fld.Table != nil { ci.OrgTable = fld.Table.Name.O } - if fld.Column.Flen == types.UnspecifiedLength { - ci.ColumnLength = 0 - } else { + if fld.Column.Flen != types.UnspecifiedLength { ci.ColumnLength = uint32(fld.Column.Flen) } if fld.Column.Tp == mysql.TypeNewDecimal { diff --git a/sessionctx/variable/session.go b/sessionctx/variable/session.go index 6a0982bb7154b..d04755d7236ca 100644 --- a/sessionctx/variable/session.go +++ b/sessionctx/variable/session.go @@ -1304,11 +1304,9 @@ func NewSessionVars() *SessionVars { vars.enforceMPPExecution = DefTiDBEnforceMPPExecution vars.MPPStoreFailTTL = DefTiDBMPPStoreFailTTL - var enableChunkRPC string + enableChunkRPC := "0" if config.GetGlobalConfig().TiKVClient.EnableChunkRPC { enableChunkRPC = "1" - } else { - enableChunkRPC = "0" } terror.Log(vars.SetSystemVar(TiDBEnableChunkRPC, enableChunkRPC)) for _, engine := range config.GetGlobalConfig().IsolationRead.Engines { @@ -2196,7 +2194,6 @@ func (s *SessionVars) SlowLogFormat(logItems *SlowQueryLogItems) string { vStr = "pseudo" } else { vStr = strconv.FormatUint(v, 10) - } if firstComma { buf.WriteString("," + k + ":" + vStr)