Skip to content

Commit

Permalink
Merge branch 'release-5.1' into cp_27267
Browse files Browse the repository at this point in the history
  • Loading branch information
ti-chi-bot authored Sep 17, 2021
2 parents 9562d56 + d67969c commit b9af5e0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
10 changes: 10 additions & 0 deletions expression/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9810,6 +9810,16 @@ func (s *testIntegrationSuite2) TestIssue25526(c *C) {
rows.Check(testkit.Rows())
}

func (s *testIntegrationSuite) TestIssue27610(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec(`use test;`)
tk.MustExec(`drop table if exists PK_TCOLLATION3966STROBJSTROBJ;`)
tk.MustExec("CREATE TABLE `PK_TCOLLATION3966STROBJSTROBJ` (\n `COL1` enum('ll','aa','bb','cc','dd','ee') COLLATE utf8_general_ci NOT NULL,\n `COL2` varchar(20) COLLATE utf8_general_ci DEFAULT NULL,\n PRIMARY KEY (`COL1`) /*T![clustered_index] CLUSTERED */\n) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;")
tk.MustExec(`insert into PK_TCOLLATION3966STROBJSTROBJ values("ee", "tttt");`)
tk.MustQuery("SELECT col1, COL2 FROM PK_TCOLLATION3966STROBJSTROBJ WHERE COL1 IN ('notexist','6') and col2 not in (\"abcd\");").
Check(testkit.Rows())
}

func (s *testIntegrationSuite) TestIssue26977(c *C) {
tk := testkit.NewTestKit(c, s.store)
result := tk.MustQuery("select a + 1 as f from (select cast(0xfffffffffffffff0 as unsigned) as a union select cast(1 as unsigned)) t having f != 2;")
Expand Down
15 changes: 14 additions & 1 deletion util/ranger/points.go
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,20 @@ func (r *builder) buildFromIn(expr *expression.ScalarFunction) ([]*point, bool)
dt.SetString(dt.GetString(), colCollate)
}
if expr.GetArgs()[0].GetType().Tp == mysql.TypeEnum {
dt, err = dt.ConvertTo(r.sc, expr.GetArgs()[0].GetType())
switch dt.Kind() {
case types.KindString, types.KindBytes, types.KindBinaryLiteral:
// Can't use ConvertTo directly, since we shouldn't convert numerical string to Enum in select stmt.
targetType := expr.GetArgs()[0].GetType()
enum, parseErr := types.ParseEnumName(targetType.Elems, dt.GetString(), targetType.Collate)
if parseErr == nil {
dt.SetMysqlEnum(enum, targetType.Collate)
} else {
err = parseErr
}
default:
dt, err = dt.ConvertTo(r.sc, expr.GetArgs()[0].GetType())
}

if err != nil {
// in (..., an impossible value (not valid enum), ...), the range is empty, so skip it.
continue
Expand Down

0 comments on commit b9af5e0

Please sign in to comment.