Skip to content

Commit

Permalink
address comments: move handling ColumnOptionCollate to TiDB side
Browse files Browse the repository at this point in the history
  • Loading branch information
bb7133 committed Mar 26, 2019
1 parent 9cfdcc3 commit 4b60e72
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 25 deletions.
6 changes: 5 additions & 1 deletion ast/ddl.go
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,11 @@ func (n *ColumnOption) Restore(ctx *RestoreCtx) error {
return errors.Annotate(err, "An error occurred while splicing ColumnOption ReferenceDef")
}
case ColumnOptionCollate:
// Do nothing, we should never see a ColumnOptionCollate after parsing
if n.StrValue == "" {
return errors.New("Empty ColumnOption COLLATE")
}
ctx.WriteKeyWord("COLLATE ")
ctx.WritePlain(n.StrValue)
default:
return errors.New("An error occurred while splicing ColumnOption")
}
Expand Down
13 changes: 1 addition & 12 deletions parser.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 1 addition & 12 deletions parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -1481,18 +1481,7 @@ ColumnDefList:
ColumnDef:
ColumnName Type ColumnOptionListOpt
{
def := &ast.ColumnDef{Name: $1.(*ast.ColumnName), Tp: $2.(*types.FieldType)}
opts := make([]*ast.ColumnOption, 0)
for _, opt := range $3.([]*ast.ColumnOption) {
// ColumnOptionCollate is only used to set FieldType.Collate
if opt.Tp == ast.ColumnOptionCollate {
def.Tp.Collate = opt.StrValue
} else {
opts = append(opts, opt)
}
}
def.Options = opts
$$ = def
$$ = &ast.ColumnDef{Name: $1.(*ast.ColumnName), Tp: $2.(*types.FieldType), Options: $3.([]*ast.ColumnOption)}
}

ColumnName:
Expand Down

0 comments on commit 4b60e72

Please sign in to comment.