chore: move setOptimizerSwitch to InitDBConnections
This commit is contained in:
parent
eec7aa5fee
commit
4fa7c865ad
@ -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 == "" {
|
if this.migrationContext.OptimizerSwitch == "" {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
optimizerString := fmt.Sprintf("SET SESSION optimizer_switch=%q", this.migrationContext.OptimizerSwitch)
|
optimizerString := fmt.Sprintf("SET SESSION optimizer_switch=%q", this.migrationContext.OptimizerSwitch)
|
||||||
_, err := tx.Query(optimizerString)
|
_, err := this.db.Query(optimizerString)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,6 +109,10 @@ func (this *Applier) InitDBConnections() (err error) {
|
|||||||
this.connectionConfig.ImpliedKey = impliedKey
|
this.connectionConfig.ImpliedKey = impliedKey
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
err = this.setOptimizerSwitch()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
if err := this.readTableColumns(); err != nil {
|
if err := this.readTableColumns(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -556,11 +560,6 @@ func (this *Applier) ReadMigrationRangeValues() error {
|
|||||||
}
|
}
|
||||||
defer tx.Rollback()
|
defer tx.Rollback()
|
||||||
|
|
||||||
err = this.setOptimizerSwitch(tx)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := this.readMigrationMinValues(tx, this.migrationContext.UniqueKey); err != nil {
|
if err := this.readMigrationMinValues(tx, this.migrationContext.UniqueKey); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user