From ebdcdb1eac512b97d4a94caa5f063ea35155faaa Mon Sep 17 00:00:00 2001 From: maiyang Date: Sat, 17 Mar 2018 08:45:34 +0800 Subject: [PATCH] executor: remove Next function for prepared.go (#6003) --- executor/prepared.go | 25 ------------------------- session.go | 2 +- 2 files changed, 1 insertion(+), 26 deletions(-) diff --git a/executor/prepared.go b/executor/prepared.go index 826818f3e4..aff2d676a2 100644 --- a/executor/prepared.go +++ b/executor/prepared.go @@ -93,18 +93,8 @@ func NewPrepareExec(ctx sessionctx.Context, is infoschema.InfoSchema, sqlTxt str } } -// Next implements the Executor Next interface. -func (e *PrepareExec) Next(ctx context.Context) (Row, error) { - return nil, errors.Trace(e.DoPrepare()) -} - // NextChunk implements the Executor NextChunk interface. func (e *PrepareExec) NextChunk(ctx context.Context, chk *chunk.Chunk) error { - return errors.Trace(e.DoPrepare()) -} - -// DoPrepare prepares the statement, it can be called multiple times without side effect. -func (e *PrepareExec) DoPrepare() error { vars := e.ctx.GetSessionVars() if e.ID != 0 { // Must be the case when we retry a prepare. @@ -194,12 +184,6 @@ type ExecuteExec struct { plan plan.Plan } -// Next implements the Executor Next interface. -// It will never be called. -func (e *ExecuteExec) Next(ctx context.Context) (Row, error) { - return nil, nil -} - // NextChunk implements the Executor NextChunk interface. func (e *ExecuteExec) NextChunk(ctx context.Context, chk *chunk.Chunk) error { return nil @@ -236,17 +220,8 @@ type DeallocateExec struct { Name string } -// Next implements the Executor Next interface. -func (e *DeallocateExec) Next(ctx context.Context) (Row, error) { - return nil, errors.Trace(e.run(ctx)) -} - // NextChunk implements the Executor NextChunk interface. func (e *DeallocateExec) NextChunk(ctx context.Context, chk *chunk.Chunk) error { - return errors.Trace(e.run(ctx)) -} - -func (e *DeallocateExec) run(ctx context.Context) error { vars := e.ctx.GetSessionVars() id, ok := vars.PreparedStmtNameToID[e.Name] if !ok { diff --git a/session.go b/session.go index 3eb5b3bcda..2de747bc1f 100644 --- a/session.go +++ b/session.go @@ -859,7 +859,7 @@ func (s *session) PrepareStmt(sql string) (stmtID uint32, paramCount int, fields // So we have to call PrepareTxnCtx here. s.PrepareTxnCtx(ctx) prepareExec := executor.NewPrepareExec(s, executor.GetInfoSchema(s), sql) - err = prepareExec.DoPrepare() + err = prepareExec.NextChunk(ctx, nil) if err != nil { err = errors.Trace(err) return