diff --git a/cmd/importer/db.go b/cmd/importer/db.go index d397da2a7..fc103741c 100644 --- a/cmd/importer/db.go +++ b/cmd/importer/db.go @@ -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 { diff --git a/ddl/partition.go b/ddl/partition.go index 8292c3ccb..d3ca9b508 100644 --- a/ddl/partition.go +++ b/ddl/partition.go @@ -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 { diff --git a/ddl/util/syncer_test.go b/ddl/util/syncer_test.go index a71ed0a13..d175f7d80 100644 --- a/ddl/util/syncer_test.go +++ b/ddl/util/syncer_test.go @@ -17,6 +17,7 @@ package util_test import ( "context" "fmt" + "strconv" "sync" "testing" "time" @@ -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) diff --git a/errno/errname.go b/errno/errname.go index 7daf7818c..83a824835 100644 --- a/errno/errname.go +++ b/errno/errname.go @@ -201,11 +201,11 @@ var MySQLErrName = map[uint16]string{ ErrErrorDuringCheckpoint: "Got error %d during CHECKPOINT", ErrNewAbortingConnection: "Aborted connection %d to db: '%-.192s' user: '%-.48s' host: '%-.64s' (%-.64s)", ErrDumpNotImplemented: "The storage engine for the table does not support binary table dump", - ErrFlushMainBinlogClosed: "Binlog closed, cannot RESET MASTER", + ErrFlushMainBinlogClosed: "Binlog closed, cannot RESET MASTER", ErrIndexRebuild: "Failed rebuilding the index of dumped table '%-.192s'", - ErrMain: "Error from main: '%-.64s'", - ErrMainNetRead: "Net error reading from main", - ErrMainNetWrite: "Net error writing to main", + ErrMain: "Error from main: '%-.64s'", + ErrMainNetRead: "Net error reading from main", + ErrMainNetWrite: "Net error writing to main", ErrFtMatchingKeyNotFound: "Can't find FULLTEXT index matching the column list", ErrLockOrActiveTransaction: "Can't execute the given command because you have active locked tables or an active transaction", ErrUnknownSystemVariable: "Unknown system variable '%-.64s'", @@ -213,11 +213,11 @@ var MySQLErrName = map[uint16]string{ ErrCrashedOnRepair: "Table '%-.192s' is marked as crashed and last (automatic?) repair failed", ErrWarningNotCompleteRollback: "Some non-transactional changed tables couldn't be rolled back", ErrTransCacheFull: "Multi-statement transaction required more than 'maxBinlogCacheSize' bytes of storage; increase this mysqld variable and try again", - ErrSubordinateMustStop: "This operation cannot be performed with a running subordinate; run STOP SLAVE first", - ErrSubordinateNotRunning: "This operation requires a running subordinate; configure subordinate and do START SLAVE", - ErrBadSubordinate: "The server is not configured as subordinate; fix in config file or with CHANGE MASTER TO", - ErrMainInfo: "Could not initialize main info structure; more error messages can be found in the MySQL error log", - ErrSubordinateThread: "Could not create subordinate thread; check system resources", + ErrSubordinateMustStop: "This operation cannot be performed with a running subordinate; run STOP SLAVE first", + ErrSubordinateNotRunning: "This operation requires a running subordinate; configure subordinate and do START SLAVE", + ErrBadSubordinate: "The server is not configured as subordinate; fix in config file or with CHANGE MASTER TO", + ErrMainInfo: "Could not initialize main info structure; more error messages can be found in the MySQL error log", + ErrSubordinateThread: "Could not create subordinate thread; check system resources", ErrTooManyUserConnections: "User %-.64s already has more than 'maxUserConnections' active connections", ErrSetConstantsOnly: "You may only use constant expressions with SET", ErrLockWaitTimeout: "Lock wait timeout exceeded; try restarting transaction", @@ -233,8 +233,8 @@ var MySQLErrName = map[uint16]string{ ErrCannotAddForeign: "Cannot add foreign key constraint", ErrNoReferencedRow: "Cannot add or update a child row: a foreign key constraint fails", ErrRowIsReferenced: "Cannot delete or update a parent row: a foreign key constraint fails", - ErrConnectToMain: "Error connecting to main: %-.128s", - ErrQueryOnMain: "Error running query on main: %-.128s", + ErrConnectToMain: "Error connecting to main: %-.128s", + ErrQueryOnMain: "Error running query on main: %-.128s", ErrErrorWhenExecutingCommand: "Error when executing command %s: %-.128s", ErrWrongUsage: "Incorrect usage of %s and %s", ErrWrongNumberOfColumnsInSelect: "The used SELECT statements have a different number of columns", @@ -251,8 +251,8 @@ var MySQLErrName = map[uint16]string{ ErrVarCantBeRead: "Variable '%-.64s' can only be set, not read", ErrCantUseOptionHere: "Incorrect usage/placement of '%s'", ErrNotSupportedYet: "This version of TiDB doesn't yet support '%s'", - ErrMainFatalErrorReadingBinlog: "Got fatal error %d from main when reading data from binary log: '%-.320s'", - ErrSubordinateIgnoredTable: "Subordinate SQL thread ignored the query because of replicate-*-table rules", + ErrMainFatalErrorReadingBinlog: "Got fatal error %d from main when reading data from binary log: '%-.320s'", + ErrSubordinateIgnoredTable: "Subordinate SQL thread ignored the query because of replicate-*-table rules", ErrIncorrectGlobalLocalVar: "Variable '%-.192s' is a %s variable", ErrWrongFkDef: "Incorrect foreign key definition for '%-.192s': %s", ErrKeyRefDoNotMatchTableRef: "Key reference and table reference don't match", @@ -269,8 +269,8 @@ var MySQLErrName = map[uint16]string{ ErrNotSupportedAuthMode: "Client does not support authentication protocol requested by server; consider upgrading MySQL client", ErrSpatialCantHaveNull: "All parts of a SPATIAL index must be NOT NULL", ErrCollationCharsetMismatch: "COLLATION '%s' is not valid for CHARACTER SET '%s'", - ErrSubordinateWasRunning: "Subordinate is already running", - ErrSubordinateWasNotRunning: "Subordinate already has been stopped", + ErrSubordinateWasRunning: "Subordinate is already running", + ErrSubordinateWasNotRunning: "Subordinate already has been stopped", ErrTooBigForUncompress: "Uncompressed data size too large; the maximum size is %d (probably, length of uncompressed data was corrupted)", ErrZlibZMem: "ZLIB: Not enough memory", ErrZlibZBuf: "ZLIB: Not enough room in the output buffer (probably, length of uncompressed data was corrupted)", @@ -289,11 +289,11 @@ var MySQLErrName = map[uint16]string{ ErrCantAggregateNcollations: "Illegal mix of collations for operation '%s'", ErrVariableIsNotStruct: "Variable '%-.64s' is not a variable component (can't be used as XXXX.variableName)", ErrUnknownCollation: "Unknown collation: '%-.64s'", - ErrSubordinateIgnoredSslParams: "SSL parameters in CHANGE MASTER are ignored because this MySQL subordinate was compiled without SSL support; they can be used later if MySQL subordinate with SSL is started", + ErrSubordinateIgnoredSslParams: "SSL parameters in CHANGE MASTER are ignored because this MySQL subordinate was compiled without SSL support; they can be used later if MySQL subordinate with SSL is started", ErrServerIsInSecureAuthMode: "Server is running in --secure-auth mode, but '%s'@'%s' has a password in the old format; please change the password to the new format", ErrWarnFieldResolved: "Field or reference '%-.192s%s%-.192s%s%-.192s' of SELECT #%d was resolved in SELECT #%d", - ErrBadSubordinateUntilCond: "Incorrect parameter or combination of parameters for START SLAVE UNTIL", - ErrMissingSkipSubordinate: "It is recommended to use --skip-subordinate-start when doing step-by-step replication with START SLAVE UNTIL; otherwise, you will get problems if you get an unexpected subordinate's mysqld restart", + ErrBadSubordinateUntilCond: "Incorrect parameter or combination of parameters for START SLAVE UNTIL", + ErrMissingSkipSubordinate: "It is recommended to use --skip-subordinate-start when doing step-by-step replication with START SLAVE UNTIL; otherwise, you will get problems if you get an unexpected subordinate's mysqld restart", ErrUntilCondIgnored: "SQL thread is not to be started so UNTIL options are ignored", ErrWrongNameForIndex: "Incorrect index name '%-.100s'", ErrWrongNameForCatalog: "Incorrect catalog name '%-.100s'", @@ -605,14 +605,14 @@ var MySQLErrName = map[uint16]string{ ErrBinlogPurgeEmFile: "Too many files opened, please execute the command again", ErrEventCannotCreateInThePast: "Event execution time is in the past and ON COMPLETION NOT PRESERVE is set. The event was dropped immediately after creation.", ErrEventCannotAlterInThePast: "Event execution time is in the past and ON COMPLETION NOT PRESERVE is set. The event was not changed. Specify a time in the future.", - ErrSubordinateIncident: "The incident %s occurred on the main. Message: %-.64s", + ErrSubordinateIncident: "The incident %s occurred on the main. Message: %-.64s", ErrNoPartitionForGivenValueSilent: "Table has no partition for some existing values", ErrBinlogUnsafeStatement: "Unsafe statement written to the binary log using statement format since BINLOGFORMAT = STATEMENT. %s", - ErrSubordinateFatal: "Fatal : %s", - ErrSubordinateRelayLogReadFailure: "Relay log read failure: %s", - ErrSubordinateRelayLogWriteFailure: "Relay log write failure: %s", - ErrSubordinateCreateEventFailure: "Failed to create %s", - ErrSubordinateMainComFailure: "Main command %s failed: %s", + ErrSubordinateFatal: "Fatal : %s", + ErrSubordinateRelayLogReadFailure: "Relay log read failure: %s", + ErrSubordinateRelayLogWriteFailure: "Relay log write failure: %s", + ErrSubordinateCreateEventFailure: "Failed to create %s", + ErrSubordinateMainComFailure: "Main command %s failed: %s", ErrBinlogLoggingImpossible: "Binary logging not possible. Message: %s", ErrViewNoCreationCtx: "View `%-.64s`.`%-.64s` has no creation context", ErrViewInvalidCreationCtx: "Creation context of view `%-.64s`.`%-.64s' is invalid", @@ -625,21 +625,21 @@ var MySQLErrName = map[uint16]string{ ErrCantCreateSroutine: "Cannot create stored routine `%-.64s`. Check warnings", ErrNeverUsed: "Ambiguous subordinate modes combination. %s", ErrNoFormatDescriptionEventBeforeBinlogStatement: "The BINLOG statement of type `%s` was not preceded by a format description BINLOG statement.", - ErrSubordinateCorruptEvent: "Corrupted replication event was detected", + ErrSubordinateCorruptEvent: "Corrupted replication event was detected", ErrLoadDataInvalidColumn: "Invalid column reference (%-.64s) in LOAD DATA", ErrLogPurgeNoFile: "Being purged log %s was not found", ErrXaRbtimeout: "XARBTIMEOUT: Transaction branch was rolled back: took too long", ErrXaRbdeadlock: "XARBDEADLOCK: Transaction branch was rolled back: deadlock was detected", ErrNeedReprepare: "Prepared statement needs to be re-prepared", ErrDelayedNotSupported: "DELAYED option not supported for table '%-.192s'", - WarnNoMainInfo: "The main info structure does not exist", + WarnNoMainInfo: "The main info structure does not exist", WarnOptionIgnored: "<%-.64s> option ignored", WarnPluginDeleteBuiltin: "Built-in plugins cannot be deleted", WarnPluginBusy: "Plugin is busy and will be uninstalled on shutdown", ErrVariableIsReadonly: "%s variable '%s' is read-only. Use SET %s to assign the value", ErrWarnEngineTransactionRollback: "Storage engine %s does not support rollback for this statement. Transaction rolled back and must be restarted", - ErrSubordinateHeartbeatFailure: "Unexpected main's heartbeat data: %s", - ErrSubordinateHeartbeatValueOutOfRange: "The requested value for the heartbeat period is either negative or exceeds the maximum allowed (%s seconds).", + ErrSubordinateHeartbeatFailure: "Unexpected main's heartbeat data: %s", + ErrSubordinateHeartbeatValueOutOfRange: "The requested value for the heartbeat period is either negative or exceeds the maximum allowed (%s seconds).", ErrNdbReplicationSchema: "Bad schema for mysql.ndbReplication table. Message: %-.64s", ErrConflictFnParse: "Error in parsing conflict function. Message: %-.64s", ErrExceptionsWrite: "Write to exceptions table failed. Message: %-.128s\"", @@ -665,7 +665,7 @@ var MySQLErrName = map[uint16]string{ WarnCondItemTruncated: "Data truncated for condition item '%s'", ErrCondItemTooLong: "Data too long for condition item '%s'", ErrUnknownLocale: "Unknown locale: '%-.64s'", - ErrSubordinateIgnoreServerIds: "The requested server id %d clashes with the subordinate startup option --replicate-same-server-id", + ErrSubordinateIgnoreServerIds: "The requested server id %d clashes with the subordinate startup option --replicate-same-server-id", ErrQueryCacheDisabled: "Query cache is disabled; restart the server with queryCacheType=1 to enable it", ErrSameNamePartitionField: "Duplicate partition field name '%-.192s'", ErrPartitionColumnList: "Inconsistency in usage of column lists for partitioning", @@ -692,8 +692,8 @@ var MySQLErrName = map[uint16]string{ ErrBinlogUnsafeSystemFunction: "Statement is unsafe because it uses a system function that may return a different value on the subordinate.", ErrBinlogUnsafeNontransAfterTrans: "Statement is unsafe because it accesses a non-transactional table after accessing a transactional table within the same transaction.", ErrMessageAndStatement: "%s Statement: %s", - ErrSubordinateConversionFailed: "Column %d of table '%-.192s.%-.192s' cannot be converted from type '%-.32s' to type '%-.32s'", - ErrSubordinateCantCreateConversion: "Can't create conversion table for table '%-.192s.%-.192s'", + ErrSubordinateConversionFailed: "Column %d of table '%-.192s.%-.192s' cannot be converted from type '%-.32s' to type '%-.32s'", + ErrSubordinateCantCreateConversion: "Can't create conversion table for table '%-.192s.%-.192s'", ErrInsideTransactionPreventsSwitchBinlogFormat: "Cannot modify @@session.binlogFormat inside a transaction", ErrPathLength: "The path specified for %.64s is too long.", ErrWarnDeprecatedSyntaxNoReplacement: "'%s' is deprecated and will be removed in a future release.", @@ -718,8 +718,8 @@ var MySQLErrName = map[uint16]string{ ErrGrantPluginUserExists: "GRANT with IDENTIFIED WITH is illegal because the user %-.*s already exists", ErrTruncateIllegalFk: "Cannot truncate a table referenced in a foreign key constraint (%.192s)", ErrPluginIsPermanent: "Plugin '%s' is forcePlusPermanent and can not be unloaded", - ErrSubordinateHeartbeatValueOutOfRangeMin: "The requested value for the heartbeat period is less than 1 millisecond. The value is reset to 0, meaning that heartbeating will effectively be disabled.", - ErrSubordinateHeartbeatValueOutOfRangeMax: "The requested value for the heartbeat period exceeds the value of `subordinateNetTimeout' seconds. A sensible value for the period should be less than the timeout.", + ErrSubordinateHeartbeatValueOutOfRangeMin: "The requested value for the heartbeat period is less than 1 millisecond. The value is reset to 0, meaning that heartbeating will effectively be disabled.", + ErrSubordinateHeartbeatValueOutOfRangeMax: "The requested value for the heartbeat period exceeds the value of `subordinateNetTimeout' seconds. A sensible value for the period should be less than the timeout.", ErrStmtCacheFull: "Multi-row statements required more than 'maxBinlogStmtCacheSize' bytes of storage; increase this mysqld variable and try again", ErrMultiUpdateKeyConflict: "Primary key/partition key update is not allowed since the table is updated both as '%-.192s' and '%-.192s'.", ErrTableNeedsRebuild: "Table rebuild required. Please do \"ALTER TABLE `%-.32s` FORCE\" or dump/reload to fix it!", @@ -744,7 +744,7 @@ var MySQLErrName = map[uint16]string{ ErrUnsupportedEngine: "Storage engine '%s' does not support system tables. [%s.%s]", ErrBinlogUnsafeAutoincNotFirst: "INSERT into autoincrement field which is not the first part in the composed primary key is unsafe.", ErrCannotLoadFromTableV2: "Cannot load from %s.%s. The table is probably corrupted", - ErrMainDelayValueOutOfRange: "The requested value %d for the main delay exceeds the maximum %d", + ErrMainDelayValueOutOfRange: "The requested value %d for the main delay exceeds the maximum %d", ErrOnlyFdAndRbrEventsAllowedInBinlogStatement: "Only FormatDescriptionLogEvent and row events are allowed in BINLOG statements (but %s was provided)", ErrPartitionExchangeDifferentOption: "Non matching attribute '%-.64s' between partition and table", ErrPartitionExchangePartTable: "Table to exchange with partition is partitioned: '%-.64s'", @@ -775,10 +775,10 @@ var MySQLErrName = map[uint16]string{ ErrFulltextNotSupportedWithPartitioning: "FULLTEXT index is not supported for partitioned tables.", ErrDaInvalidConditionNumber: "Invalid condition number", ErrInsecurePlainText: "Sending passwords in plain text without SSL/TLS is extremely insecure.", - ErrInsecureChangeMain: "Storing MySQL user name or password information in the main.info repository is not secure and is therefore not recommended. Please see the MySQL Manual for more about this issue and possible alternatives.", + ErrInsecureChangeMain: "Storing MySQL user name or password information in the main.info repository is not secure and is therefore not recommended. Please see the MySQL Manual for more about this issue and possible alternatives.", ErrForeignDuplicateKeyWithChildInfo: "Foreign key constraint for table '%.192s', record '%-.192s' would lead to a duplicate entry in table '%.192s', key '%.192s'", ErrForeignDuplicateKeyWithoutChildInfo: "Foreign key constraint for table '%.192s', record '%-.192s' would lead to a duplicate entry in a child table", - ErrSQLthreadWithSecureSubordinate: "Setting authentication options is not possible when only the Subordinate SQL Thread is being started.", + ErrSQLthreadWithSecureSubordinate: "Setting authentication options is not possible when only the Subordinate SQL Thread is being started.", ErrTableHasNoFt: "The table does not have FULLTEXT index to support this query", ErrVariableNotSettableInSfOrTrigger: "The system variable %.200s cannot be set in stored functions or triggers.", ErrVariableNotSettableInTransaction: "The system variable %.200s cannot be set when there is an ongoing transaction.", @@ -791,7 +791,7 @@ var MySQLErrName = map[uint16]string{ ErrMalformedGtidSetEncoding: "Malformed GTID set encoding.", ErrMalformedGtidSpecification: "Malformed GTID specification '%.200s'.", ErrGnoExhausted: "Impossible to generate Global Transaction Identifier: the integer component reached the maximal value. Restart the server with a new serverUuid.", - ErrBadSubordinateAutoPosition: "Parameters MASTERLOGFILE, MASTERLOGPOS, RELAYLOGFILE and RELAYLOGPOS cannot be set when MASTERAUTOPOSITION is active.", + ErrBadSubordinateAutoPosition: "Parameters MASTERLOGFILE, MASTERLOGPOS, RELAYLOGFILE and RELAYLOGPOS cannot be set when MASTERAUTOPOSITION is active.", ErrAutoPositionRequiresGtidModeOn: "CHANGE MASTER TO MASTERAUTOPOSITION = 1 can only be executed when @@GLOBAL.GTIDMODE = ON.", ErrCantDoImplicitCommitInTrxWhenGtidNextIsSet: "Cannot execute statements with implicit commit inside a transaction when @@SESSION.GTIDNEXT != AUTOMATIC or @@SESSION.GTIDNEXTLIST != NULL.", ErrGtidMode2Or3RequiresEnforceGtidConsistencyOn: "@@GLOBAL.GTIDMODE = ON or UPGRADESTEP2 requires @@GLOBAL.ENFORCEGTIDCONSISTENCY = 1.", @@ -804,12 +804,12 @@ var MySQLErrName = map[uint16]string{ ErrGtidUnsafeCreateSelect: "CREATE TABLE ... SELECT is forbidden when @@GLOBAL.ENFORCEGTIDCONSISTENCY = 1.", ErrGtidUnsafeCreateDropTemporaryTableInTransaction: "When @@GLOBAL.ENFORCEGTIDCONSISTENCY = 1, the statements CREATE TEMPORARY TABLE and DROP TEMPORARY TABLE can be executed in a non-transactional context only, and require that AUTOCOMMIT = 1.", ErrGtidModeCanOnlyChangeOneStepAtATime: "The value of @@GLOBAL.GTIDMODE can only change one step at a time: OFF <-> UPGRADESTEP1 <-> UPGRADESTEP2 <-> ON. Also note that this value must be stepped up or down simultaneously on all servers; see the Manual for instructions.", - ErrMainHasPurgedRequiredGtids: "The subordinate is connecting using CHANGE MASTER TO MASTERAUTOPOSITION = 1, but the main has purged binary logs containing GTIDs that the subordinate requires.", + ErrMainHasPurgedRequiredGtids: "The subordinate is connecting using CHANGE MASTER TO MASTERAUTOPOSITION = 1, but the main has purged binary logs containing GTIDs that the subordinate requires.", ErrCantSetGtidNextWhenOwningGtid: "@@SESSION.GTIDNEXT cannot be changed by a client that owns a GTID. The client owns %s. Ownership is released on COMMIT or ROLLBACK.", ErrUnknownExplainFormat: "Unknown EXPLAIN format name: '%s'", ErrCantExecuteInReadOnlyTransaction: "Cannot execute statement in a READ ONLY transaction.", ErrTooLongTablePartitionComment: "Comment for table partition '%-.64s' is too long (max = %d)", - ErrSubordinateConfiguration: "Subordinate is not configured or failed to initialize properly. You must at least set --server-id to enable either a main or a subordinate. Additional error messages can be found in the MySQL error log.", + ErrSubordinateConfiguration: "Subordinate is not configured or failed to initialize properly. You must at least set --server-id to enable either a main or a subordinate. Additional error messages can be found in the MySQL error log.", ErrInnodbFtLimit: "InnoDB presently supports one FULLTEXT index creation at a time", ErrInnodbNoFtTempTable: "Cannot create FULLTEXT index on temporary InnoDB table", ErrInnodbFtWrongDocidColumn: "Column '%-.192s' is of wrong type for an InnoDB FULLTEXT index", @@ -817,11 +817,11 @@ var MySQLErrName = map[uint16]string{ ErrInnodbOnlineLogTooBig: "Creating index '%-.192s' required more than 'innodbOnlineAlterLogMaxSize' bytes of modification log. Please try again.", ErrUnknownAlterAlgorithm: "Unknown ALGORITHM '%s'", ErrUnknownAlterLock: "Unknown LOCK type '%s'", - ErrMtsChangeMainCantRunWithGaps: "CHANGE MASTER cannot be executed when the subordinate was stopped with an error or killed in MTS mode. Consider using RESET SLAVE or START SLAVE UNTIL.", + ErrMtsChangeMainCantRunWithGaps: "CHANGE MASTER cannot be executed when the subordinate was stopped with an error or killed in MTS mode. Consider using RESET SLAVE or START SLAVE UNTIL.", ErrMtsRecoveryFailure: "Cannot recover after SLAVE errored out in parallel execution mode. Additional error messages can be found in the MySQL error log.", ErrMtsResetWorkers: "Cannot clean up worker info tables. Additional error messages can be found in the MySQL error log.", ErrColCountDoesntMatchCorruptedV2: "Column count of %s.%s is wrong. Expected %d, found %d. The table is probably corrupted", - ErrSubordinateSilentRetryTransaction: "Subordinate must silently retry current transaction", + ErrSubordinateSilentRetryTransaction: "Subordinate must silently retry current transaction", ErrDiscardFkChecksRunning: "There is a foreign key check running on table '%-.192s'. Cannot discard the table.", ErrTableSchemaMismatch: "Schema mismatch (%s)", ErrTableInSystemTablespace: "Table '%-.192s' in system tablespace", @@ -873,7 +873,7 @@ var MySQLErrName = map[uint16]string{ ErrAlterOperationNotSupportedReasonHiddenFts: "Cannot replace hidden FTSDOCID with a user-visible one", ErrAlterOperationNotSupportedReasonChangeFts: "Cannot drop or rename FTSDOCID", ErrAlterOperationNotSupportedReasonFts: "Fulltext index creation requires a lock", - ErrSQLSubordinateSkipCounterNotSettableInGtidMode: "sqlSubordinateSkipCounter can not be set when the server is running with @@GLOBAL.GTIDMODE = ON. Instead, for each transaction that you want to skip, generate an empty transaction with the same GTID as the transaction", + ErrSQLSubordinateSkipCounterNotSettableInGtidMode: "sqlSubordinateSkipCounter can not be set when the server is running with @@GLOBAL.GTIDMODE = ON. Instead, for each transaction that you want to skip, generate an empty transaction with the same GTID as the transaction", ErrDupUnknownInIndex: "Duplicate entry for key '%-.192s'", ErrIdentCausesTooLongPath: "Long database name and identifier for object resulted in path length exceeding %d characters. Path: '%s'.", ErrAlterOperationNotSupportedReasonNotNull: "cannot silently convert NULL values, as required in this SQLMODE", diff --git a/executor/aggfuncs/aggfunc_test.go b/executor/aggfuncs/aggfunc_test.go index 3a995be8f..c8e90ac71 100644 --- a/executor/aggfuncs/aggfunc_test.go +++ b/executor/aggfuncs/aggfunc_test.go @@ -15,6 +15,7 @@ package aggfuncs_test import ( "fmt" + "strconv" "testing" "time" @@ -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: diff --git a/executor/executor.go b/executor/executor.go index b196f55a6..4586aaed5 100644 --- a/executor/executor.go +++ b/executor/executor.go @@ -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 { diff --git a/executor/executor_test.go b/executor/executor_test.go index 017ec4bd8..c0c40500e 100644 --- a/executor/executor_test.go +++ b/executor/executor_test.go @@ -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")) diff --git a/executor/insert_test.go b/executor/insert_test.go index d6e912f95..da066fe8c 100644 --- a/executor/insert_test.go +++ b/executor/insert_test.go @@ -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)`) @@ -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')`) @@ -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`) } @@ -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)`) @@ -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')`) @@ -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`) } @@ -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)`) @@ -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`) } diff --git a/executor/join_test.go b/executor/join_test.go index 8a7a13cea..82ff6495b 100644 --- a/executor/join_test.go +++ b/executor/join_test.go @@ -17,6 +17,7 @@ import ( "context" "fmt" "math/rand" + "strconv" "time" . "github.com/pingcap/check" @@ -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 diff --git a/executor/reload_expr_pushdown_blacklist.go b/executor/reload_expr_pushdown_blacklist.go index ce078bed9..a9bdfbd03 100644 --- a/executor/reload_expr_pushdown_blacklist.go +++ b/executor/reload_expr_pushdown_blacklist.go @@ -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, diff --git a/expression/builtin.go b/expression/builtin.go index b221084a9..7ddf42910 100644 --- a/expression/builtin.go +++ b/expression/builtin.go @@ -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}}, diff --git a/expression/util.go b/expression/util.go index 2edf6528d..416dd1033 100644 --- a/expression/util.go +++ b/expression/util.go @@ -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" diff --git a/infoschema/perfschema/tables.go b/infoschema/perfschema/tables.go index ff12ecb02..77494eb76 100644 --- a/infoschema/perfschema/tables.go +++ b/infoschema/perfschema/tables.go @@ -17,6 +17,7 @@ import ( "fmt" "net/http" "sort" + "strconv" "strings" "sync" "time" @@ -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) diff --git a/meta/meta.go b/meta/meta.go index 6514ffd96..3ed399edb 100644 --- a/meta/meta.go +++ b/meta/meta.go @@ -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) } diff --git a/planner/core/cacheable_checker.go b/planner/core/cacheable_checker.go index d6c316141..f3f00c8a7 100644 --- a/planner/core/cacheable_checker.go +++ b/planner/core/cacheable_checker.go @@ -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" ) diff --git a/planner/core/cacheable_checker_test.go b/planner/core/cacheable_checker_test.go index 97370f72c..92952d4d2 100644 --- a/planner/core/cacheable_checker_test.go +++ b/planner/core/cacheable_checker_test.go @@ -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" ) diff --git a/planner/core/point_get_plan.go b/planner/core/point_get_plan.go index afa2bf9e2..d11849bea 100644 --- a/planner/core/point_get_plan.go +++ b/planner/core/point_get_plan.go @@ -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" diff --git a/session/bootstrap_test.go b/session/bootstrap_test.go index f03e66300..25b32a338 100644 --- a/session/bootstrap_test.go +++ b/session/bootstrap_test.go @@ -16,6 +16,7 @@ package session import ( "context" "fmt" + "strconv" . "github.com/pingcap/check" "github.com/pingcap/parser" @@ -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) @@ -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) diff --git a/sessionctx/variable/varsutil.go b/sessionctx/variable/varsutil.go index 3b66a069b..fd0749f0a 100644 --- a/sessionctx/variable/varsutil.go +++ b/sessionctx/variable/varsutil.go @@ -15,7 +15,6 @@ package variable import ( "encoding/json" - "fmt" "math" "strconv" "strings" @@ -114,9 +113,9 @@ 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() { @@ -124,7 +123,7 @@ func GetSessionOnlySysVars(s *SessionVars, key string) (string, bool, error) { } 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") @@ -249,7 +248,7 @@ 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 { @@ -257,11 +256,11 @@ func checkUInt64SystemVar(name, value string, min, max uint64, 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 } @@ -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 } diff --git a/statistics/handle/bootstrap.go b/statistics/handle/bootstrap.go index 4bc825753..a7770d9c2 100644 --- a/statistics/handle/bootstrap.go +++ b/statistics/handle/bootstrap.go @@ -15,7 +15,7 @@ package handle import ( "context" - "fmt" + "strconv" "github.com/cznic/mathutil" "github.com/pingcap/errors" @@ -338,5 +338,5 @@ func getFullTableName(is infoschema.InfoSchema, tblInfo *model.TableInfo) string } } } - return fmt.Sprintf("%d", tblInfo.ID) + return strconv.Itoa(tblInfo.ID) } diff --git a/store/mockstore/mocktikv/mock.go b/store/mockstore/mocktikv/mock.go index fe0ff2ef2..5a3b355ff 100644 --- a/store/mockstore/mocktikv/mock.go +++ b/store/mockstore/mocktikv/mock.go @@ -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. diff --git a/store/mockstore/mocktikv/pd.go b/store/mockstore/mocktikv/pd.go index fcc93be99..817d0bffb 100644 --- a/store/mockstore/mocktikv/pd.go +++ b/store/mockstore/mocktikv/pd.go @@ -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. diff --git a/store/tikv/interface.go b/store/tikv/interface.go index 562982d48..7f4438f1b 100644 --- a/store/tikv/interface.go +++ b/store/tikv/interface.go @@ -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" diff --git a/store/tikv/isolation_test.go b/store/tikv/isolation_test.go index d8dd33320..941e7b41f 100644 --- a/store/tikv/isolation_test.go +++ b/store/tikv/isolation_test.go @@ -17,8 +17,8 @@ package tikv import ( "context" - "fmt" "sort" + "strconv" "sync" "time" @@ -150,7 +150,7 @@ func (s *testIsolationSuite) TestReadWriteConflict(c *C) { writeDone := make(chan struct{}) go func() { for i := 1; i <= writeCount; i++ { - w := s.SetWithRetry(c, []byte("k"), []byte(fmt.Sprintf("%d", i))) + w := s.SetWithRetry(c, []byte("k"), []byte(strconv.Itoa(i))) writes = append(writes, w) time.Sleep(time.Microsecond * 10) } @@ -186,10 +186,10 @@ func (s *testIsolationSuite) TestReadWriteConflict(c *C) { if r.startTS >= w.commitTS { break } - c.Assert(string(r.value), Equals, fmt.Sprintf("%d", i)) + c.Assert(string(r.value), Equals, strconv.Itoa(i)) } } for ; j < len(reads); j++ { - c.Assert(string(reads[j].value), Equals, fmt.Sprintf("%d", len(writes))) + c.Assert(string(reads[j].value), Equals, strconv.Itoa(len(writes))) } } diff --git a/store/tikv/oracle/oracles/pd.go b/store/tikv/oracle/oracles/pd.go index b2bfb53c0..ecd5472f6 100644 --- a/store/tikv/oracle/oracles/pd.go +++ b/store/tikv/oracle/oracles/pd.go @@ -19,7 +19,6 @@ import ( "time" "github.com/pingcap/errors" - "github.com/pingcap/pd/v4/client" "github.com/pingcap/tidb/metrics" "github.com/pingcap/tidb/store/tikv/oracle" "github.com/pingcap/tidb/util/logutil" diff --git a/store/tikv/pd_codec.go b/store/tikv/pd_codec.go index 436b92905..46cb9160d 100644 --- a/store/tikv/pd_codec.go +++ b/store/tikv/pd_codec.go @@ -18,7 +18,7 @@ import ( "github.com/pingcap/errors" "github.com/pingcap/kvproto/pkg/metapb" - "github.com/pingcap/pd/v4/client" + pd "github.com/pingcap/pd/v4/client" "github.com/pingcap/tidb/util/codec" ) diff --git a/store/tikv/rawkv.go b/store/tikv/rawkv.go index 8f2b6ccad..f7c68f502 100644 --- a/store/tikv/rawkv.go +++ b/store/tikv/rawkv.go @@ -20,7 +20,7 @@ import ( "github.com/pingcap/errors" "github.com/pingcap/kvproto/pkg/kvrpcpb" - "github.com/pingcap/pd/v4/client" + pd "github.com/pingcap/pd/v4/client" "github.com/pingcap/tidb/config" "github.com/pingcap/tidb/metrics" "github.com/pingcap/tidb/store/tikv/tikvrpc" diff --git a/store/tikv/store_test.go b/store/tikv/store_test.go index 30a0745eb..5e4bdfeef 100644 --- a/store/tikv/store_test.go +++ b/store/tikv/store_test.go @@ -24,7 +24,6 @@ import ( pb "github.com/pingcap/kvproto/pkg/kvrpcpb" "github.com/pingcap/kvproto/pkg/metapb" "github.com/pingcap/kvproto/pkg/pdpb" - "github.com/pingcap/pd/v4/client" "github.com/pingcap/tidb/kv" "github.com/pingcap/tidb/store/mockoracle" "github.com/pingcap/tidb/store/tikv/tikvrpc" diff --git a/store/tikv/test_util.go b/store/tikv/test_util.go index 052f233c1..af8614b92 100644 --- a/store/tikv/test_util.go +++ b/store/tikv/test_util.go @@ -16,7 +16,7 @@ package tikv import ( "github.com/google/uuid" "github.com/pingcap/errors" - "github.com/pingcap/pd/v4/client" + pd "github.com/pingcap/pd/v4/client" "github.com/pingcap/tidb/kv" ) diff --git a/store/tikv/txn.go b/store/tikv/txn.go index b148686fb..06db1d7d7 100644 --- a/store/tikv/txn.go +++ b/store/tikv/txn.go @@ -18,6 +18,7 @@ import ( "context" "fmt" "sort" + "strconv" "sync" "sync/atomic" "time" @@ -169,7 +170,7 @@ func (txn *tikvTxn) Set(k kv.Key, v []byte) error { } func (txn *tikvTxn) String() string { - return fmt.Sprintf("%d", txn.StartTS()) + return strconv.Itoa(txn.StartTS()) } func (txn *tikvTxn) Iter(k kv.Key, upperBound kv.Key) (kv.Iterator, error) { diff --git a/table/tables/partition.go b/table/tables/partition.go index eac6a8276..42474c6af 100644 --- a/table/tables/partition.go +++ b/table/tables/partition.go @@ -295,7 +295,7 @@ func (t *partitionedTable) locateRangePartition(ctx sessionctx.Context, pi *mode if err == nil { val, _, err := e.EvalInt(ctx, chunk.MutRowFromDatums(r).ToRow()) if err == nil { - valueMsg = fmt.Sprintf("%d", val) + valueMsg = strconv.Itoa(val) } } } else { diff --git a/tidb-server/main.go b/tidb-server/main.go index e50e1c89d..14e131b29 100644 --- a/tidb-server/main.go +++ b/tidb-server/main.go @@ -32,7 +32,6 @@ import ( "github.com/pingcap/log" "github.com/pingcap/parser/mysql" "github.com/pingcap/parser/terror" - "github.com/pingcap/pd/v4/client" pumpcli "github.com/pingcap/tidb-tools/tidb-binlog/pump_client" "github.com/pingcap/tidb/bindinfo" "github.com/pingcap/tidb/config" @@ -565,7 +564,7 @@ func setGlobalVars() { variable.SysVars["lower_case_table_names"].Value = strconv.Itoa(cfg.LowerCaseTableNames) variable.SysVars[variable.LogBin].Value = variable.BoolToIntStr(config.GetGlobalConfig().Binlog.Enable) - variable.SysVars[variable.Port].Value = fmt.Sprintf("%d", cfg.Port) + variable.SysVars[variable.Port].Value = strconv.Itoa(cfg.Port) variable.SysVars[variable.Socket].Value = cfg.Socket variable.SysVars[variable.DataDir].Value = cfg.Path variable.SysVars[variable.TiDBSlowQueryFile].Value = cfg.Log.SlowQueryFile diff --git a/util/prefix_helper_test.go b/util/prefix_helper_test.go index 2c0543406..2cb45bc7f 100644 --- a/util/prefix_helper_test.go +++ b/util/prefix_helper_test.go @@ -16,6 +16,7 @@ package util_test import ( "context" "fmt" + "strconv" "testing" . "github.com/pingcap/check" @@ -58,7 +59,7 @@ func (s *testPrefixSuite) TearDownSuite(c *C) { } func encodeInt(n int) []byte { - return []byte(fmt.Sprintf("%d", n)) + return []byte(strconv.Itoa(n)) } type MockContext struct { diff --git a/util/set/string_set_test.go b/util/set/string_set_test.go index 9d1959b22..67ec2008a 100644 --- a/util/set/string_set_test.go +++ b/util/set/string_set_test.go @@ -14,7 +14,7 @@ package set import ( - "fmt" + "strconv" "github.com/pingcap/check" ) @@ -44,7 +44,7 @@ func (s *stringSetTestSuite) TestStringSet(c *check.C) { set = NewStringSet("1", "2", "3", "4", "5", "6") for i := 1; i < 7; i++ { - c.Assert(set.Exist(fmt.Sprintf("%d", i)), check.IsTrue) + c.Assert(set.Exist(strconv.Itoa(i)), check.IsTrue) } c.Assert(set.Exist("7"), check.IsFalse) diff --git a/util/stmtsummary/statement_summary_test.go b/util/stmtsummary/statement_summary_test.go index 1f08ecd9e..8cdce6bfb 100644 --- a/util/stmtsummary/statement_summary_test.go +++ b/util/stmtsummary/statement_summary_test.go @@ -860,7 +860,7 @@ func (s *testStmtSummarySuite) TestEnableSummaryParallel(c *C) { // Add 32 times with same digest. for i := 0; i < loops; i++ { // Sometimes enable it and sometimes disable it. - s.ssMap.SetEnabled(fmt.Sprintf("%d", i%2), false) + s.ssMap.SetEnabled(strconv.Itoa(i%2), false) s.ssMap.AddStatement(stmtExecInfo1) // Try to read it. s.ssMap.ToHistoryDatum(nil, true)