Skip to content

Commit

Permalink
sessionctx: remove statusVars
Browse files Browse the repository at this point in the history
  • Loading branch information
zimulala committed Nov 18, 2015
1 parent e804b23 commit 06f285c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
9 changes: 3 additions & 6 deletions sessionctx/variable/statusvar.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
"github.com/juju/errors"
)

var statusVars map[string]*StatusVal
var statisticsList []Statistics
var globalStatusScopes = make(map[string]ScopeFlag)

Expand Down Expand Up @@ -45,8 +44,7 @@ func RegisterStatistics(s Statistics) {

// GetStatusVars gets registered statistics status variables.
func GetStatusVars() (map[string]*StatusVal, error) {
statusVars = make(map[string]*StatusVal)
ret := make(map[string]*StatusVal)
statusVars := make(map[string]*StatusVal)

for _, statistics := range statisticsList {
vals, err := statistics.Stats()
Expand All @@ -57,7 +55,6 @@ func GetStatusVars() (map[string]*StatusVal, error) {
for name, val := range vals {
scope := statistics.GetScope(name)
statusVars[name] = &StatusVal{Value: val, Scope: scope}
ret[name] = &StatusVal{Value: val, Scope: scope}
}
}

Expand All @@ -67,10 +64,10 @@ func GetStatusVars() (map[string]*StatusVal, error) {
}
for status := range defaultStatusVars {
// To get more accurate value from the global status variables table.
ret[status] = &StatusVal{Scope: DefaultScopeFlag}
statusVars[status] = &StatusVal{Scope: DefaultScopeFlag}
}

return ret, nil
return statusVars, nil
}

// GetDefaultStatusVars gets status variables from the global status variables table.
Expand Down
6 changes: 2 additions & 4 deletions sessionctx/variable/statusvar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ func (s *testStatusVarSuite) TestStatusVar(c *C) {

vars, err := GetStatusVars()
c.Assert(err, IsNil)
for status, val := range vars {
v := statusVars[status]
c.Assert(v, DeepEquals, val)
}
v := &StatusVal{Scope: DefaultScopeFlag, Value: testStatusVal}
c.Assert(v, DeepEquals, vars[testStatus])
}

0 comments on commit 06f285c

Please sign in to comment.