Loading mysql-test/r/sp.result +67 −67 Original line number Diff line number Diff line Loading @@ -3417,6 +3417,9 @@ Table Create Table tm1 CREATE TEMPORARY TABLE `tm1` ( `spv1` decimal(6,3) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop procedure bug12589_1| drop procedure bug12589_2| drop procedure bug12589_3| drop table if exists t3| drop procedure if exists bug7049_1| drop procedure if exists bug7049_2| Loading Loading @@ -3617,6 +3620,70 @@ count(*) drop table t3, t4| drop procedure bug14210| set @@session.max_heap_table_size=default| drop function if exists bug14723| drop procedure if exists bug14723| /*!50003 create function bug14723() returns bigint(20) main_loop: begin return 42; end */;; show create function bug14723;; Function sql_mode Create Function bug14723 CREATE FUNCTION `bug14723`() RETURNS bigint(20) main_loop: begin return 42; end select bug14723();; bug14723() 42 /*!50003 create procedure bug14723() main_loop: begin select 42; end */;; show create procedure bug14723;; Procedure sql_mode Create Procedure bug14723 CREATE PROCEDURE `bug14723`() main_loop: begin select 42; end call bug14723();; 42 42 drop function bug14723| drop procedure bug14723| create procedure bug14845() begin declare a char(255); declare done int default 0; declare c cursor for select count(*) from t1 where 1 = 0; declare continue handler for sqlstate '02000' set done = 1; open c; repeat fetch c into a; if not done then select a; end if; until done end repeat; close c; end| call bug14845()| a 0 drop procedure bug14845| drop procedure if exists bug13549_1| drop procedure if exists bug13549_2| CREATE PROCEDURE `bug13549_2`() begin call bug13549_1(); end| CREATE PROCEDURE `bug13549_1`() begin declare done int default 0; set done= not done; end| CALL bug13549_2()| drop procedure bug13549_2| drop procedure bug13549_1| drop function if exists bug10100f| drop procedure if exists bug10100p| drop procedure if exists bug10100t| Loading Loading @@ -3802,71 +3869,4 @@ drop procedure bug10100pd| drop procedure bug10100pc| drop view v1| drop table t3| drop function if exists bug14723| drop procedure if exists bug14723| /*!50003 create function bug14723() returns bigint(20) main_loop: begin return 42; end */;; show create function bug14723;; Function sql_mode Create Function bug14723 CREATE FUNCTION `bug14723`() RETURNS bigint(20) main_loop: begin return 42; end select bug14723();; bug14723() 42 /*!50003 create procedure bug14723() main_loop: begin select 42; end */;; show create procedure bug14723;; Procedure sql_mode Create Procedure bug14723 CREATE PROCEDURE `bug14723`() main_loop: begin select 42; end call bug14723();; 42 42 drop function bug14723| drop procedure bug14723| create procedure bug14845() begin declare a char(255); declare done int default 0; declare c cursor for select count(*) from t1 where 1 = 0; declare continue handler for sqlstate '02000' set done = 1; open c; repeat fetch c into a; if not done then select a; end if; until done end repeat; close c; end| call bug14845()| a 0 drop procedure bug14845| drop procedure bug12589_1| drop procedure bug12589_2| drop procedure bug12589_3| drop procedure if exists bug13549_1| drop procedure if exists bug13549_2| CREATE PROCEDURE `bug13549_2`() begin call bug13549_1(); end| CREATE PROCEDURE `bug13549_1`() begin declare done int default 0; set done= not done; end| CALL bug13549_2()| drop procedure bug13549_2| drop procedure bug13549_1| drop table t1,t2; sql/item.cc +0 −1 Original line number Diff line number Diff line Loading @@ -921,7 +921,6 @@ Item_splocal::type() const DBUG_ASSERT(owner == thd->spcont->owner); return thd->spcont->get_item(m_offset)->type(); } } return NULL_ITEM; // Anything but SUBSELECT_ITEM } Loading sql/sp.cc +4 −8 Original line number Diff line number Diff line Loading @@ -400,7 +400,7 @@ db_load_routine(THD *thd, int type, sp_name *name, sp_head **sphp, const char *definer, longlong created, longlong modified) { LEX *oldlex= thd->lex, newlex; sp_rcontext *save_spcont= ;thd->spcont; sp_rcontext *save_spcont= thd->spcont; String defstr; char olddb[128]; bool dbchanged; Loading Loading @@ -431,8 +431,6 @@ db_load_routine(THD *thd, int type, sp_name *name, sp_head **sphp, lex_start(thd, (uchar*)defstr.c_ptr(), defstr.length()); (*sphp)->set_definer((char*) definer, (uint) strlen(definer)); (*sphp)->set_info(created, modified, &chistics, sql_mode); thd->spcont= 0; if (yyparse(thd) || thd->is_fatal_error || newlex.sphead == NULL) { Loading @@ -446,18 +444,16 @@ db_load_routine(THD *thd, int type, sp_name *name, sp_head **sphp, else { if (dbchanged && (ret= mysql_change_db(thd, olddb, 1))) goto db_end; goto end; *sphp= newlex.sphead; (*sphp)->set_definer((char*) definer, (uint) strlen(definer)); (*sphp)->set_info((char *)definer, (uint)strlen(definer), created, modified, &chistics, sql_mode); (*sphp)->set_info(created, modified, &chistics, sql_mode); (*sphp)->optimize(); } db_end: end: thd->spcont= save_spcont; thd->variables.sql_mode= old_sql_mode; thd->variables.select_limit= select_limit; end: thd->lex= oldlex; return ret; } Loading sql/sql_parse.cc +4 −2 Original line number Diff line number Diff line Loading @@ -4566,9 +4566,11 @@ mysql_execute_command(THD *thd) goto error; } if (lex->sql_command == SQLCOM_SHOW_PROC_CODE) sp= sp_find_procedure(thd, lex->spname); sp= sp_find_routine(thd, TYPE_ENUM_PROCEDURE, lex->spname, &thd->sp_proc_cache, FALSE); else sp= sp_find_function(thd, lex->spname); sp= sp_find_routine(thd, TYPE_ENUM_FUNCTION, lex->spname, &thd->sp_func_cache, FALSE); if (!sp || !sp->show_routine_code(thd)) { /* We don't distinguish between errors for now */ Loading sql/sql_trigger.cc +1 −0 Original line number Diff line number Diff line Loading @@ -913,6 +913,7 @@ bool Table_triggers_list::check_n_load(THD *thd, const char *db, thd->db= save_db.str; thd->db_length= save_db.length; thd->lex= old_lex; thd->spcont= save_spcont; thd->variables.sql_mode= save_sql_mode; DBUG_RETURN(0); Loading Loading
mysql-test/r/sp.result +67 −67 Original line number Diff line number Diff line Loading @@ -3417,6 +3417,9 @@ Table Create Table tm1 CREATE TEMPORARY TABLE `tm1` ( `spv1` decimal(6,3) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop procedure bug12589_1| drop procedure bug12589_2| drop procedure bug12589_3| drop table if exists t3| drop procedure if exists bug7049_1| drop procedure if exists bug7049_2| Loading Loading @@ -3617,6 +3620,70 @@ count(*) drop table t3, t4| drop procedure bug14210| set @@session.max_heap_table_size=default| drop function if exists bug14723| drop procedure if exists bug14723| /*!50003 create function bug14723() returns bigint(20) main_loop: begin return 42; end */;; show create function bug14723;; Function sql_mode Create Function bug14723 CREATE FUNCTION `bug14723`() RETURNS bigint(20) main_loop: begin return 42; end select bug14723();; bug14723() 42 /*!50003 create procedure bug14723() main_loop: begin select 42; end */;; show create procedure bug14723;; Procedure sql_mode Create Procedure bug14723 CREATE PROCEDURE `bug14723`() main_loop: begin select 42; end call bug14723();; 42 42 drop function bug14723| drop procedure bug14723| create procedure bug14845() begin declare a char(255); declare done int default 0; declare c cursor for select count(*) from t1 where 1 = 0; declare continue handler for sqlstate '02000' set done = 1; open c; repeat fetch c into a; if not done then select a; end if; until done end repeat; close c; end| call bug14845()| a 0 drop procedure bug14845| drop procedure if exists bug13549_1| drop procedure if exists bug13549_2| CREATE PROCEDURE `bug13549_2`() begin call bug13549_1(); end| CREATE PROCEDURE `bug13549_1`() begin declare done int default 0; set done= not done; end| CALL bug13549_2()| drop procedure bug13549_2| drop procedure bug13549_1| drop function if exists bug10100f| drop procedure if exists bug10100p| drop procedure if exists bug10100t| Loading Loading @@ -3802,71 +3869,4 @@ drop procedure bug10100pd| drop procedure bug10100pc| drop view v1| drop table t3| drop function if exists bug14723| drop procedure if exists bug14723| /*!50003 create function bug14723() returns bigint(20) main_loop: begin return 42; end */;; show create function bug14723;; Function sql_mode Create Function bug14723 CREATE FUNCTION `bug14723`() RETURNS bigint(20) main_loop: begin return 42; end select bug14723();; bug14723() 42 /*!50003 create procedure bug14723() main_loop: begin select 42; end */;; show create procedure bug14723;; Procedure sql_mode Create Procedure bug14723 CREATE PROCEDURE `bug14723`() main_loop: begin select 42; end call bug14723();; 42 42 drop function bug14723| drop procedure bug14723| create procedure bug14845() begin declare a char(255); declare done int default 0; declare c cursor for select count(*) from t1 where 1 = 0; declare continue handler for sqlstate '02000' set done = 1; open c; repeat fetch c into a; if not done then select a; end if; until done end repeat; close c; end| call bug14845()| a 0 drop procedure bug14845| drop procedure bug12589_1| drop procedure bug12589_2| drop procedure bug12589_3| drop procedure if exists bug13549_1| drop procedure if exists bug13549_2| CREATE PROCEDURE `bug13549_2`() begin call bug13549_1(); end| CREATE PROCEDURE `bug13549_1`() begin declare done int default 0; set done= not done; end| CALL bug13549_2()| drop procedure bug13549_2| drop procedure bug13549_1| drop table t1,t2;
sql/item.cc +0 −1 Original line number Diff line number Diff line Loading @@ -921,7 +921,6 @@ Item_splocal::type() const DBUG_ASSERT(owner == thd->spcont->owner); return thd->spcont->get_item(m_offset)->type(); } } return NULL_ITEM; // Anything but SUBSELECT_ITEM } Loading
sql/sp.cc +4 −8 Original line number Diff line number Diff line Loading @@ -400,7 +400,7 @@ db_load_routine(THD *thd, int type, sp_name *name, sp_head **sphp, const char *definer, longlong created, longlong modified) { LEX *oldlex= thd->lex, newlex; sp_rcontext *save_spcont= ;thd->spcont; sp_rcontext *save_spcont= thd->spcont; String defstr; char olddb[128]; bool dbchanged; Loading Loading @@ -431,8 +431,6 @@ db_load_routine(THD *thd, int type, sp_name *name, sp_head **sphp, lex_start(thd, (uchar*)defstr.c_ptr(), defstr.length()); (*sphp)->set_definer((char*) definer, (uint) strlen(definer)); (*sphp)->set_info(created, modified, &chistics, sql_mode); thd->spcont= 0; if (yyparse(thd) || thd->is_fatal_error || newlex.sphead == NULL) { Loading @@ -446,18 +444,16 @@ db_load_routine(THD *thd, int type, sp_name *name, sp_head **sphp, else { if (dbchanged && (ret= mysql_change_db(thd, olddb, 1))) goto db_end; goto end; *sphp= newlex.sphead; (*sphp)->set_definer((char*) definer, (uint) strlen(definer)); (*sphp)->set_info((char *)definer, (uint)strlen(definer), created, modified, &chistics, sql_mode); (*sphp)->set_info(created, modified, &chistics, sql_mode); (*sphp)->optimize(); } db_end: end: thd->spcont= save_spcont; thd->variables.sql_mode= old_sql_mode; thd->variables.select_limit= select_limit; end: thd->lex= oldlex; return ret; } Loading
sql/sql_parse.cc +4 −2 Original line number Diff line number Diff line Loading @@ -4566,9 +4566,11 @@ mysql_execute_command(THD *thd) goto error; } if (lex->sql_command == SQLCOM_SHOW_PROC_CODE) sp= sp_find_procedure(thd, lex->spname); sp= sp_find_routine(thd, TYPE_ENUM_PROCEDURE, lex->spname, &thd->sp_proc_cache, FALSE); else sp= sp_find_function(thd, lex->spname); sp= sp_find_routine(thd, TYPE_ENUM_FUNCTION, lex->spname, &thd->sp_func_cache, FALSE); if (!sp || !sp->show_routine_code(thd)) { /* We don't distinguish between errors for now */ Loading
sql/sql_trigger.cc +1 −0 Original line number Diff line number Diff line Loading @@ -913,6 +913,7 @@ bool Table_triggers_list::check_n_load(THD *thd, const char *db, thd->db= save_db.str; thd->db_length= save_db.length; thd->lex= old_lex; thd->spcont= save_spcont; thd->variables.sql_mode= save_sql_mode; DBUG_RETURN(0); Loading