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

*: cleanup error code #13874

Merged
merged 3 commits into from
Dec 3, 2019
Merged
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 meta/autoid/autoid.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ func NewAllocator(store kv.Storage, dbID int64, isUnsigned bool) Allocator {
}
}

//codeInvalidTableID is the code of autoid error.
// codeInvalidTableID is the code of autoid error.
const codeInvalidTableID terror.ErrCode = 1

var localSchemaID = int64(math.MaxInt64)
Expand Down
8 changes: 3 additions & 5 deletions privilege/privileges/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,17 @@ import (

// privilege error codes.
const (
codeInvalidPrivilegeType terror.ErrCode = 1
codeInvalidUserNameFormat = 2
codeErrNonexistingGrant = mysql.ErrNonexistingGrant
codeInvalidPrivilegeType terror.ErrCode = 1
)

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

func init() {
privilegeMySQLErrCodes := map[terror.ErrCode]uint16{
codeErrNonexistingGrant: mysql.ErrNonexistingGrant,
mysql.ErrNonexistingGrant: mysql.ErrNonexistingGrant,
}
terror.ErrClassToMySQLCodes[terror.ClassPrivilege] = privilegeMySQLErrCodes
}
20 changes: 7 additions & 13 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ var (
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])
errNotAllowedCommand = terror.ClassServer.New(mysql.ErrNotAllowedCommand, mysql.MySQLErrName[mysql.ErrNotAllowedCommand])
errAccessDenied = terror.ClassServer.New(mysql.ErrAccessDenied, mysql.MySQLErrName[mysql.ErrAccessDenied])
)

// DefaultCapability is the capability of the server when it is created using the default configuration.
Expand Down Expand Up @@ -617,21 +617,15 @@ func (s *Server) kickIdleConnection() {

// Server error codes.
const (
codeUnknownFieldType = 1
codeInvalidPayloadLen = 2
codeInvalidSequence = 3
codeInvalidType = 4

codeNotAllowedCommand = 1148
codeAccessDenied = mysql.ErrAccessDenied
codeMaxExecTimeExceeded = mysql.ErrMaxExecTimeExceeded
codeUnknownFieldType = 1
codeInvalidSequence = 3
codeInvalidType = 4
)

func init() {
serverMySQLErrCodes := map[terror.ErrCode]uint16{
codeNotAllowedCommand: mysql.ErrNotAllowedCommand,
codeAccessDenied: mysql.ErrAccessDenied,
codeMaxExecTimeExceeded: mysql.ErrMaxExecTimeExceeded,
mysql.ErrNotAllowedCommand: mysql.ErrNotAllowedCommand,
mysql.ErrAccessDenied: mysql.ErrAccessDenied,
}
terror.ErrClassToMySQLCodes[terror.ClassServer] = serverMySQLErrCodes
}
9 changes: 2 additions & 7 deletions session/tidb.go
Original file line number Diff line number Diff line change
Expand Up @@ -367,17 +367,12 @@ func ResultSetToStringSlice(ctx context.Context, s Session, rs sqlexec.RecordSet

// Session errors.
var (
ErrForUpdateCantRetry = terror.ClassSession.New(codeForUpdateCantRetry,
mysql.MySQLErrName[mysql.ErrForUpdateCantRetry])
)

const (
codeForUpdateCantRetry terror.ErrCode = mysql.ErrForUpdateCantRetry
ErrForUpdateCantRetry = terror.ClassSession.New(mysql.ErrForUpdateCantRetry, mysql.MySQLErrName[mysql.ErrForUpdateCantRetry])
)

func init() {
sessionMySQLErrCodes := map[terror.ErrCode]uint16{
codeForUpdateCantRetry: mysql.ErrForUpdateCantRetry,
mysql.ErrForUpdateCantRetry: mysql.ErrForUpdateCantRetry,
}
terror.ErrClassToMySQLCodes[terror.ClassSession] = sessionMySQLErrCodes
}
8 changes: 3 additions & 5 deletions structure/structure.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@ import (

// structure error codes.
const (
codeInvalidHashKeyFlag terror.ErrCode = 1
codeInvalidHashKeyPrefix terror.ErrCode = 2
codeInvalidListIndex terror.ErrCode = 3
codeInvalidListMetaData terror.ErrCode = 4
codeWriteOnSnapshot terror.ErrCode = 5
codeInvalidHashKeyFlag terror.ErrCode = 1
codeInvalidListMetaData terror.ErrCode = 4
codeWriteOnSnapshot terror.ErrCode = 5
)

var (
Expand Down