Skip to content

Commit 05f32eb

Browse files
committed
minor cleanup
1 parent 1be6a4c commit 05f32eb

File tree

2 files changed

+3
-30
lines changed

2 files changed

+3
-30
lines changed

go/logic/applier.go

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -199,41 +199,15 @@ func (this *Applier) ValidateOrDropExistingTables() error {
199199
// It is safer to attempt the change than try and parse the DDL, since
200200
// there might be specifics about the table which make it not possible to apply instantly.
201201
func (this *Applier) AttemptInstantDDL() error {
202-
203202
query := fmt.Sprintf(`ALTER /* gh-ost */ TABLE %s.%s %s, ALGORITHM=INSTANT`,
204203
sql.EscapeName(this.migrationContext.DatabaseName),
205204
sql.EscapeName(this.migrationContext.OriginalTableName),
206205
this.migrationContext.AlterStatementOptions,
207206
)
208-
this.migrationContext.Log.Infof("INSTANT DDL Query is: %s", query)
209-
210-
err := func() error {
211-
tx, err := this.db.Begin()
212-
if err != nil {
213-
return err
214-
}
215-
defer tx.Rollback()
216-
217-
sessionQuery := fmt.Sprintf(`SET SESSION time_zone = '%s'`, this.migrationContext.ApplierTimeZone)
218-
sessionQuery = fmt.Sprintf("%s, %s", sessionQuery, this.generateSqlModeQuery())
219-
220-
if _, err := tx.Exec(sessionQuery); err != nil {
221-
return err
222-
}
223-
if _, err := tx.Exec(query); err != nil {
224-
this.migrationContext.Log.Infof("INSTANT DDL failed: %s", err)
225-
return err
226-
}
227-
if err := tx.Commit(); err != nil {
228-
// Neither SET SESSION nor ALTER are really transactional, so strictly speaking
229-
// there's no need to commit; but let's do this the legit way anyway.
230-
return err
231-
}
232-
return nil
233-
}()
234-
207+
this.migrationContext.Log.Infof("INSTANT DDL query is: %s", query)
208+
// We don't need a trx, because for instant DDL the SQL mode doesn't matter.
209+
_, err := this.db.Exec(query)
235210
return err
236-
237211
}
238212

239213
// CreateGhostTable creates the ghost table on the applier host

go/logic/migrator.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,6 @@ func (this *Migrator) Migrate() (err error) {
370370
if err := this.initiateApplier(); err != nil {
371371
return err
372372
}
373-
374373
if err := this.createFlagFiles(); err != nil {
375374
return err
376375
}

0 commit comments

Comments
 (0)