diff --git a/expression/integration_test.go b/expression/integration_test.go index b74c7334c8bf6..d739c81c433d0 100755 --- a/expression/integration_test.go +++ b/expression/integration_test.go @@ -6184,6 +6184,17 @@ func (s *testIntegrationSuite) TestIssue15992(c *C) { tk.MustExec("drop table t0;") } +func (s *testIntegrationSuite) TestIssue16419(c *C) { + tk := testkit.NewTestKitWithInit(c, s.store) + tk.MustExec("use test;") + tk.MustExec("drop table if exists t0") + tk.MustExec("drop table if exists t1") + tk.MustExec("CREATE TABLE t0(c0 INT);") + tk.MustExec("CREATE TABLE t1(c0 INT);") + tk.MustQuery("SELECT * FROM t1 NATURAL LEFT JOIN t0 WHERE NOT t1.c0;").Check(testkit.Rows()) + tk.MustExec("drop table t0, t1;") +} + func (s *testIntegrationSuite) TestIssue16029(c *C) { tk := testkit.NewTestKit(c, s.store) tk.MustExec("use test;") diff --git a/planner/core/rule_predicate_push_down.go b/planner/core/rule_predicate_push_down.go index 812a373c7889b..0d1951ab35521 100644 --- a/planner/core/rule_predicate_push_down.go +++ b/planner/core/rule_predicate_push_down.go @@ -337,7 +337,7 @@ func simplifyOuterJoin(p *LogicalJoin, predicates []expression.Expression) { // If it is a conjunction containing a null-rejected condition as a conjunct. // If it is a disjunction of null-rejected conditions. func isNullRejected(ctx sessionctx.Context, schema *expression.Schema, expr expression.Expression) bool { - expr = expression.PushDownNot(nil, expr) + expr = expression.PushDownNot(ctx, expr) sc := ctx.GetSessionVars().StmtCtx sc.InNullRejectCheck = true result := expression.EvaluateExprWithNull(ctx, schema, expr)