From ea2994a36771d1227f0a294d2fbe15c0026a5137 Mon Sep 17 00:00:00 2001 From: imtbkcat Date: Fri, 10 Aug 2018 18:25:03 +0800 Subject: [PATCH] fix issue 7248 --- executor/set_test.go | 3 ++- sessionctx/variable/varsutil.go | 9 ++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/executor/set_test.go b/executor/set_test.go index faea6313239a4..a2c7c6c2773e1 100644 --- a/executor/set_test.go +++ b/executor/set_test.go @@ -133,7 +133,8 @@ func (s *testSuite) TestSetVar(c *C) { c.Assert(charset, Equals, "utf8") c.Assert(collation, Equals, "utf8_bin") - tk.MustExec("set @@character_set_results = NULL") + tk.MustExec("set character_set_results = NULL") + tk.MustQuery("select @@character_set_results").Check(testkit.Rows("")) // Test set transaction isolation level, which is equivalent to setting variable "tx_isolation". tk.MustExec("SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED") diff --git a/sessionctx/variable/varsutil.go b/sessionctx/variable/varsutil.go index 95063ba9be8fe..014b129a942e8 100644 --- a/sessionctx/variable/varsutil.go +++ b/sessionctx/variable/varsutil.go @@ -127,12 +127,11 @@ func SetSessionSystemVar(vars *SessionVars, name string, value types.Datum) erro if sysVar == nil { return UnknownSystemVar } - if value.IsNull() { - return vars.deleteSystemVar(name) - } - var sVal string + sVal := "" var err error - sVal, err = value.ToString() + if !value.IsNull() { + sVal, err = value.ToString() + } if err != nil { return errors.Trace(err) }