Skip to content

Commit

Permalink
Small internal cleanups (vitessio#16467)
Browse files Browse the repository at this point in the history
Signed-off-by: Dirkjan Bussink <[email protected]>
  • Loading branch information
dbussink authored Jul 24, 2024
1 parent 7f639d3 commit 4bf9c34
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 12 deletions.
13 changes: 3 additions & 10 deletions go/mysql/collations/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,11 @@ func fetchCacheEnvironment(version collver) *Environment {
// The version string must be in the format that is sent by the server as the version packet
// when opening a new MySQL connection
func NewEnvironment(serverVersion string) *Environment {
// 5.7 is the oldest version we support today, so use that as
// the default.
// NOTE: this should be changed when we EOL MySQL 5.7 support
var version collver = collverMySQL57
// 8.0 is the oldest fully supported version, so use that as the default.
// All newer MySQL versions including 9 are so far compatible as well.
var version collver = collverMySQL8
serverVersion = strings.TrimSpace(strings.ToLower(serverVersion))
switch {
case strings.HasSuffix(serverVersion, "-ripple"):
// the ripple binlog server can mask the actual version of mysqld;
// assume we have the highest
version = collverMySQL8
case strings.Contains(serverVersion, "mariadb"):
switch {
case strings.Contains(serverVersion, "10.0."):
Expand All @@ -125,8 +120,6 @@ func NewEnvironment(serverVersion string) *Environment {
version = collverMySQL56
case strings.HasPrefix(serverVersion, "5.7."):
version = collverMySQL57
case strings.HasPrefix(serverVersion, "8."):
version = collverMySQL8
}
return fetchCacheEnvironment(version)
}
Expand Down
2 changes: 1 addition & 1 deletion go/mysql/collations/integration/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func mysqlconn(t *testing.T) *mysql.Conn {
if err != nil {
t.Fatal(err)
}
if !strings.HasPrefix(conn.ServerVersion, "8.") {
if strings.HasPrefix(conn.ServerVersion, "5.7.") {
conn.Close()
t.Skipf("collation integration tests are only supported in MySQL 8.0+")
}
Expand Down
2 changes: 1 addition & 1 deletion go/vt/vtgate/evalengine/api_coerce.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
)

func CoerceTo(value sqltypes.Value, typ Type, sqlmode SQLMode) (sqltypes.Value, error) {
cast, err := valueToEvalCast(value, value.Type(), collations.Unknown, typ.values, sqlmode)
cast, err := valueToEvalCast(value, value.Type(), typ.collation, typ.values, sqlmode)
if err != nil {
return sqltypes.Value{}, err
}
Expand Down

0 comments on commit 4bf9c34

Please sign in to comment.