expression: fix different types compare error (#21338)

This commit is contained in:
zhaoxugang
2020-12-25 16:50:11 +08:00
committed by GitHub
parent 27071f14d7
commit 3e2ff1d16c
2 changed files with 15 additions and 0 deletions

View File

@ -1092,6 +1092,8 @@ func getBaseCmpType(lhs, rhs types.EvalType, lft, rft *types.FieldType) types.Ev
return types.ETString
} else if (lhs == types.ETInt || (lft != nil && lft.Hybrid())) && (rhs == types.ETInt || (rft != nil && rft.Hybrid())) {
return types.ETInt
} else if (lhs == types.ETDecimal && rhs == types.ETString) || (lhs == types.ETString && rhs == types.ETDecimal) {
return types.ETReal
} else if ((lhs == types.ETInt || (lft != nil && lft.Hybrid())) || lhs == types.ETDecimal) &&
((rhs == types.ETInt || (rft != nil && rft.Hybrid())) || rhs == types.ETDecimal) {
return types.ETDecimal

View File

@ -8392,6 +8392,19 @@ func (s *testIntegrationSuite) TestIssue12205(c *C) {
testkit.Rows("Warning 1292 Truncated incorrect time value: '18446744072635875000'"))
}
// for issue 20128
func (s *testIntegrationSerialSuite) TestIssue20128(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
tk.MustExec("drop table if exists t;")
tk.MustExec("create table t(b enum('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z') DEFAULT NULL, c decimal(40,20));")
tk.MustExec("insert into t values('z', 19.18040000000000000000);")
tk.MustExec("insert into t values('z', 26.18040000000000000000);")
tk.MustExec("insert into t values('z', 25.18040000000000000000);")
tk.MustQuery("select * from t where t.b > t.c;").Check(testkit.Rows("z 19.18040000000000000000", "z 25.18040000000000000000"))
tk.MustQuery("select * from t where t.b < t.c;").Check(testkit.Rows("z 26.18040000000000000000"))
}
func (s *testIntegrationSuite) TestIssue21677(c *C) {
tk := testkit.NewTestKit(c, s.store)