Skip to content

Commit

Permalink
clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
wjhuang2016 committed Dec 19, 2019
1 parent a5bb03c commit 133428e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions ddl/ddl_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -3328,7 +3328,7 @@ func (d *ddl) CreatePrimaryKey(ctx sessionctx.Context, ti ast.Ident, indexName m
}

// Primary keys cannot include expression index parts. A primary key requires the generated column to be stored,
// but functional key parts are implemented as virtual generated columns, not stored generated columns.
// but expression index parts are implemented as virtual generated columns, not stored generated columns.
for _, idxPart := range indexPartSpecifications {
if idxPart.Expr != nil {
return ErrFunctionalIndexPrimaryKey
Expand All @@ -3341,7 +3341,7 @@ func (d *ddl) CreatePrimaryKey(ctx sessionctx.Context, ti ast.Ident, indexName m
// to job queue, the fail path logic is super fast.
// After DDL job is put to the queue, and if the check fail, TiDB will run the DDL cancel logic.
// The recover step causes DDL wait a few seconds, makes the unit test painfully slow.
_, err = buildIndexColumns(tblInfo.Columns, indexPartSpecifications, indexName)
_, err = buildIndexColumns(tblInfo.Columns, indexPartSpecifications)
if err != nil {
return errors.Trace(err)
}
Expand Down Expand Up @@ -3467,7 +3467,7 @@ func (d *ddl) CreateIndex(ctx sessionctx.Context, ti ast.Ident, keyType ast.Inde
// to job queue, the fail path logic is super fast.
// After DDL job is put to the queue, and if the check fail, TiDB will run the DDL cancel logic.
// The recover step causes DDL wait a few seconds, makes the unit test painfully slow.
_, err = buildIndexColumns(append(tblInfo.Columns, hiddenCols...), indexPartSpecifications, indexName)
_, err = buildIndexColumns(append(tblInfo.Columns, hiddenCols...), indexPartSpecifications)
if err != nil {
return errors.Trace(err)
}
Expand Down
10 changes: 5 additions & 5 deletions ddl/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ const (
MaxCommentLength = 1024
)

func buildIndexColumns(columns []*model.ColumnInfo, indexPartSpecifications []*ast.IndexPartSpecification, indexName model.CIStr) ([]*model.IndexColumn, error) {
func buildIndexColumns(columns []*model.ColumnInfo, indexPartSpecifications []*ast.IndexPartSpecification) ([]*model.IndexColumn, error) {
// Build offsets.
idxPart := make([]*model.IndexColumn, 0, len(indexPartSpecifications))
idxParts := make([]*model.IndexColumn, 0, len(indexPartSpecifications))
var col *model.ColumnInfo

// The sum of length of all index columns.
Expand All @@ -81,14 +81,14 @@ func buildIndexColumns(columns []*model.ColumnInfo, indexPartSpecifications []*a
return nil, errors.Trace(errTooLongKey)
}

idxPart = append(idxPart, &model.IndexColumn{
idxParts = append(idxParts, &model.IndexColumn{
Name: col.Name,
Offset: col.Offset,
Length: ip.Length,
})
}

return idxPart, nil
return idxParts, nil
}

func checkPKOnGeneratedColumn(tblInfo *model.TableInfo, indexPartSpecifications []*ast.IndexPartSpecification) (*model.ColumnInfo, error) {
Expand Down Expand Up @@ -209,7 +209,7 @@ func buildIndexInfo(tblInfo *model.TableInfo, indexName model.CIStr, indexPartSp
return nil, errors.Trace(err)
}

idxColumns, err := buildIndexColumns(tblInfo.Columns, indexPartSpecifications, indexName)
idxColumns, err := buildIndexColumns(tblInfo.Columns, indexPartSpecifications)
if err != nil {
return nil, errors.Trace(err)
}
Expand Down

0 comments on commit 133428e

Please sign in to comment.