From 4bf9c34e0fdcbba482222b8e67bdfc4566497c4e Mon Sep 17 00:00:00 2001 From: Dirkjan Bussink Date: Wed, 24 Jul 2024 10:27:25 +0200 Subject: [PATCH] Small internal cleanups (#16467) Signed-off-by: Dirkjan Bussink --- go/mysql/collations/env.go | 13 +++---------- go/mysql/collations/integration/main_test.go | 2 +- go/vt/vtgate/evalengine/api_coerce.go | 2 +- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/go/mysql/collations/env.go b/go/mysql/collations/env.go index ae5419a5797..77e498562bf 100644 --- a/go/mysql/collations/env.go +++ b/go/mysql/collations/env.go @@ -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."): @@ -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) } diff --git a/go/mysql/collations/integration/main_test.go b/go/mysql/collations/integration/main_test.go index 23c6f8d2716..665a86ad266 100644 --- a/go/mysql/collations/integration/main_test.go +++ b/go/mysql/collations/integration/main_test.go @@ -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+") } diff --git a/go/vt/vtgate/evalengine/api_coerce.go b/go/vt/vtgate/evalengine/api_coerce.go index eef83c58422..f26ba5ea758 100644 --- a/go/vt/vtgate/evalengine/api_coerce.go +++ b/go/vt/vtgate/evalengine/api_coerce.go @@ -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 }