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 authored and yu34po committed Jan 2, 2019
1 parent acc8fa2 commit 82be7b7
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 @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion sessionctx/variable/varsutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 82be7b7

Please sign in to comment.