Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/importer/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func nextInt64Value(column *column, min int64, max int64) int64 {
}

func intToDecimalString(intValue int64, decimal int) string {
data := fmt.Sprintf("%d", intValue)
data := strconv.Itoa(intValue)

// add leading zero
if len(data) < decimal {
Expand Down
2 changes: 1 addition & 1 deletion ddl/partition.go
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ func checkCreatePartitionValue(ctx sessionctx.Context, tblInfo *model.TableInfo)
}
if fromExpr {
// Constant fold the expression.
defs[i].LessThan[0] = fmt.Sprintf("%d", currentRangeValue)
defs[i].LessThan[0] = strconv.Itoa(currentRangeValue)
}

if i == 0 {
Expand Down
3 changes: 2 additions & 1 deletion ddl/util/syncer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package util_test
import (
"context"
"fmt"
"strconv"
"sync"
"testing"
"time"
Expand Down Expand Up @@ -84,7 +85,7 @@ func TestSyncerSimple(t *testing.T) {
if err != nil {
t.Fatalf("client get global version failed %v", err)
}
if InitialVersion != fmt.Sprintf("%d", globalVer) {
if InitialVersion != strconv.Itoa(globalVer) {
t.Fatalf("client get global version %d isn't equal to init version %s", globalVer, InitialVersion)
}
childCtx, _ := goctx.WithTimeout(ctx, minInterval)
Expand Down
84 changes: 42 additions & 42 deletions errno/errname.go

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion executor/aggfuncs/aggfunc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ package aggfuncs_test

import (
"fmt"
"strconv"
"testing"
"time"

Expand Down Expand Up @@ -263,7 +264,7 @@ func getDataGenFunc(ft *types.FieldType) func(i int) types.Datum {
case mysql.TypeDouble:
return func(i int) types.Datum { return types.NewFloat64Datum(float64(i)) }
case mysql.TypeString:
return func(i int) types.Datum { return types.NewStringDatum(fmt.Sprintf("%d", i)) }
return func(i int) types.Datum { return types.NewStringDatum(strconv.Itoa(i)) }
case mysql.TypeDate:
return func(i int) types.Datum { return types.NewTimeDatum(types.TimeFromDays(int64(i + 365))) }
case mysql.TypeDuration:
Expand Down
2 changes: 1 addition & 1 deletion executor/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ func (e *CancelDDLJobsExec) Next(ctx context.Context, req *chunk.Chunk) error {
}
numCurBatch := mathutil.Min(req.Capacity(), len(e.jobIDs)-e.cursor)
for i := e.cursor; i < e.cursor+numCurBatch; i++ {
req.AppendString(0, fmt.Sprintf("%d", e.jobIDs[i]))
req.AppendString(0, strconv.Itoa(e.jobIDs[i]))
if e.errs[i] != nil {
req.AppendString(1, fmt.Sprintf("error: %v", e.errs[i]))
} else {
Expand Down
4 changes: 2 additions & 2 deletions executor/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2675,13 +2675,13 @@ func (s *testSuite) TestTiDBCurrentTS(c *C) {
tsStr := rows[0][0].(string)
txn, err := tk.Se.Txn(true)
c.Assert(err, IsNil)
c.Assert(tsStr, Equals, fmt.Sprintf("%d", txn.StartTS()))
c.Assert(tsStr, Equals, strconv.Itoa(txn.StartTS()))
tk.MustExec("begin")
rows = tk.MustQuery("select @@tidb_current_ts").Rows()
newTsStr := rows[0][0].(string)
txn, err = tk.Se.Txn(true)
c.Assert(err, IsNil)
c.Assert(newTsStr, Equals, fmt.Sprintf("%d", txn.StartTS()))
c.Assert(newTsStr, Equals, strconv.Itoa(txn.StartTS()))
c.Assert(newTsStr, Not(Equals), tsStr)
tk.MustExec("commit")
tk.MustQuery("select @@tidb_current_ts").Check(testkit.Rows("0"))
Expand Down
28 changes: 14 additions & 14 deletions executor/insert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -986,7 +986,7 @@ func (s *testSuite9) TestAutoRandomID(c *C) {
firstValue, err := strconv.Atoi(rs.Rows()[0][0].(string))
c.Assert(err, IsNil)
c.Assert(firstValue, Greater, 0)
tk.MustQuery(`select last_insert_id()`).Check(testkit.Rows(fmt.Sprintf("%d", firstValue)))
tk.MustQuery(`select last_insert_id()`).Check(testkit.Rows(strconv.Itoa(firstValue)))
tk.MustExec(`delete from ar`)

tk.MustExec(`insert into ar(id) values (0)`)
Expand All @@ -995,7 +995,7 @@ func (s *testSuite9) TestAutoRandomID(c *C) {
firstValue, err = strconv.Atoi(rs.Rows()[0][0].(string))
c.Assert(err, IsNil)
c.Assert(firstValue, Greater, 0)
tk.MustQuery(`select last_insert_id()`).Check(testkit.Rows(fmt.Sprintf("%d", firstValue)))
tk.MustQuery(`select last_insert_id()`).Check(testkit.Rows(strconv.Itoa(firstValue)))
tk.MustExec(`delete from ar`)

tk.MustExec(`insert into ar(name) values ('a')`)
Expand All @@ -1004,7 +1004,7 @@ func (s *testSuite9) TestAutoRandomID(c *C) {
firstValue, err = strconv.Atoi(rs.Rows()[0][0].(string))
c.Assert(err, IsNil)
c.Assert(firstValue, Greater, 0)
tk.MustQuery(`select last_insert_id()`).Check(testkit.Rows(fmt.Sprintf("%d", firstValue)))
tk.MustQuery(`select last_insert_id()`).Check(testkit.Rows(strconv.Itoa(firstValue)))

tk.MustExec(`drop table ar`)
}
Expand All @@ -1029,9 +1029,9 @@ func (s *testSuite9) TestMultiAutoRandomID(c *C) {
firstValue, err := strconv.Atoi(rs.Rows()[0][0].(string))
c.Assert(err, IsNil)
c.Assert(firstValue, Greater, 0)
c.Assert(rs.Rows()[1][0].(string), Equals, fmt.Sprintf("%d", firstValue+1))
c.Assert(rs.Rows()[2][0].(string), Equals, fmt.Sprintf("%d", firstValue+2))
tk.MustQuery(`select last_insert_id()`).Check(testkit.Rows(fmt.Sprintf("%d", firstValue)))
c.Assert(rs.Rows()[1][0].(string), Equals, strconv.Itoa(firstValue+1))
c.Assert(rs.Rows()[2][0].(string), Equals, strconv.Itoa(firstValue+2))
tk.MustQuery(`select last_insert_id()`).Check(testkit.Rows(strconv.Itoa(firstValue)))
tk.MustExec(`delete from ar`)

tk.MustExec(`insert into ar(id) values (0),(0),(0)`)
Expand All @@ -1040,9 +1040,9 @@ func (s *testSuite9) TestMultiAutoRandomID(c *C) {
firstValue, err = strconv.Atoi(rs.Rows()[0][0].(string))
c.Assert(err, IsNil)
c.Assert(firstValue, Greater, 0)
c.Assert(rs.Rows()[1][0].(string), Equals, fmt.Sprintf("%d", firstValue+1))
c.Assert(rs.Rows()[2][0].(string), Equals, fmt.Sprintf("%d", firstValue+2))
tk.MustQuery(`select last_insert_id()`).Check(testkit.Rows(fmt.Sprintf("%d", firstValue)))
c.Assert(rs.Rows()[1][0].(string), Equals, strconv.Itoa(firstValue+1))
c.Assert(rs.Rows()[2][0].(string), Equals, strconv.Itoa(firstValue+2))
tk.MustQuery(`select last_insert_id()`).Check(testkit.Rows(strconv.Itoa(firstValue)))
tk.MustExec(`delete from ar`)

tk.MustExec(`insert into ar(name) values ('a'),('a'),('a')`)
Expand All @@ -1051,9 +1051,9 @@ func (s *testSuite9) TestMultiAutoRandomID(c *C) {
firstValue, err = strconv.Atoi(rs.Rows()[0][0].(string))
c.Assert(err, IsNil)
c.Assert(firstValue, Greater, 0)
c.Assert(rs.Rows()[1][0].(string), Equals, fmt.Sprintf("%d", firstValue+1))
c.Assert(rs.Rows()[2][0].(string), Equals, fmt.Sprintf("%d", firstValue+2))
tk.MustQuery(`select last_insert_id()`).Check(testkit.Rows(fmt.Sprintf("%d", firstValue)))
c.Assert(rs.Rows()[1][0].(string), Equals, strconv.Itoa(firstValue+1))
c.Assert(rs.Rows()[2][0].(string), Equals, strconv.Itoa(firstValue+2))
tk.MustQuery(`select last_insert_id()`).Check(testkit.Rows(strconv.Itoa(firstValue)))

tk.MustExec(`drop table ar`)
}
Expand Down Expand Up @@ -1082,7 +1082,7 @@ func (s *testSuite9) TestAutoRandomIDAllowZero(c *C) {
firstValue, err := strconv.Atoi(rs.Rows()[0][0].(string))
c.Assert(err, IsNil)
c.Assert(firstValue, Equals, 0)
tk.MustQuery(`select last_insert_id()`).Check(testkit.Rows(fmt.Sprintf("%d", firstValue)))
tk.MustQuery(`select last_insert_id()`).Check(testkit.Rows(strconv.Itoa(firstValue)))
tk.MustExec(`delete from ar`)

tk.MustExec(`insert into ar(id) values (null)`)
Expand All @@ -1091,7 +1091,7 @@ func (s *testSuite9) TestAutoRandomIDAllowZero(c *C) {
firstValue, err = strconv.Atoi(rs.Rows()[0][0].(string))
c.Assert(err, IsNil)
c.Assert(firstValue, Greater, 0)
tk.MustQuery(`select last_insert_id()`).Check(testkit.Rows(fmt.Sprintf("%d", firstValue)))
tk.MustQuery(`select last_insert_id()`).Check(testkit.Rows(strconv.Itoa(firstValue)))

tk.MustExec(`drop table ar`)
}
Expand Down
3 changes: 2 additions & 1 deletion executor/join_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"context"
"fmt"
"math/rand"
"strconv"
"time"

. "github.com/pingcap/check"
Expand Down Expand Up @@ -1245,7 +1246,7 @@ func (s *testSuiteJoinSerial) TestIndexNestedLoopHashJoin(c *C) {
))
rs := tk.MustQuery("select /*+ INL_HASH_JOIN(s) */ * from t left join s on t.a=s.a order by t.pk")
for i, row := range rs.Rows() {
c.Assert(row[0].(string), Equals, fmt.Sprintf("%d", i))
c.Assert(row[0].(string), Equals, strconv.Itoa(i))
}

// index hash join with semi join
Expand Down
2 changes: 1 addition & 1 deletion executor/reload_expr_pushdown_blacklist.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ var funcName2Alias = map[string]string{
"is_ipv4_mapped": ast.IsIPv4Mapped,
"is_ipv6": ast.IsIPv6,
"is_used_lock": ast.IsUsedLock,
"main_pos_wait": ast.MainPosWait,
"main_pos_wait": ast.MainPosWait,
"name_const": ast.NameConst,
"release_all_locks": ast.ReleaseAllLocks,
"sleep": ast.Sleep,
Expand Down
2 changes: 1 addition & 1 deletion expression/builtin.go
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@ var funcs = map[string]functionClass{
ast.IsIPv4Mapped: &isIPv4MappedFunctionClass{baseFunctionClass{ast.IsIPv4Mapped, 1, 1}},
ast.IsIPv6: &isIPv6FunctionClass{baseFunctionClass{ast.IsIPv6, 1, 1}},
ast.IsUsedLock: &isUsedLockFunctionClass{baseFunctionClass{ast.IsUsedLock, 1, 1}},
ast.MainPosWait: &mainPosWaitFunctionClass{baseFunctionClass{ast.MainPosWait, 2, 4}},
ast.MainPosWait: &mainPosWaitFunctionClass{baseFunctionClass{ast.MainPosWait, 2, 4}},
ast.NameConst: &nameConstFunctionClass{baseFunctionClass{ast.NameConst, 2, 2}},
ast.ReleaseAllLocks: &releaseAllLocksFunctionClass{baseFunctionClass{ast.ReleaseAllLocks, 0, 0}},
ast.UUID: &uuidFunctionClass{baseFunctionClass{ast.UUID, 0, 0}},
Expand Down
2 changes: 1 addition & 1 deletion expression/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"github.com/pingcap/parser/terror"
"github.com/pingcap/tidb/sessionctx"
"github.com/pingcap/tidb/types"
"github.com/pingcap/tidb/types/parser_driver"
driver "github.com/pingcap/tidb/types/parser_driver"
"github.com/pingcap/tidb/util/chunk"
"github.com/pingcap/tidb/util/collate"
"github.com/pingcap/tidb/util/logutil"
Expand Down
5 changes: 3 additions & 2 deletions infoschema/perfschema/tables.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"fmt"
"net/http"
"sort"
"strconv"
"strings"
"sync"
"time"
Expand Down Expand Up @@ -203,10 +204,10 @@ func (vt *perfSchemaTable) getRows(ctx sessionctx.Context, cols []*table.Column)
case tableNameTiDBProfileGoroutines:
fullRows, err = (&profile.Collector{}).ProfileGraph("goroutine")
case tableNameTiKVProfileCPU:
interval := fmt.Sprintf("%d", profile.CPUProfileInterval/time.Second)
interval := strconv.Itoa(profile.CPUProfileInterval / time.Second)
fullRows, err = dataForRemoteProfile(ctx, "tikv", "/debug/pprof/profile?seconds="+interval, false)
case tableNamePDProfileCPU:
interval := fmt.Sprintf("%d", profile.CPUProfileInterval/time.Second)
interval := strconv.Itoa(profile.CPUProfileInterval / time.Second)
fullRows, err = dataForRemoteProfile(ctx, "pd", "/pd/api/v1/debug/pprof/profile?seconds="+interval, false)
case tableNamePDProfileMemory:
fullRows, err = dataForRemoteProfile(ctx, "pd", "/pd/api/v1/debug/pprof/heap", false)
Expand Down
2 changes: 1 addition & 1 deletion meta/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,7 @@ func (m *Meta) GetBootstrapVersion() (int64, error) {

// FinishBootstrap finishes bootstrap.
func (m *Meta) FinishBootstrap(version int64) error {
err := m.txn.Set(mBootstrapKey, []byte(fmt.Sprintf("%d", version)))
err := m.txn.Set(mBootstrapKey, []byte(strconv.Itoa(version)))
return errors.Trace(err)
}

Expand Down
2 changes: 1 addition & 1 deletion planner/core/cacheable_checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"github.com/pingcap/parser/ast"
"github.com/pingcap/tidb/expression"
"github.com/pingcap/tidb/infoschema"
"github.com/pingcap/tidb/types/parser_driver"
driver "github.com/pingcap/tidb/types/parser_driver"
"github.com/pingcap/tidb/util/logutil"
"go.uber.org/zap"
)
Expand Down
2 changes: 1 addition & 1 deletion planner/core/cacheable_checker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"github.com/pingcap/tidb/expression"
"github.com/pingcap/tidb/infoschema"
"github.com/pingcap/tidb/planner/core"
"github.com/pingcap/tidb/types/parser_driver"
driver "github.com/pingcap/tidb/types/parser_driver"
"github.com/pingcap/tidb/util/testkit"
)

Expand Down
2 changes: 1 addition & 1 deletion planner/core/point_get_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
"github.com/pingcap/tidb/sessionctx"
"github.com/pingcap/tidb/sessionctx/stmtctx"
"github.com/pingcap/tidb/types"
"github.com/pingcap/tidb/types/parser_driver"
driver "github.com/pingcap/tidb/types/parser_driver"
"github.com/pingcap/tidb/util/math"
"github.com/pingcap/tidb/util/plancodec"
"github.com/pingcap/tipb/go-tipb"
Expand Down
5 changes: 3 additions & 2 deletions session/bootstrap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package session
import (
"context"
"fmt"
"strconv"

. "github.com/pingcap/check"
"github.com/pingcap/parser"
Expand Down Expand Up @@ -208,7 +209,7 @@ func (s *testBootstrapSuite) TestUpgrade(c *C) {
c.Assert(err, IsNil)
c.Assert(req.NumRows() == 0, IsFalse)
c.Assert(row.Len(), Equals, 1)
c.Assert(row.GetBytes(0), BytesEquals, []byte(fmt.Sprintf("%d", currentBootstrapVersion)))
c.Assert(row.GetBytes(0), BytesEquals, []byte(strconv.Itoa(currentBootstrapVersion)))
c.Assert(r.Close(), IsNil)

se1 := newSession(c, store, s.dbName)
Expand Down Expand Up @@ -254,7 +255,7 @@ func (s *testBootstrapSuite) TestUpgrade(c *C) {
c.Assert(req.NumRows() == 0, IsFalse)
row = req.GetRow(0)
c.Assert(row.Len(), Equals, 1)
c.Assert(row.GetBytes(0), BytesEquals, []byte(fmt.Sprintf("%d", currentBootstrapVersion)))
c.Assert(row.GetBytes(0), BytesEquals, []byte(strconv.Itoa(currentBootstrapVersion)))
c.Assert(r.Close(), IsNil)

ver, err = getBootstrapVersion(se2)
Expand Down
17 changes: 8 additions & 9 deletions sessionctx/variable/varsutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ package variable

import (
"encoding/json"
"fmt"
"math"
"strconv"
"strings"
Expand Down Expand Up @@ -114,17 +113,17 @@ func GetSessionOnlySysVars(s *SessionVars, key string) (string, bool, error) {
// For virtual system variables:
switch sysVar.Name {
case TiDBCurrentTS:
return fmt.Sprintf("%d", s.TxnCtx.StartTS), true, nil
return strconv.Itoa(s.TxnCtx.StartTS), true, nil
case TiDBGeneralLog:
return fmt.Sprintf("%d", atomic.LoadUint32(&ProcessGeneralLog)), true, nil
return strconv.Itoa(atomic.LoadUint32(&ProcessGeneralLog)), true, nil
case TiDBPProfSQLCPU:
val := "0"
if EnablePProfSQLCPU.Load() {
val = "1"
}
return val, true, nil
case TiDBExpensiveQueryTimeThreshold:
return fmt.Sprintf("%d", atomic.LoadUint64(&ExpensiveQueryTimeThreshold)), true, nil
return strconv.Itoa(atomic.LoadUint64(&ExpensiveQueryTimeThreshold)), true, nil
case TiDBConfig:
conf := config.GetGlobalConfig()
j, err := json.MarshalIndent(conf, "", "\t")
Expand Down Expand Up @@ -249,19 +248,19 @@ func checkUInt64SystemVar(name, value string, min, max uint64, vars *SessionVars
return value, ErrWrongTypeForVar.GenWithStackByArgs(name)
}
vars.StmtCtx.AppendWarning(ErrTruncatedWrongValue.GenWithStackByArgs(name, value))
return fmt.Sprintf("%d", min), nil
return strconv.Itoa(min), nil
}
val, err := strconv.ParseUint(value, 10, 64)
if err != nil {
return value, ErrWrongTypeForVar.GenWithStackByArgs(name)
}
if val < min {
vars.StmtCtx.AppendWarning(ErrTruncatedWrongValue.GenWithStackByArgs(name, value))
return fmt.Sprintf("%d", min), nil
return strconv.Itoa(min), nil
}
if val > max {
vars.StmtCtx.AppendWarning(ErrTruncatedWrongValue.GenWithStackByArgs(name, value))
return fmt.Sprintf("%d", max), nil
return strconv.Itoa(max), nil
}
return value, nil
}
Expand All @@ -273,11 +272,11 @@ func checkInt64SystemVar(name, value string, min, max int64, vars *SessionVars)
}
if val < min {
vars.StmtCtx.AppendWarning(ErrTruncatedWrongValue.GenWithStackByArgs(name, value))
return fmt.Sprintf("%d", min), nil
return strconv.Itoa(min), nil
}
if val > max {
vars.StmtCtx.AppendWarning(ErrTruncatedWrongValue.GenWithStackByArgs(name, value))
return fmt.Sprintf("%d", max), nil
return strconv.Itoa(max), nil
}
return value, nil
}
Expand Down
4 changes: 2 additions & 2 deletions statistics/handle/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ package handle

import (
"context"
"fmt"
"strconv"

"github.com/cznic/mathutil"
"github.com/pingcap/errors"
Expand Down Expand Up @@ -338,5 +338,5 @@ func getFullTableName(is infoschema.InfoSchema, tblInfo *model.TableInfo) string
}
}
}
return fmt.Sprintf("%d", tblInfo.ID)
return strconv.Itoa(tblInfo.ID)
}
1 change: 0 additions & 1 deletion store/mockstore/mocktikv/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ package mocktikv

import (
"github.com/pingcap/errors"
"github.com/pingcap/pd/v4/client"
)

// NewTiKVAndPDClient creates a TiKV client and PD client from options.
Expand Down
1 change: 0 additions & 1 deletion store/mockstore/mocktikv/pd.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"github.com/pingcap/errors"
"github.com/pingcap/kvproto/pkg/metapb"
"github.com/pingcap/kvproto/pkg/pdpb"
"github.com/pingcap/pd/v4/client"
)

// Use global variables to prevent pdClients from creating duplicate timestamps.
Expand Down
2 changes: 1 addition & 1 deletion store/tikv/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ package tikv
import (
"time"

"github.com/pingcap/pd/v4/client"
pd "github.com/pingcap/pd/v4/client"
"github.com/pingcap/tidb/kv"
"github.com/pingcap/tidb/store/tikv/oracle"
"github.com/pingcap/tidb/store/tikv/tikvrpc"
Expand Down
Loading