Beispiel #1
0
func getSessionStatusVar(ctx context.Context, sessionVars *variable.SessionVars,
	globalVars variable.GlobalVarAccessor, name string) (string, error) {
	sv, ok := sessionVars.StatusVars[name]
	if ok {
		return sv, nil
	}

	value, err := globalVars.GetGlobalStatusVar(ctx, name)
	if err != nil && terror.UnknownStatusVar.Equal(err) {
		return "", errors.Trace(err)
	}

	return value, nil
}
Beispiel #2
0
func (e *SimpleExec) getVarValue(v *ast.VariableAssignment, sysVar *variable.SysVar, globalVars variable.GlobalVarAccessor) (value types.Datum, err error) {
	switch v.Value.(type) {
	case *ast.DefaultExpr:
		// To set a SESSION variable to the GLOBAL value or a GLOBAL value
		// to the compiled-in MySQL default value, use the DEFAULT keyword.
		// See http://dev.mysql.com/doc/refman/5.7/en/set-statement.html
		if sysVar != nil {
			value = types.NewStringDatum(sysVar.Value)
		} else {
			s, err1 := globalVars.GetGlobalSysVar(e.ctx, strings.ToLower(v.Name))
			if err1 != nil {
				return value, errors.Trace(err1)
			}
			value = types.NewStringDatum(s)
		}
	default:
		value, err = evaluator.Eval(e.ctx, v.Value)
	}
	return value, errors.Trace(err)
}