expression: fix different types compare error (#21338)
This commit is contained in:
@ -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
|
||||
|
||||
@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user