Skip to content

Commit

Permalink
address comment
Browse files Browse the repository at this point in the history
  • Loading branch information
crazycs520 committed Oct 15, 2018
1 parent f67aeeb commit 88106f5
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion ddl/ddl.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ var (
errIncorrectPrefixKey = terror.ClassDDL.New(codeIncorrectPrefixKey, "Incorrect prefix key; the used key part isn't a string, the used length is longer than the key part, or the storage engine doesn't support unique prefix keys")
errTooLongKey = terror.ClassDDL.New(codeTooLongKey,
fmt.Sprintf("Specified key was too long; max key length is %d bytes", maxPrefixLength))
errKeyColumnDoesNotExits = terror.ClassDDL.New(codeKeyColumnDoesNotExits, "this key column doesn't exist in table")
errKeyColumnDoesNotExits = terror.ClassDDL.New(codeKeyColumnDoesNotExits, mysql.MySQLErrName[mysql.ErrKeyColumnDoesNotExits])
errUnknownTypeLength = terror.ClassDDL.New(codeUnknownTypeLength, "Unknown length for type tp %d")
errUnknownFractionLength = terror.ClassDDL.New(codeUnknownFractionLength, "Unknown Length for type tp %d and fraction %d")
errInvalidJobVersion = terror.ClassDDL.New(codeInvalidJobVersion, "DDL job with version %d greater than current %d")
Expand Down
4 changes: 2 additions & 2 deletions ddl/ddl_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ func buildTableInfo(ctx sessionctx.Context, d *ddl, tableName model.CIStr, cols
fk.State = model.StatePublic
for _, key := range constr.Keys {
if !table.FindColInfo(tbInfo.Columns, key.Column.Name.O) {
return nil, errKeyColumnDoesNotExits.GenWithStack("key column %s doesn't exist in table", key.Column.Name)
return nil, errKeyColumnDoesNotExits.GenWithStackByArgs(key.Column.Name)
}
fk.Cols = append(fk.Cols, key.Column.Name)
}
Expand All @@ -752,7 +752,7 @@ func buildTableInfo(ctx sessionctx.Context, d *ddl, tableName model.CIStr, cols
for _, key := range constr.Keys {
col = table.FindCol(cols, key.Column.Name.O)
if col == nil {
return nil, errKeyColumnDoesNotExits.GenWithStack("key column %s doesn't exist in table", key.Column.Name)
return nil, errKeyColumnDoesNotExits.GenWithStackByArgs(key.Column.Name)
}
// Virtual columns cannot be used in primary key.
if col.IsGenerated() && !col.GeneratedStored {
Expand Down
2 changes: 1 addition & 1 deletion executor/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ func (s *testSuite) TestTableForeignKey(c *C) {
tk.MustExec("use test")
tk.MustExec("create table t1 (a int, b int);")
_, err := tk.Exec("create table t2 (c int, foreign key (a) references t1(a));")
c.Assert(err.Error(), Equals, "[ddl:1072]key column a doesn't exist in table")
c.Assert(err.Error(), Equals, "[ddl:1072]Key column 'a' doesn't exist in table")
tk.MustExec("drop table if exists t1,t2;")
}

Expand Down

0 comments on commit 88106f5

Please sign in to comment.