Skip to content

Commit

Permalink
ddl: fix alter column set default wrongly updates the schema (#32249)…
Browse files Browse the repository at this point in the history
… (#32264)

close #31074
  • Loading branch information
ti-srebot authored Feb 23, 2022
1 parent c65493d commit 840c6a4
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions ddl/ddl_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -4561,10 +4561,11 @@ func (d *ddl) AlterColumn(ctx sessionctx.Context, ident ast.Ident, spec *ast.Alt

colName := specNewColumn.Name.Name
// Check whether alter column has existed.
col := table.FindCol(t.Cols(), colName.L)
if col == nil {
oldCol := table.FindCol(t.Cols(), colName.L)
if oldCol == nil {
return ErrBadField.GenWithStackByArgs(colName, ident.Name)
}
col := table.ToColumn(oldCol.Clone())

// Clean the NoDefaultValueFlag value.
col.Flag &= ^mysql.NoDefaultValueFlag
Expand Down

0 comments on commit 840c6a4

Please sign in to comment.