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

*: Remove unused code #13674

Merged
merged 6 commits into from
Nov 22, 2019
Merged
Show file tree
Hide file tree
Changes from 5 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
1 change: 0 additions & 1 deletion ddl/ddl.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ var (
errInvalidDDLJob = terror.ClassDDL.New(mysql.ErrInvalidDDLJob, mysql.MySQLErrName[mysql.ErrInvalidDDLJob])
errCancelledDDLJob = terror.ClassDDL.New(mysql.ErrCancelledDDLJob, mysql.MySQLErrName[mysql.ErrCancelledDDLJob])
errFileNotFound = terror.ClassDDL.New(mysql.ErrFileNotFound, mysql.MySQLErrName[mysql.ErrFileNotFound])
errInvalidDDLJobFlag = terror.ClassDDL.New(mysql.ErrInvalidDDLJobFlag, mysql.MySQLErrName[mysql.ErrInvalidDDLJobFlag])
errRunMultiSchemaChanges = terror.ClassDDL.New(mysql.ErrUnsupportedDDLOperation, fmt.Sprintf(mysql.MySQLErrName[mysql.ErrUnsupportedDDLOperation], "multi schema change"))
errWaitReorgTimeout = terror.ClassDDL.New(mysql.ErrLockWaitTimeout, mysql.MySQLErrName[mysql.ErrWaitReorgTimeout])
errInvalidStoreVer = terror.ClassDDL.New(mysql.ErrInvalidStoreVersion, mysql.MySQLErrName[mysql.ErrInvalidStoreVersion])
Expand Down
2 changes: 0 additions & 2 deletions ddl/ddl_algorithm.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ var (
supported: []ast.AlgorithmType{ast.AlgorithmTypeInplace},
defAlgorithm: ast.AlgorithmTypeInplace,
}

defaultAlgorithm = ast.AlgorithmTypeInstant
)

