Skip to content

Commit

Permalink
sessionctx, executor: add max_allowed_packet verification (#8090) (#8104
Browse files Browse the repository at this point in the history
)
  • Loading branch information
iamzhoug37 authored and ngaut committed Oct 30, 2018
1 parent 3e6f687 commit 26a3a3d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
8 changes: 8 additions & 0 deletions executor/set_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,14 @@ func (s *testSuite) TestValidateSetVar(c *C) {
_, err = tk.Exec("set @@global.max_connections='hello'")
c.Assert(terror.ErrorEqual(err, variable.ErrWrongTypeForVar), IsTrue)

tk.MustExec("set @@global.max_allowed_packet=-1")
tk.MustQuery("show warnings").Check(testutil.RowsWithSep("|", "Warning|1292|Truncated incorrect max_allowed_packet value: '-1'"))
result = tk.MustQuery("select @@global.max_allowed_packet;")
result.Check(testkit.Rows("1024"))

_, err = tk.Exec("set @@global.max_allowed_packet='hello'")
c.Assert(terror.ErrorEqual(err, variable.ErrWrongTypeForVar), IsTrue)

tk.MustExec("set @@global.max_connect_errors=18446744073709551615")

tk.MustExec("set @@global.max_connect_errors=-1")
Expand Down
3 changes: 3 additions & 0 deletions sessionctx/variable/varsutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,9 @@ func ValidateSetSystemVar(vars *SessionVars, name string, value string) (string,
return checkUInt64SystemVar(name, value, 0, 2, vars)
case InnodbLockWaitTimeout:
return checkUInt64SystemVar(name, value, 1, 1073741824, vars)
// See "https://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_max_allowed_packet"
case MaxAllowedPacket:
return checkUInt64SystemVar(name, value, 1024, 1073741824, vars)
case MaxConnections:
return checkUInt64SystemVar(name, value, 1, 100000, vars)
case MaxConnectErrors:
Expand Down

0 comments on commit 26a3a3d

Please sign in to comment.