Skip to content

Commit

Permalink
session: validate value for global time_zone sys variable (pingcap#8876)
Browse files Browse the repository at this point in the history
  • Loading branch information
eurekaka committed Dec 28, 2018
1 parent e689572 commit f672356
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions session/session_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,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) {
Expand Down
3 changes: 2 additions & 1 deletion sessionctx/variable/varsutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,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 WarningCount, ErrorCount:
return value, ErrReadOnly.GenWithStackByArgs(name)
case GeneralLog, TiDBGeneralLog, AvoidTemporalUpgrade, BigTables, CheckProxyUsers, CoreFile, EndMakersInJSON, SQLLogBin, OfflineMode,
Expand Down

0 comments on commit f672356

Please sign in to comment.