diff --git a/go/logic/applier.go b/go/logic/applier.go index 506fcd4..e30b74d 100644 --- a/go/logic/applier.go +++ b/go/logic/applier.go @@ -49,12 +49,12 @@ func newDmlBuildResultError(err error) *dmlBuildResult { } } -func (this *Applier) setOptimizerSwitch(tx *gosql.Tx) error { +func (this *Applier) setOptimizerSwitch() error { if this.migrationContext.OptimizerSwitch == "" { return nil } optimizerString := fmt.Sprintf("SET SESSION optimizer_switch=%q", this.migrationContext.OptimizerSwitch) - _, err := tx.Query(optimizerString) + _, err := this.db.Query(optimizerString) return err } @@ -109,6 +109,10 @@ func (this *Applier) InitDBConnections() (err error) { this.connectionConfig.ImpliedKey = impliedKey } } + err = this.setOptimizerSwitch() + if err != nil { + return err + } if err := this.readTableColumns(); err != nil { return err } @@ -556,11 +560,6 @@ func (this *Applier) ReadMigrationRangeValues() error { } defer tx.Rollback() - err = this.setOptimizerSwitch(tx) - if err != nil { - return err - } - if err := this.readMigrationMinValues(tx, this.migrationContext.UniqueKey); err != nil { return err }