From b3d70cc8d703e071dad6299f9996242b34ea862c Mon Sep 17 00:00:00 2001 From: shenli Date: Thu, 4 Feb 2016 14:41:31 +0800 Subject: [PATCH] *: Fix bug in AggregateExec.Close() Pass sqllogic test select --- executor/aggregate_test.go | 8 ++++++++ executor/executor.go | 6 +++--- 2 files changed, 11 insertions(+), 3 deletions(-) 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 }