Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/pingcap/tidb into nextchunk
Browse files Browse the repository at this point in the history
:q!
  • Loading branch information
XuHuaiyu committed Apr 3, 2018
2 parents ebdd9bd + 57afbe2 commit 6e999b7
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 9 deletions.
3 changes: 0 additions & 3 deletions config/config.toml.example
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ split-table = true
# The limit of concurrent executed sessions.
token-limit = 1000

# Enable chunk executors.
enable-chunk = true

# Only print a log when out of memory quota.
# Valid options: ["log", "cancel"]
oom-action = "log"
Expand Down
21 changes: 16 additions & 5 deletions 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 All @@ -95,8 +95,8 @@ const (
// CreateTablePrivTable is the SQL statement creates table scope privilege table in system db.
CreateTablePrivTable = `CREATE TABLE if not exists mysql.tables_priv (
Host CHAR(60),
DB CHAR(64),
User CHAR(16),
DB CHAR(64),
User CHAR(32),
Table_name CHAR(64),
Grantor CHAR(77),
Timestamp Timestamp DEFAULT CURRENT_TIMESTAMP,
Expand All @@ -106,8 +106,8 @@ const (
// CreateColumnPrivTable is the SQL statement creates column scope privilege table in system db.
CreateColumnPrivTable = `CREATE TABLE if not exists mysql.columns_priv(
Host CHAR(60),
DB CHAR(64),
User CHAR(16),
DB CHAR(64),
User CHAR(32),
Table_name CHAR(64),
Column_name CHAR(64),
Timestamp Timestamp DEFAULT CURRENT_TIMESTAMP,
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,12 @@ 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)")
doReentrantDDL(s, "ALTER TABLE mysql.tables_priv MODIFY User CHAR(32)")
doReentrantDDL(s, "ALTER TABLE mysql.columns_priv 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
8 changes: 8 additions & 0 deletions session/session_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1975,3 +1975,11 @@ func (s *testSessionSuite) TestRollbackOnCompileError(c *C) {
}
c.Assert(recoverErr, IsTrue)
}

func (s *testSessionSuite) TestDBUserNameLength(c *C) {
tk := testkit.NewTestKitWithInit(c, s.store)
tk.MustExec("create table if not exists t (a int)")
// Test user name length can be longer than 16.
tk.MustExec(`grant all privileges on test.* to 'abcddfjakldfjaldddds'@'%' identified by ''`)
tk.MustExec(`grant all privileges on test.t to 'abcddfjakldfjaldddds'@'%' identified by ''`)
}

0 comments on commit 6e999b7

Please sign in to comment.