summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorpem@mysql.comhem.se <>2005-04-26 17:31:59 +0200
committerpem@mysql.comhem.se <>2005-04-26 17:31:59 +0200
commit281c0a813006aa5cc56610b46962d68856452ef1 (patch)
tree3e1d843329a69cf864b698ec0a864fa22df608ab /sql
parentb890c05b4dd3461879a30da3b9cbf44e8f7b6040 (diff)
downloadmariadb-git-281c0a813006aa5cc56610b46962d68856452ef1.tar.gz
Fixed BUG#8408: Stored procedure crash if function contains SHOW
We simply have to disallow any kind of result set being sent back from a function. Can't see any way to make that to work.
Diffstat (limited to 'sql')
-rw-r--r--sql/item_func.cc10
-rw-r--r--sql/share/errmsg.txt2
-rw-r--r--sql/sql_yacc.yy6
3 files changed, 18 insertions, 0 deletions
diff --git a/sql/item_func.cc b/sql/item_func.cc
index fb21551e22f..3472c0ab786 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -4554,6 +4554,7 @@ Item_func_sp::execute(Item **itp)
{
DBUG_ENTER("Item_func_sp::execute");
THD *thd= current_thd;
+ bool clcap_mr;
int res;
#ifndef NO_EMBEDDED_ACCESS_CHECKS
st_sp_security_context save_ctx;
@@ -4567,6 +4568,9 @@ Item_func_sp::execute(Item **itp)
DBUG_RETURN(-1);
}
+ clcap_mr= (thd->client_capabilities & CLIENT_MULTI_RESULTS);
+ thd->client_capabilities &= ~CLIENT_MULTI_RESULTS;
+
#ifndef EMBEDDED_LIBRARY
my_bool nsok= thd->net.no_send_ok;
thd->net.no_send_ok= TRUE;
@@ -4582,6 +4586,8 @@ Item_func_sp::execute(Item **itp)
m_sp->m_db.str, m_sp->m_name.str, 0))
{
sp_restore_security_context(thd, m_sp, &save_ctx);
+ if (clcap_mr)
+ thd->client_capabilities |= CLIENT_MULTI_RESULTS;
DBUG_RETURN(-1);
}
#endif
@@ -4595,6 +4601,10 @@ Item_func_sp::execute(Item **itp)
#ifndef EMBEDDED_LIBRARY
thd->net.no_send_ok= nsok;
#endif
+
+ if (clcap_mr)
+ thd->client_capabilities |= CLIENT_MULTI_RESULTS;
+
DBUG_RETURN(res);
}
diff --git a/sql/share/errmsg.txt b/sql/share/errmsg.txt
index 8d7a1fe0093..66986a884b3 100644
--- a/sql/share/errmsg.txt
+++ b/sql/share/errmsg.txt
@@ -5342,3 +5342,5 @@ ER_SP_DUP_HANDLER 42000
eng "Duplicate handler declared in the same block"
ER_SP_NOT_VAR_ARG 42000
eng "OUT or INOUT argument %d for routine %s is not a variable"
+ER_SP_NO_RETSET_IN_FUNC 0A000
+ eng "Not allowed to return a result set from a function"
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 27e75fd9940..80bf409f7a4 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -1442,6 +1442,12 @@ create_function_tail:
LEX *lex= Lex;
sp_head *sp= lex->sphead;
+ if (sp->m_multi_results)
+ {
+ my_message(ER_SP_NO_RETSET_IN_FUNC, ER(ER_SP_NO_RETSET_IN_FUNC),
+ MYF(0));
+ YYABORT;
+ }
if (sp->check_backpatch(YYTHD))
YYABORT;
lex->sql_command= SQLCOM_CREATE_SPFUNCTION;