Пример #1
0
func (e *ShowExec) fetchShowStatus() error {
	statusVars, err := variable.GetStatusVars()
	if err != nil {
		return errors.Trace(err)
	}
	for status, v := range statusVars {
		if e.GlobalScope && v.Scope == variable.ScopeSession {
			continue
		}
		value, err := types.ToString(v.Value)
		if err != nil {
			return errors.Trace(err)
		}
		row := &Row{Data: types.MakeDatums(status, value)}
		e.rows = append(e.rows, row)
	}
	return nil
}
Пример #2
0
func (s *ShowPlan) fetchShowStatus(ctx context.Context) error {
	m := map[interface{}]interface{}{}

	statusVars, err := variable.GetStatusVars()
	if err != nil {
		return errors.Trace(err)
	}

	for status, v := range statusVars {
		if s.Pattern != nil {
			s.Pattern.Expr = expression.Value{Val: status}
		} else if s.Where != nil {
			m[expression.ExprEvalIdentFunc] = func(name string) (interface{}, error) {
				if strings.EqualFold(name, "Variable_name") {
					return status, nil
				}

				return nil, errors.Errorf("unknown field %s", name)
			}
		}

		match, err := s.evalCondition(ctx, m)
		if err != nil {
			return errors.Trace(err)
		}
		if !match {
			continue
		}

		if s.GlobalScope && v.Scope == variable.ScopeSession {
			continue
		}

		value, err := types.ToString(v.Value)
		if err != nil {
			return errors.Trace(err)
		}
		row := &plan.Row{Data: []interface{}{status, value}}
		s.rows = append(s.rows, row)
	}

	return nil
}