From d209a36aaf7d5ce12b2cae12abb4d5c545aff82a Mon Sep 17 00:00:00 2001 From: Jian Zhang Date: Thu, 14 Dec 2017 09:28:49 +0800 Subject: [PATCH] executor: support Chunk for SetExecutor (#5397) --- executor/builder.go | 4 +++- executor/set.go | 12 ++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/executor/builder.go b/executor/builder.go index 72c03c94d0ff7..b80103d197300 100644 --- a/executor/builder.go +++ b/executor/builder.go @@ -312,10 +312,12 @@ func (b *executorBuilder) buildSimple(v *plan.Simple) Executor { } func (b *executorBuilder) buildSet(v *plan.Set) Executor { - return &SetExecutor{ + e := &SetExecutor{ baseExecutor: newBaseExecutor(v.Schema(), b.ctx), vars: v.VarAssigns, } + e.supportChk = true + return e } func (b *executorBuilder) buildInsert(v *plan.Insert) Executor { diff --git a/executor/set.go b/executor/set.go index 77bb4133034ea..73c9fa77d1f39 100644 --- a/executor/set.go +++ b/executor/set.go @@ -30,6 +30,7 @@ import ( "github.com/pingcap/tidb/terror" "github.com/pingcap/tidb/types" "github.com/pingcap/tidb/util/charset" + "github.com/pingcap/tidb/util/chunk" "github.com/pingcap/tidb/util/sqlexec" goctx "golang.org/x/net/context" ) @@ -55,6 +56,17 @@ func (e *SetExecutor) Next(goCtx goctx.Context) (Row, error) { return nil, nil } +// NextChunk implements the Executor NextChunk interface. +func (e *SetExecutor) NextChunk(goCtx goctx.Context, chk *chunk.Chunk) error { + chk.Reset() + if !e.done { + e.done = true + err := e.executeSet() + return errors.Trace(err) + } + return nil +} + func (e *SetExecutor) executeSet() error { sessionVars := e.ctx.GetSessionVars() for _, v := range e.vars {