@@ -1220,6 +1220,12 @@ func (this *Applier) ApplyDMLEventQueries(dmlEvents [](*binlog.BinlogDMLEvent))
1220
1220
}
1221
1221
defer conn .Close ()
1222
1222
1223
+ sessionQuery := "SET /* gh-ost */ SESSION time_zone = '+00:00'"
1224
+ sessionQuery = fmt .Sprintf ("%s, %s" , sessionQuery , this .generateSqlModeQuery ())
1225
+ if _ , err := conn .ExecContext (ctx , sessionQuery ); err != nil {
1226
+ return err
1227
+ }
1228
+
1223
1229
tx , err := conn .BeginTx (ctx , nil )
1224
1230
if err != nil {
1225
1231
return err
@@ -1229,13 +1235,6 @@ func (this *Applier) ApplyDMLEventQueries(dmlEvents [](*binlog.BinlogDMLEvent))
1229
1235
return err
1230
1236
}
1231
1237
1232
- sessionQuery := "SET /* gh-ost */ SESSION time_zone = '+00:00'"
1233
- sessionQuery = fmt .Sprintf ("%s, %s" , sessionQuery , this .generateSqlModeQuery ())
1234
-
1235
- if _ , err := tx .Exec (sessionQuery ); err != nil {
1236
- return rollback (err )
1237
- }
1238
-
1239
1238
buildResults := make ([]* dmlBuildResult , 0 , len (dmlEvents ))
1240
1239
nArgs := 0
1241
1240
for _ , dmlEvent := range dmlEvents {
@@ -1248,6 +1247,9 @@ func (this *Applier) ApplyDMLEventQueries(dmlEvents [](*binlog.BinlogDMLEvent))
1248
1247
}
1249
1248
}
1250
1249
1250
+ // We batch together the DML queries into multi-statements to minimize network trips.
1251
+ // We have to use the raw driver connection to access the rows affected
1252
+ // for each statement in the multi-statement.
1251
1253
execErr := conn .Raw (func (driverConn any ) error {
1252
1254
ex := driverConn .(driver.ExecerContext )
1253
1255
nvc := driverConn .(driver.NamedValueChecker )
0 commit comments