Skip to content

Commit

Permalink
move explain code to explain.go
Browse files Browse the repository at this point in the history
  • Loading branch information
zhexuany committed Jul 16, 2018
1 parent 9b201a1 commit f0169aa
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
11 changes: 0 additions & 11 deletions executor/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -618,17 +618,6 @@ func (b *executorBuilder) buildDDL(v *plan.DDL) Executor {
return e
}

func (b *executorBuilder) buildExplain(v *plan.Explain) Executor {
e := &ExplainExec{
baseExecutor: newBaseExecutor(b.ctx, v.Schema(), v.ExplainID()),
}
e.rows = make([][]string, 0, len(v.Rows))
for _, row := range v.Rows {
e.rows = append(e.rows, row)
}
return e
}

func (b *executorBuilder) buildUnionScanExec(v *plan.PhysicalUnionScan) Executor {
src := b.build(v.Children()[0])
if b.err != nil {
Expand Down
14 changes: 14 additions & 0 deletions executor/explain.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ package executor

import (
"github.com/cznic/mathutil"
"github.com/pingcap/tidb/plan"
"github.com/pingcap/tidb/util/chunk"
"golang.org/x/net/context"
)
Expand All @@ -27,6 +28,19 @@ type ExplainExec struct {
cursor int
}

// buildExplain builds a explain executor. `e.rows` collects final result and
// displays it in sql-shell.
func (b *executorBuilder) buildExplain(v *plan.Explain) Executor {
e := &ExplainExec{
baseExecutor: newBaseExecutor(b.ctx, v.Schema(), v.ExplainID()),
}
e.rows = make([][]string, 0, len(v.Rows))
for _, row := range v.Rows {
e.rows = append(e.rows, row)
}
return e
}

// Close implements the Executor Close interface.
func (e *ExplainExec) Close() error {
e.rows = nil
Expand Down

0 comments on commit f0169aa

Please sign in to comment.