diff --git a/session/session_test.go b/session/session_test.go index 8aa98e3d2d6db..f95bd913cc15d 100644 --- a/session/session_test.go +++ b/session/session_test.go @@ -469,6 +469,10 @@ func (s *testSessionSuite) TestGlobalVarAccessor(c *C) { result = tk.MustQuery("select @@autocommit;") result.Check(testkit.Rows("ON")) tk.MustExec("set @@global.autocommit=1") + + _, err = tk.Exec("set global time_zone = 'timezone'") + c.Assert(err, NotNil) + c.Assert(terror.ErrorEqual(err, variable.ErrUnknownTimeZone), IsTrue) } func (s *testSessionSuite) TestGetSysVariables(c *C) { diff --git a/sessionctx/variable/varsutil.go b/sessionctx/variable/varsutil.go index f25df3a3938d5..17a687f612cc1 100644 --- a/sessionctx/variable/varsutil.go +++ b/sessionctx/variable/varsutil.go @@ -315,7 +315,8 @@ func ValidateSetSystemVar(vars *SessionVars, name string, value string) (string, if strings.EqualFold(value, "SYSTEM") { return "SYSTEM", nil } - return value, nil + _, err := parseTimeZone(value) + return value, err case ValidatePasswordLength, ValidatePasswordNumberCount: return checkUInt64SystemVar(name, value, 0, math.MaxUint64, vars) case WarningCount, ErrorCount: