-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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 add index after add column with default value #3510
Conversation
@zimulala CI failed. |
table/tables/tables.go
Outdated
@@ -673,6 +661,27 @@ func (t *Table) IterRecords(ctx context.Context, startKey kv.Key, cols []*table. | |||
return nil | |||
} | |||
|
|||
func GetColDefaultValue(ctx context.Context, col *table.Column, defaultVals []types.Datum) ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add comment.
table/tables/tables.go
Outdated
if mysql.HasNotNullFlag(col.Flag) { | ||
return nil, errors.New("Miss column") | ||
} | ||
v[i], err = GetColDefaultValue(ctx, col, defaultVals) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we move this before line 479?
ddl/index.go
Outdated
} | ||
idxColumnVal, ret.err = tables.GetColDefaultValue(ctx, col, defaultVals) | ||
if ret.err != nil { | ||
ret.err = errors.Trace(err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
table/tables/tables.go
Outdated
@@ -673,6 +661,27 @@ func (t *Table) IterRecords(ctx context.Context, startKey kv.Key, cols []*table. | |||
return nil | |||
} | |||
|
|||
func GetColDefaultValue(ctx context.Context, col *table.Column, defaultVals []types.Datum) ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can implement a GetAllColDefaultValues to return default values for every column at one time. Passing a slice every time is a little strange.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If implement a GetAllColDefaultValues
, it will be an interface and its arguments are hard to understand. I tried and thought it was not very good. @hanfei1991
PTAL @shenli @hanfei1991 |
LGTM |
LGTM |
Conflicts: table/tables/tables.go
Conflicts: table/tables/tables.go
No description provided.