Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix check field generated #12

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions session/session_inception.go
Original file line number Diff line number Diff line change
Expand Up @@ -2631,6 +2631,7 @@ func (s *session) mysqlCheckField(t *TableInfo, field *ast.ColumnDef) {
notNullFlag := false
autoIncrement := false
hasDefaultValue := false
hasGenerated := false
var defaultValue *types.Datum
var defaultExpr ast.ExprNode

Expand All @@ -2656,6 +2657,8 @@ func (s *session) mysqlCheckField(t *TableInfo, field *ast.ColumnDef) {
hasDefaultValue = true
case ast.ColumnOptionPrimaryKey:
isPrimary = true
case ast.ColumnOptionGenerated:
hasGenerated = true
}
}
}
Expand Down Expand Up @@ -2745,9 +2748,8 @@ func (s *session) mysqlCheckField(t *TableInfo, field *ast.ColumnDef) {
}

if !hasDefaultValue && field.Tp.Tp != mysql.TypeTimestamp &&
!types.IsTypeBlob(field.Tp.Tp) && !autoIncrement && !isPrimary && field.Tp.Tp != mysql.TypeJSON {
!types.IsTypeBlob(field.Tp.Tp) && !autoIncrement && !isPrimary && field.Tp.Tp != mysql.TypeJSON && !hasGenerated {
s.AppendErrorNo(ER_WITH_DEFAULT_ADD_COLUMN, field.Name.Name.O, tableName)

}

// if (thd->variables.sql_mode & MODE_NO_ZERO_DATE &&
Expand Down