Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ranger: fix incorrect enum range for xxx_ci collation #24661

Merged
merged 8 commits into from
May 19, 2021
2 changes: 1 addition & 1 deletion util/ranger/points.go
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ func handleEnumFromBinOp(sc *stmtctx.StatementContext, ft *types.FieldType, val
for i := range ft.Elems {
tmpEnum.Name = ft.Elems[i]
tmpEnum.Value = uint64(i) + 1
d := types.NewMysqlEnumDatum(tmpEnum)
d := types.NewCollateMysqlEnumDatum(tmpEnum, ft.Collate)
if v, err := d.CompareDatum(sc, &val); err == nil {
switch op {
case ast.LT:
Expand Down
11 changes: 10 additions & 1 deletion util/ranger/ranger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,12 +347,14 @@ create table t(
d varchar(10),
e binary(10),
f varchar(10) collate utf8mb4_general_ci,
g enum('A','B','C') collate utf8mb4_general_ci,
index idx_ab(a(50), b),
index idx_cb(c, a),
index idx_d(d(2)),
index idx_e(e(2)),
index idx_f(f),
index idx_de(d(2), e)
index idx_de(d(2), e),
index idx_g(g)
)`)

tests := []struct {
Expand Down Expand Up @@ -628,6 +630,13 @@ create table t(
filterConds: "[in(test.t.d, aab, aac)]",
resultStr: "[[\"aa\" 0x61,\"aa\" 0x61]]",
},
{
indexPos: 6,
exprStr: "g = 'a'",
accessConds: "[eq(test.t.g, a)]",
filterConds: "[]",
resultStr: "[[\"A\",\"A\"]]",
},
}

collate.SetNewCollationEnabledForTest(true)
Expand Down