Skip to content

Commit 58c381f

Browse files
author
Shlomi Noach
committed
some cleanup
1 parent 203ea6c commit 58c381f

1 file changed

Lines changed: 4 additions & 11 deletions

File tree

go/logic/applier.go

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -921,18 +921,14 @@ func (this *Applier) ShowStatusVariable(variableName string) (result int64, err
921921
return result, nil
922922
}
923923

924+
// updateModifiesUniqueKeyColumns checks whether a UPDATE DML event actually
925+
// modifies values of the migration's unique key (the iterated key). This will call
926+
// for special handling.
924927
func (this *Applier) updateModifiesUniqueKeyColumns(dmlEvent *binlog.BinlogDMLEvent) (modifiedColumn string, isModified bool) {
925-
// log.Debugf("............ UPDATE")
926-
// log.Debugf("............ UPDATE: %+v", this.migrationContext.UniqueKey.Columns.String())
927-
// log.Debugf("............ UPDATE: %+v", dmlEvent.WhereColumnValues.String())
928-
// log.Debugf("............ UPDATE: %+v", dmlEvent.NewColumnValues.String())
929928
for _, column := range this.migrationContext.UniqueKey.Columns.Columns() {
930929
tableOrdinal := this.migrationContext.OriginalTableColumns.Ordinals[column.Name]
931930
whereColumnValue := dmlEvent.WhereColumnValues.AbstractValues()[tableOrdinal]
932931
newColumnValue := dmlEvent.NewColumnValues.AbstractValues()[tableOrdinal]
933-
// log.Debugf("............ UPDATE: old value= %+v", whereColumnValue)
934-
// log.Debugf("............ UPDATE: new value= %+v", newColumnValue)
935-
// log.Debugf("............ UPDATE: equals? %+v", newColumnValue == whereColumnValue)
936932
if newColumnValue != whereColumnValue {
937933
return column.Name, true
938934
}
@@ -956,15 +952,12 @@ func (this *Applier) buildDMLEventQuery(dmlEvent *binlog.BinlogDMLEvent) (result
956952
}
957953
case binlog.UpdateDML:
958954
{
959-
if modifiedColumn, isModified := this.updateModifiesUniqueKeyColumns(dmlEvent); isModified {
960-
log.Debugf("---------------- Detected modifiedColumn: %+v. Will turn into DELETE+INSERT", modifiedColumn)
955+
if _, isModified := this.updateModifiesUniqueKeyColumns(dmlEvent); isModified {
961956
dmlEvent.DML = binlog.DeleteDML
962957
results = append(results, this.buildDMLEventQuery(dmlEvent)...)
963958
dmlEvent.DML = binlog.InsertDML
964959
results = append(results, this.buildDMLEventQuery(dmlEvent)...)
965960
return results
966-
// return buildResults(newDmlBuildResultError(log.Errorf("gh-ost detected an UPDATE to a unique key column this migration is iterating on. Such update is not supported. Column is `%s`", modifiedColumn)))
967-
// return query, args, rowsDelta, log.Errorf("gh-ost detected an UPDATE to a unique key column this migration is iterating on. Such update is not supported. Column is `%s`", modifiedColumn)
968961
}
969962
query, sharedArgs, uniqueKeyArgs, err := sql.BuildDMLUpdateQuery(dmlEvent.DatabaseName, this.migrationContext.GetGhostTableName(), this.migrationContext.OriginalTableColumns, this.migrationContext.SharedColumns, this.migrationContext.MappedSharedColumns, &this.migrationContext.UniqueKey.Columns, dmlEvent.NewColumnValues.AbstractValues(), dmlEvent.WhereColumnValues.AbstractValues())
970963
args := sqlutils.Args()

0 commit comments

Comments
 (0)