diff --git a/mysql-test/r/create.result b/mysql-test/r/create.result index b8723a87661..c7997369f4d 100644 --- a/mysql-test/r/create.result +++ b/mysql-test/r/create.result @@ -1559,6 +1559,8 @@ SHOW INDEX FROM t1; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment t1 1 c1 1 c1 A NULL NULL NULL YES BTREE DROP TABLE t1; +create user mysqltest_1@'test@test'; +ERROR HY000: Malformed hostname (illegal symbol: '@') CREATE TABLE t1 (a INTEGER AUTO_INCREMENT PRIMARY KEY, b INTEGER NOT NULL); INSERT IGNORE INTO t1 (b) VALUES (5); CREATE TABLE IF NOT EXISTS t2 (a INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY) diff --git a/mysql-test/t/create.test b/mysql-test/t/create.test index 60d98fce490..2eeca1eea90 100644 --- a/mysql-test/t/create.test +++ b/mysql-test/t/create.test @@ -1175,6 +1175,11 @@ CREATE TABLE t1(c1 VARCHAR(33), KEY USING HASH (c1) USING BTREE) ENGINE=MEMORY; SHOW INDEX FROM t1; DROP TABLE t1; +# +# Bug#35924 DEFINER should be stored 'quoted' in I_S +# +--error ER_UNKNOWN_ERROR +create user mysqltest_1@'test@test'; # # Bug#38821: Assert table->auto_increment_field_not_null failed in open_table() diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index f2b2806ea60..d11f2838e3a 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -803,6 +803,7 @@ bool check_string_byte_length(LEX_STRING *str, const char *err_msg, bool check_string_char_length(LEX_STRING *str, const char *err_msg, uint max_char_length, CHARSET_INFO *cs, bool no_error); +bool check_host_name(LEX_STRING *str); bool parse_sql(THD *thd, Parser_state *parser_state, diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 30fef9c7ee7..a710b80b4e0 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -7503,6 +7503,39 @@ int test_if_data_home_dir(const char *dir) C_MODE_END +/** + Check that host name string is valid. + + @param[in] str string to be checked + + @return Operation status + @retval FALSE host name is ok + @retval TRUE host name string is longer than max_length or + has invalid symbols +*/ + +bool check_host_name(LEX_STRING *str) +{ + const char *name= str->str; + const char *end= str->str + str->length; + if (check_string_byte_length(str, ER(ER_HOSTNAME), HOSTNAME_LENGTH)) + return TRUE; + + while (name != end) + { + if (*name == '@') + { + my_printf_error(ER_UNKNOWN_ERROR, + "Malformed hostname (illegal symbol: '%c')", MYF(0), + *name); + return TRUE; + } + name++; + } + return FALSE; +} + + extern int MYSQLparse(void *thd); // from sql_yacc.cc diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 278fe88c336..8d9b3a2d4b5 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -11301,8 +11301,7 @@ user: if (check_string_char_length(&$$->user, ER(ER_USERNAME), USERNAME_CHAR_LENGTH, system_charset_info, 0) || - check_string_byte_length(&$$->host, ER(ER_HOSTNAME), - HOSTNAME_LENGTH)) + check_host_name(&$$->host)) MYSQL_YYABORT; } | CURRENT_USER optional_braces