diff --git a/session/bootstrap.go b/session/bootstrap.go index 5039f813de304..a00c5159232bc 100644 --- a/session/bootstrap.go +++ b/session/bootstrap.go @@ -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, @@ -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, @@ -585,6 +585,8 @@ func upgradeToVer18(s Session) { 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. diff --git a/session/session_test.go b/session/session_test.go index 424df255b4c2e..fb5b75d8a154e 100644 --- a/session/session_test.go +++ b/session/session_test.go @@ -1978,6 +1978,8 @@ func (s *testSessionSuite) TestRollbackOnCompileError(c *C) { 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 lengh 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 ''`) }