Skip to content

Commit

Permalink
ranger: fix incorrect enum range for xxx_ci collation
Browse files Browse the repository at this point in the history
Signed-off-by: lzmhhh123 <[email protected]>
  • Loading branch information
lzmhhh123 committed May 17, 2021
1 parent 80a557e commit 5e3b056
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
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

0 comments on commit 5e3b056

Please sign in to comment.