Skip to content

Commit

Permalink
cherry pick pingcap#36277 to release-5.4
Browse files Browse the repository at this point in the history
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
  • Loading branch information
AilinKid authored and ti-srebot committed Jul 21, 2022
1 parent ef81f12 commit de1d1ce
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion ddl/sequence.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,11 @@ func onAlterSequence(t *meta.Meta, job *model.Job) (ver int64, _ error) {
job.State = model.JobStateCancelled
return ver, errors.Trace(err)
}
shouldUpdateVer := !reflect.DeepEqual(*tblInfo.Sequence, copySequenceInfo) || restart
same := reflect.DeepEqual(*tblInfo.Sequence, copySequenceInfo)
if same && !restart {
job.State = model.JobStateDone
return ver, errors.Trace(err)
}
tblInfo.Sequence = &copySequenceInfo

// Restart the sequence value.
Expand All @@ -276,7 +280,13 @@ func onAlterSequence(t *meta.Meta, job *model.Job) (ver int64, _ error) {
}

// Store the sequence info into kv.
<<<<<<< HEAD
ver, err = updateVersionAndTableInfo(t, job, tblInfo, shouldUpdateVer)
=======
// Set shouldUpdateVer always to be true even altering doesn't take effect, since some tools like drainer won't take
// care of SchemaVersion=0.
ver, err = updateVersionAndTableInfo(d, t, job, tblInfo, true)
>>>>>>> 1bc13cd18... ddl: prevent returning zero schema version for alter sequence (#36277)
if err != nil {
return ver, errors.Trace(err)
}
Expand Down

0 comments on commit de1d1ce

Please sign in to comment.