List:Commits« Previous MessageNext Message »
From:kpettersson Date:October 3 2006 6:10pm
Subject:bk commit into 5.0 tree (Kristofer.Pettersson:1.2273) 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-10-03 18:10:20+02:00, Kristofer.Pettersson@naruto. +3 -0
  Bug#22043 Odd casting with date + INTERVAL arithmetic
  - DROP PROCEDURE was writing the global database context instead of the 
    context specified in the statement.
  - A function for changing database context for the current statement
    was added.
  - Code formatting was improved.

  mysql-test/r/binlog-sp.result@stripped, 2006-10-03 18:08:58+02:00,
Kristofer.Pettersson@naruto. +16 -0
    - Added test results
    

  mysql-test/r/binlog-sp.result@stripped, 2006-10-03 18:08:58+02:00,
Kristofer.Pettersson@naruto. +0 -0

  mysql-test/t/binlog-sp.test@stripped, 2006-10-03 18:08:58+02:00, Kristofer.Pettersson@naruto.
+14 -0
    - Added test case

  mysql-test/t/binlog-sp.test@stripped, 2006-10-03 18:08:58+02:00, Kristofer.Pettersson@naruto.
+0 -0

  sql/sql_parse.cc@stripped, 2006-10-03 18:08:57+02:00, Kristofer.Pettersson@naruto. +90 -68
    - Added sp_use_new_db because we want to change the current database
      context based on the current statement.
    - Cleaned up the code style.

# 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.573/sql/sql_parse.cc	2006-10-03 18:10:40 +02:00
+++ 1.574/sql/sql_parse.cc	2006-10-03 18:10:40 +02:00
@@ -4575,98 +4575,120 @@
     }
   case SQLCOM_DROP_PROCEDURE:
   case SQLCOM_DROP_FUNCTION:
-    {
+    {      
       int result;
       int type= (lex->sql_command == SQLCOM_DROP_PROCEDURE ?
                  TYPE_ENUM_PROCEDURE : TYPE_ENUM_FUNCTION);
-
+      
       result= sp_routine_exists_in_table(thd, type, lex->spname);
-      mysql_reset_errors(thd, 0);
+      mysql_reset_errors(thd, 0); 
       if (result == SP_OK)
       {
+        char old_db_buf[NAME_BYTE_LEN+1];
+        LEX_STRING old_db= { old_db_buf, sizeof(old_db_buf) };
+        bool dbchanged;
         char *db= lex->spname->m_db.str;
-	char *name= lex->spname->m_name.str;
-
-	if (check_routine_access(thd, ALTER_PROC_ACL, db, name,
+	      char *name= lex->spname->m_name.str;
+        /*
+          Set the current database based on the arguments in this statment.
+          This will make sure that the replication of this statement works
+          if --replicate-do-db is used. 
+         */
+        if ((result= sp_use_new_db(thd, lex->spname->m_db, &old_db, 0,
&dbchanged)))
+        {
+            result= SP_NO_DB_ERROR;
+            goto error;
+        }
+	      if (check_routine_access(thd, ALTER_PROC_ACL, db, name,
                                  lex->sql_command == SQLCOM_DROP_PROCEDURE, 0))
+        {   
           goto error;
+        }
 
         if (end_active_trans(thd)) 
           goto error;
 #ifndef NO_EMBEDDED_ACCESS_CHECKS
-	if (sp_automatic_privileges && !opt_noacl &&
-	    sp_revoke_privileges(thd, db, name, 
-                                 lex->sql_command == SQLCOM_DROP_PROCEDURE))
-	{
-	  push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 
-		       ER_PROC_AUTO_REVOKE_FAIL,
-		       ER(ER_PROC_AUTO_REVOKE_FAIL));
-	}
+	      if (sp_automatic_privileges && !opt_noacl &&
+	          sp_revoke_privileges(thd, db, name, 
+            lex->sql_command == SQLCOM_DROP_PROCEDURE))
+	      {
+	        push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 
+		             ER_PROC_AUTO_REVOKE_FAIL,
+		             ER(ER_PROC_AUTO_REVOKE_FAIL));
+	      }
 #endif
-	if (lex->sql_command == SQLCOM_DROP_PROCEDURE)
-	  result= sp_drop_procedure(thd, lex->spname);
-	else
-	  result= sp_drop_function(thd, lex->spname);
-      }
-      else
+	      if (lex->sql_command == SQLCOM_DROP_PROCEDURE)
+	        result= sp_drop_procedure(thd, lex->spname);
+	      else
+	        result= sp_drop_function(thd, lex->spname);
+
+      } // end if result == SP_OK
+      else // if result != SP_OK
       {
 #ifdef HAVE_DLOPEN
-	if (lex->sql_command == SQLCOM_DROP_FUNCTION)
-	{
-          udf_func *udf = find_udf(lex->spname->m_name.str,
-                                   lex->spname->m_name.length);
-          if (udf)
-          {
-	    if (check_access(thd, DELETE_ACL, "mysql", 0, 1, 0, 0))
-	      goto error;
-	    if (!(res = mysql_drop_function(thd, &lex->spname->m_name)))
-	    {
-	      send_ok(thd);
-	      break;
-	    }
-	  }
-	}
+	        if (lex->sql_command == SQLCOM_DROP_FUNCTION)
+	        {
+            udf_func *udf = find_udf(lex->spname->m_name.str,
+                                      lex->spname->m_name.length);
+            if (udf)
+            {
+	            if (check_access(thd, DELETE_ACL, "mysql", 0, 1, 0, 0))
+	              goto error;
+	            if (!(res = mysql_drop_function(thd, &lex->spname->m_name)))
+	            {
+	              send_ok(thd);
+	              break;
+	            }
+	          }
+	        }
 #endif
-	if (lex->spname->m_db.str)
-	  result= SP_KEY_NOT_FOUND;
-	else
-	{
-	  my_message(ER_NO_DB_ERROR, ER(ER_NO_DB_ERROR), MYF(0));
-	  goto error;
-	}
+	        if (lex->spname->m_db.str)
+	          result= SP_KEY_NOT_FOUND;
+	        else
+	        {
+	          my_message(ER_NO_DB_ERROR, ER(ER_NO_DB_ERROR), MYF(0));
+	          goto error;
+	        }
       }
       res= result;
       switch (result)
       {
-      case SP_OK:
-        if (mysql_bin_log.is_open())
-        {
-          thd->clear_error();
-          Query_log_event qinfo(thd, thd->query, thd->query_length, 0, FALSE);
-          mysql_bin_log.write(&qinfo);
-        }
-	send_ok(thd);
-	break;
-      case SP_KEY_NOT_FOUND:
-	if (lex->drop_if_exists)
-	{
-	  push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
-			      ER_SP_DOES_NOT_EXIST, ER(ER_SP_DOES_NOT_EXIST),
-			      SP_COM_STRING(lex), lex->spname->m_name.str);
-	  res= FALSE;
-	  send_ok(thd);
-	  break;
-	}
-	my_error(ER_SP_DOES_NOT_EXIST, MYF(0),
-                 SP_COM_STRING(lex), lex->spname->m_qname.str);
-	goto error;
-      default:
-	my_error(ER_SP_DROP_FAILED, MYF(0),
-                 SP_COM_STRING(lex), lex->spname->m_qname.str);
-	goto error;
+        case SP_OK:
+          /*
+             Log a successful query result to the binlog.
+          */
+          if (mysql_bin_log.is_open())
+          {
+            thd->clear_error();
+            Query_log_event qinfo(thd, thd->query, thd->query_length, 0, FALSE);
+            mysql_bin_log.write(&qinfo);
+          }
+	        send_ok(thd);
+	        break;
+        case SP_KEY_NOT_FOUND:
+	        if (lex->drop_if_exists)
+	        {
+	          push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
+			              ER_SP_DOES_NOT_EXIST, ER(ER_SP_DOES_NOT_EXIST),
+			              SP_COM_STRING(lex), lex->spname->m_name.str);
+	          res= FALSE;
+	          send_ok(thd);
+	          break;
+	        }
+	        my_error(ER_SP_DOES_NOT_EXIST, MYF(0),
+                         SP_COM_STRING(lex), lex->spname->m_qname.str);
+	        goto error;
+        default:
+	        my_error(ER_SP_DROP_FAILED, MYF(0),
+                         SP_COM_STRING(lex), lex->spname->m_qname.str);
+	        goto error;
       }
