Skip to content

Commit

Permalink
executor: accelerate TestShowVar (#24131)
Browse files Browse the repository at this point in the history
  • Loading branch information
XuHuaiyu authored Apr 19, 2021
1 parent bc4bde7 commit adfe029
Showing 1 changed file with 23 additions and 13 deletions.
36 changes: 23 additions & 13 deletions executor/show_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1233,27 +1233,37 @@ 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) {
continue
}
// When ScopeSession only. `show global variables` must return empty.

if v.Scope == variable.ScopeSession {
showSQL = "show variables like '" + v.Name + "'"
res := tk.MustQuery(showSQL)
c.Check(res.Rows(), HasLen, 1)
showSQL = "show global variables like '" + v.Name + "'"
res = tk.MustQuery(showSQL)
c.Check(res.Rows(), HasLen, 0)
sessionVars = append(sessionVars, v.Name)
} else {
showSQL = "show global variables like '" + v.Name + "'"
res := tk.MustQuery(showSQL)
c.Check(res.Rows(), HasLen, 1)
showSQL = "show variables like '" + v.Name + "'"
res = tk.MustQuery(showSQL)
c.Check(res.Rows(), HasLen, 1)
globalVars = append(globalVars, v.Name)
}
}

// 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

0 comments on commit adfe029

Please sign in to comment.