Skip to content

Commit

Permalink
collations: fix coercion semantics according to 8.0.31 changes (vites…
Browse files Browse the repository at this point in the history
…sio#11487) (vitessio#11836)

Signed-off-by: Vicent Marti <[email protected]>

Signed-off-by: Vicent Marti <[email protected]>
Signed-off-by: Florent Poinsard <[email protected]>
Co-authored-by: Florent Poinsard <[email protected]>
Signed-off-by: Manan Gupta <[email protected]>

Signed-off-by: Vicent Marti <[email protected]>
Signed-off-by: Florent Poinsard <[email protected]>
Signed-off-by: Manan Gupta <[email protected]>
Co-authored-by: Vicent Martí <[email protected]>
Co-authored-by: Florent Poinsard <[email protected]>
  • Loading branch information
3 people authored Nov 29, 2022
1 parent 9d2f752 commit f55765c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 7 additions & 0 deletions go/mysql/collations/coercion.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions go/mysql/collations/integration/coercion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit f55765c

Please sign in to comment.