Skip to content

Commit 203ea6c

Browse files
author
Shlomi Noach
committed
refactor, simplifid code
1 parent 3898d49 commit 203ea6c

1 file changed

Lines changed: 4 additions & 8 deletions

File tree

go/logic/applier.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,6 @@ func newDmlBuildResultError(err error) *dmlBuildResult {
4646
}
4747
}
4848

49-
func buildResults(args ...(*dmlBuildResult)) [](*dmlBuildResult) {
50-
return args
51-
}
52-
5349
// Applier connects and writes the the applier-server, which is the server where migration
5450
// happens. This is typically the master, but could be a replica when `--test-on-replica` or
5551
// `--execute-on-replica` are given.
@@ -951,12 +947,12 @@ func (this *Applier) buildDMLEventQuery(dmlEvent *binlog.BinlogDMLEvent) (result
951947
case binlog.DeleteDML:
952948
{
953949
query, uniqueKeyArgs, err := sql.BuildDMLDeleteQuery(dmlEvent.DatabaseName, this.migrationContext.GetGhostTableName(), this.migrationContext.OriginalTableColumns, &this.migrationContext.UniqueKey.Columns, dmlEvent.WhereColumnValues.AbstractValues())
954-
return buildResults(newDmlBuildResult(query, uniqueKeyArgs, -1, err))
950+
return append(results, newDmlBuildResult(query, uniqueKeyArgs, -1, err))
955951
}
956952
case binlog.InsertDML:
957953
{
958954
query, sharedArgs, err := sql.BuildDMLInsertQuery(dmlEvent.DatabaseName, this.migrationContext.GetGhostTableName(), this.migrationContext.OriginalTableColumns, this.migrationContext.SharedColumns, this.migrationContext.MappedSharedColumns, dmlEvent.NewColumnValues.AbstractValues())
959-
return buildResults(newDmlBuildResult(query, sharedArgs, 1, err))
955+
return append(results, newDmlBuildResult(query, sharedArgs, 1, err))
960956
}
961957
case binlog.UpdateDML:
962958
{
@@ -974,10 +970,10 @@ func (this *Applier) buildDMLEventQuery(dmlEvent *binlog.BinlogDMLEvent) (result
974970
args := sqlutils.Args()
975971
args = append(args, sharedArgs...)
976972
args = append(args, uniqueKeyArgs...)
977-
return buildResults(newDmlBuildResult(query, args, 0, err))
973+
return append(results, newDmlBuildResult(query, args, 0, err))
978974
}
979975
}
980-
return buildResults(newDmlBuildResultError(fmt.Errorf("Unknown dml event type: %+v", dmlEvent.DML)))
976+
return append(results, newDmlBuildResultError(fmt.Errorf("Unknown dml event type: %+v", dmlEvent.DML)))
981977
}
982978

983979
// ApplyDMLEventQuery writes an entry to the ghost table, in response to an intercepted

0 commit comments

Comments
 (0)