summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/r/sp.result134
-rw-r--r--sql/item.cc1
-rw-r--r--sql/sp.cc12
-rw-r--r--sql/sql_parse.cc6
-rw-r--r--sql/sql_trigger.cc1
5 files changed, 76 insertions, 78 deletions
diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result
index b1216f94245..c3b4039d12d 100644
--- a/mysql-test/r/sp.result
+++ b/mysql-test/r/sp.result
@@ -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|
@@ -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|
@@ -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;
diff --git a/sql/item.cc b/sql/item.cc
index b7983b13766..6d5855cd0ca 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -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
}
diff --git a/sql/sp.cc b/sql/sp.cc
index f98795c54a5..8991cc78b5e 100644
--- a/sql/sp.cc
+++ b/sql/sp.cc
@@ -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;
@@ -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)
{
@@ -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;
}
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 437e910d592..d06cceba77b 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -4566,9 +4566,11 @@ end_with_restore_list:
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 */
diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc
index 224fa332d67..296b55679a3 100644
--- a/sql/sql_trigger.cc
+++ b/sql/sql_trigger.cc
@@ -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);