Skip to content

Commit 47969ac

Browse files
committed
schemadiff: Clean up MySQL version from diff hints
We already now have the MySQL version in the schemadiff environment, so we should use it from there. Having it also in the diff hints is duplicated and confusing this way. Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
1 parent aeb008c commit 47969ac

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

go/vt/schemadiff/schema.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1003,7 +1003,7 @@ func (s *Schema) SchemaDiff(other *Schema, hints *DiffHints) (*SchemaDiff, error
10031003

10041004
// Check and assign capabilities:
10051005
// Reminder: schemadiff assumes a MySQL flavor, so we only check for MySQL capabilities.
1006-
if capableOf := capabilities.MySQLVersionCapableOf(hints.MySQLServerVersion); capableOf != nil {
1006+
if capableOf := capabilities.MySQLVersionCapableOf(s.env.MySQLVersion()); capableOf != nil {
10071007
for _, diff := range schemaDiff.UnorderedDiffs() {
10081008
switch diff := diff.(type) {
10091009
case *AlterTableEntityDiff:

go/vt/schemadiff/schema_diff_test.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ import (
2323

2424
"github.com/stretchr/testify/assert"
2525
"github.com/stretchr/testify/require"
26+
27+
"vitess.io/vitess/go/mysql/collations"
28+
"vitess.io/vitess/go/vt/vtenv"
2629
)
2730

2831
func TestPermutations(t *testing.T) {
@@ -911,11 +914,15 @@ func TestSchemaDiff(t *testing.T) {
911914
}
912915
baseHints := &DiffHints{
913916
RangeRotationStrategy: RangeRotationDistinctStatements,
914-
MySQLServerVersion: "8.0.32",
915917
}
916-
env := NewTestEnv()
917918
for _, tc := range tt {
918919
t.Run(tc.name, func(t *testing.T) {
920+
vtenv, err := vtenv.New(vtenv.Options{
921+
MySQLServerVersion: tc.mysqlServerVersion,
922+
})
923+
require.NoError(t, err)
924+
env := NewEnv(vtenv, collations.CollationUtf8mb4ID)
925+
919926
if tc.fromQueries == nil {
920927
tc.fromQueries = createQueries
921928
}
@@ -927,11 +934,7 @@ func TestSchemaDiff(t *testing.T) {
927934
require.NoError(t, err)
928935
require.NotNil(t, toSchema)
929936

930-
hints := *baseHints
931-
if tc.mysqlServerVersion != "" {
932-
hints.MySQLServerVersion = tc.mysqlServerVersion
933-
}
934-
schemaDiff, err := fromSchema.SchemaDiff(toSchema, &hints)
937+
schemaDiff, err := fromSchema.SchemaDiff(toSchema, baseHints)
935938
require.NoError(t, err)
936939

937940
allDiffs := schemaDiff.UnorderedDiffs()

go/vt/schemadiff/types.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,6 @@ type DiffHints struct {
137137
TableQualifierHint int
138138
AlterTableAlgorithmStrategy int
139139
EnumReorderStrategy int
140-
141-
MySQLServerVersion string // Used to determine specific capabilities such as INSTANT DDL support
142140
}
143141

144142
const (

0 commit comments

Comments
 (0)