From 1e1fbcbd4327f4e8efb1d67fe56ec76fba825564 Mon Sep 17 00:00:00 2001 From: Tim Vaillancourt Date: Wed, 14 Aug 2024 11:23:00 +0200 Subject: [PATCH] Ensure `-attempt-instant-ddl` respects `-execute` flag (#1440) --- go/logic/migrator.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/go/logic/migrator.go b/go/logic/migrator.go index fed7c944b..3fc897cd3 100644 --- a/go/logic/migrator.go +++ b/go/logic/migrator.go @@ -362,12 +362,16 @@ func (this *Migrator) Migrate() (err error) { // In MySQL 8.0 (and possibly earlier) some DDL statements can be applied instantly. // Attempt to do this if AttemptInstantDDL is set. if this.migrationContext.AttemptInstantDDL { - this.migrationContext.Log.Infof("Attempting to execute alter with ALGORITHM=INSTANT") - if err := this.applier.AttemptInstantDDL(); err == nil { - this.migrationContext.Log.Infof("Success! table %s.%s migrated instantly", sql.EscapeName(this.migrationContext.DatabaseName), sql.EscapeName(this.migrationContext.OriginalTableName)) - return nil + if this.migrationContext.Noop { + this.migrationContext.Log.Debugf("Noop operation; not really attempting instant DDL") } else { - this.migrationContext.Log.Infof("ALGORITHM=INSTANT not supported for this operation, proceeding with original algorithm: %s", err) + this.migrationContext.Log.Infof("Attempting to execute alter with ALGORITHM=INSTANT") + if err := this.applier.AttemptInstantDDL(); err == nil { + this.migrationContext.Log.Infof("Success! table %s.%s migrated instantly", sql.EscapeName(this.migrationContext.DatabaseName), sql.EscapeName(this.migrationContext.OriginalTableName)) + return nil + } else { + this.migrationContext.Log.Infof("ALGORITHM=INSTANT not supported for this operation, proceeding with original algorithm: %s", err) + } } }