diff --git a/go/mysql/flavor.go b/go/mysql/flavor.go index a909cb444ac..1931d6f72ff 100644 --- a/go/mysql/flavor.go +++ b/go/mysql/flavor.go @@ -38,6 +38,8 @@ var ( // ErrNoPrimaryStatus means no status was returned by ShowPrimaryStatus(). ErrNoPrimaryStatus = errors.New("no master status") + + ErrUnspecifiedServerVersion = vterrors.Errorf(vtrpc.Code_INTERNAL, "server version unspecified") ) const ( @@ -136,7 +138,7 @@ type flavor interface { baseShowTables() string baseShowTablesWithSizes() string - supportsCapability(serverVersion string, capability capabilities.FlavorCapability) (bool, error) + supportsCapability(capability capabilities.FlavorCapability) (bool, error) } // flavors maps flavor names to their implementation. @@ -148,6 +150,9 @@ var flavors = make(map[string]func() flavor) // Example: if input is []int{8, 0, 23}... the function returns 'true' if we're // on MySQL 8.0.23, 8.0.24, ... func ServerVersionAtLeast(serverVersion string, parts ...int) (bool, error) { + if serverVersion == "" { + return false, ErrUnspecifiedServerVersion + } versionPrefix := strings.Split(serverVersion, "-")[0] versionTokens := strings.Split(versionPrefix, ".") for i, part := range parts { @@ -168,6 +173,13 @@ func ServerVersionAtLeast(serverVersion string, parts ...int) (bool, error) { return true, nil } +// flavorCapableOf is a utility function that returns a CapableOf function for a given flavor +func flavorCapableOf(f flavor) capabilities.CapableOf { + return func(capability capabilities.FlavorCapability) (bool, error) { + return f.supportsCapability(capability) + } +} + // GetFlavor fills in c.Flavor. If the params specify the flavor, // that is used. Otherwise, we auto-detect. // @@ -187,25 +199,29 @@ func GetFlavor(serverVersion string, flavorFunc func() flavor) (f flavor, capabl f = flavorFunc() case strings.HasPrefix(serverVersion, mariaDBReplicationHackPrefix): canonicalVersion = serverVersion[len(mariaDBReplicationHackPrefix):] - f = mariadbFlavor101{} + f = mariadbFlavor101{mariadbFlavor{serverVersion: canonicalVersion}} case strings.Contains(serverVersion, mariaDBVersionString): mariadbVersion, err := strconv.ParseFloat(serverVersion[:4], 64) if err != nil || mariadbVersion < 10.2 { - f = mariadbFlavor101{} + f = mariadbFlavor101{mariadbFlavor{serverVersion: fmt.Sprintf("%f", mariadbVersion)}} } else { - f = mariadbFlavor102{} + f = mariadbFlavor102{mariadbFlavor{serverVersion: fmt.Sprintf("%f", mariadbVersion)}} } case strings.HasPrefix(serverVersion, mysql57VersionPrefix): - f = mysqlFlavor57{} + f = mysqlFlavor57{mysqlFlavor{serverVersion: serverVersion}} case strings.HasPrefix(serverVersion, mysql80VersionPrefix): - f = mysqlFlavor80{} + f = mysqlFlavor80{mysqlFlavor{serverVersion: serverVersion}} default: - f = mysqlFlavor56{} + f = mysqlFlavor56{mysqlFlavor{serverVersion: serverVersion}} } - return f, - func(capability capabilities.FlavorCapability) (bool, error) { - return f.supportsCapability(serverVersion, capability) - }, canonicalVersion + return f, flavorCapableOf(f), canonicalVersion +} + +// ServerVersionCapableOf is a convenience function that returns a CapableOf function given a server version. +// It is a shortcut for GetFlavor(serverVersion, nil). +func ServerVersionCapableOf(serverVersion string) (capableOf capabilities.CapableOf) { + _, capableOf, _ = GetFlavor(serverVersion, nil) + return capableOf } // fillFlavor fills in c.Flavor. If the params specify the flavor, @@ -454,7 +470,7 @@ func (c *Conn) BaseShowTablesWithSizes() string { // SupportsCapability checks if the database server supports the given capability func (c *Conn) SupportsCapability(capability capabilities.FlavorCapability) (bool, error) { - return c.flavor.supportsCapability(c.ServerVersion, capability) + return c.flavor.supportsCapability(capability) } func init() { diff --git a/go/mysql/flavor_filepos.go b/go/mysql/flavor_filepos.go index ce11599d520..afdc8282e19 100644 --- a/go/mysql/flavor_filepos.go +++ b/go/mysql/flavor_filepos.go @@ -336,7 +336,7 @@ func (*filePosFlavor) baseShowTablesWithSizes() string { } // supportsCapability is part of the Flavor interface. -func (*filePosFlavor) supportsCapability(serverVersion string, capability capabilities.FlavorCapability) (bool, error) { +func (*filePosFlavor) supportsCapability(capability capabilities.FlavorCapability) (bool, error) { switch capability { default: return false, nil diff --git a/go/mysql/flavor_mariadb.go b/go/mysql/flavor_mariadb.go index 9c71522a213..2f77a71ea00 100644 --- a/go/mysql/flavor_mariadb.go +++ b/go/mysql/flavor_mariadb.go @@ -32,7 +32,9 @@ import ( ) // mariadbFlavor implements the Flavor interface for MariaDB. -type mariadbFlavor struct{} +type mariadbFlavor struct { + serverVersion string +} type mariadbFlavor101 struct { mariadbFlavor } @@ -287,7 +289,7 @@ func (mariadbFlavor) readBinlogEvent(c *Conn) (BinlogEvent, error) { } // supportsCapability is part of the Flavor interface. -func (mariadbFlavor) supportsCapability(serverVersion string, capability capabilities.FlavorCapability) (bool, error) { +func (mariadbFlavor) supportsCapability(capability capabilities.FlavorCapability) (bool, error) { switch capability { default: return false, nil diff --git a/go/mysql/flavor_mysql.go b/go/mysql/flavor_mysql.go index ad1880d5c68..2406a7e001f 100644 --- a/go/mysql/flavor_mysql.go +++ b/go/mysql/flavor_mysql.go @@ -31,7 +31,9 @@ import ( ) // mysqlFlavor implements the Flavor interface for Mysql. -type mysqlFlavor struct{} +type mysqlFlavor struct { + serverVersion string +} type mysqlFlavor56 struct { mysqlFlavor } @@ -372,7 +374,7 @@ func (mysqlFlavor56) baseShowTablesWithSizes() string { } // supportsCapability is part of the Flavor interface. -func (mysqlFlavor56) supportsCapability(serverVersion string, capability capabilities.FlavorCapability) (bool, error) { +func (mysqlFlavor56) supportsCapability(capability capabilities.FlavorCapability) (bool, error) { switch capability { default: return false, nil @@ -385,7 +387,7 @@ func (mysqlFlavor57) baseShowTablesWithSizes() string { } // supportsCapability is part of the Flavor interface. -func (mysqlFlavor57) supportsCapability(serverVersion string, capability capabilities.FlavorCapability) (bool, error) { +func (mysqlFlavor57) supportsCapability(capability capabilities.FlavorCapability) (bool, error) { switch capability { case capabilities.MySQLJSONFlavorCapability: return true, nil @@ -400,7 +402,10 @@ func (mysqlFlavor80) baseShowTablesWithSizes() string { } // supportsCapability is part of the Flavor interface. -func (mysqlFlavor80) supportsCapability(serverVersion string, capability capabilities.FlavorCapability) (bool, error) { +func (f mysqlFlavor80) supportsCapability(capability capabilities.FlavorCapability) (bool, error) { + serverVersionAtLeast := func(parts ...int) (bool, error) { + return ServerVersionAtLeast(f.serverVersion, parts...) + } switch capability { case capabilities.InstantDDLFlavorCapability, capabilities.InstantExpandEnumCapability, @@ -409,21 +414,21 @@ func (mysqlFlavor80) supportsCapability(serverVersion string, capability capabil capabilities.InstantChangeColumnDefaultFlavorCapability: return true, nil case capabilities.InstantAddDropColumnFlavorCapability: - return ServerVersionAtLeast(serverVersion, 8, 0, 29) + return serverVersionAtLeast(8, 0, 29) case capabilities.TransactionalGtidExecutedFlavorCapability: - return ServerVersionAtLeast(serverVersion, 8, 0, 17) + return serverVersionAtLeast(8, 0, 17) case capabilities.FastDropTableFlavorCapability: - return ServerVersionAtLeast(serverVersion, 8, 0, 23) + return serverVersionAtLeast(8, 0, 23) case capabilities.MySQLJSONFlavorCapability: return true, nil case capabilities.MySQLUpgradeInServerFlavorCapability: - return ServerVersionAtLeast(serverVersion, 8, 0, 16) + return serverVersionAtLeast(8, 0, 16) case capabilities.DynamicRedoLogCapacityFlavorCapability: - return ServerVersionAtLeast(serverVersion, 8, 0, 30) + return serverVersionAtLeast(8, 0, 30) case capabilities.DisableRedoLogFlavorCapability: - return ServerVersionAtLeast(serverVersion, 8, 0, 21) + return serverVersionAtLeast(8, 0, 21) case capabilities.CheckConstraintsCapability: - return ServerVersionAtLeast(serverVersion, 8, 0, 16) + return serverVersionAtLeast(8, 0, 16) case capabilities.PerformanceSchemaDataLocksTableCapability: return true, nil default: diff --git a/go/mysql/flavor_mysqlgr.go b/go/mysql/flavor_mysqlgr.go index da299dd693b..563552464d3 100644 --- a/go/mysql/flavor_mysqlgr.go +++ b/go/mysql/flavor_mysqlgr.go @@ -249,26 +249,31 @@ func (mysqlGRFlavor) baseShowTablesWithSizes() string { } // supportsCapability is part of the Flavor interface. -func (mysqlGRFlavor) supportsCapability(serverVersion string, capability capabilities.FlavorCapability) (bool, error) { +func (f mysqlGRFlavor) supportsCapability(capability capabilities.FlavorCapability) (bool, error) { + serverVersionAtLeast := func(parts ...int) (bool, error) { + return ServerVersionAtLeast(f.serverVersion, parts...) + } switch capability { case capabilities.InstantDDLFlavorCapability, capabilities.InstantExpandEnumCapability, capabilities.InstantAddLastColumnFlavorCapability, capabilities.InstantAddDropVirtualColumnFlavorCapability, capabilities.InstantChangeColumnDefaultFlavorCapability: - return ServerVersionAtLeast(serverVersion, 8, 0, 0) + return serverVersionAtLeast(8, 0, 0) case capabilities.InstantAddDropColumnFlavorCapability: - return ServerVersionAtLeast(serverVersion, 8, 0, 29) + return serverVersionAtLeast(8, 0, 29) case capabilities.TransactionalGtidExecutedFlavorCapability: - return ServerVersionAtLeast(serverVersion, 8, 0, 17) + return serverVersionAtLeast(8, 0, 17) case capabilities.FastDropTableFlavorCapability: - return ServerVersionAtLeast(serverVersion, 8, 0, 23) + return serverVersionAtLeast(8, 0, 23) case capabilities.MySQLJSONFlavorCapability: - return ServerVersionAtLeast(serverVersion, 5, 7, 0) + return serverVersionAtLeast(5, 7, 0) case capabilities.MySQLUpgradeInServerFlavorCapability: - return ServerVersionAtLeast(serverVersion, 8, 0, 16) + return serverVersionAtLeast(8, 0, 16) case capabilities.DynamicRedoLogCapacityFlavorCapability: - return ServerVersionAtLeast(serverVersion, 8, 0, 30) + return serverVersionAtLeast(8, 0, 30) + case capabilities.CheckConstraintsCapability: + return serverVersionAtLeast(8, 0, 16) default: return false, nil } diff --git a/go/mysql/flavor_test.go b/go/mysql/flavor_test.go index 4282687d338..997101d6b7c 100644 --- a/go/mysql/flavor_test.go +++ b/go/mysql/flavor_test.go @@ -44,6 +44,21 @@ func TestServerVersionAtLeast(t *testing.T) { parts: []int{8, 0, 13}, expect: true, }, + { + version: "8.0.14-log", + parts: []int{8, 0, 13}, + expect: true, + }, + { + version: "8.0.14", + parts: []int{8, 0, 15}, + expect: false, + }, + { + version: "8.0.14-log", + parts: []int{8, 0, 15}, + expect: false, + }, { version: "8.0.14", parts: []int{7, 5, 20}, @@ -79,6 +94,11 @@ func TestServerVersionAtLeast(t *testing.T) { parts: []int{8, 0, 14}, expectError: true, }, + { + version: "", + parts: []int{8, 0, 14}, + expectError: true, + }, } for _, tc := range testcases { result, err := ServerVersionAtLeast(tc.version, tc.parts...) @@ -172,6 +192,11 @@ func TestGetFlavor(t *testing.T) { capability: capabilities.CheckConstraintsCapability, isCapable: true, }, + { + version: "8.0.20-log", + capability: capabilities.CheckConstraintsCapability, + isCapable: true, + }, { version: "5.7.38", capability: capabilities.PerformanceSchemaDataLocksTableCapability, @@ -182,11 +207,23 @@ func TestGetFlavor(t *testing.T) { capability: capabilities.PerformanceSchemaDataLocksTableCapability, isCapable: true, }, + { + // What happens if server version is unspecified + version: "", + capability: capabilities.CheckConstraintsCapability, + isCapable: false, + }, + { + // Some ridiculous version + version: "5914.234.17", + capability: capabilities.CheckConstraintsCapability, + isCapable: false, + }, } for _, tc := range testcases { name := fmt.Sprintf("%s %v", tc.version, tc.capability) t.Run(name, func(t *testing.T) { - _, capableOf, _ := GetFlavor(tc.version, nil) + capableOf := ServerVersionCapableOf(tc.version) isCapable, err := capableOf(tc.capability) assert.NoError(t, err) assert.Equal(t, tc.isCapable, isCapable) diff --git a/go/test/endtoend/onlineddl/revert/onlineddl_revert_test.go b/go/test/endtoend/onlineddl/revert/onlineddl_revert_test.go index c502e051b48..f115e1041d6 100644 --- a/go/test/endtoend/onlineddl/revert/onlineddl_revert_test.go +++ b/go/test/endtoend/onlineddl/revert/onlineddl_revert_test.go @@ -560,7 +560,7 @@ func testRevert(t *testing.T) { mysqlVersion = onlineddl.GetMySQLVersion(t, clusterInstance.Keyspaces[0].Shards[0].PrimaryTablet()) require.NotEmpty(t, mysqlVersion) - _, capableOf, _ := mysql.GetFlavor(mysqlVersion, nil) + capableOf := mysql.ServerVersionCapableOf(mysqlVersion) var uuids []string ddlStrategy := "online" diff --git a/go/test/endtoend/onlineddl/scheduler/onlineddl_scheduler_test.go b/go/test/endtoend/onlineddl/scheduler/onlineddl_scheduler_test.go index 37e8f2d47ce..3c2c25ec8b5 100644 --- a/go/test/endtoend/onlineddl/scheduler/onlineddl_scheduler_test.go +++ b/go/test/endtoend/onlineddl/scheduler/onlineddl_scheduler_test.go @@ -335,7 +335,7 @@ func testScheduler(t *testing.T) { mysqlVersion := onlineddl.GetMySQLVersion(t, clusterInstance.Keyspaces[0].Shards[0].PrimaryTablet()) require.NotEmpty(t, mysqlVersion) - _, capableOf, _ := mysql.GetFlavor(mysqlVersion, nil) + capableOf := mysql.ServerVersionCapableOf(mysqlVersion) var ( t1uuid string diff --git a/go/test/endtoend/tabletmanager/tablegc/tablegc_test.go b/go/test/endtoend/tabletmanager/tablegc/tablegc_test.go index 9a04eec0290..580593fa230 100644 --- a/go/test/endtoend/tabletmanager/tablegc/tablegc_test.go +++ b/go/test/endtoend/tabletmanager/tablegc/tablegc_test.go @@ -291,7 +291,7 @@ func TestCapability(t *testing.T) { mysqlVersion := onlineddl.GetMySQLVersion(t, clusterInstance.Keyspaces[0].Shards[0].PrimaryTablet()) require.NotEmpty(t, mysqlVersion) - _, capableOf, _ := mysql.GetFlavor(mysqlVersion, nil) + capableOf := mysql.ServerVersionCapableOf(mysqlVersion) require.NotNil(t, capableOf) var err error fastDropTable, err = capableOf(capabilities.FastDropTableFlavorCapability) diff --git a/go/vt/mysqlctl/backup_blackbox_test.go b/go/vt/mysqlctl/backup_blackbox_test.go index 3c4f623beda..116a4fe80f2 100644 --- a/go/vt/mysqlctl/backup_blackbox_test.go +++ b/go/vt/mysqlctl/backup_blackbox_test.go @@ -602,7 +602,7 @@ func needInnoDBRedoLogSubdir() (needIt bool, err error) { return needIt, err } versionStr := fmt.Sprintf("%d.%d.%d", sv.Major, sv.Minor, sv.Patch) - _, capableOf, _ := mysql.GetFlavor(versionStr, nil) + capableOf := mysql.ServerVersionCapableOf(versionStr) if capableOf == nil { return needIt, fmt.Errorf("cannot determine database flavor details for version %s", versionStr) } diff --git a/go/vt/vttablet/onlineddl/analysis.go b/go/vt/vttablet/onlineddl/analysis.go index 536be947bd3..3749eb272b4 100644 --- a/go/vt/vttablet/onlineddl/analysis.go +++ b/go/vt/vttablet/onlineddl/analysis.go @@ -19,11 +19,11 @@ package onlineddl import ( "context" "encoding/json" - "strings" "vitess.io/vitess/go/mysql/capabilities" vtrpcpb "vitess.io/vitess/go/vt/proto/vtrpc" "vitess.io/vitess/go/vt/schema" + "vitess.io/vitess/go/vt/schemadiff" "vitess.io/vitess/go/vt/sqlparser" "vitess.io/vitess/go/vt/vterrors" ) @@ -175,173 +175,16 @@ func analyzeAddRangePartition(alterTable *sqlparser.AlterTable, createTable *sql return op } -// alterOptionAvailableViaInstantDDL checks if the specific alter option is eligible to run via ALGORITHM=INSTANT -// reference: https://dev.mysql.com/doc/refman/8.0/en/innodb-online-ddl-operations.html -func alterOptionAvailableViaInstantDDL(alterOption sqlparser.AlterOption, createTable *sqlparser.CreateTable, capableOf capabilities.CapableOf) (bool, error) { - findColumn := func(colName string) *sqlparser.ColumnDefinition { - if createTable == nil { - return nil - } - for _, col := range createTable.TableSpec.Columns { - if strings.EqualFold(colName, col.Name.String()) { - return col - } - } - return nil - } - findTableOption := func(optName string) *sqlparser.TableOption { - if createTable == nil { - return nil - } - for _, opt := range createTable.TableSpec.Options { - if strings.EqualFold(optName, opt.Name) { - return opt - } - } - return nil - } - isVirtualColumn := func(colName string) bool { - col := findColumn(colName) - if col == nil { - return false - } - if col.Type.Options == nil { - return false - } - if col.Type.Options.As == nil { - return false - } - return col.Type.Options.Storage == sqlparser.VirtualStorage - } - colStringStrippedDown := func(col *sqlparser.ColumnDefinition, stripDefault bool, stripEnum bool) string { - strippedCol := sqlparser.CloneRefOfColumnDefinition(col) - if stripDefault { - strippedCol.Type.Options.Default = nil - strippedCol.Type.Options.DefaultLiteral = false - } - if stripEnum { - strippedCol.Type.EnumValues = nil - } - return sqlparser.CanonicalString(strippedCol) - } - hasPrefix := func(vals []string, prefix []string) bool { - if len(vals) < len(prefix) { - return false - } - for i := range prefix { - if vals[i] != prefix[i] { - return false - } - } - return true - } - // Up to 8.0.26 we could only ADD COLUMN as last column - switch opt := alterOption.(type) { - case *sqlparser.ChangeColumn: - // We do not support INSTANT for renaming a column (ALTER TABLE ...CHANGE) because: - // 1. We discourage column rename - // 2. We do not produce CHANGE statements in declarative diff - // 3. The success of the operation depends on whether the column is referenced by a foreign key - // in another table. Which is a bit too much to compute here. - return false, nil - case *sqlparser.AddColumns: - if opt.First || opt.After != nil { - // not a "last" column. Only supported as of 8.0.29 - return capableOf(capabilities.InstantAddDropColumnFlavorCapability) - } - // Adding a *last* column is supported in 8.0 - return capableOf(capabilities.InstantAddLastColumnFlavorCapability) - case *sqlparser.DropColumn: - // not supported in COMPRESSED tables - if opt := findTableOption("ROW_FORMAT"); opt != nil { - if strings.EqualFold(opt.String, "COMPRESSED") { - return false, nil - } - } - if isVirtualColumn(opt.Name.Name.String()) { - // supported by all 8.0 versions - return capableOf(capabilities.InstantAddDropVirtualColumnFlavorCapability) - } - return capableOf(capabilities.InstantAddDropColumnFlavorCapability) - case *sqlparser.ModifyColumn: - if col := findColumn(opt.NewColDefinition.Name.String()); col != nil { - // Check if only diff is change of default - // we temporarily remove the DEFAULT expression (if any) from both - // 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) - if tableColDefinition == newColDefinition { - return capableOf(capabilities.InstantChangeColumnDefaultFlavorCapability) - } - // Check if: - // 1. this an ENUM/SET - // 2. and the change is to append values to the end of the list - // 3. and the number of added values does not increase the storage size for the enum/set - // 4. while still not caring about a change in the default value - if len(col.Type.EnumValues) > 0 && len(opt.NewColDefinition.Type.EnumValues) > 0 { - // both are enum or set - if !hasPrefix(opt.NewColDefinition.Type.EnumValues, col.Type.EnumValues) { - return false, nil - } - // we know the new column definition is identical to, or extends, the old definition. - // Now validate storage: - if strings.EqualFold(col.Type.Type, "enum") { - if len(col.Type.EnumValues) <= 255 && len(opt.NewColDefinition.Type.EnumValues) > 255 { - // this increases the SET storage size (1 byte for up to 8 values, 2 bytes beyond) - return false, nil - } - } - if strings.EqualFold(col.Type.Type, "set") { - if (len(col.Type.EnumValues)+7)/8 != (len(opt.NewColDefinition.Type.EnumValues)+7)/8 { - // this increases the SET storage size (1 byte for up to 8 values, 2 bytes for 8-15, etc.) - return false, nil - } - } - // Now don't care about change of default: - tableColDefinition := colStringStrippedDown(col, true, true) - newColDefinition := colStringStrippedDown(opt.NewColDefinition, true, true) - if tableColDefinition == newColDefinition { - return capableOf(capabilities.InstantExpandEnumCapability) - } - } - } - return false, nil - default: - return false, nil - } -} - -// AnalyzeInstantDDL takes declarative CreateTable and AlterTable, as well as a server version, and checks whether it is possible to run the ALTER +// analyzeInstantDDL takes declarative CreateTable and AlterTable, as well as a server version, and checks whether it is possible to run the ALTER // using ALGORITHM=INSTANT for that version. -// This function is INTENTIONALLY public, even though we do not guarantee that it will remain so. -func AnalyzeInstantDDL(alterTable *sqlparser.AlterTable, createTable *sqlparser.CreateTable, capableOf capabilities.CapableOf) (*SpecialAlterPlan, error) { - capable, err := capableOf(capabilities.InstantDDLFlavorCapability) +func analyzeInstantDDL(alterTable *sqlparser.AlterTable, createTable *sqlparser.CreateTable, capableOf capabilities.CapableOf) (*SpecialAlterPlan, error) { + capable, err := schemadiff.AlterTableCapableOfInstantDDL(alterTable, createTable, capableOf) if err != nil { return nil, err } if !capable { return nil, nil } - if alterTable.PartitionOption != nil { - // no INSTANT for partitions - return nil, nil - } - if alterTable.PartitionSpec != nil { - // no INSTANT for partitions - return nil, nil - } - // For the ALTER statement to qualify for ALGORITHM=INSTANT, all alter options must each qualify. - for _, alterOption := range alterTable.AlterOptions { - instantOK, err := alterOptionAvailableViaInstantDDL(alterOption, createTable, capableOf) - if err != nil { - return nil, err - } - if !instantOK { - return nil, nil - } - } op := NewSpecialAlterOperation(instantDDLSpecialOperation, alterTable, createTable) return op, nil } @@ -379,7 +222,7 @@ func (e *Executor) analyzeSpecialAlterPlan(ctx context.Context, onlineDDL *schem } } if onlineDDL.StrategySetting().IsPreferInstantDDL() { - op, err := AnalyzeInstantDDL(alterTable, createTable, capableOf) + op, err := analyzeInstantDDL(alterTable, createTable, capableOf) if err != nil { return nil, err } diff --git a/go/vt/vttablet/onlineddl/analysis_test.go b/go/vt/vttablet/onlineddl/analysis_test.go index d1510cf1773..b37a24d3bbc 100644 --- a/go/vt/vttablet/onlineddl/analysis_test.go +++ b/go/vt/vttablet/onlineddl/analysis_test.go @@ -222,8 +222,8 @@ func TestAnalyzeInstantDDL(t *testing.T) { alterTable, ok := stmt.(*sqlparser.AlterTable) require.True(t, ok) - _, capableOf, _ := mysql.GetFlavor(tc.version, nil) - plan, err := AnalyzeInstantDDL(alterTable, createTable, capableOf) + capableOf := mysql.ServerVersionCapableOf(tc.version) + plan, err := analyzeInstantDDL(alterTable, createTable, capableOf) if tc.expectError { assert.Error(t, err) } else { diff --git a/go/vt/vttablet/onlineddl/executor.go b/go/vt/vttablet/onlineddl/executor.go index 4d25c917db9..71cb2380040 100644 --- a/go/vt/vttablet/onlineddl/executor.go +++ b/go/vt/vttablet/onlineddl/executor.go @@ -833,7 +833,7 @@ func (e *Executor) killTableLockHoldersAndAccessors(ctx context.Context, tableNa } } } - _, capableOf, _ := mysql.GetFlavor(conn.ServerVersion, nil) + capableOf := mysql.ServerVersionCapableOf(conn.ServerVersion) capable, err := capableOf(capabilities.PerformanceSchemaDataLocksTableCapability) if err != nil { return err @@ -2538,7 +2538,7 @@ func (e *Executor) reviewQueuedMigrations(ctx context.Context) error { return err } defer conn.Close() - _, capableOf, _ := mysql.GetFlavor(conn.ServerVersion, nil) + capableOf := mysql.ServerVersionCapableOf(conn.ServerVersion) e.migrationMutex.Lock() defer e.migrationMutex.Unlock() @@ -3125,7 +3125,7 @@ func (e *Executor) executeSpecialAlterDDLActionMigrationIfApplicable(ctx context return false, err } defer conn.Close() - _, capableOf, _ := mysql.GetFlavor(conn.ServerVersion, nil) + capableOf := mysql.ServerVersionCapableOf(conn.ServerVersion) specialPlan, err := e.analyzeSpecialAlterPlan(ctx, onlineDDL, capableOf) if err != nil { diff --git a/go/vt/wrangler/testlib/backup_test.go b/go/vt/wrangler/testlib/backup_test.go index 1e71abf1e2b..f4aa88fb60e 100644 --- a/go/vt/wrangler/testlib/backup_test.go +++ b/go/vt/wrangler/testlib/backup_test.go @@ -892,7 +892,7 @@ func needInnoDBRedoLogSubdir() (needIt bool, err error) { return needIt, err } versionStr := fmt.Sprintf("%d.%d.%d", sv.Major, sv.Minor, sv.Patch) - _, capableOf, _ := mysql.GetFlavor(versionStr, nil) + capableOf := mysql.ServerVersionCapableOf(versionStr) if capableOf == nil { return needIt, fmt.Errorf("cannot determine database flavor details for version %s", versionStr) }