Skip to content

Commit

Permalink
schemadiff: Clean up MySQL version from diff hints (#15210)
Browse files Browse the repository at this point in the history
Signed-off-by: Dirkjan Bussink <[email protected]>
  • Loading branch information
dbussink authored Feb 12, 2024
1 parent 14473b9 commit a42032a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion go/vt/schemadiff/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
17 changes: 10 additions & 7 deletions go/vt/schemadiff/schema_diff_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
}
Expand All @@ -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()
Expand Down
2 changes: 0 additions & 2 deletions go/vt/schemadiff/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down

0 comments on commit a42032a

Please sign in to comment.