Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
CbcWestwolf committed Sep 13, 2024
1 parent f377f4f commit ad7a184
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/session/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -3148,7 +3148,7 @@ func upgradeToVer214(s sessiontypes.Session, ver int64) {
if ver >= version214 {
return
}
mustExecute(s, "DELETE FROM mysql.global_variables where VARIABLE_NAME like 'validate_password_%'")
mustExecute(s, `DELETE FROM mysql.global_variables WHERE variable_name LIKE 'validate\_password\_%'`)

initGlobalVariableIfNotExists(s, variable.ValidatePasswordCheckUserName, variable.On)
initGlobalVariableIfNotExists(s, variable.ValidatePasswordSpecialCharCount, "1")
Expand Down
3 changes: 2 additions & 1 deletion pkg/session/bootstraptest/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ go_test(
"main_test.go",
],
flaky = True,
shard_count = 12,
shard_count = 13,
deps = [
"//pkg/config",
"//pkg/ddl",
Expand All @@ -21,6 +21,7 @@ go_test(
"//pkg/session", #keep
"//pkg/session/types",
"//pkg/sessionctx",
"//pkg/sessionctx/variable",
"//pkg/testkit", #keep
"//pkg/testkit/testfailpoint",
"//pkg/testkit/testmain",
Expand Down
28 changes: 28 additions & 0 deletions pkg/session/bootstraptest/bootstrap_upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
"github.com/pingcap/tidb/pkg/session"
sessiontypes "github.com/pingcap/tidb/pkg/session/types"
"github.com/pingcap/tidb/pkg/sessionctx"
"github.com/pingcap/tidb/pkg/sessionctx/variable"
"github.com/pingcap/tidb/pkg/testkit"
"github.com/pingcap/tidb/pkg/testkit/testfailpoint"
tidbutil "github.com/pingcap/tidb/pkg/util"
Expand Down Expand Up @@ -243,6 +244,33 @@ func TestUpgradeVersion75(t *testing.T) {
require.Equal(t, "char(255)", strings.ToLower(row.GetString(1)))
}

func TestUpgradeVersion213(t *testing.T) {
store := testkit.CreateMockStore(t)

tk := testkit.NewTestKit(t, store)
ver, err := session.GetBootstrapVersion(tk.Session())
require.NoError(t, err)
require.Equal(t, session.CurrentBootstrapVersion, ver)

tk.MustQuery(`SELECT * FROM mysql.global_variables WHERE variable_name LIKE 'validate\_password\_%'`).Check(testkit.Rows())
tcs := []struct {
varName string
varVal string
}{
{variable.ValidatePasswordCheckUserName, variable.On},
{variable.ValidatePasswordSpecialCharCount, "1"},
{variable.ValidatePasswordLength, "8"},
{variable.ValidatePasswordNumberCount, "1"},
{variable.ValidatePasswordMixedCaseCount, "1"},
{variable.ValidatePasswordPolicy, "MEDIUM"},
{variable.ValidatePasswordEnable, variable.Off},
{variable.ValidatePasswordDictionary, ""},
}
for _, tc := range tcs {
tk.MustQuery(`SELECT variable_value FROM mysql.global_variables WHERE variable_name = ?`, tc.varName).Check(testkit.Rows(tc.varVal))
}
}

func TestUpgradeVersionMockLatest(t *testing.T) {
mock := true
session.WithMockUpgrade = &mock
Expand Down

0 comments on commit ad7a184

Please sign in to comment.