summaryrefslogtreecommitdiff
path: root/sql/item_func.cc
diff options
context:
space:
mode:
authorbell@sanja.is.com.ua <>2005-06-23 18:29:10 +0300
committerbell@sanja.is.com.ua <>2005-06-23 18:29:10 +0300
commit56b2fc10a8473c37951cd7f9c76fba289e83e321 (patch)
treec77bf7e6fffbe90308dfb1d0b58b5d2d64ffba2b /sql/item_func.cc
parent53595de2c17c7ffc7267b342598caef8dad3199c (diff)
downloadmariadb-git-56b2fc10a8473c37951cd7f9c76fba289e83e321.tar.gz
fixed environment restoring in case of error during SP function execution (BUG#9503)
#define macro improvement
Diffstat (limited to 'sql/item_func.cc')
-rw-r--r--sql/item_func.cc29
1 files changed, 15 insertions, 14 deletions
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 57f68bbc2a0..de497014240 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -4807,42 +4807,37 @@ Item_func_sp::execute(Item **itp)
DBUG_ENTER("Item_func_sp::execute");
THD *thd= current_thd;
ulong old_client_capabilites;
- int res;
+ int res= -1;
bool save_in_sub_stmt= thd->transaction.in_sub_stmt;
+ my_bool nsok;
#ifndef NO_EMBEDDED_ACCESS_CHECKS
st_sp_security_context save_ctx;
#endif
- if (! m_sp)
+ if (! m_sp && ! (m_sp= sp_find_function(thd, m_name, TRUE)))
{
- if (!(m_sp= sp_find_function(thd, m_name, TRUE)))
- {
- my_error(ER_SP_DOES_NOT_EXIST, MYF(0), "FUNCTION", m_name->m_qname.str);
- DBUG_RETURN(-1);
- }
+ my_error(ER_SP_DOES_NOT_EXIST, MYF(0), "FUNCTION", m_name->m_qname.str);
+ goto error;
}
old_client_capabilites= thd->client_capabilities;
thd->client_capabilities &= ~CLIENT_MULTI_RESULTS;
#ifndef EMBEDDED_LIBRARY
- my_bool nsok= thd->net.no_send_ok;
+ nsok= thd->net.no_send_ok;
thd->net.no_send_ok= TRUE;
#endif
+ res= -1;
#ifndef NO_EMBEDDED_ACCESS_CHECKS
if (check_routine_access(thd, EXECUTE_ACL,
m_sp->m_db.str, m_sp->m_name.str, 0, 0))
- DBUG_RETURN(-1);
+ goto error_check;
sp_change_security_context(thd, m_sp, &save_ctx);
if (save_ctx.changed &&
check_routine_access(thd, EXECUTE_ACL,
m_sp->m_db.str, m_sp->m_name.str, 0, 0))
- {
- sp_restore_security_context(thd, m_sp, &save_ctx);
- thd->client_capabilities|= old_client_capabilites & CLIENT_MULTI_RESULTS;
- DBUG_RETURN(-1);
- }
+ goto error_check;
#endif
/*
Like for SPs, we don't binlog the substatements. If the statement which
@@ -4850,6 +4845,7 @@ Item_func_sp::execute(Item **itp)
it's not (e.g. SELECT myfunc()) it won't be binlogged (documented known
problem).
*/
+
tmp_disable_binlog(thd); /* don't binlog the substatements */
thd->transaction.in_sub_stmt= TRUE;
@@ -4864,16 +4860,21 @@ Item_func_sp::execute(Item **itp)
ER_FAILED_ROUTINE_BREAK_BINLOG,
ER(ER_FAILED_ROUTINE_BREAK_BINLOG));
+error_check_ctx:
#ifndef NO_EMBEDDED_ACCESS_CHECKS
sp_restore_security_context(thd, m_sp, &save_ctx);
#endif
+ thd->client_capabilities|= old_client_capabilites & CLIENT_MULTI_RESULTS;
+
+error_check:
#ifndef EMBEDDED_LIBRARY
thd->net.no_send_ok= nsok;
#endif
thd->client_capabilities|= old_client_capabilites & CLIENT_MULTI_RESULTS;
+error:
DBUG_RETURN(res);
}