Skip to content

Commit

Permalink
fix prefix index (#5149)
Browse files Browse the repository at this point in the history
  • Loading branch information
breezewish authored and shenli committed Nov 20, 2017
1 parent aef8142 commit a2c2397
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 0 additions & 4 deletions ddl/ddl_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,10 +263,6 @@ func columnDefToCol(ctx context.Context, offset int, colDef *ast.ColumnDef) (*ta
if colDef.Options != nil {
len := types.UnspecifiedLength

if types.IsTypePrefixable(colDef.Tp.Tp) {
len = colDef.Tp.Flen
}

keys := []*ast.IndexColName{
{
Column: colDef.Name,
Expand Down
9 changes: 9 additions & 0 deletions ddl/ddl_db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,15 @@ func (s *testDBSuite) TestAddAnonymousIndex(c *C) {
c.Assert(t.Indices()[1].Meta().Name.String(), Equals, "primary_3")
}

// Issue 5134
func (s *testDBSuite) TestModifyColumnAfterAddIndex(c *C) {
s.tk = testkit.NewTestKit(c, s.store)
s.tk.MustExec("use " + s.schemaName)
s.mustExec(c, "create table city (city VARCHAR(2) KEY);")
s.mustExec(c, "alter table city change column city city varchar(50);")
s.mustExec(c, `insert into city values ("abc"), ("abd");`)
}

func (s *testDBSuite) testAlterLock(c *C) {
s.tk = testkit.NewTestKit(c, s.store)
s.tk.MustExec("use " + s.schemaName)
Expand Down

0 comments on commit a2c2397

Please sign in to comment.