List:Commits« Previous MessageNext Message »
From:kpettersson Date:November 23 2006 4:50pm
Subject:bk commit into 5.0 tree (Kristofer.Pettersson:1.2274) BUG#22043
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of Kristofer Pettersson. When Kristofer Pettersson 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, 2006-11-23 17:50:28+01:00, Kristofer.Pettersson@naruto. +4 -0
  Bug#22043: MySQL don't add "USE <DATABASE>" before "DROP PROCEDURE IF EXISTS"
  
  - CREATE PROCEDURE stores database name based on query context instead
    of 'current database' as set by 'USE' according to manual.
    The bugreporter interpret the filtering statements as a bug for 
    DROP PROCEDURE based on this behavior.
  - Removed the code which changes db context.
  - Added code to check that a valid db was supplied.

  mysql-test/r/rpl_sp.result@stripped, 2006-11-23 17:50:20+01:00, Kristofer.Pettersson@naruto. +25 -0
    - Added test case (result)

  mysql-test/t/rpl_sp.test@stripped, 2006-11-23 17:50:20+01:00, Kristofer.Pettersson@naruto. +23 -0
    - Added test case

  sql/sp.cc@stripped, 2006-11-23 17:50:21+01:00, Kristofer.Pettersson@naruto. +0 -9
    - Removed code for changing current db context.

  sql/sql_parse.cc@stripped, 2006-11-23 17:50:21+01:00, Kristofer.Pettersson@naruto. +24 -0
    - Added code to check if a valid db was supplied.

# 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:	Kristofer.Pettersson
# Host:	naruto.
# Root:	C:/cpp/bug22043/my50-bug22043

--- 1.574/sql/sql_parse.cc	2006-11-23 17:50:48 +01:00
+++ 1.575/sql/sql_parse.cc	2006-11-23 17:50:48 +01:00
@@ -4222,6 +4222,30 @@ end_with_restore_list:
     DBUG_ASSERT(lex->sphead != 0);
     DBUG_ASSERT(lex->sphead->m_db.str); /* Must be initialized in the parser */
 
+    /*
+      Verify that the database name is allowed, optionally
+      lowercase it.
+    */
+    if (check_db_name(lex->sphead->m_db.str))
+    {
+      my_error(ER_WRONG_DB_NAME, MYF(0), lex->sphead->m_db.str);
+      delete lex->sphead;
+      lex->sphead= 0;
+      goto error;
+    }
+
+    /*
+      Check that a database with this name
+      exists.
+    */
+    if (check_db_dir_existence(lex->sphead->m_db.str))
+    {
+      my_error(ER_BAD_DB_ERROR, MYF(0), lex->sphead->m_db.str);
+      delete lex->sphead;
+      lex->sphead= 0;
+      goto error;
+    }
+
     if (check_access(thd, CREATE_PROC_ACL, lex->sphead->m_db.str, 0, 0, 0,
                      is_schema_db(lex->sphead->m_db.str)))
     {

--- 1.18/mysql-test/r/rpl_sp.result	2006-11-23 17:50:48 +01:00
+++ 1.19/mysql-test/r/rpl_sp.result	2006-11-23 17:50:48 +01:00
@@ -465,3 +465,28 @@ RETURN 0
 DROP PROCEDURE p1;
 DROP FUNCTION f1;
 drop table t1;
+drop database if exists mysqltest;
+drop database if exists mysqltest2;
+create database mysqltest;
+create database mysqltest2;
+use mysqltest2;
+create table t ( t integer );
+create procedure mysqltest.test() begin end;
+insert into t values ( 1 );
+show binlog events in 'master-bin.000001' from 8186;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	8186	Query	1	8317	use `test`; CREATE DEFINER=`root`@`localhost` FUNCTION f1() RETURNS INT RETURN 0
+master-bin.000001	8317	Query	1	8397	use `test`; DROP PROCEDURE p1
+master-bin.000001	8397	Query	1	8476	use `test`; DROP FUNCTION f1
+master-bin.000001	8476	Query	1	8552	use `test`; drop table t1
+master-bin.000001	8552	Query	1	8653	drop database if exists mysqltest
+master-bin.000001	8653	Query	1	8756	drop database if exists mysqltest2
+master-bin.000001	8756	Query	1	8849	create database mysqltest
+master-bin.000001	8849	Query	1	8944	create database mysqltest2
+master-bin.000001	8944	Query	1	9041	use `mysqltest2`; create table t ( t integer )
+master-bin.000001	9041	Query	1	9180	use `mysqltest2`; CREATE DEFINER=`root`@`localhost` procedure mysqltest.test() begin end
+master-bin.000001	9180	Query	1	9275	use `mysqltest2`; insert into t values ( 1 )
+create procedure `\\`.test() begin end;
+ERROR 42000: Incorrect database name '\\'
+drop database mysqltest;
+drop database mysqltest2;

--- 1.13/mysql-test/t/rpl_sp.test	2006-11-23 17:50:49 +01:00
+++ 1.14/mysql-test/t/rpl_sp.test	2006-11-23 17:50:49 +01:00
@@ -519,3 +519,26 @@ DROP FUNCTION f1;
 connection master;
 drop table t1;
 sync_slave_with_master;
+
+#
+# Bug22043: MySQL don't add "USE <DATABASE>" before "DROP PROCEDURE IF EXISTS"
+#
+connection master;
+--disable_warnings
+drop database if exists mysqltest;
+drop database if exists mysqltest2;
+--enable_warnings
+create database mysqltest;
+create database mysqltest2;
+use mysqltest2;
+create table t ( t integer );
+create procedure mysqltest.test() begin end;
+insert into t values ( 1 );
+show binlog events in 'master-bin.000001' from 8186;
+--error ER_WRONG_DB_NAME
+create procedure `\\`.test() begin end;
+# Clean up
+drop database mysqltest;
+drop database mysqltest2;
+
+

--- 1.117/sql/sp.cc	2006-11-23 17:50:49 +01:00
+++ 1.118/sql/sp.cc	2006-11-23 17:50:49 +01:00
@@ -513,17 +513,10 @@ db_create_routine(THD *thd, int type, sp
   char definer[USER_HOST_BUFF_SIZE];
   char old_db_buf[NAME_BYTE_LEN+1];
   LEX_STRING old_db= { old_db_buf, sizeof(old_db_buf) };
-  bool dbchanged;
   DBUG_ENTER("db_create_routine");
   DBUG_PRINT("enter", ("type: %d name: %.*s",type,sp->m_name.length,
                        sp->m_name.str));
 
-  if ((ret= sp_use_new_db(thd, sp->m_db, &old_db, 0, &dbchanged)))
-  {
-    ret= SP_NO_DB_ERROR;
-    goto done;
-  }
-
   if (!(table= open_proc_table_for_update(thd)))
     ret= SP_OPEN_TABLE_FAILED;
   else
@@ -648,8 +641,6 @@ db_create_routine(THD *thd, int type, sp
 
 done:
   close_thread_tables(thd);
-  if (dbchanged)
-    (void) mysql_change_db(thd, old_db.str, 1);
   DBUG_RETURN(ret);
 }
 


Thread
bk commit into 5.0 tree (Kristofer.Pettersson:1.2274) BUG#22043kpettersson23 Nov