Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

session: upgrade mysql.db user column length to 32 #6209

Merged
merged 5 commits into from
Apr 3, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion session/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const (
CreateDBPrivTable = `CREATE TABLE if not exists mysql.db (
Host CHAR(60),
DB CHAR(64),
User CHAR(16),
User CHAR(32),
Select_priv ENUM('N','Y') Not Null DEFAULT 'N',
Insert_priv ENUM('N','Y') Not Null DEFAULT 'N',
Update_priv ENUM('N','Y') Not Null DEFAULT 'N',
Expand Down Expand Up @@ -232,6 +232,7 @@ const (
version16 = 16
version17 = 17
version18 = 18
version19 = 19
)

func checkBootstrapped(s Session) (bool, error) {
Expand Down Expand Up @@ -362,6 +363,10 @@ func upgrade(s Session) {
upgradeToVer18(s)
}

if ver < version19 {
upgradeToVer19(s)
}

updateBootstrapVer(s)
_, err = s.Execute(context.Background(), "COMMIT")

Expand Down Expand Up @@ -578,6 +583,10 @@ func upgradeToVer18(s Session) {
doReentrantDDL(s, "ALTER TABLE mysql.stats_histograms ADD COLUMN `tot_col_size` bigint(64) NOT NULL DEFAULT 0", infoschema.ErrColumnExists)
}

func upgradeToVer19(s Session) {
doReentrantDDL(s, "ALTER TABLE mysql.db MODIFY User CHAR(32)")
}

// updateBootstrapVer updates bootstrap version variable in mysql.TiDB table.
func updateBootstrapVer(s Session) {
// Update bootstrap version.
Expand Down
2 changes: 1 addition & 1 deletion session/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -1197,7 +1197,7 @@ func createSessionWithDomain(store kv.Storage, dom *domain.Domain) (*session, er

const (
notBootstrapped = 0
currentBootstrapVersion = 18
currentBootstrapVersion = 19
)

func getStoreBootstrapVersion(store kv.Storage) int64 {
Expand Down
6 changes: 6 additions & 0 deletions session/session_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1975,3 +1975,9 @@ func (s *testSessionSuite) TestRollbackOnCompileError(c *C) {
}
c.Assert(recoverErr, IsTrue)
}

func (s *testSessionSuite) TestDBUserNameLength(c *C) {
tk := testkit.NewTestKitWithInit(c, s.store)
// Test user name lengh can be longer than 16.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/lengh/length

tk.MustExec(`grant all privileges on test.* to 'abcddfjakldfjaldddds'@'%' identified by ''`)
}