Skip to content

Commit

Permalink
address comment
Browse files Browse the repository at this point in the history
  • Loading branch information
wjhuang2016 committed Jan 6, 2020
1 parent edace5d commit 4938b40
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
12 changes: 7 additions & 5 deletions ddl/db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,11 +250,13 @@ func (s *testDBSuite2) TestAddUniqueIndexRollback(c *C) {
}

func (s *testDBSuite6) TestAddExpressionIndexRollback(c *C) {
hasNullValsInKey := false
idxName := "expr_idx"
addIdxSQL := "alter table t1 add index expr_idx ((pow(c1, c2)));"
errMsg := "[ddl:8202]Cannot decode index value, because [types:1690]DOUBLE value is out of range in 'pow(144, 144)'"
testAddIndexRollback(c, s.store, s.lease, idxName, addIdxSQL, errMsg, hasNullValsInKey, true)
// TODO: This test may cause a bug which has been fixed in following PR, uncomment these code
// in that PR @wjhuang2016
//hasNullValsInKey := false
//idxName := "expr_idx"
//addIdxSQL := "alter table t1 add index expr_idx ((pow(c1, c2)));"
//errMsg := "[ddl:8202]Cannot decode index value, because [types:1690]DOUBLE value is out of range in 'pow(144, 144)'"
//testAddIndexRollback(c, s.store, s.lease, idxName, addIdxSQL, errMsg, hasNullValsInKey, true)
}

func batchInsert(tk *testkit.TestKit, tbl string, start, end int) {
Expand Down
8 changes: 2 additions & 6 deletions ddl/rollingback.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,8 @@ func convertAddIdxJob2RollbackJob(t *meta.Meta, job *model.Job, tblInfo *model.T
// So the next state is delete only state.
originalState := indexInfo.State
indexInfo.State = model.StateDeleteOnly
// change dependent hidden columns if necessary
for _, indexCol := range indexInfo.Columns {
if tblInfo.Columns[indexCol.Offset].Hidden {
tblInfo.Columns[indexCol.Offset].State = model.StateDeleteOnly
}
}
// Change dependent hidden columns if necessary.
updateHiddenColumns(tblInfo, indexInfo, model.StateDeleteOnly)
job.SchemaState = model.StateDeleteOnly
ver, err1 := updateVersionAndTableInfo(t, job, tblInfo, originalState != indexInfo.State)
if err1 != nil {
Expand Down
2 changes: 1 addition & 1 deletion util/admin/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func IsJobRollbackable(job *model.Job) bool {
case model.ActionDropIndex, model.ActionDropPrimaryKey:
// We can't cancel if index current state is in StateDeleteOnly or StateDeleteReorganization or StateWriteOnly, otherwise there will be an inconsistent issue between record and index.
// In WriteOnly state, we can rollback for normal index but can't rollback for expression index(need to drop hidden column). Since we can't
// known the type of index here, we consider all indices except primary index as non-rollbackable.
// know the type of index here, we consider all indices except primary index as non-rollbackable.
// TODO: distinguish normal index and expression index so that we can rollback `DropIndex` for normal index in WriteOnly state.
// TODO: make DropPrimaryKey rollbackable in WriteOnly, it need to deal with some tests.
if job.SchemaState == model.StateDeleteOnly ||
Expand Down

0 comments on commit 4938b40

Please sign in to comment.