Skip to content

Commit

Permalink
Fixed issue with DDL states for indexes during ALTER PARTITION
Browse files Browse the repository at this point in the history
  • Loading branch information
mjonss committed Jan 17, 2023
1 parent 3386976 commit e620a42
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions table/tables/partition.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,7 @@ func newPartitionedTable(tbl *TableCommon, tblInfo *model.TableInfo) (table.Part
// also in DroppingDefinitions (since session running on schema version -1)
// should also see the changes
if pi.DDLState == model.StateDeleteReorganization {
// use the 'StateWriteReorganization' here, since StateDeleteReorganization
// would skip index writes.
origIdx := setIndexesState(ret, model.StateWriteReorganization)
origIdx := setIndexesState(ret, pi.DDLState)
defer unsetIndexesState(ret, origIdx)
ret.reorgPartitionExpr, err = newPartitionExpr(tblInfo, pi.DroppingDefinitions)
if err != nil {
Expand Down Expand Up @@ -200,7 +198,18 @@ func setIndexesState(t *partitionedTable, state model.SchemaState) []*model.Inde
t.meta.Indices = make([]*model.IndexInfo, 0, len(orig))
for i := range orig {
t.meta.Indices = append(t.meta.Indices, orig[i].Clone())
t.meta.Indices[i].State = state
if t.meta.Indices[i].State == model.StatePublic {
switch state {
case model.StateDeleteOnly, model.StateNone:
t.meta.Indices[i].State = model.StateDeleteOnly
case model.StatePublic:
// Keep as is
default:
// use the 'StateWriteReorganization' here, since StateDeleteReorganization
// would skip index writes.
t.meta.Indices[i].State = model.StateWriteReorganization
}
}
}
return orig
}
Expand Down

0 comments on commit e620a42

Please sign in to comment.