From: Date: April 27 2005 4:57pm Subject: bk commit into 5.0 tree (pem:1.1902) BUG#8408 List-Archive: http://lists.mysql.com/internals/24381 X-Bug: 8408 Message-Id: <200504271457.j3REv7kH017847@mail.mysql.com> 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.1902 05/04/27 16:35:49 pem@stripped +5 -0 Post-review fixes of the patch for BUG#8408: Stored procedure crash if function contains SHOW (Review on irc by monty) sql/sql_parse.cc 1.443 05/04/27 16:35:43 pem@stripped +1 -1 Include the procedure name in the new error message. sql/share/errmsg.txt 1.28 05/04/27 16:35:43 pem@stripped +1 -1 Changed the ER_SP_BADSELECT error; more accurate, and includes the procedure name. sql/item_func.cc 1.183 05/04/27 16:35:43 pem@stripped +4 -6 Corrected (and better) way to set/reset the client cap. flag in Item_func_sp::execute() mysql-test/t/sp-error.test 1.68 05/04/27 16:35:43 pem@stripped +12 -11 Renamed a procedure and function to avoid confusion mysql-test/r/sp-error.result 1.66 05/04/27 16:35:42 pem@stripped +10 -10 Renamed a procedure and function to avoid confusion # 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.182/sql/item_func.cc Tue Apr 26 17:31:53 2005 +++ 1.183/sql/item_func.cc Wed Apr 27 16:35:43 2005 @@ -4554,7 +4554,7 @@ { DBUG_ENTER("Item_func_sp::execute"); THD *thd= current_thd; - bool clcap_mr; + ulong old_client_capabilites; int res; #ifndef NO_EMBEDDED_ACCESS_CHECKS st_sp_security_context save_ctx; @@ -4568,7 +4568,7 @@ DBUG_RETURN(-1); } - clcap_mr= (thd->client_capabilities & CLIENT_MULTI_RESULTS); + old_client_capabilites= thd->client_capabilities; thd->client_capabilities &= ~CLIENT_MULTI_RESULTS; #ifndef EMBEDDED_LIBRARY @@ -4586,8 +4586,7 @@ 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; + thd->client_capabilities|= old_client_capabilites & CLIENT_MULTI_RESULTS; DBUG_RETURN(-1); } #endif @@ -4602,8 +4601,7 @@ thd->net.no_send_ok= nsok; #endif - if (clcap_mr) - thd->client_capabilities |= CLIENT_MULTI_RESULTS; + thd->client_capabilities|= old_client_capabilites & CLIENT_MULTI_RESULTS; DBUG_RETURN(res); } --- 1.442/sql/sql_parse.cc Fri Apr 22 12:53:42 2005 +++ 1.443/sql/sql_parse.cc Wed Apr 27 16:35:43 2005 @@ -4052,7 +4052,7 @@ { if (! (thd->client_capabilities & CLIENT_MULTI_RESULTS)) { - my_message(ER_SP_BADSELECT, ER(ER_SP_BADSELECT), MYF(0)); + my_error(ER_SP_BADSELECT, MYF(0), sp->m_qname.str); #ifndef EMBEDDED_LIBRARY thd->net.no_send_ok= nsok; #endif --- 1.27/sql/share/errmsg.txt Tue Apr 26 17:31:53 2005 +++ 1.28/sql/share/errmsg.txt Wed Apr 27 16:35:43 2005 @@ -5090,7 +5090,7 @@ ER_SP_UNINIT_VAR 01000 eng "Referring to uninitialized variable %s" ER_SP_BADSELECT 0A000 - eng "SELECT in a stored procedure must have INTO" + eng "PROCEDURE %s can't return a result set in the given context" ER_SP_BADRETURN 42000 eng "RETURN is only allowed in a FUNCTION" ER_SP_BADSTATEMENT 0A000 --- 1.65/mysql-test/r/sp-error.result Tue Apr 26 17:31:53 2005 +++ 1.66/mysql-test/r/sp-error.result Wed Apr 27 16:35:42 2005 @@ -594,8 +594,6 @@ 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; @@ -615,19 +613,21 @@ return b; end| ERROR 0A000: Not allowed to return a result set from a function -create function bug8408() returns int +drop function if exists bug8408_f| +drop procedure if exists bug8408_p| +create function bug8408_f() returns int begin -call bug8408(); +call bug8408_p(); return 0; end| -create procedure bug8408() +create procedure bug8408_p() select * from t1| -call bug8408()| +call bug8408_p()| val x -select bug8408()| -ERROR 0A000: SELECT in a stored procedure must have INTO -drop procedure bug8408| -drop function bug8408| +select bug8408_f()| +ERROR 0A000: PROCEDURE test.bug8408_p can't return a result set in the given context +drop procedure bug8408_p| +drop function bug8408_f| create function bug8408() returns int begin declare n int default 0; --- 1.67/mysql-test/t/sp-error.test Tue Apr 26 17:31:53 2005 +++ 1.68/mysql-test/t/sp-error.test Wed Apr 27 16:35:43 2005 @@ -835,10 +835,6 @@ # 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 @@ -861,21 +857,26 @@ return b; end| +--disable_warnings +drop function if exists bug8408_f| +drop procedure if exists bug8408_p| +--enable_warnings + # Some things must be caught at invokation time -create function bug8408() returns int +create function bug8408_f() returns int begin - call bug8408(); + call bug8408_p(); return 0; end| -create procedure bug8408() +create procedure bug8408_p() select * from t1| -call bug8408()| +call bug8408_p()| --error ER_SP_BADSELECT -select bug8408()| +select bug8408_f()| -drop procedure bug8408| -drop function bug8408| +drop procedure bug8408_p| +drop function bug8408_f| # But this is ok create function bug8408() returns int