diff --git a/mysql-test/main/skip_grants.result b/mysql-test/main/skip_grants.result index a8633807571..daf4191a555 100644 --- a/mysql-test/main/skip_grants.result +++ b/mysql-test/main/skip_grants.result @@ -139,3 +139,11 @@ drop user baz@baz; # # End of 10.3 tests # +# +# MDEV-34501: SIGSEGV in pfs_start_mutex_wait_v1, __strlen_avx2, or __strlen_evex from safe_mutex_lock on CREATE DEFINER when using skip-grant-tables +# +CREATE DEFINER=a PROCEDURE p() SELECT 1; +CREATE DEFINER=a FUNCTION f() RETURNS INT RETURN 100; +DROP PROCEDURE p; +DROP FUNCTION f; +# End of 10.5 tests diff --git a/mysql-test/main/skip_grants.test b/mysql-test/main/skip_grants.test index eb8d3c3df88..2c4eddda2b2 100644 --- a/mysql-test/main/skip_grants.test +++ b/mysql-test/main/skip_grants.test @@ -164,3 +164,14 @@ drop user baz@baz; --echo # --echo # End of 10.3 tests --echo # + +--echo # +--echo # MDEV-34501: SIGSEGV in pfs_start_mutex_wait_v1, __strlen_avx2, or __strlen_evex from safe_mutex_lock on CREATE DEFINER when using skip-grant-tables +--echo # +CREATE DEFINER=a PROCEDURE p() SELECT 1; +CREATE DEFINER=a FUNCTION f() RETURNS INT RETURN 100; + +DROP PROCEDURE p; +DROP FUNCTION f; + +--echo # End of 10.5 tests diff --git a/mysql-test/main/sp-bugs.result b/mysql-test/main/sp-bugs.result index bd5883f0a04..c1f64a1fa14 100644 --- a/mysql-test/main/sp-bugs.result +++ b/mysql-test/main/sp-bugs.result @@ -388,5 +388,14 @@ ERROR 23000: Column 'c2' in from clause is ambiguous DROP PROCEDURE p2; DROP TABLE t1, t2; # +# MDEV-34501: SIGSEGV in pfs_start_mutex_wait_v1, __strlen_avx2, or __strlen_evex from safe_mutex_lock on CREATE DEFINER when using skip-grant-tables +# +# This test is a duplicate of the one located in the file skip_grants.test +# and placed here to check the same test case against embedded-server +CREATE DEFINER=a PROCEDURE p() SELECT 1; +CREATE DEFINER=a FUNCTION f() RETURNS INT RETURN 100; +DROP PROCEDURE p; +DROP FUNCTION f; +# # End of 10.5 tests # diff --git a/mysql-test/main/sp-bugs.test b/mysql-test/main/sp-bugs.test index f44216fbf46..9a4b867a92b 100644 --- a/mysql-test/main/sp-bugs.test +++ b/mysql-test/main/sp-bugs.test @@ -414,6 +414,26 @@ CALL p2 (@a,@c); DROP PROCEDURE p2; DROP TABLE t1, t2; +--echo # +--echo # MDEV-34501: SIGSEGV in pfs_start_mutex_wait_v1, __strlen_avx2, or __strlen_evex from safe_mutex_lock on CREATE DEFINER when using skip-grant-tables +--echo # +--echo # This test is a duplicate of the one located in the file skip_grants.test +--echo # and placed here to check the same test case against embedded-server + +# Disable warnings before running the following CREATE PROCEDURE/FUNCTION +# statement since the warning message +# "The user specified as a definer ('a'@'%') does not exist" +# is output in case the test be run against a regular server +# and isn't output if embedded server is used (@sa sp_process_definer() +# in sql_parse.cc). +--disable_warnings +CREATE DEFINER=a PROCEDURE p() SELECT 1; +CREATE DEFINER=a FUNCTION f() RETURNS INT RETURN 100; +--enable_warnings + +DROP PROCEDURE p; +DROP FUNCTION f; + --echo # --echo # End of 10.5 tests --echo # diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index a7e9ea7d6f7..385d3da18e2 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -12944,6 +12944,9 @@ LEX_USER *get_current_user(THD *thd, LEX_USER *user, bool lock) if (is_invalid_role_name(user->user.str)) return 0; + if (!initialized) + return dup; + if (lock) mysql_mutex_lock(&acl_cache->lock); if (find_acl_role(dup->user.str)) diff --git a/sql/structs.h b/sql/structs.h index aa50035ac7a..2fbd263c825 100644 --- a/sql/structs.h +++ b/sql/structs.h @@ -227,7 +227,7 @@ struct AUTHID LEX_CSTRING user, host; void init() { memset(this, 0, sizeof(*this)); } void copy(MEM_ROOT *root, const LEX_CSTRING *usr, const LEX_CSTRING *host); - bool is_role() const { return user.str[0] && !host.str[0]; } + bool is_role() const { return user.str[0] && (!host.str || !host.str[0]); } void set_lex_string(LEX_CSTRING *l, char *buf) { if (is_role())