Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sessionctx/variable: fix panic when set variable='' (#9533) #9541

Merged
merged 1 commit into from
Mar 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions expression/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"github.com/pingcap/tidb/plan"
"github.com/pingcap/tidb/session"
"github.com/pingcap/tidb/sessionctx"
"github.com/pingcap/tidb/sessionctx/variable"
"github.com/pingcap/tidb/store/mockstore"
"github.com/pingcap/tidb/table"
"github.com/pingcap/tidb/terror"
Expand Down Expand Up @@ -3225,6 +3226,10 @@ func (s *testIntegrationSuite) TestSetVariables(c *C) {
_, err = tk.Exec("set global transaction read write;")
r = tk.MustQuery(`select @@session.tx_read_only, @@global.tx_read_only, @@session.transaction_read_only, @@global.transaction_read_only;`)
r.Check(testkit.Rows("0 0 0 0"))

_, err = tk.Exec("set @@global.max_user_connections='';")
c.Assert(err, NotNil)
c.Assert(err.Error(), Equals, variable.ErrWrongTypeForVar.GenByArgs("max_user_connections").Error())
}

func (s *testIntegrationSuite) TestIssues(c *C) {
Expand Down
3 changes: 3 additions & 0 deletions sessionctx/variable/varsutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ func ValidateGetSystemVar(name string, isGlobal bool) error {
}

func checkUInt64SystemVar(name, value string, min, max uint64, vars *SessionVars) (string, error) {
if len(value) == 0 {
return value, ErrWrongTypeForVar.GenByArgs(name)
}
if value[0] == '-' {
_, err := strconv.ParseInt(value, 10, 64)
if err != nil {
Expand Down