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

expression: fix a bug that the coercibilities of enum and set are wrong (#20274) #20364

Merged
merged 3 commits into from
Oct 14, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions expression/collation.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func deriveCoercibilityForScarlarFunc(sf *ScalarFunction) Coercibility {
if _, ok := sysConstFuncs[sf.FuncName.L]; ok {
return CoercibilitySysconst
}
if !types.IsString(sf.RetType.Tp) {
if sf.RetType.EvalType() != types.ETString {
return CoercibilityNumeric
}
coer := CoercibilityIgnorable
Expand All @@ -155,14 +155,14 @@ func deriveCoercibilityForScarlarFunc(sf *ScalarFunction) Coercibility {
func deriveCoercibilityForConstant(c *Constant) Coercibility {
if c.Value.IsNull() {
return CoercibilityIgnorable
} else if !types.IsString(c.RetType.Tp) {
} else if c.RetType.EvalType() != types.ETString {
return CoercibilityNumeric
}
return CoercibilityCoercible
}

func deriveCoercibilityForColumn(c *Column) Coercibility {
if !types.IsString(c.RetType.Tp) {
if c.RetType.EvalType() != types.ETString {
return CoercibilityNumeric
}
return CoercibilityImplicit
Expand Down
12 changes: 12 additions & 0 deletions expression/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6676,6 +6676,18 @@ func (s *testIntegrationSuite) TestIssue17727(c *C) {
tk.MustQuery("select @@last_plan_from_cache;").Check(testkit.Rows("1"))
}

func (s *testIntegrationSerialSuite) TestIssue20268(c *C) {
collate.SetNewCollationEnabledForTest(true)
defer collate.SetNewCollationEnabledForTest(false)

tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
tk.MustExec("drop table if exists t")
tk.MustExec("CREATE TABLE `t` ( `a` enum('a','b') DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;")
tk.MustExec("insert into t values('a');")
tk.MustExec("select * from t where a = 'A';")
}

func (s *testIntegrationSuite) TestIssue18515(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
Expand Down