func (v *explainVisitor) explain(p plan.Plan) { switch x := p.(type) { case *plan.TableScan: v.entries = append(v.entries, v.newEntryForTableScan(x)) case *plan.IndexScan: v.entries = append(v.entries, v.newEntryForIndexScan(x)) case *plan.Sort: v.sort = true } for _, c := range p.GetChildren() { v.explain(c) } }
func (e *ExplainExec) prepareExplainInfo(p plan.Plan, parent plan.Plan) error { for _, child := range p.GetChildren() { err := e.prepareExplainInfo(child, p) if err != nil { return errors.Trace(err) } } explain, err := json.MarshalIndent(p, "", " ") if err != nil { return errors.Trace(err) } parentStr := "" if parent != nil { parentStr = parent.GetID() } row := &Row{ Data: types.MakeDatums(p.GetID(), string(explain), parentStr), } e.rows = append(e.rows, row) return nil }