+      /*
+         We are done with SQLCOM_DROP_PROCEDURE
+       */
       break;
     }
+
   case SQLCOM_SHOW_CREATE_PROC:
     {
       if (lex->spname->m_name.length > NAME_LEN)
--- New file ---
+++ mysql-test/r/binlog-sp.result	06/10/03 18:08:58
use mysql;
create procedure test.proc1() begin end;
drop procedure if exists proc1;
Warnings:
Note	1305	PROCEDURE proc1 does not exist
drop procedure if exists test.proc1;
use test;
create procedure proc1() begin end;
drop procedure if exists proc1;
show binlog events in 'master-bin.000001' from 2;
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
master-bin.000001	4	Format_desc	1	98	Server ver: 5.0.26-debug-log, Binlog ver: 4
master-bin.000001	98	Query	1	227	use `test`; CREATE DEFINER=`root`@`localhost` procedure
test.proc1() begin end
master-bin.000001	227	Query	1	325	use `test`; drop procedure if exists test.proc1
master-bin.000001	325	Query	1	449	use `test`; CREATE DEFINER=`root`@`localhost` procedure
proc1() begin end
master-bin.000001	449	Query	1	542	use `test`; drop procedure if exists proc1

--- New file ---
+++ mysql-test/t/binlog-sp.test	06/10/03 18:08:58
#
# Bug#22043 MySQL don't add "USE <DATABASE>" before "DROP PROCEDURE IF EXISTS"
#
use mysql;
create procedure test.proc1() begin end;
drop procedure if exists proc1;
drop procedure if exists test.proc1;

use test;
create procedure proc1() begin end;
drop procedure if exists proc1;

show binlog events in 'master-bin.000001' from 2;




Thread
bk commit into 5.0 tree (Kristofer.Pettersson:1.2273) BUG#22043kpettersson3 Oct