Skip to content

Commit

Permalink
FB8-47 : Increase max user name length to 80
Browse files Browse the repository at this point in the history
JIRA issue: https://jira.percona.com/browse/FB8-47

Reference patch: 3dbbcfc

The max user name length is increased to 80 chars (utf8mb3)
Since the system tables are InnoDB tables and because Primary key is
on the full username (80 *3 = 240 bytes) and other columns, InnoDB
initialization with 4k page size fails. This is new limitation.

---------- 3dbbcfc --------

Summary:
This mitigates upstream bug: http://bugs.mysql.com/3083

User name length limit of 16 was too short, so made it 80.

80 is effectively the limit without making additional changes
because of MyISAM's 1000 byte limit on key length and the
primary key of mysql.columns_priv. To compute the size of
the key for that table, the lengths of the char fields are
summed and then multipled by 3, resulting in a limit on the
max size of user name lengths being 81 characters.

Test Plan:
Added long user names to basic grant and replication tests.

Did full build and test run without perfschema, no failures.

Did full build and test run with perfschema, no new failures.

Jenkins both 'arc unit', and 'arc unit --everything', pass

Built a test rpm, ran it through rpm tests, passed.

Installed the test rpm on a test server, then downgraded it:
"use mysql; show create table user;", and got:
* Before upgrade: "...`User` char(16)..."
* After upgrade: "...`User` char(16)..."
* After restart: "...`User` char(16)..."
* After running mysql_upgrade: "...`User` char(80)..."
* After downgrade: "...`User` char(80)..."
* After restart: "...`User` char(80)..."
* After running mysql_upgrade: "...`User` char(16)..."

Originally Reviewed By: santoshb
  • Loading branch information
satya-bodapati committed Feb 5, 2019
1 parent 6554a76 commit 8a37b97
Show file tree
Hide file tree
Showing 106 changed files with 538 additions and 762 deletions.
2 changes: 1 addition & 1 deletion include/mysql/components/services/psi_thread_bits.h
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ typedef void (*get_thread_event_id_v1_t)(unsigned long long *thread_internal_id,
unsigned long long *event_id);

/* Duplicate definitions to avoid dependency on mysql_com.h */
#define PSI_USERNAME_LENGTH (32 * 3)
#define PSI_USERNAME_LENGTH (80 * 3)
#define PSI_NAME_LEN (64 * 3)
#define PSI_HOSTNAME_LENGTH (60)

Expand Down
2 changes: 1 addition & 1 deletion include/mysql/plugin_auth.h.pp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@
unsigned int user_name_length;
const char *auth_string;
unsigned long auth_string_length;
char authenticated_as[96 + 1];
char authenticated_as[240 + 1];
char external_user[512];
int password_used;
const char *host_or_ip;
Expand Down
2 changes: 1 addition & 1 deletion include/mysql/plugin_auth_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#define MYSQL_PLUGIN_AUTH_COMMON_INCLUDED

/** the max allowed length for a user name */
#define MYSQL_USERNAME_LENGTH 96
#define MYSQL_USERNAME_LENGTH 240

