Skip to content

Commit 2be75e4

Browse files
authored
Merge pull request #3242 from dolthub/daylon/jdbc-collations
Added collation ignoring for information_schema
2 parents c672e4b + d4680ac commit 2be75e4

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

sql/expression/collatedexpr.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ package expression
1616

1717
import (
1818
"fmt"
19+
"strings"
1920

2021
"github.com/dolthub/go-mysql-server/sql"
2122
"github.com/dolthub/go-mysql-server/sql/types"
@@ -85,8 +86,19 @@ func (ce *CollatedExpression) Eval(ctx *sql.Context, row sql.Row) (interface{},
8586
return nil, sql.ErrCollatedExprWrongType.New()
8687
}
8788
if ce.collation.CharacterSet() != typ.(sql.TypeWithCollation).Collation().CharacterSet() {
88-
return nil, sql.ErrCollationInvalidForCharSet.New(
89-
ce.collation.Name(), typ.(sql.TypeWithCollation).Collation().CharacterSet().Name())
89+
// We expose information_schema as utf8mb3 but some tools will try to use our default charset of utf8mb4, so we
90+
// ignore the collation altogether in these cases. This is added due to tools throwing collations in places
91+
// where it's not necessary.
92+
shouldIgnore := false
93+
if gf, ok := ce.expr.(*GetField); ok {
94+
if strings.EqualFold("information_schema", gf.db) {
95+
shouldIgnore = true
96+
}
97+
}
98+
if !shouldIgnore {
99+
return nil, sql.ErrCollationInvalidForCharSet.New(
100+
ce.collation.Name(), typ.(sql.TypeWithCollation).Collation().CharacterSet().Name())
101+
}
90102
}
91103
return ce.expr.Eval(ctx, row)
92104
}

0 commit comments

Comments
 (0)