summaryrefslogtreecommitdiff
path: root/sql/sp_head.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/sp_head.cc')
-rw-r--r--sql/sp_head.cc68
1 files changed, 38 insertions, 30 deletions
diff --git a/sql/sp_head.cc b/sql/sp_head.cc
index a6e88c08789..576830a6587 100644
--- a/sql/sp_head.cc
+++ b/sql/sp_head.cc
@@ -24,11 +24,17 @@
#include "sp_rcontext.h"
#include "sp_cache.h"
+/*
+ Sufficient max length of printed destinations and frame offsets (all uints).
+*/
+#define SP_INSTR_UINT_MAXLEN 8
+#define SP_STMT_PRINT_MAXLEN 40
+
+
Item_result
sp_map_result_type(enum enum_field_types type)
{
- switch (type)
- {
+ switch (type) {
case MYSQL_TYPE_TINY:
case MYSQL_TYPE_SHORT:
case MYSQL_TYPE_LONG:
@@ -891,17 +897,17 @@ static bool subst_spvars(THD *thd, sp_instr *instr, LEX_STRING *query_str)
SYNOPSIS
sp_head::recursion_level_error()
+ thd Thread handle
NOTE
For functions and triggers we return error about prohibited recursion.
For stored procedures we return about reaching recursion limit.
*/
-void sp_head::recursion_level_error()
+void sp_head::recursion_level_error(THD *thd)
{
if (m_type == TYPE_ENUM_PROCEDURE)
{
- THD *thd= current_thd;
my_error(ER_SP_RECURSION_LIMIT, MYF(0),
thd->variables.max_sp_recursion_depth,
m_name);
@@ -952,10 +958,15 @@ int sp_head::execute(THD *thd)
DBUG_ASSERT(!(m_flags & IS_INVOKED));
m_flags|= IS_INVOKED;
m_first_instance->m_first_free_instance= m_next_cached_sp;
- DBUG_PRINT("info", ("first free for 0x%lx ++: 0x%lx->0x%lx, level: %lu, flags %x",
- (ulong)m_first_instance, this, m_next_cached_sp,
- m_next_cached_sp->m_recursion_level,
- m_next_cached_sp->m_flags));
+ if (m_next_cached_sp)
+ {
+ DBUG_PRINT("info",
+ ("first free for 0x%lx ++: 0x%lx->0x%lx level: %lu flags %x",
+ (ulong)m_first_instance, (ulong) this,
+ (ulong) m_next_cached_sp,
+ m_next_cached_sp->m_recursion_level,
+ m_next_cached_sp->m_flags));
+ }
/*
Check that if there are not any instances after this one then
pointer to the last instance points on this instance or if there are
@@ -1140,9 +1151,9 @@ int sp_head::execute(THD *thd)
}
m_flags&= ~IS_INVOKED;
DBUG_PRINT("info", ("first free for 0x%lx --: 0x%lx->0x%lx, level: %lu, flags %x",
- (ulong)m_first_instance,
- m_first_instance->m_first_free_instance, this,
- m_recursion_level, m_flags));
+ (ulong) m_first_instance,
+ (ulong) m_first_instance->m_first_free_instance,
+ (ulong) this, m_recursion_level, m_flags));
/*
Check that we have one of following:
@@ -1152,7 +1163,7 @@ int sp_head::execute(THD *thd)
2) There are some free instances which mean that first free instance
should go just after this one and recursion level of that free instance
- should be on 1 more then recursion leven of this instance.
+ should be on 1 more then recursion level of this instance.
*/
DBUG_ASSERT((m_first_instance->m_first_free_instance == 0 &&
this == m_first_instance->m_last_cached_sp &&
@@ -1684,16 +1695,16 @@ sp_head::set_info(longlong created, longlong modified,
void
-sp_head::set_definer(char *definer, uint definerlen)
+
+sp_head::set_definer(const char *definer, uint definerlen)
{
char *p= strrchr(definer, '@');
if (!p)
{
- m_definer_user.str= strmake_root(mem_root, "", 0);
+ m_definer_user.str= (char*) "";
m_definer_user.length= 0;
-
- m_definer_host.str= strmake_root(mem_root, "", 0);
+ m_definer_host.str= (char*) "";
m_definer_host.length= 0;
}
else
@@ -1788,9 +1799,9 @@ sp_head::show_create_procedure(THD *thd)
byte *sql_mode_str;
ulong sql_mode_len;
bool full_access;
-
DBUG_ENTER("sp_head::show_create_procedure");
DBUG_PRINT("info", ("procedure %s", m_name.str));
+
LINT_INIT(sql_mode_str);
LINT_INIT(sql_mode_len);
@@ -2143,12 +2154,7 @@ sp_instr_stmt::execute(THD *thd, uint *nextp)
DBUG_RETURN(res);
}
-/*
- Sufficient max length of printed destinations and frame offsets (all uints).
-*/
-#define SP_INSTR_UINT_MAXLEN 8
-#define SP_STMT_PRINT_MAXLEN 40
void
sp_instr_stmt::print(String *str)
{
@@ -2170,16 +2176,16 @@ sp_instr_stmt::print(String *str)
/* Copy the query string and replace '\n' with ' ' in the process */
for (i= 0 ; i < len ; i++)
{
- if (m_query.str[i] == '\n')
- str->qs_append(' ');
- else
- str->qs_append(m_query.str[i]);
+ char c= m_query.str[i];
+ if (c == '\n')
+ c= ' ';
+ str->qs_append(c);
}
if (m_query.length > SP_STMT_PRINT_MAXLEN)
str->qs_append(STRING_WITH_LEN("...")); /* Indicate truncated string */
str->qs_append('"');
}
-#undef SP_STMT_PRINT_MAXLEN
+
int
sp_instr_stmt::exec_core(THD *thd, uint *nextp)
@@ -2523,6 +2529,7 @@ sp_instr_hpush_jump::execute(THD *thd, uint *nextp)
DBUG_RETURN(0);
}
+
void
sp_instr_hpush_jump::print(String *str)
{
@@ -2533,8 +2540,7 @@ sp_instr_hpush_jump::print(String *str)
str->qs_append(m_dest);
str->qs_append(' ');
str->qs_append(m_frame);
- switch (m_type)
- {
+ switch (m_type) {
case SP_HANDLER_NONE:
str->qs_append(STRING_WITH_LEN(" NONE")); // This would be a bug
break;
@@ -2548,11 +2554,13 @@ sp_instr_hpush_jump::print(String *str)
str->qs_append(STRING_WITH_LEN(" UNDO"));
break;
default:
- str->qs_append(STRING_WITH_LEN(" UNKNOWN:")); // This would be a bug as well
+ // This would be a bug as well
+ str->qs_append(STRING_WITH_LEN(" UNKNOWN:"));
str->qs_append(m_type);
}
}
+
uint
sp_instr_hpush_jump::opt_mark(sp_head *sp)
{