Skip to content

Commit

Permalink
expression: fix errors in Apply when the type of correlation column i…
Browse files Browse the repository at this point in the history
…s `bit` (#19331)

* fix apply panic

* fixup

* fix CI

* fix CI

Co-authored-by: ti-srebot <66930949+ti-srebot@users.noreply.github.com>
  • Loading branch information
qw4990 and ti-srebot authored Sep 2, 2020
1 parent 729fdcb commit 853e0b4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
4 changes: 3 additions & 1 deletion expression/expression.go
Original file line number Diff line number Diff line change
Expand Up @@ -1113,7 +1113,9 @@ func canExprPushDown(expr Expression, pc PbConverter, storeType kv.StoreType) bo
return false
}
switch x := expr.(type) {
case *Constant, *CorrelatedColumn:
case *CorrelatedColumn:
return pc.conOrCorColToPBExpr(expr) != nil && pc.columnToPBExpr(&x.Column) != nil
case *Constant:
return pc.conOrCorColToPBExpr(expr) != nil
case *Column:
return pc.columnToPBExpr(x) != nil
Expand Down
13 changes: 13 additions & 0 deletions expression/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7100,6 +7100,19 @@ func (s *testIntegrationSerialSuite) TestIssue19116(c *C) {
tk.MustQuery("select coercibility(1=1);").Check(testkit.Rows("5"))
}

func (s *testIntegrationSerialSuite) TestIssue19315(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
tk.MustExec("drop table if exists t")
tk.MustExec("drop table if exists t1")
tk.MustExec("CREATE TABLE `t` (`a` bit(10) DEFAULT NULL,`b` int(11) DEFAULT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin")
tk.MustExec("INSERT INTO `t` VALUES (_binary '\\0',1),(_binary '\\0',2),(_binary '\\0',5),(_binary '\\0',4),(_binary '\\0',2),(_binary '\\0 ',4)")
tk.MustExec("CREATE TABLE `t1` (`a` int(11) DEFAULT NULL, `b` int(11) DEFAULT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin")
tk.MustExec("INSERT INTO `t1` VALUES (1,1),(1,5),(2,3),(2,4),(3,3)")
err := tk.QueryToErr("select * from t where t.b > (select min(t1.b) from t1 where t1.a > t.a)")
c.Assert(err, IsNil)
}

func (s *testIntegrationSerialSuite) TestIssue18674(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustQuery("select -1.0 % -1.0").Check(testkit.Rows("0.0"))
Expand Down

0 comments on commit 853e0b4

Please sign in to comment.