Skip to content

Commit

Permalink
executor: remove Next function for prepared.go (pingcap#6003)
Browse files Browse the repository at this point in the history
  • Loading branch information
yangwenmai authored and XuHuaiyu committed Mar 17, 2018
1 parent 063924a commit ebdcdb1
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 26 deletions.
25 changes: 0 additions & 25 deletions executor/prepared.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion session.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ebdcdb1

Please sign in to comment.