From 4fa7c865add58cba58e4598a03ac59c48358aa86 Mon Sep 17 00:00:00 2001 From: Cyril Levis Date: Wed, 28 Dec 2022 10:07:40 +0100 Subject: [PATCH] chore: move setOptimizerSwitch to InitDBConnections --- go/logic/applier.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) 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 }