diff --git a/ddl/index.go b/ddl/index.go index 5a56861f73..bd62948f94 100644 --- a/ddl/index.go +++ b/ddl/index.go @@ -29,12 +29,6 @@ import ( ) func buildIndexInfo(tblInfo *model.TableInfo, unique bool, indexName model.CIStr, indexID int64, idxColNames []*coldef.IndexColName) (*model.IndexInfo, error) { - for _, col := range tblInfo.Columns { - if col.Name.L == indexName.L { - return nil, errors.Errorf("CREATE INDEX: index name collision with existing column: %s", indexName) - } - } - // build offsets idxColumns := make([]*model.IndexColumn, 0, len(idxColNames)) for _, ic := range idxColNames { diff --git a/ddl/index_test.go b/ddl/index_test.go index 32df668353..43399e7df8 100644 --- a/ddl/index_test.go +++ b/ddl/index_test.go @@ -612,6 +612,9 @@ func (s *testIndexSuite) TestAddIndex(c *C) { job := testCreateIndex(c, ctx, d, s.dbInfo, tblInfo, true, "c1_uni", "c1") testCheckJobDone(c, d, job, true) + job = testCreateIndex(c, ctx, d, s.dbInfo, tblInfo, true, "c1", "c1") + testCheckJobDone(c, d, job, true) + _, err = ctx.GetTxn(true) c.Assert(err, IsNil)