partition: fix hash partition with not between condition get wrong result (#22914)

This commit is contained in:
xiongjiwei
2021-03-25 11:53:23 +08:00
committed by GitHub
parent 4b7a3767b0
commit 47749a156a
2 changed files with 11 additions and 0 deletions

View File

@ -2626,6 +2626,15 @@ func (s *testIntegrationSuite) TestIssue22199(c *C) {
tk.MustGetErrMsg("select t1.*, (select t2.* from t1) from t1", "[planner:1051]Unknown table 't2'")
}
func (s *testIntegrationSuite) TestIssue22892(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
tk.MustExec("drop table if exists t1")
tk.MustExec("create table t1(a int) partition by hash (a) partitions 5;")
tk.MustExec("insert into t1 values (0);")
tk.MustQuery("select * from t1 where a not between 1 and 2;").Check(testkit.Rows("0"))
}
func (s *testIntegrationSerialSuite) TestPushDownProjectionForTiFlash(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")

View File

@ -638,6 +638,8 @@ func (r *builder) buildFromNot(expr *expression.ScalarFunction) []*point {
startPoint := &point{value: types.MinNotNullDatum(), start: true}
endPoint := &point{value: types.MaxValueDatum()}
return []*point{startPoint, endPoint}
case ast.LogicAnd:
return r.intersection(r.build(expr.GetArgs()[0]), r.build(expr.GetArgs()[1]))
}
return nil
}