Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release-19.0] schemadiff: Clean up MySQL version from diff hints (#15210) #15213

Merged
merged 1 commit into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading