diff --git a/expression/integration_test.go b/expression/integration_test.go index 328d1306e0fbb..614f06a51b838 100755 --- a/expression/integration_test.go +++ b/expression/integration_test.go @@ -6097,6 +6097,15 @@ func (s *testIntegrationSerialSuite) TestCollationBasic(c *C) { tk.MustQuery("select * from t_ci where a='A'").Check(testkit.Rows("a")) tk.MustQuery("select * from t_ci where a='a '").Check(testkit.Rows("a")) tk.MustQuery("select * from t_ci where a='a '").Check(testkit.Rows("a")) + + tk.MustExec("drop table if exists t") + tk.MustExec("create table t(c set('A', 'B') collate utf8mb4_general_ci);") + tk.MustExec("insert into t values('a');") + tk.MustExec("insert into t values('B');") + tk.MustQuery("select c from t where c = 'a';").Check(testkit.Rows("A")) + tk.MustQuery("select c from t where c = 'A';").Check(testkit.Rows("A")) + tk.MustQuery("select c from t where c = 'b';").Check(testkit.Rows("B")) + tk.MustQuery("select c from t where c = 'B';").Check(testkit.Rows("B")) } func (s *testIntegrationSerialSuite) TestWeightString(c *C) { diff --git a/planner/core/point_get_plan.go b/planner/core/point_get_plan.go index d78400cbc9648..d499a6cf81922 100644 --- a/planner/core/point_get_plan.go +++ b/planner/core/point_get_plan.go @@ -1040,7 +1040,8 @@ func getNameValuePairs(stmtCtx *stmtctx.StatementContext, tbl *model.TableInfo, } } // The converted result must be same as original datum. - cmp, err := d.CompareDatum(stmtCtx, &dVal) + // Compare them based on the dVal's type. + cmp, err := dVal.CompareDatum(stmtCtx, &d) if err != nil { return nil, false } else if cmp != 0 {