Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

*: fix some varcheck lint warnings #23011

Merged
merged 10 commits into from
Mar 1, 2021
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ check-static: tools/bin/golangci-lint
tools/bin/golangci-lint run -v --disable-all --deadline=3m \
--enable=misspell \
--enable=ineffassign \
--enable=varcheck \
$$($(PACKAGE_DIRECTORIES))

check-slow:tools/bin/gometalinter tools/bin/gosec
Expand Down
19 changes: 10 additions & 9 deletions ddl/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,16 @@ var (
errIncorrectPrefixKey = dbterror.ClassDDL.NewStd(mysql.ErrWrongSubKey)
errTooLongKey = dbterror.ClassDDL.NewStd(mysql.ErrTooLongKey)
errKeyColumnDoesNotExits = dbterror.ClassDDL.NewStd(mysql.ErrKeyColumnDoesNotExits)
errUnknownTypeLength = dbterror.ClassDDL.NewStd(mysql.ErrUnknownTypeLength)
errInvalidDDLJobVersion = dbterror.ClassDDL.NewStd(mysql.ErrInvalidDDLJobVersion)
errInvalidUseOfNull = dbterror.ClassDDL.NewStd(mysql.ErrInvalidUseOfNull)
errTooManyFields = dbterror.ClassDDL.NewStd(mysql.ErrTooManyFields)
errTooManyKeys = dbterror.ClassDDL.NewStd(mysql.ErrTooManyKeys)
errInvalidSplitRegionRanges = dbterror.ClassDDL.NewStd(mysql.ErrInvalidSplitRegionRanges)
errReorgPanic = dbterror.ClassDDL.NewStd(mysql.ErrReorgPanic)
errFkColumnCannotDrop = dbterror.ClassDDL.NewStd(mysql.ErrFkColumnCannotDrop)
errFKIncompatibleColumns = dbterror.ClassDDL.NewStd(mysql.ErrFKIncompatibleColumns)
// nolint:varcheck
errUnknownTypeLength = dbterror.ClassDDL.NewStd(mysql.ErrUnknownTypeLength)
errInvalidDDLJobVersion = dbterror.ClassDDL.NewStd(mysql.ErrInvalidDDLJobVersion)
errInvalidUseOfNull = dbterror.ClassDDL.NewStd(mysql.ErrInvalidUseOfNull)
errTooManyFields = dbterror.ClassDDL.NewStd(mysql.ErrTooManyFields)
errTooManyKeys = dbterror.ClassDDL.NewStd(mysql.ErrTooManyKeys)
errInvalidSplitRegionRanges = dbterror.ClassDDL.NewStd(mysql.ErrInvalidSplitRegionRanges)
errReorgPanic = dbterror.ClassDDL.NewStd(mysql.ErrReorgPanic)
errFkColumnCannotDrop = dbterror.ClassDDL.NewStd(mysql.ErrFkColumnCannotDrop)
errFKIncompatibleColumns = dbterror.ClassDDL.NewStd(mysql.ErrFKIncompatibleColumns)
tangenta marked this conversation as resolved.
Show resolved Hide resolved

errOnlyOnRangeListPartition = dbterror.ClassDDL.NewStd(mysql.ErrOnlyOnRangeListPartition)
// errWrongKeyColumn is for table column cannot be indexed.
Expand Down
3 changes: 0 additions & 3 deletions domain/infosync/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,6 @@ const (
// ErrPrometheusAddrIsNotSet is the error that Prometheus address is not set in PD and etcd
var ErrPrometheusAddrIsNotSet = dbterror.ClassDomain.NewStd(errno.ErrPrometheusAddrIsNotSet)

// errPlacementRulesDisabled is exported for internal usage, indicating PD rejected the request due to disabled placement feature.
var errPlacementRulesDisabled = errors.New("placement rules feature is disabled")

// InfoSyncer stores server info to etcd when the tidb-server starts and delete when tidb-server shuts down.
type InfoSyncer struct {
etcdCli *clientv3.Client
Expand Down
18 changes: 0 additions & 18 deletions executor/hash_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,6 @@ import (
"github.com/pingcap/tidb/util/memory"
)

const (
// estCountMaxFactor defines the factor of estCountMax with maxChunkSize.
// estCountMax is maxChunkSize * estCountMaxFactor, the maximum threshold of estCount.
// if estCount is larger than estCountMax, set estCount to estCountMax.
// Set this threshold to prevent buildSideEstCount being too large and causing a performance and memory regression.
estCountMaxFactor = 10 * 1024

// estCountMinFactor defines the factor of estCountMin with maxChunkSize.
// estCountMin is maxChunkSize * estCountMinFactor, the minimum threshold of estCount.
// If estCount is smaller than estCountMin, set estCount to 0.
// Set this threshold to prevent buildSideEstCount being too small and causing a performance regression.
estCountMinFactor = 8

// estCountDivisor defines the divisor of buildSideEstCount.
// Set this divisor to prevent buildSideEstCount being too large and causing a performance regression.
estCountDivisor = 8
)

// hashContext keeps the needed hash context of a db table in hash join.
type hashContext struct {
allTypes []*types.FieldType
Expand Down
7 changes: 0 additions & 7 deletions executor/merge_join.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ package executor

import (
"context"
"fmt"

"github.com/pingcap/failpoint"
"github.com/pingcap/tidb/config"
Expand All @@ -24,7 +23,6 @@ import (
"github.com/pingcap/tidb/util/chunk"
"github.com/pingcap/tidb/util/disk"
"github.com/pingcap/tidb/util/memory"
"github.com/pingcap/tidb/util/stringutil"
)

// MergeJoinExec implements the merge join algorithm.
Expand Down Expand Up @@ -53,11 +51,6 @@ type MergeJoinExec struct {
diskTracker *disk.Tracker
}

var (
innerTableLabel fmt.Stringer = stringutil.StringerStr("innerTable")
outerTableLabel fmt.Stringer = stringutil.StringerStr("outerTable")
)

type mergeJoinTable struct {
isInner bool
childIndex int
Expand Down
1 change: 1 addition & 0 deletions expression/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"github.com/pingcap/tidb/util/dbterror"
)

// nolint:varcheck
// Error instances.
var (
// All the exported errors are defined here:
Expand Down
4 changes: 0 additions & 4 deletions planner/core/find_best_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,6 @@ func (c *PlanCounterTp) IsForce() bool {
return *c != -1
}

// wholeTaskTypes records all possible kinds of task that a plan can return. For Agg, TopN and Limit, we will try to get
// these tasks one by one.
var wholeTaskTypes = [...]property.TaskType{property.CopSingleReadTaskType, property.CopDoubleReadTaskType, property.RootTaskType}

var invalidTask = &rootTask{cst: math.MaxFloat64}

// GetPropByOrderByItems will check if this sort property can be pushed or not. In order to simplify the problem, we only
Expand Down
7 changes: 0 additions & 7 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -698,10 +698,3 @@ func setSystemTimeZoneVariable() {
variable.SetSysVar("system_time_zone", tz)
})
}

// Server error codes.
const (
codeUnknownFieldType = 1
codeInvalidSequence = 3
codeInvalidType = 4
)
1 change: 0 additions & 1 deletion sessionctx/binloginfo/binloginfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ var pumpsClient *pumpcli.PumpsClient
var pumpsClientLock sync.RWMutex
var shardPat = regexp.MustCompile(`SHARD_ROW_ID_BITS\s*=\s*\d+\s*`)
var preSplitPat = regexp.MustCompile(`PRE_SPLIT_REGIONS\s*=\s*\d+\s*`)
var autoRandomPat = regexp.MustCompile(`AUTO_RANDOM\s*\(\s*\d+\s*\)\s*`)

// BinlogInfo contains binlog data and binlog client.
type BinlogInfo struct {
Expand Down
1 change: 1 addition & 0 deletions store/mockstore/unistore/cophandler/mpp.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const (
)

const (
// nolint:varcheck
taskInit int32 = iota
taskRunning
taskFailed
Expand Down
5 changes: 0 additions & 5 deletions util/chunk/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,9 @@
package chunk

import (
"fmt"

"github.com/pingcap/errors"
"github.com/pingcap/tidb/types"
"github.com/pingcap/tidb/util/memory"
"github.com/pingcap/tidb/util/stringutil"
)

// List holds a slice of chunks, use to append rows with max chunk size properly handled.
Expand All @@ -42,8 +39,6 @@ type RowPtr struct {
RowIdx uint32
}

var chunkListLabel fmt.Stringer = stringutil.StringerStr("chunk.List")

// NewList creates a new List with field types, init chunk size and max chunk size.
func NewList(fieldTypes []*types.FieldType, initChunkSize, maxChunkSize int) *List {
l := &List{
Expand Down