From 50d858ff5c302f3ada6b87686bc2008f3e3a9201 Mon Sep 17 00:00:00 2001 From: Ewan Chou Date: Mon, 4 Jan 2016 16:02:05 +0800 Subject: [PATCH] plan/plans: fix is null panic. --- plan/plans/from.go | 4 +++- session_test.go | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/plan/plans/from.go b/plan/plans/from.go index c055972050..20ee2662d9 100644 --- a/plan/plans/from.go +++ b/plan/plans/from.go @@ -244,7 +244,9 @@ func (r *TableDefaultPlan) filterIsNull(ctx context.Context, x *expression.IsNul cn := cns[0] t := r.T col := column.FindCol(t.Cols(), cn) - + if col == nil { + return r, false, nil + } if col.IsPKHandleColumn(t.Meta()) { if x.Not { // PK handle column never be null. diff --git a/session_test.go b/session_test.go index fa890d09e6..e522ae6604 100644 --- a/session_test.go +++ b/session_test.go @@ -611,6 +611,8 @@ func (s *testSessionSuite) TestSelect(c *C) { row, err = r.FirstRow() c.Assert(err, IsNil) match(c, row, 3) + + mustExecSQL(c, se, `select * from t1, t2 where t1.c1 is null`) } func (s *testSessionSuite) TestSubQuery(c *C) {