From a42032af229f379cd45e3e3988b6245287295dde Mon Sep 17 00:00:00 2001 From: Dirkjan Bussink Date: Mon, 12 Feb 2024 18:13:26 +0100 Subject: [PATCH] schemadiff: Clean up MySQL version from diff hints (#15210) Signed-off-by: Dirkjan Bussink --- go/vt/schemadiff/schema.go | 2 +- go/vt/schemadiff/schema_diff_test.go | 17 ++++++++++------- go/vt/schemadiff/types.go | 2 -- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/go/vt/schemadiff/schema.go b/go/vt/schemadiff/schema.go index f65e1e9ac55..084b703b14f 100644 --- a/go/vt/schemadiff/schema.go +++ b/go/vt/schemadiff/schema.go @@ -1003,7 +1003,7 @@ func (s *Schema) SchemaDiff(other *Schema, hints *DiffHints) (*SchemaDiff, error // Check and assign capabilities: // Reminder: schemadiff assumes a MySQL flavor, so we only check for MySQL capabilities. - if capableOf := capabilities.MySQLVersionCapableOf(hints.MySQLServerVersion); capableOf != nil { + if capableOf := capabilities.MySQLVersionCapableOf(s.env.MySQLVersion()); capableOf != nil { for _, diff := range schemaDiff.UnorderedDiffs() { switch diff := diff.(type) { case *AlterTableEntityDiff: diff --git a/go/vt/schemadiff/schema_diff_test.go b/go/vt/schemadiff/schema_diff_test.go index 3b59166c05c..4fbc31a6492 100644 --- a/go/vt/schemadiff/schema_diff_test.go +++ b/go/vt/schemadiff/schema_diff_test.go @@ -23,6 +23,9 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "vitess.io/vitess/go/mysql/collations" + "vitess.io/vitess/go/vt/vtenv" ) func TestPermutations(t *testing.T) { @@ -911,11 +914,15 @@ func TestSchemaDiff(t *testing.T) { } baseHints := &DiffHints{ RangeRotationStrategy: RangeRotationDistinctStatements, - MySQLServerVersion: "8.0.32", } - env := NewTestEnv() for _, tc := range tt { t.Run(tc.name, func(t *testing.T) { + vtenv, err := vtenv.New(vtenv.Options{ + MySQLServerVersion: tc.mysqlServerVersion, + }) + require.NoError(t, err) + env := NewEnv(vtenv, collations.CollationUtf8mb4ID) + if tc.fromQueries == nil { tc.fromQueries = createQueries } @@ -927,11 +934,7 @@ func TestSchemaDiff(t *testing.T) { require.NoError(t, err) require.NotNil(t, toSchema) - hints := *baseHints - if tc.mysqlServerVersion != "" { - hints.MySQLServerVersion = tc.mysqlServerVersion - } - schemaDiff, err := fromSchema.SchemaDiff(toSchema, &hints) + schemaDiff, err := fromSchema.SchemaDiff(toSchema, baseHints) require.NoError(t, err) allDiffs := schemaDiff.UnorderedDiffs() diff --git a/go/vt/schemadiff/types.go b/go/vt/schemadiff/types.go index 73ce096ef42..30814dfc26c 100644 --- a/go/vt/schemadiff/types.go +++ b/go/vt/schemadiff/types.go @@ -137,8 +137,6 @@ type DiffHints struct { TableQualifierHint int AlterTableAlgorithmStrategy int EnumReorderStrategy int - - MySQLServerVersion string // Used to determine specific capabilities such as INSTANT DDL support } const (