From 738f933016c27feaddf589335cc6ed735acba03a Mon Sep 17 00:00:00 2001 From: HuaiyuXu <391585975@qq.com> Date: Wed, 6 Dec 2017 13:17:29 +0800 Subject: [PATCH] *: session variable value should not be modified when get global variable (#5317) --- new_session_test.go | 11 +++++++++++ sessionctx/varsutil/varsutil.go | 1 - 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/new_session_test.go b/new_session_test.go index 06a8709cd4335..a0bd7fa34bd6c 100644 --- a/new_session_test.go +++ b/new_session_test.go @@ -296,6 +296,17 @@ func (s *testSessionSuite) TestGlobalVarAccessor(c *C) { result.Check(testkit.Rows("sql_select_limit 18446744073709551615")) result = tk.MustQuery("show session variables where variable_name='sql_select_limit';") result.Check(testkit.Rows("sql_select_limit 100000000000")) + + result = tk.MustQuery("select @@global.autocommit;") + result.Check(testkit.Rows("ON")) + result = tk.MustQuery("select @@autocommit;") + result.Check(testkit.Rows("ON")) + tk.MustExec("set @@global.autocommit = 0;") + result = tk.MustQuery("select @@global.autocommit;") + result.Check(testkit.Rows("0")) + result = tk.MustQuery("select @@autocommit;") + result.Check(testkit.Rows("ON")) + tk.MustExec("set @@global.autocommit=1") } func (s *testSessionSuite) TestRetryResetStmtCtx(c *C) { diff --git a/sessionctx/varsutil/varsutil.go b/sessionctx/varsutil/varsutil.go index d6417e495e1f8..251e990406ce0 100644 --- a/sessionctx/varsutil/varsutil.go +++ b/sessionctx/varsutil/varsutil.go @@ -76,7 +76,6 @@ func GetGlobalSystemVar(s *variable.SessionVars, key string) (string, error) { if err != nil { return "", errors.Trace(err) } - s.Systems[key] = gVal return gVal, nil }