func getProperAlgorithm(specify ast.AlgorithmType, algorithm *AlterAlgorithm) (ast.AlgorithmType, error) {
Expand Down
1 change: 0 additions & 1 deletion ddl/partition.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import (

const (
partitionMaxValue = "MAXVALUE"
primarykey = "PRIMARY KEY"
)

// buildTablePartitionInfo builds partition info and checks for some errors.
Expand Down
30 changes: 14 additions & 16 deletions ddl/stat.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,20 @@ import (
)

var (
serverID = "server_id"
ddlSchemaVersion = "ddl_schema_version"
ddlOwnerID = "ddl_owner_id"
ddlOwnerLastUpdateTS = "ddl_owner_last_update_ts"
ddlJobID = "ddl_job_id"
ddlJobAction = "ddl_job_action"
ddlJobStartTS = "ddl_job_start_ts"
ddlJobState = "ddl_job_state"
ddlJobError = "ddl_job_error"
ddlJobRows = "ddl_job_row_count"
ddlJobSchemaState = "ddl_job_schema_state"
ddlJobSchemaID = "ddl_job_schema_id"
ddlJobTableID = "ddl_job_table_id"
ddlJobSnapshotVer = "ddl_job_snapshot_ver"
ddlJobReorgHandle = "ddl_job_reorg_handle"
ddlJobArgs = "ddl_job_args"
serverID = "server_id"
ddlSchemaVersion = "ddl_schema_version"
ddlJobID = "ddl_job_id"
ddlJobAction = "ddl_job_action"
ddlJobStartTS = "ddl_job_start_ts"
ddlJobState = "ddl_job_state"
ddlJobError = "ddl_job_error"
ddlJobRows = "ddl_job_row_count"
ddlJobSchemaState = "ddl_job_schema_state"
ddlJobSchemaID = "ddl_job_schema_id"
ddlJobTableID = "ddl_job_table_id"
ddlJobSnapshotVer = "ddl_job_snapshot_ver"
ddlJobReorgHandle = "ddl_job_reorg_handle"
ddlJobArgs = "ddl_job_args"
)

// GetScope gets the status variables scope.
Expand Down
2 changes: 0 additions & 2 deletions ddl/util/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ var (
// SyncerSessionTTL is the etcd session's TTL in seconds.
// and it's an exported variable for testing.
SyncerSessionTTL = 90
// ddlLogCtx uses for log.
ddlLogCtx = context.Background()
)

// SchemaSyncer is used to synchronize schema version between the DDL worker leader and followers through etcd.
Expand Down
2 changes: 0 additions & 2 deletions domain/db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ type dbTestSuite struct{}

var _ = Suite(&dbTestSuite{})

var suite = new(dbTestSuite)

func (ts *dbTestSuite) TestIntegration(c *C) {
var err error
lease := 50 * time.Millisecond
Expand Down
7 changes: 0 additions & 7 deletions domain/topn_slow_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,6 @@ type showSlowMessage struct {
sync.WaitGroup
}

type queryType int

const (
queryTypeTop queryType = iota
queryTypeRecent
)

func (q *topNSlowQueries) QueryRecent(count int) []*SlowQueryInfo {
return q.recent.Query(count)
}
Expand Down
5 changes: 0 additions & 5 deletions executor/aggfuncs/func_count.go
Original file line number Diff line number Diff line change
Expand Up @@ -389,8 +389,3 @@ func appendJSON(encodedBytes, _ []byte, val json.BinaryJSON) []byte {
encodedBytes = append(encodedBytes, val.Value...)
return encodedBytes
}

func appendString(encodedBytes, _ []byte, val string) []byte {
encodedBytes = append(encodedBytes, val...)
return encodedBytes
}
2 changes: 0 additions & 2 deletions executor/distsql.go
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,6 @@ func (e *IndexLookUpExecutor) startWorkers(ctx context.Context, initBatchSize in
return nil
}

var indexLookupDistSQLTrackerLabel fmt.Stringer = stringutil.StringerStr("IndexLookupDistSQLTracker")

// startIndexWorker launch a background goroutine to fetch handles, send the results to workCh.
func (e *IndexLookUpExecutor) startIndexWorker(ctx context.Context, kvRanges []kv.KeyRange, workCh chan<- *lookupTableTask, initBatchSize int) error {
if e.runtimeStats != nil {
Expand Down
7 changes: 0 additions & 7 deletions executor/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,13 +362,6 @@ func (e *ShowExec) fetchShowTableStatus() error {
return nil
}

func createOptions(tb *model.TableInfo) string {
if tb.GetPartitionInfo() != nil {
return "partitioned"
}
return ""
}

func (e *ShowExec) fetchShowColumns(ctx context.Context) error {
tb, err := e.getTable()

Expand Down
5 changes: 0 additions & 5 deletions executor/table_readers_required_rows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,6 @@ func mockSelectResult(ctx context.Context, sctx sessionctx.Context, kvReq *kv.Re
}, nil
}

func mockSelectResultWithoutCheck(ctx context.Context, sctx sessionctx.Context, kvReq *kv.Request,
fieldTypes []*types.FieldType, fb *statistics.QueryFeedback, copPlanIDs []string) (distsql.SelectResult, error) {
return &requiredRowsSelectResult{retTypes: fieldTypes}, nil
}

func buildTableReader(sctx sessionctx.Context) Executor {
e := &TableReaderExecutor{
baseExecutor: buildMockBaseExec(sctx),
Expand Down
3 changes: 0 additions & 3 deletions expression/builtin_encryption.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,6 @@ var (
_ builtinFunc = &builtinUncompressedLengthSig{}
)

// ivSize indicates the initialization vector supplied to aes_decrypt
const ivSize = aes.BlockSize

// aesModeAttr indicates that the key length and iv attribute for specific block_encryption_mode.
// keySize is the key length in bits and mode is the encryption mode.
// ivRequired indicates that initialization vector is required or not.
Expand Down
15 changes: 0 additions & 15 deletions expression/distsql_builtin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -796,21 +796,6 @@ func (s *testEvalSuite) TestEval(c *C) {
}
}

func buildExpr(tp tipb.ExprType, children ...interface{}) *tipb.Expr {
expr := new(tipb.Expr)
expr.Tp = tp
expr.Children = make([]*tipb.Expr, len(children))
for i, child := range children {
switch x := child.(type) {
case types.Datum:
expr.Children[i] = datumExpr(nil, x)
case *tipb.Expr:
expr.Children[i] = x
}
}
return expr
}

func datumExpr(c *C, d types.Datum) *tipb.Expr {
expr := new(tipb.Expr)
switch d.Kind() {
Expand Down
2 changes: 0 additions & 2 deletions meta/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@ var (
)

var (
errInvalidTableKey = terror.ClassMeta.New(codeInvalidTableKey, "invalid table meta key")
errInvalidDBKey = terror.ClassMeta.New(codeInvalidDBKey, "invalid db key")

// ErrDBExists is the error for db exists.
ErrDBExists = terror.ClassMeta.New(codeDatabaseExists, "database already exists")
Expand Down
16 changes: 7 additions & 9 deletions plugin/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,13 @@ import (
)

var (
errInvalidPluginID = createPluginError(mysql.ErrInvalidPluginID)
errInvalidPluginManifest = createPluginError(mysql.ErrInvalidPluginManifest)
errInvalidPluginName = createPluginError(mysql.ErrInvalidPluginName)
errInvalidPluginVersion = createPluginError(mysql.ErrInvalidPluginVersion)
errDuplicatePlugin = createPluginError(mysql.ErrDuplicatePlugin)
errInvalidPluginSysVarName = createPluginError(mysql.ErrInvalidPluginSysVarName)
errRequireVersionCheckFail = createPluginError(mysql.ErrRequireVersionCheckFail)
errUnsupportedReloadPlugin = createPluginError(mysql.ErrUnsupportedReloadPlugin)
errUnsupportedReloadPluginVar = createPluginError(mysql.ErrUnsupportedReloadPluginVar)
errInvalidPluginID = createPluginError(mysql.ErrInvalidPluginID)
errInvalidPluginManifest = createPluginError(mysql.ErrInvalidPluginManifest)
errInvalidPluginName = createPluginError(mysql.ErrInvalidPluginName)
errInvalidPluginVersion = createPluginError(mysql.ErrInvalidPluginVersion)
errDuplicatePlugin = createPluginError(mysql.ErrDuplicatePlugin)
errInvalidPluginSysVarName = createPluginError(mysql.ErrInvalidPluginSysVarName)
errRequireVersionCheckFail = createPluginError(mysql.ErrRequireVersionCheckFail)
)

func createPluginError(code terror.ErrCode) *terror.Error {
Expand Down
1 change: 0 additions & 1 deletion privilege/privileges/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ var (
userTablePrivilegeMask = computePrivMask(mysql.AllGlobalPrivs)
dbTablePrivilegeMask = computePrivMask(mysql.AllDBPrivs)
tablePrivMask = computePrivMask(mysql.AllTablePrivs)
columnPrivMask = computePrivMask(mysql.AllColumnPrivs)
)

func computePrivMask(privs []mysql.PrivilegeType) mysql.PrivilegeType {
Expand Down
5 changes: 2 additions & 3 deletions privilege/privileges/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ const (
)

var (
errInvalidPrivilegeType = terror.ClassPrivilege.New(codeInvalidPrivilegeType, "unknown privilege type %s")
errInvalidUserNameFormat = terror.ClassPrivilege.New(codeInvalidUserNameFormat, "wrong username format")
errNonexistingGrant = terror.ClassPrivilege.New(codeErrNonexistingGrant, mysql.MySQLErrName[mysql.ErrNonexistingGrant])
errInvalidPrivilegeType = terror.ClassPrivilege.New(codeInvalidPrivilegeType, "unknown privilege type %s")
errNonexistingGrant = terror.ClassPrivilege.New(codeErrNonexistingGrant, mysql.MySQLErrName[mysql.ErrNonexistingGrant])
)

func init() {
Expand Down
12 changes: 5 additions & 7 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,11 @@ func init() {
}

var (
errUnknownFieldType = terror.ClassServer.New(codeUnknownFieldType, "unknown field type")
errInvalidPayloadLen = terror.ClassServer.New(codeInvalidPayloadLen, "invalid payload length")
errInvalidSequence = terror.ClassServer.New(codeInvalidSequence, "invalid sequence")
errInvalidType = terror.ClassServer.New(codeInvalidType, "invalid type")
errNotAllowedCommand = terror.ClassServer.New(codeNotAllowedCommand, "the used command is not allowed with this TiDB version")
errAccessDenied = terror.ClassServer.New(codeAccessDenied, mysql.MySQLErrName[mysql.ErrAccessDenied])
errMaxExecTimeExceeded = terror.ClassServer.New(codeMaxExecTimeExceeded, mysql.MySQLErrName[mysql.ErrMaxExecTimeExceeded])
errUnknownFieldType = terror.ClassServer.New(codeUnknownFieldType, "unknown field type")
errInvalidSequence = terror.ClassServer.New(codeInvalidSequence, "invalid sequence")
errInvalidType = terror.ClassServer.New(codeInvalidType, "invalid type")
errNotAllowedCommand = terror.ClassServer.New(codeNotAllowedCommand, "the used command is not allowed with this TiDB version")
errAccessDenied = terror.ClassServer.New(codeAccessDenied, mysql.MySQLErrName[mysql.ErrAccessDenied])
)

// DefaultCapability is the capability of the server when it is created using the default configuration.
Expand Down
9 changes: 0 additions & 9 deletions store/helper/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -436,11 +436,6 @@ func isIntersectingKeyRange(x withKeyRange, startKey, endKey string) bool {
return !isBeforeKeyRange(x, startKey, endKey) && !isBehindKeyRange(x, startKey, endKey)
}

// IsBefore returns true is x is before y
func inBefore(x, y withKeyRange) bool {
return isBeforeKeyRange(x, y.getStartKey(), y.getEndKey())
}

// isBehind returns true is x is behind y
func isBehind(x, y withKeyRange) bool {
return isBehindKeyRange(x, y.getStartKey(), y.getEndKey())
Expand Down Expand Up @@ -570,10 +565,6 @@ func bytesKeyToHex(key []byte) string {
return strings.ToUpper(hex.EncodeToString(key))
}

func hexKeyToBytes(key string) ([]byte, error) {
return hex.DecodeString(key)
}

// GetRegionsInfo gets the region information of current store by using PD's api.
func (h *Helper) GetRegionsInfo() (*RegionsInfo, error) {
var regionsInfo RegionsInfo
Expand Down
6 changes: 0 additions & 6 deletions store/mockstore/mocktikv/mvcc.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,6 @@ func (mh *marshalHelper) ReadSlice(r *bytes.Buffer, slice *[]byte) {
*slice = data
}

func newEntry(key MvccKey) *mvccEntry {
return &mvccEntry{
key: key,
}
}

// lockErr returns ErrLocked.
// Note that parameter key is raw key, while key in ErrLocked is mvcc key.
func (l *mvccLock) lockErr(key []byte) error {
Expand Down
9 changes: 4 additions & 5 deletions structure/structure.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,10 @@ const (
)

var (
errInvalidHashKeyFlag = terror.ClassStructure.New(codeInvalidHashKeyFlag, "invalid encoded hash key flag")
errInvalidHashKeyPrefix = terror.ClassStructure.New(codeInvalidHashKeyPrefix, "invalid encoded hash key prefix")
errInvalidListIndex = terror.ClassStructure.New(codeInvalidListMetaData, "invalid list index")
errInvalidListMetaData = terror.ClassStructure.New(codeInvalidListMetaData, "invalid list meta data")
errWriteOnSnapshot = terror.ClassStructure.New(codeWriteOnSnapshot, "write on snapshot")
errInvalidHashKeyFlag = terror.ClassStructure.New(codeInvalidHashKeyFlag, "invalid encoded hash key flag")
errInvalidListIndex = terror.ClassStructure.New(codeInvalidListMetaData, "invalid list index")
errInvalidListMetaData = terror.ClassStructure.New(codeInvalidListMetaData, "invalid list meta data")
errWriteOnSnapshot = terror.ClassStructure.New(codeWriteOnSnapshot, "write on snapshot")
)

// NewStructure creates a TxStructure with Retriever, RetrieverMutator and key prefix.
Expand Down
4 changes: 0 additions & 4 deletions table/tables/tables.go
Original file line number Diff line number Diff line change
Expand Up @@ -1069,10 +1069,6 @@ func (t *tableCommon) canSkipUpdateBinlog(col *table.Column, value types.Datum)
return false
}

var (
recordPrefixSep = []byte("_r")
)

// FindIndexByColName returns a public table index containing only one column named `name`.
func FindIndexByColName(t table.Table, name string) table.Index {
for _, idx := range t.Indices() {
Expand Down
7 changes: 3 additions & 4 deletions tablecodec/tablecodec.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,9 @@ import (
)

var (
errInvalidKey = terror.ClassXEval.New(codeInvalidKey, "invalid key")
errInvalidRecordKey = terror.ClassXEval.New(codeInvalidRecordKey, "invalid record key")
errInvalidIndexKey = terror.ClassXEval.New(codeInvalidIndexKey, "invalid index key")
errInvalidColumnCount = terror.ClassXEval.New(codeInvalidColumnCount, "invalid column count")
errInvalidKey = terror.ClassXEval.New(codeInvalidKey, "invalid key")
errInvalidRecordKey = terror.ClassXEval.New(codeInvalidRecordKey, "invalid record key")
errInvalidIndexKey = terror.ClassXEval.New(codeInvalidIndexKey, "invalid index key")
)

var (
Expand Down
24 changes: 0 additions & 24 deletions types/time.go
Original file line number Diff line number Diff line change
Expand Up @@ -2491,9 +2491,6 @@ func isAMOrPM(t *MysqlTime, input string, ctx map[string]int) (string, bool) {
// digitRegex: it was used to scan a variable-length monthly day or month in the string. Ex: "01" or "1" or "30"
var oneOrTwoDigitRegex = regexp.MustCompile("^[0-9]{1,2}")

// twoDigitRegex: it was just for two digit number string. Ex: "01" or "12"
var twoDigitRegex = regexp.MustCompile("^[1-9][0-9]?")

// oneToSixDigitRegex: it was just for [0, 999999]
var oneToSixDigitRegex = regexp.MustCompile("^[0-9]{0,6}")

Expand Down Expand Up @@ -2597,17 +2594,6 @@ func dayOfYearThreeDigits(t *MysqlTime, input string, ctx map[string]int) (strin
return input[3:], true
}

func abbreviatedWeekday(t *MysqlTime, input string, ctx map[string]int) (string, bool) {
if len(input) >= 3 {
dayName := input[:3]
if _, ok := weekdayAbbrev[dayName]; ok {
// TODO: We need refact mysql time to support this.
return input, false
}
}
return input, false
}

func abbreviatedMonth(t *MysqlTime, input string, ctx map[string]int) (string, bool) {
if len(input) >= 3 {
monthName := input[:3]
Expand Down Expand Up @@ -2642,16 +2628,6 @@ func monthNumeric(t *MysqlTime, input string, ctx map[string]int) (string, bool)
return input[length:], true
}

// dayOfMonthWithSuffix returns different suffix according t being which day. i.e. 0 return th. 1 return st.
func dayOfMonthWithSuffix(t *MysqlTime, input string, ctx map[string]int) (string, bool) {
month, remain := parseOrdinalNumbers(input)
if month >= 0 {
t.month = uint8(month)
return remain, true
}
return input, false
}

func parseOrdinalNumbers(input string) (value int, remain string) {
for i, c := range input {
if !unicode.IsDigit(c) {
Expand Down
3 changes: 1 addition & 2 deletions util/codec/bytes.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ const (
)

var (
pads = make([]byte, encGroupSize)
encPads = []byte{encPad}
pads = make([]byte, encGroupSize)
)

// EncodeBytes guarantees the encoded value is in ascending order for comparison,
Expand Down