Below is the list of changes that have just been committed into a local
5.0 repository of pem. When pem does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet
1.1887 05/04/26 17:31:59 pem@stripped +5 -0
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.
sql/sql_yacc.yy
1.368 05/04/26 17:31:53 pem@stripped +6 -0
Don't allow result sets in functions.
sql/share/errmsg.txt
1.27 05/04/26 17:31:53 pem@stripped +2 -0
Added error message for statements not allowed in functions (detected during parsing).
sql/item_func.cc
1.182 05/04/26 17:31:53 pem@stripped +10 -0
Disable result sets from functions but temporarily turning CLIENT_MULTI_RESULTS off.
mysql-test/t/sp-error.test
1.67 05/04/26 17:31:53 pem@stripped +61 -0
New test case for BUG#8408.
mysql-test/r/sp-error.result
1.65 05/04/26 17:31:53 pem@stripped +48 -0
New test case for BUG#8408.
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: pem
# Host: mysql.comhem.se
# Root: /home/pem/work/mysql-5.0
--- 1.181/sql/item_func.cc Wed Apr 20 19:08:27 2005
+++ 1.182/sql/item_func.cc Tue Apr 26 17:31:53 2005
@@ -4554,6 +4554,7 @@
{
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 @@
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 @@
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 @@
#ifndef EMBEDDED_LIBRARY
thd->net.no_send_ok= nsok;
#endif
+
+ if (clcap_mr)
+ thd->client_capabilities |= CLIENT_MULTI_RESULTS;
+
DBUG_RETURN(res);
}
--- 1.367/sql/sql_yacc.yy Fri Apr 22 08:50:58 2005
+++ 1.368/sql/sql_yacc.yy Tue Apr 26 17:31:53 2005
@@ -1442,6 +1442,12 @@
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;
--- 1.26/sql/share/errmsg.txt Wed Apr 20 17:59:22 2005
+++ 1.27/sql/share/errmsg.txt Tue Apr 26 17:31:53 2005
@@ -5342,3 +5342,5 @@
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"
--- 1.64/mysql-test/r/sp-error.result Wed Apr 20 17:59:22 2005
+++ 1.65/mysql-test/r/sp-error.result Tue Apr 26 17:31:53 2005
@@ -594,4 +594,52 @@
return 0;
end|
ERROR HY000: Can't drop or alter a FUNCTION from within another stored routine
+drop function if exists bug8408|
+drop procedure if exists bug8408|
+create function bug8408() returns int
+begin
+select * from t1;
+return 0;
+end|
+ERROR 0A000: Not allowed to return a result set from a function
+create function bug8408() returns int
+begin
+show warnings;
+return 0;
+end|
+ERROR 0A000: Not allowed to return a result set from a function
+create function bug8408(a int) returns int
+begin
+declare b int;
+select b;
+return b;
+end|
+ERROR 0A000: Not allowed to return a result set from a function
+create function bug8408() returns int
+begin
+call bug8408();
+return 0;
+end|
+create procedure bug8408()
+select * from t1|
+call bug8408()|
+val x
+select bug8408()|
+ERROR 0A000: SELECT in a stored procedure must have INTO
+drop procedure bug8408|
+drop function bug8408|
+create function bug8408() returns int
+begin
+declare n int default 0;
+select count(*) into n from t1;
+return n;
+end|
+insert into t1 value (2, 2.7), (3, 3.14), (7, 7.0)|
+select *,bug8408() from t1|
+val x bug8408()
+2 2.7 3
+3 3.14 3
+7 7 3
+drop function bug8408|
+delete from t1|
drop table t1|
--- 1.66/mysql-test/t/sp-error.test Wed Apr 20 17:59:22 2005
+++ 1.67/mysql-test/t/sp-error.test Tue Apr 26 17:31:53 2005
@@ -832,6 +832,67 @@
#
+# BUG#8408: Stored procedure crash if function contains SHOW
+# BUG#9058: Stored Procedures: Crash if function included SELECT
+#
+--disable_warnings
+drop function if exists bug8408|
+drop procedure if exists bug8408|
+--enable_warnings
+
+# Some things are caught when parsing
+--error ER_SP_NO_RETSET_IN_FUNC
+create function bug8408() returns int
+begin
+ select * from t1;
+ return 0;
+end|
+--error ER_SP_NO_RETSET_IN_FUNC
+create function bug8408() returns int
+begin
+ show warnings;
+ return 0;
+end|
+--error ER_SP_NO_RETSET_IN_FUNC
+create function bug8408(a int) returns int
+begin
+ declare b int;
+ select b;
+ return b;
+end|
+
+# Some things must be caught at invokation time
+create function bug8408() returns int
+begin
+ call bug8408();
+ return 0;
+end|
+create procedure bug8408()
+ select * from t1|
+
+call bug8408()|
+--error ER_SP_BADSELECT
+select bug8408()|
+
+drop procedure bug8408|
+drop function bug8408|
+
+# But this is ok
+create function bug8408() returns int
+begin
+ declare n int default 0;
+ select count(*) into n from t1;
+ return n;
+end|
+
+insert into t1 value (2, 2.7), (3, 3.14), (7, 7.0)|
+select *,bug8408() from t1|
+
+drop function bug8408|
+delete from t1|
+
+
+#
# BUG#NNNN: New bug synopsis
#
#--disable_warnings
| Thread |
|---|
| • bk commit into 5.0 tree (pem:1.1887) BUG#8408 | pem | 26 Apr |