diff --git a/go/vt/schemadiff/capability.go b/go/vt/schemadiff/capability.go index cde99ac18c3..f0261e193f9 100644 --- a/go/vt/schemadiff/capability.go +++ b/go/vt/schemadiff/capability.go @@ -73,7 +73,7 @@ func alterOptionCapableOfInstantDDL(alterOption sqlparser.AlterOption, createTab } return true, col.Type.Options.Storage } - colStringStrippedDown := func(col *sqlparser.ColumnDefinition, stripDefault bool, stripEnum bool) string { + colStringStrippedDown := func(col *sqlparser.ColumnDefinition, stripDefault bool, stripEnum bool, stripVisibility bool) string { strippedCol := sqlparser.Clone(col) if stripDefault { strippedCol.Type.Options.Default = nil @@ -82,6 +82,9 @@ func alterOptionCapableOfInstantDDL(alterOption sqlparser.AlterOption, createTab if stripEnum { strippedCol.Type.EnumValues = nil } + if stripVisibility { + strippedCol.Type.Options.Invisible = nil + } return sqlparser.CanonicalString(strippedCol) } hasPrefix := func(vals []string, prefix []string) bool { @@ -164,8 +167,8 @@ func alterOptionCapableOfInstantDDL(alterOption sqlparser.AlterOption, createTab // table and ALTER statement, and compare the columns: if they're otherwise equal, // then the only change can be an addition/change/removal of DEFAULT, which // is instant-table. - tableColDefinition := colStringStrippedDown(col, true, false) - newColDefinition := colStringStrippedDown(opt.NewColDefinition, true, false) + tableColDefinition := colStringStrippedDown(col, true, false, true) + newColDefinition := colStringStrippedDown(opt.NewColDefinition, true, false, true) if tableColDefinition == newColDefinition { return capableOf(capabilities.InstantChangeColumnDefaultFlavorCapability) } @@ -194,8 +197,8 @@ func alterOptionCapableOfInstantDDL(alterOption sqlparser.AlterOption, createTab } } // Now don't care about change of default: - tableColDefinition := colStringStrippedDown(col, true, true) - newColDefinition := colStringStrippedDown(opt.NewColDefinition, true, true) + tableColDefinition := colStringStrippedDown(col, true, true, true) + newColDefinition := colStringStrippedDown(opt.NewColDefinition, true, true, true) if tableColDefinition == newColDefinition { return capableOf(capabilities.InstantExpandEnumCapability) } diff --git a/go/vt/schemadiff/capability_test.go b/go/vt/schemadiff/capability_test.go index ca3387bb1a7..b0241eeb3eb 100644 --- a/go/vt/schemadiff/capability_test.go +++ b/go/vt/schemadiff/capability_test.go @@ -272,6 +272,24 @@ func TestAlterTableCapableOfInstantDDL(t *testing.T) { alter: "alter table t modify column c1 set('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i')", expectCapableOfInstantDDL: false, }, + { + name: "make a column invisible", + create: "create table t1 (id int, i1 int)", + alter: "alter table t1 modify column i1 int invisible", + expectCapableOfInstantDDL: true, + }, + { + name: "make a column visible", + create: "create table t1 (id int, i1 int)", + alter: "alter table t1 change column i1 i1 int visible", + expectCapableOfInstantDDL: true, + }, + { + name: "make a column invisible via SET, unsupported", + create: "create table t1 (id int, i1 int)", + alter: "alter table t1 alter column i1 set invisible", + expectCapableOfInstantDDL: false, + }, } for _, tcase := range tcases { t.Run(tcase.name, func(t *testing.T) {