*: update the function call
This commit is contained in:
@ -35,6 +35,7 @@ import (
|
||||
"github.com/pingcap/tidb/terror"
|
||||
"github.com/pingcap/tidb/util/charset"
|
||||
"github.com/pingcap/tidb/util/format"
|
||||
"github.com/pingcap/tidb/util/types"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -472,7 +473,7 @@ func getSessionStatusVar(ctx context.Context, sessionVars *variable.SessionVars,
|
||||
globalVars variable.GlobalVarAccessor, name string) (string, error) {
|
||||
sv, ok := sessionVars.StatusVars[name]
|
||||
if ok {
|
||||
return sv, nil
|
||||
return types.ToString(sv)
|
||||
}
|
||||
|
||||
value, err := globalVars.GetGlobalStatusVar(ctx, name)
|
||||
@ -480,14 +481,14 @@ func getSessionStatusVar(ctx context.Context, sessionVars *variable.SessionVars,
|
||||
return "", errors.Trace(err)
|
||||
}
|
||||
|
||||
return value, nil
|
||||
return types.ToString(value)
|
||||
}
|
||||
|
||||
func getGlobalStatusVar(ctx context.Context, sessionVars *variable.SessionVars,
|
||||
globalVars variable.GlobalVarAccessor, name string) (string, error) {
|
||||
value, err := globalVars.GetGlobalStatusVar(ctx, name)
|
||||
if err == nil {
|
||||
return value, nil
|
||||
return types.ToString(value)
|
||||
}
|
||||
|
||||
if terror.UnknownStatusVar.Equal(err) {
|
||||
@ -496,7 +497,7 @@ func getGlobalStatusVar(ctx context.Context, sessionVars *variable.SessionVars,
|
||||
|
||||
sv, _ := sessionVars.StatusVars[name]
|
||||
|
||||
return sv, nil
|
||||
return types.ToString(sv)
|
||||
}
|
||||
|
||||
func (s *ShowPlan) fetchShowStatus(ctx context.Context) error {
|
||||
@ -504,7 +505,12 @@ func (s *ShowPlan) fetchShowStatus(ctx context.Context) error {
|
||||
globalVars := variable.GetGlobalVarAccessor(ctx)
|
||||
m := map[interface{}]interface{}{}
|
||||
|
||||
for _, status := range variable.StatusVals {
|
||||
statusVars, err := variable.GetStatusVars()
|
||||
if err != nil {
|
||||
return errors.Trace(err)
|
||||
}
|
||||
|
||||
for status, v := range statusVars {
|
||||
if s.Pattern != nil {
|
||||
s.Pattern.Expr = expression.Value{Val: status}
|
||||
} else if s.Where != nil {
|
||||
@ -540,7 +546,7 @@ func (s *ShowPlan) fetchShowStatus(ctx context.Context) error {
|
||||
continue
|
||||
}
|
||||
|
||||
row := &plan.Row{Data: []interface{}{v.Name, value}}
|
||||
row := &plan.Row{Data: []interface{}{status, value}}
|
||||
s.rows = append(s.rows, row)
|
||||
}
|
||||
|
||||
|
||||
10
session.go
10
session.go
@ -296,24 +296,24 @@ func (s *session) getExecRet(ctx context.Context, sql string) (string, error) {
|
||||
}
|
||||
|
||||
// GetGlobalStatusVar implements GlobalVarAccessor.GetGlobalStatusVar interface.
|
||||
func (s *session) GetGlobalStatusVar(ctx context.Context, name string) (string, error) {
|
||||
func (s *session) GetGlobalStatusVar(ctx context.Context, name string) (*variable.StatusVal, error) {
|
||||
// TODO: get global status variables from store.
|
||||
v := variable.GetStatusVar(name)
|
||||
if v == nil {
|
||||
return "", terror.UnknownStatusVar.Gen("unknown status variable:%s", name)
|
||||
return nil, terror.UnknownStatusVar.Gen("unknown status variable:%s", name)
|
||||
}
|
||||
|
||||
return v.Value, nil
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// SetGlobalStatusVar implements GlobalVarAccessor.SetGlobalStatusVar interface.
|
||||
func (s *session) SetGlobalStatusVar(ctx context.Context, name string, value string) error {
|
||||
func (s *session) SetGlobalStatusVar(ctx context.Context, name string, value *variable.StatusVal) error {
|
||||
// TODO: set global status variables from store.
|
||||
v := variable.GetStatusVar(name)
|
||||
if v == nil {
|
||||
return terror.UnknownStatusVar.Gen("unknown status variable:%s", name)
|
||||
}
|
||||
v.Value = value
|
||||
v = value
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -581,9 +581,9 @@ type GlobalVarAccessor interface {
|
||||
// SetGlobalSysVar sets the global system variable name to value.
|
||||
SetGlobalSysVar(ctx context.Context, name string, value string) error
|
||||
// GetGlobalStatusVar gets the global status variable value for name.
|
||||
GetGlobalStatusVar(ctx context.Context, name string) (string, error)
|
||||
GetGlobalStatusVar(ctx context.Context, name string) (*StatusVal, error)
|
||||
// SetGlobalStatusVar sets the global status variable name to value.
|
||||
SetGlobalStatusVar(ctx context.Context, name string, value string) error
|
||||
SetGlobalStatusVar(ctx context.Context, name string, value *StatusVal) error
|
||||
}
|
||||
|
||||
// globalSysVarAccessorKeyType is a dummy type to avoid naming collision in context.
|
||||
|
||||
@ -58,21 +58,21 @@ func (c *Context) FinishTxn(rollback bool) error {
|
||||
}
|
||||
|
||||
// GetGlobalStatusVar implements GlobalVarAccessor GetGlobalStatusVar interface.
|
||||
func (c *Context) GetGlobalStatusVar(ctx context.Context, name string) (string, error) {
|
||||
func (c *Context) GetGlobalStatusVar(ctx context.Context, name string) (*variable.StatusVal, error) {
|
||||
v := variable.GetStatusVar(name)
|
||||
if v == nil {
|
||||
return "", terror.UnknownStatusVar.Gen("unknown status variable: %s", name)
|
||||
return nil, terror.UnknownStatusVar.Gen("unknown status variable: %s", name)
|
||||
}
|
||||
return v.Value, nil
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// SetGlobalStatusVar implements GlobalVarAccessor SetGlobalStatusVar interface.
|
||||
func (c *Context) SetGlobalStatusVar(ctx context.Context, name string, value string) error {
|
||||
func (c *Context) SetGlobalStatusVar(ctx context.Context, name string, value *variable.StatusVal) error {
|
||||
v := variable.GetStatusVar(name)
|
||||
if v == nil {
|
||||
return terror.UnknownStatusVar.Gen("unknown status variable: %s", name)
|
||||
}
|
||||
v.Value = value
|
||||
v = value
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user