diff --git a/expression/collation.go b/expression/collation.go index c449f1fb7a6a0..29821094efca4 100644 --- a/expression/collation.go +++ b/expression/collation.go @@ -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 @@ -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 diff --git a/expression/integration_test.go b/expression/integration_test.go index 9ae1d20ccf70b..18679b342a231 100755 --- a/expression/integration_test.go +++ b/expression/integration_test.go @@ -6685,6 +6685,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")