MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Chad MILLER Date:May 15 2008 11:09pm
Subject:bk commit into 5.0 tree (cmiller:1.2625) BUG#36570
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of cmiller.  When cmiller 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@stripped, 2008-05-15 19:09:37-04:00, cmiller@stripped +5 -0
  Update for Bug#36570.  Qualify routine names with db name when
  writing to the binlog ONLY if the source text is qualified.

  mysql-test/r/rpl_sp.result@stripped, 2008-05-15 19:09:36-04:00, cmiller@stripped +8 -6
    Qualify routine names with DB if qualified in query.  Offsets change also.

  mysql-test/t/rpl_sp.test@stripped, 2008-05-15 19:09:36-04:00, cmiller@stripped +7 -5
    Use different db to show qualification works.  Qualify routine names
    with DB if qualified in query.

  sql/sp.cc@stripped, 2008-05-15 19:09:36-04:00, cmiller@stripped +23 -13
    Make the db name part of the CREATE string if it is specified.
    
    Specify it in part of writing to the binlog when creating a new
    routine.

  sql/sp_head.cc@stripped, 2008-05-15 19:09:36-04:00, cmiller@stripped +4 -0
    Set the sp_head m_explicit_name member as the sp_name member is set.  
    We can not peek at this later, as the sp_name is gone by then.

  sql/sp_head.h@stripped, 2008-05-15 19:09:36-04:00, cmiller@stripped +1 -0
    Add a member to track whether the name is qualified with the 
    database.

diff -Nrup a/mysql-test/r/rpl_sp.result b/mysql-test/r/rpl_sp.result
--- a/mysql-test/r/rpl_sp.result	2008-05-14 19:23:52 -04:00
+++ b/mysql-test/r/rpl_sp.result	2008-05-15 19:09:36 -04:00
@@ -516,7 +516,7 @@ master-bin.000001	#	Query	1	#	drop datab
 master-bin.000001	#	Query	1	#	create database mysqltest
 master-bin.000001	#	Query	1	#	create database mysqltest2
 master-bin.000001	#	Query	1	#	use `mysqltest2`; create table t ( t integer )
-master-bin.000001	#	Query	1	#	use `mysqltest2`; CREATE DEFINER=`root`@`localhost` PROCEDURE `test`()
+master-bin.000001	#	Query	1	#	use `mysqltest2`; CREATE DEFINER=`root`@`localhost` PROCEDURE `mysqltest`.`test`()
 begin end
 master-bin.000001	#	Query	1	#	use `mysqltest2`; insert into t values ( 1 )
 master-bin.000001	#	Query	1	#	use `mysqltest2`; CREATE DEFINER=`root`@`localhost` FUNCTION `f1`() RETURNS int(11)
@@ -534,16 +534,18 @@ use test;
 begin
 select 1;
 end|
-create procedure ` mysqltestbug36570_p2`(/*!50001 a int*/)`label`:
+use mysql|
+create procedure test.` mysqltestbug36570_p2`(/*!50001 a int*/)`label`:
 begin
 select a;
 end|
-/*!50001 create function mysqltestbug36570_f1() */
+/*!50001 create function test.mysqltestbug36570_f1() */
 returns int
 /*!50001 deterministic */
 begin
 return 3;
 end|
+use test|
 show procedure status like '%mysqltestbug36570%';
 Db	Name	Type	Definer	Modified	Created	Security_type	Comment
 test	 mysqltestbug36570_p2	PROCEDURE	root@localhost	t	t	DEFINER	
@@ -562,6 +564,6 @@ show function status like '%mysqltestbug
 Db	Name	Type	Definer	Modified	Created	Security_type	Comment
 test	mysqltestbug36570_f1	FUNCTION	root@localhost	t	t	DEFINER	
 use test;
-drop procedure if exists mysqltestbug36570_p1;
-drop procedure if exists ` mysqltestbug36570_p2`;
-drop function if exists mysqltestbug36570_f1;
+drop procedure mysqltestbug36570_p1;
+drop procedure ` mysqltestbug36570_p2`;
+drop function mysqltestbug36570_f1;
diff -Nrup a/mysql-test/t/rpl_sp.test b/mysql-test/t/rpl_sp.test
--- a/mysql-test/t/rpl_sp.test	2008-05-14 19:23:52 -04:00
+++ b/mysql-test/t/rpl_sp.test	2008-05-15 19:09:36 -04:00
@@ -590,17 +590,19 @@ begin
 	select 1;
 end|
 
-create procedure ` mysqltestbug36570_p2`(/*!50001 a int*/)`label`:
+use mysql|
+create procedure test.` mysqltestbug36570_p2`(/*!50001 a int*/)`label`:
 begin
 	select a;
 end|
 
