Skip to content

Commit

Permalink
planner: fix the bug that wrong collation is used when try fast path …
Browse files Browse the repository at this point in the history
…for enum or set (#23217) (#23292)
  • Loading branch information
ti-srebot authored Mar 18, 2021
1 parent a3648ac commit aad2f72
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
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

0 comments on commit aad2f72

Please sign in to comment.