diff --git a/go/logic/applier.go b/go/logic/applier.go index e798596..cabd66a 100644 --- a/go/logic/applier.go +++ b/go/logic/applier.go @@ -414,7 +414,28 @@ func (this *Applier) ApplyIterationInsertQuery() (chunkSize int64, rowsAffected if err != nil { return chunkSize, rowsAffected, duration, err } - sqlResult, err := sqlutils.Exec(this.db, query, explodedArgs...) + + sqlResult, err := func() (gosql.Result, error) { + tx, err := this.db.Begin() + if err != nil { + return nil, err + } + if _, err := tx.Exec(`SET + SESSION time_zone = '+00:00', + sql_mode = CONCAT(@@session.sql_mode, ',STRICT_ALL_TABLES') + `); err != nil { + return nil, err + } + result, err := tx.Exec(query, explodedArgs...) + if err != nil { + return nil, err + } + if err := tx.Commit(); err != nil { + return nil, err + } + return result, nil + }() + if err != nil { return chunkSize, rowsAffected, duration, err } diff --git a/localtests/tz-datetime-ts/create.sql b/localtests/tz-datetime-ts/create.sql index 958e8fd..6d2ca2a 100644 --- a/localtests/tz-datetime-ts/create.sql +++ b/localtests/tz-datetime-ts/create.sql @@ -4,7 +4,7 @@ create table gh_ost_test ( i int not null, ts0 timestamp default current_timestamp, ts1 timestamp, - ts2 timestamp, + ts2 datetime, t datetime, updated tinyint unsigned default 0, primary key(id), @@ -21,11 +21,13 @@ create event gh_ost_test enable do begin + insert into gh_ost_test values (null, 7, null, now(), now(), '2010-10-20 10:20:30', 0); + insert into gh_ost_test values (null, 11, null, now(), now(), '2010-10-20 10:20:30', 0); update gh_ost_test set ts2=now() + interval 10 minute, updated = 1 where i = 11 order by id desc limit 1; set session time_zone='system'; - insert into gh_ost_test values (null, 11, null, now(), now(), '2010-10-20 10:20:30', 0); + insert into gh_ost_test values (null, 13, null, now(), now(), '2010-10-20 10:20:30', 0); update gh_ost_test set ts2=now() + interval 10 minute, updated = 1 where i = 13 order by id desc limit 1; set session time_zone='+00:00';