diff --git a/expression/integration_test.go b/expression/integration_test.go index 440067d3ca9e0..f19afccb3d906 100644 --- a/expression/integration_test.go +++ b/expression/integration_test.go @@ -6301,6 +6301,15 @@ func (s *testIntegrationSerialSuite) TestCollationBasic(c *C) { tk.MustQuery("select a from t_ci where a='A'").Check(testkit.Rows("a")) tk.MustQuery("select a from t_ci where a='a '").Check(testkit.Rows("a")) tk.MustQuery("select a 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 1e9c9ae48c081..0ec72814b934e 100644 --- a/planner/core/point_get_plan.go +++ b/planner/core/point_get_plan.go @@ -1100,7 +1100,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 {