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

planner: fix the bug that wrong collation is used when try fast path for enum or set (#23217) #23292

Merged
merged 7 commits into from
Mar 18, 2021
9 changes: 9 additions & 0 deletions expression/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion planner/core/point_get_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down