From 1a91a6d05b247ed19a801ebf4ca5d940bfb9a29c Mon Sep 17 00:00:00 2001 From: Breezewish Date: Fri, 17 Nov 2017 16:54:12 +0800 Subject: [PATCH] fix prefix index --- ddl/ddl_api.go | 4 ---- ddl/ddl_db_test.go | 9 +++++++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/ddl/ddl_api.go b/ddl/ddl_api.go index a7b953058ee40..8d2b144d88365 100644 --- a/ddl/ddl_api.go +++ b/ddl/ddl_api.go @@ -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, diff --git a/ddl/ddl_db_test.go b/ddl/ddl_db_test.go index 049310f8b2059..0caeb3d3e956f 100644 --- a/ddl/ddl_db_test.go +++ b/ddl/ddl_db_test.go @@ -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)