Skip to content

Commit

Permalink
FB8-47 : Increase max user name length to 80 (facebook#937) (facebook…
Browse files Browse the repository at this point in the history
…#937)

Summary:
https://jira.percona.com/browse/FB8-47

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.

Reference Patch: facebook@3dbbcfc

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.
Pull Request resolved: facebook#937

Reviewed By: lloyd

Differential Revision: D13890369 (facebook@1075e57)

Pulled By: lth

fbshipit-source-id: 2ec67345fb8
  • Loading branch information
satya-bodapati authored and inikep committed Jul 13, 2021
1 parent 2a25184 commit cfca90c
Show file tree
Hide file tree
Showing 113 changed files with 645 additions and 580 deletions.
2 changes: 1 addition & 1 deletion include/mysql/components/services/psi_thread_bits.h
Expand Up @@ -338,7 +338,7 @@ typedef void (*get_thread_event_id_v2_t)(struct PSI_thread *psi,
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 (255)

Expand Down
2 changes: 1 addition & 1 deletion include/mysql/plugin_auth.h.pp
Expand Up @@ -162,7 +162,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
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
Expand Up @@ -110,7 +110,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[(255)];
size_t m_hostname_length;
Expand Down
4 changes: 2 additions & 2 deletions include/mysql_com.h
Expand Up @@ -60,8 +60,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
Expand Up @@ -1147,7 +1147,7 @@ show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`ID` bigint unsigned NOT NULL DEFAULT '0',
`USER` varchar(32) NOT NULL DEFAULT '',
`USER` varchar(80) NOT NULL DEFAULT '',
`HOST` varchar(261) NOT NULL DEFAULT '',
`DB` varchar(64) DEFAULT NULL,
`COMMAND` varchar(16) NOT NULL DEFAULT '',
Expand All @@ -1161,7 +1161,7 @@ show create table t1;
Table Create Table
t1 CREATE TEMPORARY TABLE `t1` (
`ID` bigint unsigned NOT NULL DEFAULT '0',
`USER` varchar(32) NOT NULL DEFAULT '',
`USER` varchar(80) NOT NULL DEFAULT '',
`HOST` varchar(261) 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_ci.result
Expand Up @@ -123,7 +123,7 @@ SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`ID` bigint unsigned NOT NULL DEFAULT '0',
`USER` varchar(32) NOT NULL DEFAULT '',
`USER` varchar(80) NOT NULL DEFAULT '',
`HOST` varchar(261) 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
Expand Up @@ -123,7 +123,7 @@ SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`ID` bigint unsigned NOT NULL DEFAULT '0',
`USER` varchar(32) NOT NULL DEFAULT '',
`USER` varchar(80) NOT NULL DEFAULT '',
`HOST` varchar(261) NOT NULL DEFAULT '',
`DB` varchar(64) DEFAULT NULL,
`COMMAND` varchar(16) NOT NULL DEFAULT '',
Expand Down
4 changes: 2 additions & 2 deletions mysql-test/r/dd_upgrade_test.result
Expand Up @@ -194,7 +194,7 @@ SHOW CREATE TABLE mysql.user;
Table Create Table
user CREATE TABLE `user` (
`Host` char(255) CHARACTER SET ascii COLLATE ascii_general_ci 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 @@ -446,7 +446,7 @@ threads CREATE TABLE `threads` (
`NAME` varchar(128) NOT NULL,
`TYPE` varchar(10) NOT NULL,
`PROCESSLIST_ID` bigint unsigned DEFAULT NULL,
`PROCESSLIST_USER` varchar(32) DEFAULT NULL,
`PROCESSLIST_USER` varchar(80) DEFAULT NULL,
`PROCESSLIST_HOST` varchar(255) CHARACTER SET ascii COLLATE ascii_general_ci 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
Expand Up @@ -161,6 +161,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(".*The system table mysql.global_grants is missing.*");
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
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(288) CHARACTER SET utf8 NOT NULL DEFAULT '',
`user()` varchar(336) 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

0 comments on commit cfca90c

Please sign in to comment.