-/*!50001 create function mysqltestbug36570_f1() */
+/*!50001 create function test.mysqltestbug36570_f1() */
 	returns int
 	/*!50001 deterministic */
 begin
 	return 3;
 end|
+use test|
 
 delimiter ;|
 
@@ -616,6 +618,6 @@ show function status like '%mysqltestbug
 
 connection master;
 use test;
-drop procedure if exists mysqltestbug36570_p1;
-drop procedure if exists ` mysqltestbug36570_p2`;
-drop function if exists mysqltestbug36570_f1;
+drop procedure mysqltestbug36570_p1;
+drop procedure ` mysqltestbug36570_p2`;
+drop function mysqltestbug36570_f1;
diff -Nrup a/sql/sp.cc b/sql/sp.cc
--- a/sql/sp.cc	2008-05-14 19:23:52 -04:00
+++ b/sql/sp.cc	2008-05-15 19:09:36 -04:00
@@ -25,6 +25,7 @@
 static bool
 create_string(THD *thd, String *buf,
 	      int sp_type,
+	      const char *db, ulong dblen,
 	      const char *name, ulong namelen,
 	      const char *params, ulong paramslen,
 	      const char *returns, ulong returnslen,
@@ -426,12 +427,13 @@ db_load_routine(THD *thd, int type, sp_n
    */
 
   if (!create_string(thd, &defstr,
-		     type,
-		     name->m_name.str, name->m_name.length,
-		     params, strlen(params),
-		     returns, strlen(returns),
-		     body, strlen(body),
-		     &chistics, &definer_user_name, &definer_host_name))
+                     type,
+                     NULL, 0,
+                     name->m_name.str, name->m_name.length,
+                     params, strlen(params),
+                     returns, strlen(returns),
+                     body, strlen(body),
+                     &chistics, &definer_user_name, &definer_host_name))
   {
     ret= SP_INTERNAL_ERROR;
     goto end;
@@ -628,6 +630,8 @@ db_create_routine(THD *thd, int type, sp
 
       if (!create_string(thd, &log_query,
                          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_params.str, sp->m_params.length,
                          retstr.c_ptr(), retstr.length(),
@@ -1803,17 +1807,18 @@ sp_cache_routines_and_add_tables_for_tri
  */
 static bool
 create_string(THD *thd, String *buf,
-	      int type,
-	      const char *name, ulong namelen,
-	      const char *params, ulong paramslen,
-	      const char *returns, ulong returnslen,
-	      const char *body, ulong bodylen,
-	      st_sp_chistics *chistics,
+              int type,
+              const char *db, ulong dblen,
+              const char *name, ulong namelen,
+              const char *params, ulong paramslen,
+              const char *returns, ulong returnslen,
+              const char *body, ulong bodylen,
+              st_sp_chistics *chistics,
               const LEX_STRING *definer_user,
               const LEX_STRING *definer_host)
 {
   /* 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= "*/ +
                  USER_HOST_BUFF_SIZE))
     return FALSE;
@@ -1824,6 +1829,11 @@ create_string(THD *thd, String *buf,
     buf->append(STRING_WITH_LEN("FUNCTION "));
   else
     buf->append(STRING_WITH_LEN("PROCEDURE "));
+  if (dblen > 0)
+  {
+    append_identifier(thd, buf, db, dblen);
+    buf->append('.');
+  }
   append_identifier(thd, buf, name, namelen);
   buf->append('(');
   buf->append(params, paramslen);
diff -Nrup a/sql/sp_head.cc b/sql/sp_head.cc
--- a/sql/sp_head.cc	2008-01-23 16:04:18 -05:00
+++ b/sql/sp_head.cc	2008-05-15 19:09:36 -04:00
@@ -522,6 +522,8 @@ sp_head::init(LEX *lex)
   m_qname.str= NULL;
   m_qname.length= 0;
 
+  m_explicit_name= false;
+
   m_db.str= NULL;
   m_db.length= 0;
 
@@ -563,6 +565,8 @@ sp_head::init_sp_name(THD *thd, sp_name 
   m_name.length= spname->m_name.length;
   m_name.str= strmake_root(thd->mem_root, spname->m_name.str,
                            spname->m_name.length);
+
+  m_explicit_name= spname->m_explicit_name;
 
   if (spname->m_qname.length == 0)
     spname->init_qname(thd);
diff -Nrup a/sql/sp_head.h b/sql/sp_head.h
--- a/sql/sp_head.h	2008-01-23 15:26:38 -05:00
+++ b/sql/sp_head.h	2008-05-15 19:09:36 -04:00
@@ -121,6 +121,7 @@ public:
   st_sp_chistics *m_chistics;
   ulong m_sql_mode;		// For SHOW CREATE and execution
   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.
     [routine_type]db.name\0
Thread
bk commit into 5.0 tree (cmiller:1.2625) BUG#36570Chad MILLER16 May