Commit e5853157 authored by pem@mysql.com's avatar pem@mysql.com

Additional fix for BUG#7049, after review.

Make sure "select" aborts when finding a SP condition handler beyond the current scope.
parent 6a88684e
...@@ -3310,7 +3310,6 @@ select 1| ...@@ -3310,7 +3310,6 @@ select 1|
1 1
call bug12379_1()| call bug12379_1()|
bug12379() bug12379()
NULL
42 42
42 42
select 2| select 2|
...@@ -3318,7 +3317,6 @@ select 2| ...@@ -3318,7 +3317,6 @@ select 2|
2 2
call bug12379_2()| call bug12379_2()|
bug12379() bug12379()
NULL
select 3| select 3|
3 3
3 3
......
...@@ -2342,6 +2342,8 @@ static int my_message_sql(uint error, const char *str, myf MyFlags) ...@@ -2342,6 +2342,8 @@ static int my_message_sql(uint error, const char *str, myf MyFlags)
if (thd->spcont && if (thd->spcont &&
thd->spcont->find_handler(error, MYSQL_ERROR::WARN_LEVEL_ERROR)) thd->spcont->find_handler(error, MYSQL_ERROR::WARN_LEVEL_ERROR))
{ {
if (! thd->spcont->found_handler_here())
thd->net.report_error= 1; /* Make "select" abort correctly */
DBUG_RETURN(0); DBUG_RETURN(0);
} }
......
...@@ -76,6 +76,8 @@ void net_send_error(THD *thd, uint sql_errno, const char *err) ...@@ -76,6 +76,8 @@ void net_send_error(THD *thd, uint sql_errno, const char *err)
if (thd->spcont && thd->spcont->find_handler(sql_errno, if (thd->spcont && thd->spcont->find_handler(sql_errno,
MYSQL_ERROR::WARN_LEVEL_ERROR)) MYSQL_ERROR::WARN_LEVEL_ERROR))
{ {
if (! thd->spcont->found_handler_here())
thd->net.report_error= 1; /* Make "select" abort correctly */
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
thd->query_error= 1; // needed to catch query errors during replication thd->query_error= 1; // needed to catch query errors during replication
...@@ -181,6 +183,8 @@ net_printf_error(THD *thd, uint errcode, ...) ...@@ -181,6 +183,8 @@ net_printf_error(THD *thd, uint errcode, ...)
if (thd->spcont && thd->spcont->find_handler(errcode, if (thd->spcont && thd->spcont->find_handler(errcode,
MYSQL_ERROR::WARN_LEVEL_ERROR)) MYSQL_ERROR::WARN_LEVEL_ERROR))
{ {
if (! thd->spcont->found_handler_here())
thd->net.report_error= 1; /* Make "select" abort correctly */
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
thd->query_error= 1; // needed to catch query errors during replication thd->query_error= 1; // needed to catch query errors during replication
......
...@@ -149,6 +149,13 @@ class sp_rcontext : public Sql_alloc ...@@ -149,6 +149,13 @@ class sp_rcontext : public Sql_alloc
return m_handler[m_hfound].type; return m_handler[m_hfound].type;
} }
// Returns true if we found a handler in this context
inline bool
found_handler_here()
{
return (m_hfound >= 0);
}
// Clears the handler find state // Clears the handler find state
inline void inline void
clear_handler() clear_handler()
......
...@@ -144,6 +144,8 @@ MYSQL_ERROR *push_warning(THD *thd, MYSQL_ERROR::enum_warning_level level, ...@@ -144,6 +144,8 @@ MYSQL_ERROR *push_warning(THD *thd, MYSQL_ERROR::enum_warning_level level,
thd->really_abort_on_warning()) ? thd->really_abort_on_warning()) ?
MYSQL_ERROR::WARN_LEVEL_ERROR : level)) MYSQL_ERROR::WARN_LEVEL_ERROR : level))
{ {
if (! thd->spcont->found_handler_here())
thd->net.report_error= 1; /* Make "select" abort correctly */
DBUG_RETURN(NULL); DBUG_RETURN(NULL);
} }
query_cache_abort(&thd->net); query_cache_abort(&thd->net);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment