From 05f32ebf297456ee759ced15aaa124acb6e7d207 Mon Sep 17 00:00:00 2001 From: Morgan Tocker Date: Thu, 10 Nov 2022 09:30:13 -0700 Subject: [PATCH] minor cleanup --- go/logic/applier.go | 32 +++----------------------------- go/logic/migrator.go | 1 - 2 files changed, 3 insertions(+), 30 deletions(-) diff --git a/go/logic/applier.go b/go/logic/applier.go index b9313a3..abda2b0 100644 --- a/go/logic/applier.go +++ b/go/logic/applier.go @@ -199,41 +199,15 @@ func (this *Applier) ValidateOrDropExistingTables() error { // It is safer to attempt the change than try and parse the DDL, since // there might be specifics about the table which make it not possible to apply instantly. func (this *Applier) AttemptInstantDDL() error { - query := fmt.Sprintf(`ALTER /* gh-ost */ TABLE %s.%s %s, ALGORITHM=INSTANT`, sql.EscapeName(this.migrationContext.DatabaseName), sql.EscapeName(this.migrationContext.OriginalTableName), this.migrationContext.AlterStatementOptions, ) - this.migrationContext.Log.Infof("INSTANT DDL Query is: %s", query) - - err := func() error { - tx, err := this.db.Begin() - if err != nil { - return err - } - defer tx.Rollback() - - sessionQuery := fmt.Sprintf(`SET SESSION time_zone = '%s'`, this.migrationContext.ApplierTimeZone) - sessionQuery = fmt.Sprintf("%s, %s", sessionQuery, this.generateSqlModeQuery()) - - if _, err := tx.Exec(sessionQuery); err != nil { - return err - } - if _, err := tx.Exec(query); err != nil { - this.migrationContext.Log.Infof("INSTANT DDL failed: %s", err) - return err - } - if err := tx.Commit(); err != nil { - // Neither SET SESSION nor ALTER are really transactional, so strictly speaking - // there's no need to commit; but let's do this the legit way anyway. - return err - } - return nil - }() - + this.migrationContext.Log.Infof("INSTANT DDL query is: %s", query) + // We don't need a trx, because for instant DDL the SQL mode doesn't matter. + _, err := this.db.Exec(query) return err - } // CreateGhostTable creates the ghost table on the applier host diff --git a/go/logic/migrator.go b/go/logic/migrator.go index 40415d0..25989f8 100644 --- a/go/logic/migrator.go +++ b/go/logic/migrator.go @@ -370,7 +370,6 @@ func (this *Migrator) Migrate() (err error) { if err := this.initiateApplier(); err != nil { return err } - if err := this.createFlagFiles(); err != nil { return err }