diff --git a/executor/batch_point_get_test.go b/executor/batch_point_get_test.go index 926834dc9281b..8f8c39d4b0eed 100644 --- a/executor/batch_point_get_test.go +++ b/executor/batch_point_get_test.go @@ -156,6 +156,16 @@ func (s *testBatchPointGetSuite) TestIssue18843(c *C) { tk.MustQuery("select * from t18843 where f is null").Check(testkit.Rows("2 ")) } +func (s *testBatchPointGetSuite) TestIssue24562(c *C) { + tk := testkit.NewTestKit(c, s.store) + tk.MustExec("use test") + tk.MustExec("drop table if exists ttt") + tk.MustExec("create table ttt(a enum(\"a\",\"b\",\"c\",\"d\"), primary key(a));") + tk.MustExec("insert into ttt values(1)") + tk.MustQuery("select * from ttt where ttt.a in (\"1\",\"b\")").Check(testkit.Rows()) + tk.MustQuery("select * from ttt where ttt.a in (1,\"b\")").Check(testkit.Rows("a")) +} + func (s *testBatchPointGetSuite) TestBatchPointGetUnsignedHandleWithSort(c *C) { tk := testkit.NewTestKit(c, s.store) tk.MustExec("use test") diff --git a/executor/point_get.go b/executor/point_get.go index e87f3ab7bfb01..48c7a377ccf6e 100644 --- a/executor/point_get.go +++ b/executor/point_get.go @@ -441,6 +441,18 @@ func EncodeUniqueIndexValuesForKey(ctx sessionctx.Context, tblInfo *model.TableI var str string str, err = idxVals[i].ToString() idxVals[i].SetString(str, colInfo.FieldType.Collate) + } else if colInfo.Tp == mysql.TypeEnum && (idxVals[i].Kind() == types.KindString || idxVals[i].Kind() == types.KindBytes || idxVals[i].Kind() == types.KindBinaryLiteral) { + var str string + var e types.Enum + str, err = idxVals[i].ToString() + if err != nil { + return nil, kv.ErrNotExist + } + e, err = types.ParseEnumName(colInfo.FieldType.Elems, str, colInfo.FieldType.Collate) + if err != nil { + return nil, kv.ErrNotExist + } + idxVals[i].SetMysqlEnum(e, colInfo.FieldType.Collate) } else { // If a truncated error or an overflow error is thrown when converting the type of `idxVal[i]` to // the type of `colInfo`, the `idxVal` does not exist in the `idxInfo` for sure.