diff --git a/executor/aggregate_test.go b/executor/aggregate_test.go index a3fd8f3059..31e3ebd12f 100644 --- a/executor/aggregate_test.go +++ b/executor/aggregate_test.go @@ -116,4 +116,12 @@ func (s *testAggFuncSuite) TestCount(c *C) { val, err = evaluator.Eval(ctx, fc2) c.Assert(err, IsNil) c.Assert(val, Equals, int64(2)) + + agg.Close() + val, err = evaluator.Eval(ctx, fc1) + c.Assert(err, IsNil) + c.Assert(val, IsNil) + val, err = evaluator.Eval(ctx, fc2) + c.Assert(err, IsNil) + c.Assert(val, Equals, int64(0)) } diff --git a/executor/executor.go b/executor/executor.go index 1ba7a5554b..5494a2c90d 100644 --- a/executor/executor.go +++ b/executor/executor.go @@ -1074,11 +1074,11 @@ func (e *AggregateExec) innerNext() (bool, error) { // Close implements Executor Close interface. func (e *AggregateExec) Close() error { - if e.Src != nil { - return e.Src.Close() - } for _, af := range e.AggFuncs { af.Clear() } + if e.Src != nil { + return e.Src.Close() + } return nil }