diff --git a/go/mysql/collations/coercion.go b/go/mysql/collations/coercion.go index 227389a52ba..1fe6e21c37b 100644 --- a/go/mysql/collations/coercion.go +++ b/go/mysql/collations/coercion.go @@ -208,9 +208,16 @@ func (env *Environment) MergeCollations(left, right TypedCollation, opt Coercion if leftColl == nil || rightColl == nil { return TypedCollation{}, nil, nil, fmt.Errorf("unsupported TypeCollationID: %v / %v", left.Collation, right.Collation) } + leftCS := leftColl.Charset() rightCS := rightColl.Charset() + if left.Coercibility == CoerceExplicit && right.Coercibility == CoerceExplicit { + if left.Collation != right.Collation { + goto cannotCoerce + } + } + if leftCS.Name() == rightCS.Name() { switch { case left.Coercibility < right.Coercibility: diff --git a/go/mysql/collations/integration/coercion_test.go b/go/mysql/collations/integration/coercion_test.go index a05d2afad52..c8bf2241989 100644 --- a/go/mysql/collations/integration/coercion_test.go +++ b/go/mysql/collations/integration/coercion_test.go @@ -135,8 +135,8 @@ func TestComparisonSemantics(t *testing.T) { conn := mysqlconn(t) defer conn.Close() - if strings.HasPrefix(conn.ServerVersion, "8.0.31") { - t.Skipf("Coercion semantics have changed in 8.0.31") + if v, err := conn.ServerVersionAtLeast(8, 0, 31); err != nil || !v { + t.Skipf("The behavior of Coercion Semantics is not correct before 8.0.31") } for _, coll := range collations.Local().AllCollations() {