/**
return values of the plugin authenticate_user() method.
Expand Down
2 changes: 1 addition & 1 deletion include/mysql/psi/psi_abi_thread_v1.h.pp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
unsigned long m_processlist_id;
unsigned long long m_thread_os_id;
void *m_user_data;
char m_username[(32 * 3)];
char m_username[(80 * 3)];
size_t m_username_length;
char m_hostname[(60)];
size_t m_hostname_length;
Expand Down
4 changes: 2 additions & 2 deletions include/mysql_com.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@
#define PARTITION_EXPR_CHAR_LEN \
2048 /**< Maximum expression length in chars \
*/
#define USERNAME_CHAR_LENGTH 32
#define USERNAME_CHAR_LENGTH_STR "32"
#define USERNAME_CHAR_LENGTH 80
#define USERNAME_CHAR_LENGTH_STR "80"
#ifndef NAME_LEN
#define NAME_LEN (NAME_CHAR_LEN * SYSTEM_CHARSET_MBMAXLEN)
#endif
Expand Down
4 changes: 2 additions & 2 deletions mysql-test/r/create.result
Original file line number Diff line number Diff line change
Expand Up @@ -1158,7 +1158,7 @@ show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`ID` bigint(21) unsigned NOT NULL DEFAULT '0',
`USER` varchar(32) NOT NULL DEFAULT '',
`USER` varchar(80) NOT NULL DEFAULT '',
`HOST` varchar(64) NOT NULL DEFAULT '',
`DB` varchar(64) DEFAULT NULL,
`COMMAND` varchar(16) NOT NULL DEFAULT '',
Expand All @@ -1172,7 +1172,7 @@ show create table t1;
Table Create Table
t1 CREATE TEMPORARY TABLE `t1` (
`ID` bigint(21) unsigned NOT NULL DEFAULT '0',
`USER` varchar(32) NOT NULL DEFAULT '',
`USER` varchar(80) NOT NULL DEFAULT '',
`HOST` varchar(64) NOT NULL DEFAULT '',
`DB` varchar(64) DEFAULT NULL,
`COMMAND` varchar(16) NOT NULL DEFAULT '',
Expand Down
2 changes: 1 addition & 1 deletion mysql-test/r/dd_is_compatibility_cs.result
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`ID` bigint(21) unsigned NOT NULL DEFAULT '0',
`USER` varchar(32) NOT NULL DEFAULT '',
`USER` varchar(80) NOT NULL DEFAULT '',
`HOST` varchar(64) NOT NULL DEFAULT '',
`DB` varchar(64) DEFAULT NULL,
`COMMAND` varchar(16) NOT NULL DEFAULT '',
Expand Down
258 changes: 0 additions & 258 deletions mysql-test/r/dd_schema_definition_after_upgrade_debug.result

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions mysql-test/r/dd_upgrade_test.result
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ SHOW CREATE TABLE mysql.user;
Table Create Table
user CREATE TABLE `user` (
`Host` char(60) COLLATE utf8_bin NOT NULL DEFAULT '',
`User` char(32) COLLATE utf8_bin NOT NULL DEFAULT '',
`User` char(80) COLLATE utf8_bin NOT NULL DEFAULT '',
`Select_priv` enum('N','Y') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'N',
`Insert_priv` enum('N','Y') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'N',
`Update_priv` enum('N','Y') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'N',
Expand Down Expand Up @@ -550,7 +550,7 @@ threads CREATE TABLE `threads` (
`NAME` varchar(128) NOT NULL,
`TYPE` varchar(10) NOT NULL,
`PROCESSLIST_ID` bigint(20) unsigned DEFAULT NULL,
`PROCESSLIST_USER` varchar(32) DEFAULT NULL,
`PROCESSLIST_USER` varchar(80) DEFAULT NULL,
`PROCESSLIST_HOST` varchar(60) DEFAULT NULL,
`PROCESSLIST_DB` varchar(64) DEFAULT NULL,
`PROCESSLIST_COMMAND` varchar(16) DEFAULT NULL,
Expand Down
1 change: 1 addition & 0 deletions mysql-test/r/dictionary_tablespace.result
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ call mtr.add_suppression("table is missing or has an incorrect definition");
call mtr.add_suppression("ACL DDLs will not work unless mysql_upgrade is executed");
call mtr.add_suppression(".* Native table .* has the wrong structure");
call mtr.add_suppression("Column count of mysql.* is wrong");
call mtr.add_suppression("Cannot load from mysql.* The table is probably corrupted!");
call mtr.add_suppression("The privilege system failed to initialize correctly.*");
call mtr.add_suppression(".*Missing system table mysql.global_grants.*");
call mtr.add_suppression("ACL table mysql.[a-z_]* missing. Some operations may fail.");
Expand Down
2 changes: 1 addition & 1 deletion mysql-test/r/func_system.result
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`database()` varchar(34) CHARACTER SET utf8 DEFAULT NULL,
`user()` varchar(93) CHARACTER SET utf8 NOT NULL DEFAULT '',
`user()` varchar(141) CHARACTER SET utf8 NOT NULL DEFAULT '',
`version` char(60) DEFAULT NULL
) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
drop table t1;
Expand Down
Loading

0 comments on commit 8a37b97

Please sign in to comment.