From 15c6541e27838969a874f8bf1ff846db3b69a6bf Mon Sep 17 00:00:00 2001 From: Morgan Tocker Date: Sun, 8 Aug 2021 20:00:20 -0600 Subject: [PATCH] session, variable: cleanup TiDBEvolvePlanBaselines sysvar --- session/session.go | 3 --- sessionctx/variable/sysvar.go | 11 ++++++----- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/session/session.go b/session/session.go index 8e825130656e0..ed6c565e0c993 100644 --- a/session/session.go +++ b/session/session.go @@ -1158,9 +1158,6 @@ func (s *session) SetGlobalSysVar(name, value string) (err error) { if value, err = sv.Validate(s.sessionVars, value, variable.ScopeGlobal); err != nil { return err } - if sv.Name == variable.TiDBEvolvePlanBaselines && value == "ON" && !config.CheckTableBeforeDrop { - return errors.Errorf("Cannot enable baseline evolution feature, it is not generally available now") - } if err = sv.SetGlobalFromHook(s.sessionVars, value, false); err != nil { return err } diff --git a/sessionctx/variable/sysvar.go b/sessionctx/variable/sysvar.go index 30f4958f569bc..b3627bd10a435 100644 --- a/sessionctx/variable/sysvar.go +++ b/sessionctx/variable/sysvar.go @@ -176,10 +176,6 @@ func (sv *SysVar) SetSessionFromHook(s *SessionVars, val string) error { return err } } - // The 'baseline evolution' only work in the test environment before the feature is GA. - if sv.Name == TiDBEvolvePlanBaselines && val == "ON" && !config.CheckTableBeforeDrop { - return errors.Errorf("Cannot enable baseline evolution feature, it is not generally available now") - } s.systems[sv.Name] = val // Call the Set function on all the aliases for this sysVar @@ -1488,7 +1484,12 @@ var defaultSysVars = []*SysVar{ s.UsePlanBaselines = TiDBOptOn(val) return nil }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBEvolvePlanBaselines, Value: BoolToOnOff(DefTiDBEvolvePlanBaselines), Type: TypeBool, SetSession: func(s *SessionVars, val string) error { + {Scope: ScopeGlobal | ScopeSession, Name: TiDBEvolvePlanBaselines, Value: BoolToOnOff(DefTiDBEvolvePlanBaselines), Type: TypeBool, Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { + if normalizedValue == "ON" && !config.CheckTableBeforeDrop { + return normalizedValue, errors.Errorf("Cannot enable baseline evolution feature, it is not generally available now") + } + return normalizedValue, nil + }, SetSession: func(s *SessionVars, val string) error { s.EvolvePlanBaselines = TiDBOptOn(val) return nil }},