From 4d54559b82136a2f0ef23dc3402b3cb5439f1f29 Mon Sep 17 00:00:00 2001 From: ti-srebot <66930949+ti-srebot@users.noreply.github.com> Date: Sat, 3 Oct 2020 19:35:40 +0800 Subject: [PATCH] sessionctx/variable: fix cannot select session scope ScopeNone variable (#19584) (#19944) Signed-off-by: ti-srebot --- session/session_test.go | 7 +++---- sessionctx/variable/varsutil.go | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/session/session_test.go b/session/session_test.go index 9f0d9568d5ebb..7584d5c8b935c 100644 --- a/session/session_test.go +++ b/session/session_test.go @@ -685,10 +685,9 @@ func (s *testSessionSuite) TestGetSysVariables(c *C) { // Test ScopeNone tk.MustExec("select @@performance_schema_max_mutex_classes") tk.MustExec("select @@global.performance_schema_max_mutex_classes") - _, err = tk.Exec("select @@session.performance_schema_max_mutex_classes") - c.Assert(terror.ErrorEqual(err, variable.ErrIncorrectScope), IsTrue, Commentf("err %v", err)) - _, err = tk.Exec("select @@local.performance_schema_max_mutex_classes") - c.Assert(terror.ErrorEqual(err, variable.ErrIncorrectScope), IsTrue, Commentf("err %v", err)) + // For issue 19524, test + tk.MustExec("select @@session.performance_schema_max_mutex_classes") + tk.MustExec("select @@local.performance_schema_max_mutex_classes") } func (s *testSessionSuite) TestRetryResetStmtCtx(c *C) { diff --git a/sessionctx/variable/varsutil.go b/sessionctx/variable/varsutil.go index 101127c68fad6..d7cf6b8e49c40 100644 --- a/sessionctx/variable/varsutil.go +++ b/sessionctx/variable/varsutil.go @@ -228,7 +228,7 @@ func ValidateGetSystemVar(name string, isGlobal bool) error { return ErrUnknownSystemVar.GenWithStackByArgs(name) } switch sysVar.Scope { - case ScopeGlobal, ScopeNone: + case ScopeGlobal: if !isGlobal { return ErrIncorrectScope.GenWithStackByArgs(name, "GLOBAL") }