Commit 15dcc14c authored by cmiller@zippy.cornsilk.net's avatar cmiller@zippy.cornsilk.net

Merge zippy.cornsilk.net:/home/cmiller/work/mysql/bug36570/my50-bug36570

into  zippy.cornsilk.net:/home/cmiller/work/mysql/bug36570/my51-bug36570
parents 91f2db7c 573828aa
...@@ -303,9 +303,7 @@ SET @@session.sql_mode=0/*!*/; ...@@ -303,9 +303,7 @@ SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/; /*!\C latin1 *//*!*/;
SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/; SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/;
SET @@session.lc_time_names=0/*!*/; CREATE DEFINER=`root`@`localhost` PROCEDURE `p1`()
SET @@session.collation_database=DEFAULT/*!*/;
CREATE DEFINER=`root`@`localhost` procedure p1()
begin begin
select 1; select 1;
end end
......
...@@ -592,17 +592,19 @@ begin ...@@ -592,17 +592,19 @@ begin
select 1; select 1;
end| end|
create procedure ` mysqltestbug36570_p2`(/*!50001 a int*/)`label`: use mysql|
create procedure test.` mysqltestbug36570_p2`(/*!50001 a int*/)`label`:
begin begin
select a; select a;
end| end|
/*!50001 create function mysqltestbug36570_f1() */ /*!50001 create function test.mysqltestbug36570_f1() */
returns int returns int
/*!50001 deterministic */ /*!50001 deterministic */
begin begin
return 3; return 3;
end| end|
use test|
delimiter ;| delimiter ;|
...@@ -618,8 +620,8 @@ show function status like '%mysqltestbug36570%'; ...@@ -618,8 +620,8 @@ show function status like '%mysqltestbug36570%';
connection master; connection master;
use test; use test;
drop procedure if exists mysqltestbug36570_p1; drop procedure mysqltestbug36570_p1;
drop procedure if exists ` mysqltestbug36570_p2`; drop procedure ` mysqltestbug36570_p2`;
drop function if exists mysqltestbug36570_f1; drop function mysqltestbug36570_f1;
--echo End of 5.0 tests --echo End of 5.0 tests
--echo End of 5.1 tests --echo End of 5.1 tests
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
static bool static bool
create_string(THD *thd, String *buf, create_string(THD *thd, String *buf,
int sp_type, int sp_type,
const char *db, ulong dblen,
const char *name, ulong namelen, const char *name, ulong namelen,
const char *params, ulong paramslen, const char *params, ulong paramslen,
const char *returns, ulong returnslen, const char *returns, ulong returnslen,
...@@ -589,6 +590,7 @@ db_load_routine(THD *thd, int type, sp_name *name, sp_head **sphp, ...@@ -589,6 +590,7 @@ db_load_routine(THD *thd, int type, sp_name *name, sp_head **sphp,
if (!create_string(thd, &defstr, if (!create_string(thd, &defstr,
type, type,
NULL, 0,
name->m_name.str, name->m_name.length, name->m_name.str, name->m_name.length,
params, strlen(params), params, strlen(params),
returns, strlen(returns), returns, strlen(returns),
...@@ -922,6 +924,8 @@ sp_create_routine(THD *thd, int type, sp_head *sp) ...@@ -922,6 +924,8 @@ sp_create_routine(THD *thd, int type, sp_head *sp)
if (!create_string(thd, &log_query, if (!create_string(thd, &log_query,
sp->m_type, sp->m_type,
(sp->m_explicit_name ? sp->m_db.str : NULL),
(sp->m_explicit_name ? sp->m_db.length : 0),
sp->m_name.str, sp->m_name.length, sp->m_name.str, sp->m_name.length,
sp->m_params.str, sp->m_params.length, sp->m_params.str, sp->m_params.length,
retstr.c_ptr(), retstr.length(), retstr.c_ptr(), retstr.length(),
...@@ -2071,6 +2075,7 @@ sp_cache_routines_and_add_tables_for_triggers(THD *thd, LEX *lex, ...@@ -2071,6 +2075,7 @@ sp_cache_routines_and_add_tables_for_triggers(THD *thd, LEX *lex,
static bool static bool
create_string(THD *thd, String *buf, create_string(THD *thd, String *buf,
int type, int type,
const char *db, ulong dblen,
const char *name, ulong namelen, const char *name, ulong namelen,
const char *params, ulong paramslen, const char *params, ulong paramslen,
const char *returns, ulong returnslen, const char *returns, ulong returnslen,
...@@ -2080,7 +2085,7 @@ create_string(THD *thd, String *buf, ...@@ -2080,7 +2085,7 @@ create_string(THD *thd, String *buf,
const LEX_STRING *definer_host) const LEX_STRING *definer_host)
{ {
/* Make some room to begin with */ /* Make some room to begin with */
if (buf->alloc(100 + namelen + paramslen + returnslen + bodylen + if (buf->alloc(100 + dblen + 1 + namelen + paramslen + returnslen + bodylen +
chistics->comment.length + 10 /* length of " DEFINER= "*/ + chistics->comment.length + 10 /* length of " DEFINER= "*/ +
USER_HOST_BUFF_SIZE)) USER_HOST_BUFF_SIZE))
return FALSE; return FALSE;
...@@ -2091,6 +2096,11 @@ create_string(THD *thd, String *buf, ...@@ -2091,6 +2096,11 @@ create_string(THD *thd, String *buf,
buf->append(STRING_WITH_LEN("FUNCTION ")); buf->append(STRING_WITH_LEN("FUNCTION "));
else else
buf->append(STRING_WITH_LEN("PROCEDURE ")); buf->append(STRING_WITH_LEN("PROCEDURE "));
if (dblen > 0)
{
append_identifier(thd, buf, db, dblen);
buf->append('.');
}
append_identifier(thd, buf, name, namelen); append_identifier(thd, buf, name, namelen);
buf->append('('); buf->append('(');
buf->append(params, paramslen); buf->append(params, paramslen);
......
...@@ -561,6 +561,8 @@ sp_head::init(LEX *lex) ...@@ -561,6 +561,8 @@ sp_head::init(LEX *lex)
m_qname.str= NULL; m_qname.str= NULL;
m_qname.length= 0; m_qname.length= 0;
m_explicit_name= false;
m_db.str= NULL; m_db.str= NULL;
m_db.length= 0; m_db.length= 0;
...@@ -603,6 +605,8 @@ sp_head::init_sp_name(THD *thd, sp_name *spname) ...@@ -603,6 +605,8 @@ sp_head::init_sp_name(THD *thd, sp_name *spname)
m_name.str= strmake_root(thd->mem_root, spname->m_name.str, m_name.str= strmake_root(thd->mem_root, spname->m_name.str,
spname->m_name.length); spname->m_name.length);
m_explicit_name= spname->m_explicit_name;
if (spname->m_qname.length == 0) if (spname->m_qname.length == 0)
spname->init_qname(thd); spname->init_qname(thd);
......
...@@ -180,6 +180,7 @@ class sp_head :private Query_arena ...@@ -180,6 +180,7 @@ class sp_head :private Query_arena
st_sp_chistics *m_chistics; st_sp_chistics *m_chistics;
ulong m_sql_mode; ///< For SHOW CREATE and execution ulong m_sql_mode; ///< For SHOW CREATE and execution
LEX_STRING m_qname; ///< db.name LEX_STRING m_qname; ///< db.name
bool m_explicit_name; ///< Prepend the db name? */
/** /**
Key representing routine in the set of stored routines used by statement. Key representing routine in the set of stored routines used by statement.
[routine_type]db.name [routine_type]db.name
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment