-
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
ddl: refactor modify column for multi-schema change #33631
Conversation
[REVIEW NOTIFICATION] This pull request has been approved by:
To complete the pull request process, please ask the reviewers in the list to review by filling The full list of commands accepted by this bot can be found here. Reviewer can indicate their review by submitting an approval review. |
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.
After this PR, the number of lines of code has increased a lot (86->211 lines). At first sight, there is no special advantage. Could you explain the idea of this refactoring in the description?
Code Coverage Details: https://codecov.io/github/pingcap/tidb/commit/24bfd6bc78b0858f082588b391b24b87128c38a5 |
ddl/column.go
Outdated
@@ -1102,6 +1099,120 @@ func (w *worker) doModifyColumnTypeWithData( | |||
return ver, errors.Trace(err) | |||
} | |||
|
|||
func replaceOldColumn(tblInfo *model.TableInfo, oldID, newID int64, |
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.
Why don't we send arguments oldCol
and changingCol
directly? Then we needn't to find these two args. And we needn't return JobStateRollingback
.
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.
Because the column info's offset can be incorrect in the case of multi-schema change like add column first, modify column
.
return ver, errors.Trace(err) | ||
} | ||
tblInfo.Indices = tblInfo.Indices[:len(tblInfo.Indices)-len(changingIdxs)] | ||
// Adjust table column offset. | ||
if err = adjustColumnInfoInModifyColumn(job, tblInfo, changingCol, oldCol, pos, changingColumnUniqueName.L); err != nil { |
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.
Could we adjust the function of adjustColumnInfoInModifyColumn
?Then we can still call it 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.
LGTM
/merge |
This pull request has been accepted and is ready to merge. Commit hash: 24bfd6b
|
What problem does this PR solve?
Issue Number: ref #14766
Problem Summary:
This PR refactors the backfilling column-type-change implementation, in order to make it more compatible with multi-schema change.
This PR also improves the code readability.
What is changed and how it works?
adjustColumnInfoInModifyColumn
is broken into several functions.Check List
Tests
Side effects
Documentation
Release note