summaryrefslogtreecommitdiff
path: root/sql/sp_head.cc
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2017-10-24 14:53:18 +0200
committerSergei Golubchik <serg@mariadb.org>2017-10-24 14:53:18 +0200
commite0a1c745ec3ed1ec6c0375a2a624697c29f480a6 (patch)
tree24ded2c6ebe3ea3413ce56af89ea0f2f63bb3a39 /sql/sp_head.cc
parent4ec88ea9c3ec52d996b39167d12a61ab95fdeacc (diff)
parent2aa51f528fd5d23cc54eca8fbd07e88e7b2993c7 (diff)
downloadmariadb-git-e0a1c745ec3ed1ec6c0375a2a624697c29f480a6.tar.gz
Merge branch '10.1' into 10.2
Diffstat (limited to 'sql/sp_head.cc')
-rw-r--r--sql/sp_head.cc12
1 files changed, 9 insertions, 3 deletions
diff --git a/sql/sp_head.cc b/sql/sp_head.cc
index b3edcdca474..20c02fce752 100644
--- a/sql/sp_head.cc
+++ b/sql/sp_head.cc
@@ -119,7 +119,6 @@ sp_get_item_value(THD *thd, Item *item, String *str)
case DECIMAL_RESULT:
if (item->field_type() != MYSQL_TYPE_BIT)
return item->val_str(str);
- else {/* Bit type is handled as binary string */}
/* fall through */
case STRING_RESULT:
{
@@ -2545,10 +2544,18 @@ bool check_show_routine_access(THD *thd, sp_head *sp, bool *full_access)
*full_access= ((!check_table_access(thd, SELECT_ACL, &tables, FALSE,
1, TRUE) &&
(tables.grant.privilege & SELECT_ACL) != 0) ||
+ /* Check if user owns the routine. */
(!strcmp(sp->m_definer_user.str,
thd->security_ctx->priv_user) &&
!strcmp(sp->m_definer_host.str,
- thd->security_ctx->priv_host)));
+ thd->security_ctx->priv_host)) ||
+ /* Check if current role or any of the sub-granted roles
+ own the routine. */
+ (sp->m_definer_host.length == 0 &&
+ (!strcmp(sp->m_definer_user.str,
+ thd->security_ctx->priv_role) ||
+ check_role_is_granted(thd->security_ctx->priv_role, NULL,
+ sp->m_definer_user.str))));
if (!*full_access)
return check_some_routine_access(thd, sp->m_db.str, sp->m_name.str,
sp->m_type == TYPE_ENUM_PROCEDURE);
@@ -4327,4 +4334,3 @@ sp_add_to_query_tables(THD *thd, LEX *lex,
lex->add_to_query_tables(table);
return table;
}
-