-
Notifications
You must be signed in to change notification settings - Fork 1
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
support multi-schema-change for drop index #20
Conversation
// Move all the dependent hidden columns to the end. | ||
endOffset := len(tblInfo.Columns) - 1 | ||
for _, offset := range hiddenColOffs { | ||
tblInfo.MoveColumnInfo(offset, endOffset) |
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.
tblInfo.MoveColumnInfo(offset, endOffset) | |
tblInfo.MoveColumnInfo(offset, endOffset) | |
endOffset-- |
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 the order does not matter, because the columns will be removed anyway.
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.
It will reduce the number of exchanges
26aba4f
to
15153a0
Compare
@@ -217,6 +217,9 @@ func onAddColumn(d *ddlCtx, t *meta.Meta, job *model.Job) (ver int64, err error) | |||
} | |||
|
|||
func locateOffsetForColumn(pos *ast.ColumnPosition, tblInfo *model.TableInfo) (offset int, err error) { | |||
if pos == nil { | |||
return -1, 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.
locateOffsetForColumn
is also used by AddColumn
so the pos can be null.
@@ -362,7 +365,7 @@ func onAddColumns(d *ddlCtx, t *meta.Meta, job *model.Job) (ver int64, err error | |||
case model.StateWriteReorganization: | |||
// reorganization -> public | |||
// Adjust table column offsets. | |||
for i, newCol := range tblInfo.Columns[:len(tblInfo.Columns)-len(positions)] { | |||
for i, newCol := range tblInfo.Columns[len(tblInfo.Columns)-len(positions):] { |
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.
Added test in TestMultiSchemaChangeAddColumns
:
create table t (a int, b int, c int);
alter table t add column (d int default 4, e int default 5);
make system variables take effects
What problem does this PR solve?
Issue Number: close #21
Problem Summary:
What is changed and how it works?
Check List
Tests
Side effects
Documentation
Release note