summaryrefslogtreecommitdiff
path: root/sql/item_func.cc
diff options
context:
space:
mode:
authorunknown <bell@sanja.is.com.ua>2005-09-21 08:29:47 +0300
committerunknown <bell@sanja.is.com.ua>2005-09-21 08:29:47 +0300
commit21a62eb1c6a281b72c24bb9a7d5af702a5b3d8d5 (patch)
tree3fd9549289ca85690f0fe0b1fc7427e8c2394642 /sql/item_func.cc
parentaa95f0d447ed43cb20f1ce3221334b8f75e82377 (diff)
downloadmariadb-git-21a62eb1c6a281b72c24bb9a7d5af702a5b3d8d5.tar.gz
postmerge fixes
libmysqld/lib_sql.cc: struct st_security_context nad to class Security_context sql/item_func.cc: fixed method call, name and contence to be compatible with new code sql/item_func.h: fixed method to be compatible wit new code sql/sql_parse.cc: fixed typo removed compiler warnings
Diffstat (limited to 'sql/item_func.cc')
-rw-r--r--sql/item_func.cc70
1 files changed, 28 insertions, 42 deletions
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 4fbc60014f3..265eb28bba8 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -4711,21 +4711,11 @@ Item_func_sp::execute(Item **itp)
THD *thd= current_thd;
int res= -1;
Sub_statement_state statement_state;
-
-#ifndef NO_EMBEDDED_ACCESS_CHECKS
Security_context *save_ctx;
-#endif
- if (! m_sp && ! (m_sp= sp_find_function(thd, m_name, TRUE)))
- {
- my_error(ER_SP_DOES_NOT_EXIST, MYF(0), "FUNCTION", m_name->m_qname.str);
+ if (find_and_check_access(thd, EXECUTE_ACL, &save_ctx))
goto error;
- }
-#ifndef NO_EMBEDDED_ACCESS_CHECKS
- if (check_access(EXECUTE_ACL, 0, &save_ctx))
- goto error;
-#endif
/*
Disable the binlogging if this is not a SELECT statement. If this is a
SELECT, leave binlogging on, so execute_function() code writes the
@@ -4734,7 +4724,7 @@ Item_func_sp::execute(Item **itp)
thd->reset_sub_statement_state(&statement_state, SUB_STMT_FUNCTION);
res= m_sp->execute_function(thd, args, arg_count, itp);
thd->restore_sub_statement_state(&statement_state);
-
+
if (res && mysql_bin_log.is_open() &&
(m_sp->m_chistics->daccess == SP_CONTAINS_SQL ||
m_sp->m_chistics->daccess == SP_MODIFIES_SQL_DATA))
@@ -4851,71 +4841,67 @@ Item_func_sp::tmp_table_field(TABLE *t_arg)
DBUG_RETURN(res);
}
+
/*
- Check access rigths to function
+ Find the function and chack access rigths to the function
SYNOPSIS
- check_access()
+ find_and_check_access()
+ thd thread handler
want_access requested access
- report_error whether to set error to thd->net.report_error
- sp_ctx sp security context for switching
+ backup backup of security context or 0
RETURN
- 0 Access granted
- 1 Requested access can't be granted or function doesn't exists
+ FALSE Access granted
+ TRUE Requested access can't be granted or function doesn't exists
NOTES
Checks if requested access to function can be granted to user.
If function isn't found yet, it searches function first.
If function can't be found or user don't have requested access
- and report_error is true error is raised.
+ error is raised.
If security context sp_ctx is provided and access can be granted then
switch back to previous context isn't performed.
- In case of access error or if context is not provided then check_access()
- switches back to previous security context.
+ In case of access error or if context is not provided then
+ find_and_check_access() switches back to previous security context.
*/
+
bool
-Item_func_sp::check_access(ulong want_access, bool report_error, st_sp_security_context *sp_ctx)
+Item_func_sp::find_and_check_access(THD *thd, ulong want_access,
+ Security_context **backup)
{
bool res;
-#ifndef NO_EMBEDDED_ACCESS_CHECKS
- THD *thd= current_thd;
- st_sp_security_context save_ctx, *curr_ctx= sp_ctx?sp_ctx:&save_ctx;
- bool ctx_switched= 0;
- res= 1;
+ Security_context *local_save,
+ **save= (backup ? backup : &local_save);
+ res= TRUE;
if (! m_sp && ! (m_sp= sp_find_function(thd, m_name, TRUE)))
{
my_error(ER_SP_DOES_NOT_EXIST, MYF(0), "FUNCTION", m_name->m_qname.str);
- if (report_error)
- thd->net.report_error= 1;
goto error;
}
+#ifndef NO_EMBEDDED_ACCESS_CHECKS
if (check_routine_access(thd, want_access,
- m_sp->m_db.str, m_sp->m_name.str, 0, 0))
+ m_sp->m_db.str, m_sp->m_name.str, 0, FALSE))
{
- if (report_error)
- thd->net.report_error= 1;
goto error;
}
- sp_change_security_context(thd, m_sp, curr_ctx);
- ctx_switched= curr_ctx->changed;
- if (curr_ctx->changed &&
+ sp_change_security_context(thd, m_sp, save);
+ if (*save &&
check_routine_access(thd, want_access,
- m_sp->m_db.str, m_sp->m_name.str, 0, 0))
+ m_sp->m_db.str, m_sp->m_name.str, 0, FALSE))
{
- if (report_error)
- thd->net.report_error= 1;
goto error_check_ctx;
}
- res= 0;
+ res= FALSE;
error_check_ctx:
- if (ctx_switched && (res || !sp_ctx))
- sp_restore_security_context(thd, m_sp, curr_ctx);
+ if (*save && (res || !backup))
+ sp_restore_security_context(thd, local_save);
error:
#else
res= 0;
+error:
#endif
return res;
};
@@ -4926,7 +4912,7 @@ Item_func_sp::fix_fields(THD *thd, Item **ref)
bool res;
DBUG_ASSERT(fixed == 0);
res= Item_func::fix_fields(thd, ref);
- if (!res && check_access(EXECUTE_ACL, 1, NULL))
+ if (!res && find_and_check_access(thd, EXECUTE_ACL, NULL))
res= 1;
return res;
}