Ejemplo n.º 1
0
// Explain implements the plan.Plan Explain interface.
func (r *TableDefaultPlan) Explain(w format.Formatter) {
	fmtStr := "┌Iterate all rows of table %q\n└Output field names %v\n"
	if r.rangeScan {
		fmtStr = "┌Range scan rows of table %q\n└Output field names %v\n"
	}
	w.Format(fmtStr, r.T.TableName(), field.RFQNames(r.Fields))
}
Ejemplo n.º 2
0
// Explain implements the plan.Plan Explain interface.
func (r *SelectFinalPlan) Explain(w format.Formatter) {
	r.Src.Explain(w)
	if r.HiddenFieldOffset == len(r.Src.GetFields()) {
		// we have no hidden fields, can return.
		return
	}
	w.Format("┌Evaluate\n└Output field names %v\n", field.RFQNames(r.ResultFields[0:r.HiddenFieldOffset]))
}
Ejemplo n.º 3
0
// Explain implements plan.Plan Explain interface.
func (r *SelectLockPlan) Explain(w format.Formatter) {
	r.Src.Explain(w)
	if r.Lock != coldef.SelectLockForUpdate {
		// no need to lock, just return.
		return
	}
	w.Format("┌Lock row keys for update\n")
}
Ejemplo n.º 4
0
// Explain implements the stmt.Statement Explain interface.
func (s *DeleteStmt) Explain(ctx context.Context, w format.Formatter) {
	p, err := s.plan(ctx)
	if err != nil {
		log.Error(err)
		return
	}
	p.Explain(w)
	w.Format("└Delete row\n")
}
Ejemplo n.º 5
0
// Explain implements the stmt.Statement Explain interface.
func (s *SelectStmt) Explain(ctx context.Context, w format.Formatter) {
	p, err := s.Plan(ctx)
	if err != nil {
		w.Format("ERROR: %v\n", err)
		return
	}

	p.Explain(w)
}
Ejemplo n.º 6
0
func (r *JoinPlan) explainNode(w format.Formatter, node plan.Plan) {
	sel := !isTableOrIndex(node)
	if sel {
		w.Format("┌Iterate all rows of virtual table\n")
	}
	node.Explain(w)
	if sel {
		w.Format("└Output field names %v\n", field.RFQNames(node.GetFields()))
	}

}
Ejemplo n.º 7
0
// Explain implements the stmt.Statement Explain interface.
func (s *UpdateStmt) Explain(ctx context.Context, w format.Formatter) {
	p, err := s.plan(ctx)
	if err != nil {
		log.Error(err)
		return
	}
	if p != nil {
		p.Explain(w)
	}
	w.Format("└Update fields %v\n", s.List)
}
Ejemplo n.º 8
0
// Explain implements the stmt.Statement Explain interface.
func (s *DeleteStmt) Explain(ctx context.Context, w format.Formatter) {
	p, err := s.indexPlan(ctx)
	if err != nil {
		log.Error(err)
		return
	}
	if p != nil {
		p.Explain(w)
	} else {
		w.Format("┌Iterate all rows of table: %s\n", s.TableIdent)
	}
	w.Format("└Delete row\n")
}
Ejemplo n.º 9
0
// Explain implements plan.Plan Explain interface.
func (r *JoinPlan) Explain(w format.Formatter) {
	// TODO: show more useful join plan
	if r.Right == nil {
		// if right is nil, we don't do a join, just simple select table
		r.Left.Explain(w)
		return
	}

	w.Format("┌Compute %s Cartesian product of\n", r.Type)

	r.explainNode(w, r.Left)
	r.explainNode(w, r.Right)

	w.Format("└Output field names %v\n", field.RFQNames(r.Fields))
}
Ejemplo n.º 10
0
Archivo: fields.go Proyecto: H0bby/tidb
// Explain implements the plan.Plan Explain interface.
func (r *SelectFieldsDefaultPlan) Explain(w format.Formatter) {
	// TODO: check for non existing fields
	r.Src.Explain(w)
	w.Format("┌Evaluate")
	for _, v := range r.Fields {
		w.Format(" %s,", v)
	}
	w.Format("\n└Output field names %v\n", field.RFQNames(r.ResultFields))
}
Ejemplo n.º 11
0
// Explain implements plan.Plan Explain interface.
func (r *OrderByDefaultPlan) Explain(w format.Formatter) {
	r.Src.Explain(w)
	w.Format("┌Order by")

	items := make([]string, len(r.By))
	for i, v := range r.By {
		order := "ASC"
		if !r.Ascs[i] {
			order = "DESC"
		}
		items[i] = fmt.Sprintf(" %s %s", v, order)
	}
	w.Format("%s", strings.Join(items, ","))
	w.Format("\n└Output field names %v\n", field.RFQNames(r.ResultFields))
}
Ejemplo n.º 12
0
// Explain implements plan.Plan Explain interface.
func (r *indexPlan) Explain(w format.Formatter) {
	w.Format("┌Iterate rows of table %q using index %q where %s in ", r.src.TableName(), r.idxName, r.col.Name.L)
	for _, span := range r.spans {
		open := "["
		close := "]"
		if span.lowExclude {
			open = "("
		}
		if span.highExclude {
			close = ")"
		}
		w.Format("%s%v,%v%s ", open, span.lowVal, span.highVal, close)
	}
	w.Format("\n└Output field names %v\n", field.RFQNames(r.GetFields()))
}
Ejemplo n.º 13
0
// Explain implements plan.Plan Explain interface.
func (r *LimitDefaultPlan) Explain(w format.Formatter) {
	r.Src.Explain(w)
	w.Format("┌Limit %d records\n└Output field names %v\n", r.Count, r.Fields)
}
Ejemplo n.º 14
0
// Explain implements plan.Plan Explain interface.
func (r *GroupByDefaultPlan) Explain(w format.Formatter) {
	r.Src.Explain(w)
	w.Format("┌Evaluate")
	for _, v := range r.Fields {
		w.Format(" %s as %s,", v.Expr, fmt.Sprintf("%q", v.Name))
	}

	switch {
	case len(r.By) == 0: //TODO this case should not exist for this plan.Plan, should become TableDefaultPlan
		w.Format("\n│Group by distinct rows")
	default:
		w.Format("\n│Group by")
		for _, v := range r.By {
			w.Format(" %s,", v)
		}
	}
	w.Format("\n└Output field names %v\n", field.RFQNames(r.ResultFields))
}
Ejemplo n.º 15
0
// Explain implements the stmt.Statement Explain interface.
func (s *CreateUserStmt) Explain(ctx context.Context, w format.Formatter) {
	w.Format("%s\n", s.Text)
}
Ejemplo n.º 16
0
// Explain implements the plan.Plan Explain interface.
func (r *DistinctDefaultPlan) Explain(w format.Formatter) {
	r.Src.Explain(w)
	w.Format("┌Compute distinct rows\n└Output field names %v\n", r.ResultFields)
}
Ejemplo n.º 17
0
// Explain implements plan.Plan Explain interface.
func (r *HavingPlan) Explain(w format.Formatter) {
	r.Src.Explain(w)
	w.Format("┌Having %s\n└Output field names %v\n", r.Expr.String(), r.Src.GetFields())
}
Ejemplo n.º 18
0
Archivo: plans.go Proyecto: szctop/tidb
// Explain implements plan.Plan Explain interface.
func (r *selectIndexDefaultPlan) Explain(w format.Formatter) {
	w.Format("┌Iterate all values of index %q\n└Output field names N/A\n", r.nm)
}
Ejemplo n.º 19
0
Archivo: plans.go Proyecto: szctop/tidb
// Explain implements plan.Plan Explain interface.
func (r *NullPlan) Explain(w format.Formatter) {
	w.Format("┌Iterate no rows\n└Output field names %v\n", field.RFQNames(r.Fields))
}
Ejemplo n.º 20
0
// Explain implements the stmt.Statement Explain interface.
func (s *DeallocateStmt) Explain(ctx context.Context, w format.Formatter) {
	w.Format("%s\n", s.Text)
}
Ejemplo n.º 21
0
// Explain implements the stmt.Statement Explain interface.
func (s *ShowStmt) Explain(ctx context.Context, w format.Formatter) {
	w.Format("%s\n", s.Text)
}
Ejemplo n.º 22
0
// Explain implements plan.Plan Explain interface.
func (r *OffsetDefaultPlan) Explain(w format.Formatter) {
	r.Src.Explain(w)
	w.Format("┌Skip first %d records\n└Output field names %v\n", r.Count, field.RFQNames(r.Fields))
}
Ejemplo n.º 23
0
Archivo: drop.go Proyecto: yzl11/vessel
// Explain implements the stmt.Statement Explain interface.
func (s *DropTableStmt) Explain(ctx context.Context, w format.Formatter) {
	w.Format("%s\n", s.Text)
}
Ejemplo n.º 24
0
// Explain implements plan.Plan Explain interface.
func (r *FilterDefaultPlan) Explain(w format.Formatter) {
	r.Plan.Explain(w)
	w.Format("┌FilterDefaultPlan Filter on %v\n", r.Expr)
	w.Format("└Output field names %v\n", field.RFQNames(r.GetFields()))
}
Ejemplo n.º 25
0
// Explain implements the plan.Plan interface.
func (r *TableNilPlan) Explain(w format.Formatter) {
	w.Format("┌Iterate all rows of table %q\n└Output field names %v\n", r.T.TableName(), field.RFQNames(r.GetFields()))
}
Ejemplo n.º 26
0
// Explain implements the stmt.Statement Explain interface.
func (s *ReplaceIntoStmt) Explain(ctx context.Context, w format.Formatter) {
	w.Format("%s\n", s.Text)
}