Skip to content

Commit

Permalink
chore: move setOptimizerSwitch to InitDBConnections
Browse files Browse the repository at this point in the history
  • Loading branch information
cyrinux committed Dec 28, 2022
1 parent eec7aa5 commit 4fa7c86
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions go/logic/applier.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 4fa7c86

Please sign in to comment.