-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
ddl: fix a bug when adding an index to a generated column with an expression error #9216
Conversation
/run-all-tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
PTAL @winkyao @ciscoxll @crazycs520 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rest,LGTM.
ddl/ddl.go
Outdated
@@ -76,6 +76,7 @@ var ( | |||
errInvalidWorker = terror.ClassDDL.New(codeInvalidWorker, "invalid worker") | |||
// errNotOwner means we are not owner and can't handle DDL jobs. | |||
errNotOwner = terror.ClassDDL.New(codeNotOwner, "not Owner") | |||
errCantDecodeIndex = terror.ClassDDL.New(codeCantDecodeIndex, "can't decode index value, because %s") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/Cant/Cannnot
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MySQL uses it to name the error like 'ErrCantDropFieldOrKey'.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But in TiDB, I think we use Cannot
is better.
F.Y.R:
xiekeyi@ubuntu:~/gopath/src/github.com/pingcap/tidb$ grep -rn "ErrCannot"
匹配到二进制文件 bin/tidb-server
匹配到二进制文件 cmd/explaintest/explain_test
executor/simple_test.go:185: c.Assert(terror.ErrorEqual(err, executor.ErrCannotUser.GenWithStackByArgs("DROP USER", "")), IsTrue, Commentf("err %v", err))
executor/simple_test.go:194: c.Assert(terror.ErrorEqual(err, executor.ErrCannotUser.GenWithStackByArgs("DROP USER", "")), IsTrue, Commentf("err %v", err))
executor/simple.go:243: return ErrCannotUser.GenWithStackByArgs("ALTER USER", strings.Join(failedUsers, ","))
executor/simple.go:302: return ErrCannotUser.GenWithStackByArgs("DROP USER", strings.Join(failedUsers, ","))
executor/errors.go:43: ErrCannotUser = terror.ClassExecutor.New(mysql.ErrCannotUser, mysql.MySQLErrName[mysql.ErrCannotUser])
executor/errors.go:57: mysql.ErrCannotUser: mysql.ErrCannotUser,
vendor/github.com/pingcap/parser/mysql/errname.go:233: ErrCannotAddForeign: "Cannot add foreign key constraint",
vendor/github.com/pingcap/parser/mysql/errname.go:414: ErrCannotUser: "Operation %s failed for %.256s",
vendor/github.com/pingcap/parser/mysql/errname.go:746: ErrCannotLoadFromTableV2: "Cannot load from %s.%s. The table is probably corrupted",
vendor/github.com/pingcap/parser/mysql/errcode.go:235: ErrCannotAddForeign = 1215
vendor/github.com/pingcap/parser/mysql/errcode.go:416: ErrCannotUser = 1396
vendor/github.com/pingcap/parser/mysql/errcode.go:748: ErrCannotLoadFromTableV2 = 1728
kv/kv.go:97: // v must NOT be nil or empty, otherwise it returns ErrCannotSetNilValue.
kv/error.go:55: // ErrCannotSetNilValue is the error when sets an empty value.
kv/error.go:56: ErrCannotSetNilValue = terror.ClassKV.New(codeCantSetNilValue, "can not set nil value")
kv/memdb_buffer.go:91: return errors.Trace(ErrCannotSetNilValue)
infoschema/infoschema.go:39: // ErrCannotAddForeign returns for foreign key exists.
infoschema/infoschema.go:40: ErrCannotAddForeign = terror.ClassSchema.New(codeCannotAddForeign, "Cannot add foreign key constraint")
infoschema/infoschema.go:329: codeCannotAddForeign: mysql.ErrCannotAddForeign,
util/admin/admin.go:92: return ErrCannotCancelDDLJob.GenWithStackByArgs(id)
util/admin/admin.go:96: return ErrCannotCancelDDLJob.GenWithStackByArgs(id)
util/admin/admin.go:102: return ErrCannotCancelDDLJob.GenWithStackByArgs(id)
util/admin/admin.go:743: // ErrCannotCancelDDLJob returns when cancel a almost finished ddl job, because cancel in now may cause data inconsistency.
util/admin/admin.go:744: ErrCannotCancelDDLJob = terror.ClassAdmin.New(codeCannotCancelDDLJob, "This job:%v is almost finished, can't be cancelled now")
ddl/db_test.go:461: err1 := admin.ErrCannotCancelDDLJob.GenWithStackByArgs(jobID)
ddl/db_test.go:615: c.Assert(checkErr.Error(), Equals, admin.ErrCannotCancelDDLJob.GenWithStackByArgs(jobID).Error())
ddl/db_test.go:1022: c.Assert(checkErr.Error(), Equals, admin.ErrCannotCancelDDLJob.GenWithStackByArgs(jobID).Error())
ddl/ddl_worker_test.go:375: {act: model.ActionDropColumn, jobIDs: []int64{firstID + 13}, cancelRetErrs: []error{admin.ErrCannotCancelDDLJob.GenWithStackByArgs(firstID + 13)}, cancelState: model.StateDeleteOnly, ddlRetErr: err},
ddl/ddl_worker_test.go:376: {act: model.ActionDropColumn, jobIDs: []int64{firstID + 14}, cancelRetErrs: []error{admin.ErrCannotCancelDDLJob.GenWithStackByArgs(firstID + 14)}, cancelState: model.StateWriteOnly, ddlRetErr: err},
ddl/ddl_worker_test.go:377: {act: model.ActionDropColumn, jobIDs: []int64{firstID + 15}, cancelRetErrs: []error{admin.ErrCannotCancelDDLJob.GenWithStackByArgs(firstID + 15)}, cancelState: model.StateWriteReorganization, ddlRetErr: err},
匹配到二进制文件 ddl/.ddl_api.go.swp
ddl/ddl_api.go:765: return infoschema.ErrCannotAddForeign
ddl/ddl_api.go:847: return nil, infoschema.ErrCannotAddForeign
ddl/ddl_api.go:870: return nil, infoschema.ErrCannotAddForeign
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh,I am sorry for that.
Indeed, cant
is more used.
xiekeyi@ubuntu:~/gopath/src/github.com/pingcap/tidb$ grep -rn "ErrCant" | wc -l
130
xiekeyi@ubuntu:~/gopath/src/github.com/pingcap/tidb$ grep -rn "ErrCannot" | wc -l
36
xiekeyi@ubuntu:~/gopath/src/github.com/pingcap/tidb$
···
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Codecov Report
@@ Coverage Diff @@
## master #9216 +/- ##
==========================================
+ Coverage 67.22% 67.23% +<.01%
==========================================
Files 371 371
Lines 77271 77271
==========================================
+ Hits 51948 51952 +4
+ Misses 20682 20680 -2
+ Partials 4641 4639 -2
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
…ression error
What problem does this PR solve?
Fix the #9214
What is changed and how it works?
If we encounter a decoding error when adding an index, then we directly return the error of adding this index.
Check List
Tests
Related changes