Skip to content

Commit

Permalink
resolve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
bb7133 committed Sep 2, 2021
1 parent ec3ff10 commit 767898b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 22 deletions.
6 changes: 6 additions & 0 deletions executor/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,9 @@ func (e *ShowExec) fetchShowVariables() (err error) {
unreachedVars = make([]string, 0, len(variable.GetSysVars()))
)
for _, v := range variable.GetSysVars() {
if variable.FilterImplicitFeatureSwitch(v.Name) {
continue
}
if !e.GlobalScope {
// For a session scope variable,
// 1. try to fetch value from SessionVars.Systems;
Expand Down Expand Up @@ -695,6 +698,9 @@ func (e *ShowExec) fetchShowVariables() (err error) {
return errors.Trace(err)
}
for _, varName := range unreachedVars {
if variable.FilterImplicitFeatureSwitch(varName) {
continue
}
varValue, ok := systemVars[varName]
if !ok {
varValue = variable.GetSysVar(varName).Value
Expand Down
20 changes: 1 addition & 19 deletions executor/show_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1242,11 +1242,10 @@ func (s *testSerialSuite1) TestShowCreateTableWithIntegerDisplayLengthWarnings(c

func (s *testSuite5) TestShowVar(c *C) {
tk := testkit.NewTestKit(c, s.store)
var showSQL string
sessionVars := make([]string, 0, len(variable.GetSysVars()))
globalVars := make([]string, 0, len(variable.GetSysVars()))
for _, v := range variable.GetSysVars() {
if variable.FilterImplicitFeatureSwitch(v) {
if variable.FilterImplicitFeatureSwitch(v.Name) {
continue
}

Expand All @@ -1257,23 +1256,6 @@ func (s *testSuite5) TestShowVar(c *C) {
}
}

// When ScopeSession only. `show global variables` must return empty.
sessionVarsStr := strings.Join(sessionVars, "','")
showSQL = "show variables where variable_name in('" + sessionVarsStr + "')"
res := tk.MustQuery(showSQL)
c.Check(res.Rows(), HasLen, len(sessionVars))
showSQL = "show global variables where variable_name in('" + sessionVarsStr + "')"
res = tk.MustQuery(showSQL)
c.Check(res.Rows(), HasLen, 0)

globalVarsStr := strings.Join(globalVars, "','")
showSQL = "show variables where variable_name in('" + globalVarsStr + "')"
res = tk.MustQuery(showSQL)
c.Check(res.Rows(), HasLen, len(globalVars))
showSQL = "show global variables where variable_name in('" + globalVarsStr + "')"
res = tk.MustQuery(showSQL)
c.Check(res.Rows(), HasLen, len(globalVars))

// Test for switch variable which shouldn't seen by users.
for _, one := range variable.FeatureSwitchVariables {
res := tk.MustQuery("show variables like '" + one + "'")
Expand Down
8 changes: 7 additions & 1 deletion session/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -949,7 +949,13 @@ func (s *session) GetAllSysVars() (map[string]string, error) {
ret := make(map[string]string, len(rows))
for _, r := range rows {
k, v := r.GetString(0), r.GetString(1)
ret[k] = v
if s.varFromTiDBTable(k) {
if v, err = s.getTiDBTableValue(k, v); err == nil {
ret[k] = v
}
} else {
ret[k] = v
}
}
return ret, nil
}
Expand Down
4 changes: 2 additions & 2 deletions sessionctx/variable/tidb_vars.go
Original file line number Diff line number Diff line change
Expand Up @@ -742,9 +742,9 @@ var FeatureSwitchVariables = []string{
}

// FilterImplicitFeatureSwitch is used to filter result of show variables, these switches should be turn blind to users.
func FilterImplicitFeatureSwitch(sysVar *SysVar) bool {
func FilterImplicitFeatureSwitch(varName string) bool {
for _, one := range FeatureSwitchVariables {
if one == sysVar.Name {
if one == varName {
return true
}
}
Expand Down

0 comments on commit 767898b

Please sign in to comment.