List:Commits« Previous MessageNext Message »
From:Chad MILLER Date:October 11 2006 4:58pm
Subject:bk commit into 5.1 tree (cmiller:1.2341)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 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, 2006-10-11 10:58:29-04:00, cmiller@stripped +11 -0
  Merge zippy.cornsilk.net:/home/cmiller/work/mysql/bug14262/my50-bug14262
  into  zippy.cornsilk.net:/home/cmiller/work/mysql/bug14262/my51-bug14262
  MERGE: 1.1810.2159.2

  BitKeeper/deleted/.del-collapsed~66d21d0d6c19df3d@stripped, 2006-10-10 16:39:05-04:00,
cmiller@stripped +0 -0
    Delete: BitKeeper/etc/collapsed

  BitKeeper/etc/collapsed@stripped, 2006-10-10 16:39:05-04:00, cmiller@stripped +5
-0
    'Auto converge'

  BitKeeper/etc/collapsed@stripped, 2006-10-10 16:39:05-04:00, cmiller@stripped +0
-0
    Rename: BitKeeper/deleted/.del-collapsed -> BitKeeper/etc/collapsed

  BitKeeper/deleted/.del-collapsed@stripped, 2006-10-10 16:39:04-04:00,
cmiller@stripped +0 -0
    'Auto converge rename'

  sql/sp.cc@stripped, 2006-10-10 16:39:11-04:00, cmiller@stripped +0 -0
    Auto merged
    MERGE: 1.82.21.1

  sql/sql_acl.cc@stripped, 2006-10-10 16:39:11-04:00, cmiller@stripped +0 -0
    Auto merged
    MERGE: 1.128.40.1

  sql/sql_db.cc@stripped, 2006-10-10 16:39:11-04:00, cmiller@stripped +0 -0
    Auto merged
    MERGE: 1.120.6.1

  sql/sql_parse.cc@stripped, 2006-10-11 10:58:28-04:00, cmiller@stripped +0 -0
    Manual merge.
    MERGE: 1.426.108.1

  sql/sql_table.cc@stripped, 2006-10-11 10:58:28-04:00, cmiller@stripped +1 -5
    Manual merge.
    MERGE: 1.239.34.1

  sql/sql_trigger.cc@stripped, 2006-10-10 16:39:12-04:00, cmiller@stripped +0 -0
    Auto merged
    MERGE: 1.35.11.1

  sql/sql_view.cc@stripped, 2006-10-11 10:58:28-04:00, cmiller@stripped +0 -0
    Manual merge.
    MERGE: 1.78.10.1

  sql/sql_view.h@stripped, 2006-10-10 16:39:12-04:00, cmiller@stripped +0 -0
    Auto merged
    MERGE: 1.11.2.1

  vio/viosocket.c@stripped, 2006-10-11 10:58:28-04:00, cmiller@stripped +0 -7
    Use local.
    MERGE: 1.37.4.1

# 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:	cmiller
# Host:	zippy.cornsilk.net
# Root:	/home/cmiller/work/mysql/bug14262/my51-bug14262/RESYNC

--- 1.218/sql/sql_acl.cc	2006-10-11 10:58:35 -04:00
+++ 1.219/sql/sql_acl.cc	2006-10-11 10:58:35 -04:00
@@ -3140,9 +3140,22 @@ bool mysql_table_grant(THD *thd, TABLE_L
   grant_option=TRUE;
   thd->mem_root= old_root;
   pthread_mutex_unlock(&acl_cache->lock);
+
+  if (!result) /* success */
+  {
+    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);
+    }
+  }
+
   rw_unlock(&LOCK_grant);
-  if (!result)
+
+  if (!result) /* success */
     send_ok(thd);
+
   /* Tables are automatically closed */
   DBUG_RETURN(result);
 }
@@ -3294,9 +3307,21 @@ bool mysql_routine_grant(THD *thd, TABLE
   grant_option=TRUE;
   thd->mem_root= old_root;
   pthread_mutex_unlock(&acl_cache->lock);
+  if (!result && !no_error)
+  {
+    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);
+    }
+  }
+
   rw_unlock(&LOCK_grant);
+
   if (!result && !no_error)
     send_ok(thd);
+
   /* Tables are automatically closed */
   DBUG_RETURN(result);
 }
@@ -3394,11 +3419,23 @@ bool mysql_grant(THD *thd, const char *d
     }
   }
   VOID(pthread_mutex_unlock(&acl_cache->lock));
+
+  if (!result)
+  {
+    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);
+    }
+  }
+
   rw_unlock(&LOCK_grant);
   close_thread_tables(thd);
 
   if (!result)
     send_ok(thd);
+
   DBUG_RETURN(result);
 }
 
@@ -5398,6 +5435,13 @@ bool mysql_create_user(THD *thd, List <L
   }
 
   VOID(pthread_mutex_unlock(&acl_cache->lock));
+
+  if (mysql_bin_log.is_open())
+  {
+    Query_log_event qinfo(thd, thd->query, thd->query_length, 0, FALSE);
+    mysql_bin_log.write(&qinfo);
+  }
+
   rw_unlock(&LOCK_grant);
   close_thread_tables(thd);
   if (result)
@@ -5454,6 +5498,13 @@ bool mysql_drop_user(THD *thd, List <LEX
   rebuild_check_host();
 
   VOID(pthread_mutex_unlock(&acl_cache->lock));
+
+  if (mysql_bin_log.is_open())
+  {
+    Query_log_event qinfo(thd, thd->query, thd->query_length, 0, FALSE);
+    mysql_bin_log.write(&qinfo);
+  }
+
   rw_unlock(&LOCK_grant);
   close_thread_tables(thd);
   if (result)
@@ -5523,6 +5574,13 @@ bool mysql_rename_user(THD *thd, List <L
   rebuild_check_host();
 
   VOID(pthread_mutex_unlock(&acl_cache->lock));
+
+  if (mysql_bin_log.is_open())
+  {
+    Query_log_event qinfo(thd, thd->query, thd->query_length, 0, FALSE);
+    mysql_bin_log.write(&qinfo);
+  }
+
   rw_unlock(&LOCK_grant);
   close_thread_tables(thd);
   if (result)
@@ -5697,6 +5755,13 @@ bool mysql_revoke_all(THD *thd,  List <L
   }
 
   VOID(pthread_mutex_unlock(&acl_cache->lock));
+
+  if (mysql_bin_log.is_open())
+  {
+    Query_log_event qinfo(thd, thd->query, thd->query_length, 0, FALSE);
+    mysql_bin_log.write(&qinfo);
+  }
+
   rw_unlock(&LOCK_grant);
   close_thread_tables(thd);
 

--- 1.141/sql/sql_db.cc	2006-10-11 10:58:35 -04:00
+++ 1.142/sql/sql_db.cc	2006-10-11 10:58:35 -04:00
@@ -705,6 +705,7 @@ bool mysql_create_db(THD *thd, char *db,
       qinfo.db     = db;
       qinfo.db_len = strlen(db);
 
+      /* These DDL methods and logging protected with LOCK_mysql_create_db */
       mysql_bin_log.write(&qinfo);
     }
     send_ok(thd, result);
@@ -783,6 +784,7 @@ bool mysql_alter_db(THD *thd, const char
     qinfo.db_len = strlen(db);
 
     thd->clear_error();
+    /* These DDL methods and logging protected with LOCK_mysql_create_db */
     mysql_bin_log.write(&qinfo);
   }
   send_ok(thd, result);
@@ -905,6 +907,7 @@ bool mysql_rm_db(THD *thd,char *db,bool 
       qinfo.db_len = strlen(db);
 
       thd->clear_error();
+      /* These DDL methods and logging protected with LOCK_mysql_create_db */
       mysql_bin_log.write(&qinfo);
     }
     thd->server_status|= SERVER_STATUS_DB_DROPPED;
@@ -931,6 +934,7 @@ bool mysql_rm_db(THD *thd,char *db,bool 
       tbl_name_len= strlen(tbl->table_name) + 3;
       if (query_pos + tbl_name_len + 1 >= query_end)
       {
+        /* These DDL methods and logging protected with LOCK_mysql_create_db */
         write_to_binlog(thd, query, query_pos -1 - query, db, db_len);
         query_pos= query_data_start;
       }
@@ -943,6 +947,7 @@ bool mysql_rm_db(THD *thd,char *db,bool 
 
     if (query_pos != query_data_start)
     {
+      /* These DDL methods and logging protected with LOCK_mysql_create_db */
       write_to_binlog(thd, query, query_pos -1 - query, db, db_len);
     }
   }

--- 1.584/sql/sql_parse.cc	2006-10-11 10:58:36 -04:00
+++ 1.585/sql/sql_parse.cc	2006-10-11 10:58:36 -04:00
@@ -3237,6 +3237,7 @@ end_with_restore_list:
     /* ! we write after unlocking the table */
     if (!res && !lex->no_write_to_binlog)
     {
+      /* Presumably, REPAIR and binlog writing doesn't require synchronization */
       if (mysql_bin_log.is_open())
       {
 	thd->clear_error(); // No binlog error generated
@@ -3269,6 +3270,7 @@ end_with_restore_list:
     /* ! we write after unlocking the table */
     if (!res && !lex->no_write_to_binlog)
     {
+      /* Presumably, ANALYZE and binlog writing doesn't require synchronization */
       if (mysql_bin_log.is_open())
       {
 	thd->clear_error(); // No binlog error generated
@@ -3293,6 +3295,7 @@ end_with_restore_list:
     /* ! we write after unlocking the table */
     if (!res && !lex->no_write_to_binlog)
     {
+      /* Presumably, OPTIMIZE and binlog writing doesn't require synchronization */
       if (mysql_bin_log.is_open())
       {
 	thd->clear_error(); // No binlog error generated
@@ -3580,6 +3583,7 @@ end_with_restore_list:
       /* So that DROP TEMPORARY TABLE gets to binlog at commit/rollback */
       thd->options|= OPTION_KEEP_LOG;
     }
+    /* DDL and binlog write order protected by LOCK_open */
     res= mysql_rm_table(thd, first_table, lex->drop_if_exists,
 			lex->drop_temporary);
   }
@@ -3979,13 +3983,9 @@ end_with_restore_list:
       break;
     if (end_active_trans(thd))
       goto error;
+    /* Conditionally writes to binlog */
     if (!(res= mysql_create_user(thd, lex->users_list)))
-    {
-      if (mysql_bin_log.is_open())
-        thd->binlog_query(THD::MYSQL_QUERY_TYPE,
-                          thd->query, thd->query_length, FALSE, FALSE);
       send_ok(thd);
-    }
     break;
   }
   case SQLCOM_DROP_USER:
@@ -3995,15 +3995,9 @@ end_with_restore_list:
       break;
     if (end_active_trans(thd))
       goto error;
+    /* Conditionally writes to binlog */
     if (!(res= mysql_drop_user(thd, lex->users_list)))
-    {
-      if (mysql_bin_log.is_open())
-      {
-        thd->binlog_query(THD::MYSQL_QUERY_TYPE,
-                          thd->query, thd->query_length, FALSE, FALSE);
-      }
       send_ok(thd);
-    }
     break;
   }
   case SQLCOM_RENAME_USER:
@@ -4013,15 +4007,9 @@ end_with_restore_list:
       break;
     if (end_active_trans(thd))
       goto error;
+    /* Conditionally writes to binlog */
     if (!(res= mysql_rename_user(thd, lex->users_list)))
-    {
-      if (mysql_bin_log.is_open())
-      {
-        thd->binlog_query(THD::MYSQL_QUERY_TYPE,
-                          thd->query, thd->query_length, FALSE, FALSE);
-      }
       send_ok(thd);
-    }
     break;
   }
   case SQLCOM_REVOKE_ALL:
@@ -4029,15 +4017,9 @@ end_with_restore_list:
     if (check_access(thd, UPDATE_ACL, "mysql", 0, 1, 1, 0) &&
         check_global_access(thd,CREATE_USER_ACL))
       break;
+    /* Conditionally writes to binlog */
     if (!(res = mysql_revoke_all(thd, lex->users_list)))
-    {
-      if (mysql_bin_log.is_open())
-      {
-        thd->binlog_query(THD::MYSQL_QUERY_TYPE,
-                          thd->query, thd->query_length, FALSE, FALSE);
-      }
       send_ok(thd);
-    }
     break;
   }
   case SQLCOM_REVOKE:
@@ -4096,6 +4078,7 @@ end_with_restore_list:
 	    check_grant_routine(thd, grants | GRANT_ACL, all_tables,
                                 lex->type == TYPE_ENUM_PROCEDURE, 0))
 	  goto error;
+        /* Conditionally writes to binlog */
         res= mysql_routine_grant(thd, all_tables,
                                  lex->type == TYPE_ENUM_PROCEDURE, 
                                  lex->users_list, grants,
@@ -4108,16 +4091,11 @@ end_with_restore_list:
 					 GRANT_ACL),
 					all_tables, 0, UINT_MAX, 0))
 	  goto error;
+        /* Conditionally writes to binlog */
         res= mysql_table_grant(thd, all_tables, lex->users_list,
 			       lex->columns, lex->grant,
 			       lex->sql_command == SQLCOM_REVOKE);
       }
-      if (!res && mysql_bin_log.is_open())
-      {
-        thd->clear_error();
-        thd->binlog_query(THD::MYSQL_QUERY_TYPE,
-                          thd->query, thd->query_length, FALSE, FALSE);
-      }
     }
     else
     {
@@ -4128,16 +4106,11 @@ end_with_restore_list:
         goto error;
       }
       else
+	/* Conditionally writes to binlog */
 	res = mysql_grant(thd, select_lex->db, lex->users_list, lex->grant,
 			  lex->sql_command == SQLCOM_REVOKE);
       if (!res)
       {
-	if (mysql_bin_log.is_open())
-	{
-          thd->clear_error();
-          thd->binlog_query(THD::MYSQL_QUERY_TYPE,
-                            thd->query, thd->query_length, FALSE, FALSE);
-	}
 	if (lex->sql_command == SQLCOM_GRANT)
 	{
 	  List_iterator <LEX_USER> str_list(lex->users_list);
@@ -4175,6 +4148,7 @@ end_with_restore_list:
         We WANT to write and we CAN write.
         ! we write after unlocking the table.
       */
+      /* Presumably, RESET and binlog writing doesn't require synchronization */
       if (!lex->no_write_to_binlog && write_to_binlog)
       {
         if (mysql_bin_log.is_open())
@@ -4691,20 +4665,16 @@ end_with_restore_list:
             already puts on CREATE FUNCTION.
           */
           if (lex->sql_command == SQLCOM_ALTER_PROCEDURE)
+            /* Conditionally writes to binlog */
             result= sp_update_procedure(thd, lex->spname, &lex->sp_chistics);
           else
+            /* Conditionally writes to binlog */
             result= sp_update_function(thd, lex->spname, &lex->sp_chistics);
         }
       }
       switch (result)
       {
       case SP_OK:
-        if (mysql_bin_log.is_open())
-        {
-          thd->clear_error();
-          thd->binlog_query(THD::MYSQL_QUERY_TYPE,
-                            thd->query, thd->query_length, FALSE, FALSE);
-        }
 	send_ok(thd);
 	break;
       case SP_KEY_NOT_FOUND:
@@ -4749,9 +4719,11 @@ end_with_restore_list:
 	}
 #endif
 	if (lex->sql_command == SQLCOM_DROP_PROCEDURE)
-	  result= sp_drop_procedure(thd, lex->spname);
+          /* Conditionally writes to binlog */
+	  result= sp_drop_procedure(thd, lex->spname); /* Conditionally writes to binlog */
 	else
-	  result= sp_drop_function(thd, lex->spname);
+          /* Conditionally writes to binlog */
+	  result= sp_drop_function(thd, lex->spname); /* Conditionally writes to binlog */
       }
       else
       {
@@ -4764,6 +4736,8 @@ end_with_restore_list:
           {
 	    if (check_access(thd, DELETE_ACL, "mysql", 0, 1, 0, 0))
 	      goto error;
+
+	    /* Does NOT write to binlog */
 	    if (!(res = mysql_drop_function(thd, &lex->spname->m_name)))
 	    {
 	      send_ok(thd);
@@ -4784,12 +4758,6 @@ end_with_restore_list:
       switch (result)
       {
       case SP_OK:
-        if (mysql_bin_log.is_open())
-        {
-          thd->clear_error();
-          thd->binlog_query(THD::MYSQL_QUERY_TYPE,
-                            thd->query, thd->query_length, FALSE, FALSE);
-        }
 	send_ok(thd);
 	break;
       case SP_KEY_NOT_FOUND:
@@ -4887,50 +4855,8 @@ end_with_restore_list:
     {
       if (end_active_trans(thd))
         goto error;
-
-      if (!(res= mysql_create_view(thd, thd->lex->create_view_mode)) &&
-          mysql_bin_log.is_open())
-      {
-        String buff;
-        const LEX_STRING command[3]=
-          {{ C_STRING_WITH_LEN("CREATE ") },
-           { C_STRING_WITH_LEN("ALTER ") },
-           { C_STRING_WITH_LEN("CREATE OR REPLACE ") }};
-        thd->clear_error();
-
-        buff.append(command[thd->lex->create_view_mode].str,
-                    command[thd->lex->create_view_mode].length);
-        view_store_options(thd, first_table, &buff);
-        buff.append(STRING_WITH_LEN("VIEW "));
-        /* Test if user supplied a db (ie: we did not use thd->db) */
-        if (first_table->db && first_table->db[0] &&
-            (thd->db == NULL || strcmp(first_table->db, thd->db)))
-        {
-          append_identifier(thd, &buff, first_table->db,
-                            first_table->db_length);
-          buff.append('.');
-        }
-        append_identifier(thd, &buff, first_table->table_name,
-                          first_table->table_name_length);
-        if (lex->view_list.elements)
-        {
-          List_iterator_fast<LEX_STRING> names(lex->view_list);
-          LEX_STRING *name;
-          int i;
-          
-          for (i= 0; name= names++; i++)
-          {
-            buff.append(i ? ", " : "(");
-            append_identifier(thd, &buff, name->str, name->length);
-          }
-          buff.append(')');
-        }
-        buff.append(STRING_WITH_LEN(" AS "));
-        buff.append(first_table->source.str, first_table->source.length);
-
-        thd->binlog_query(THD::STMT_QUERY_TYPE,
-                          buff.ptr(), buff.length(), FALSE, FALSE);
-      }
+      /* Conditionally writes to binlog. */
+      res= mysql_create_view(thd, first_table, thd->lex->create_view_mode);
       break;
     }
   case SQLCOM_DROP_VIEW:
@@ -4938,13 +4864,8 @@ end_with_restore_list:
       if (check_table_access(thd, DROP_ACL, all_tables, 0) ||
           end_active_trans(thd))
         goto error;
-      if (!(res= mysql_drop_view(thd, first_table, thd->lex->drop_mode)) &&
-          mysql_bin_log.is_open())
-      {
-        thd->clear_error();
-        thd->binlog_query(THD::STMT_QUERY_TYPE,
-                          thd->query, thd->query_length, FALSE, FALSE);
-      }
+      /* Conditionally writes to binlog. */
+      res= mysql_drop_view(thd, first_table, thd->lex->drop_mode);
       break;
     }
   case SQLCOM_CREATE_TRIGGER:
@@ -4952,6 +4873,7 @@ end_with_restore_list:
     if (end_active_trans(thd))
       goto error;
 
+    /* Conditionally writes to binlog. */
     res= mysql_create_or_drop_trigger(thd, all_tables, 1);
 
     /* We don't care about trigger body after this point */
@@ -4964,6 +4886,7 @@ end_with_restore_list:
     if (end_active_trans(thd))
       goto error;
 
+    /* Conditionally writes to binlog. */
     res= mysql_create_or_drop_trigger(thd, all_tables, 0);
     break;
   }

--- 1.372/sql/sql_table.cc	2006-10-11 10:58:36 -04:00
+++ 1.373/sql/sql_table.cc	2006-10-11 10:58:36 -04:00
@@ -5214,6 +5214,7 @@ bool mysql_alter_table(THD *thd,char *ne
 
   /* DISCARD/IMPORT TABLESPACE is always alone in an ALTER TABLE */
   if (alter_info->tablespace_op != NO_TABLESPACE_OP)
+    /* Conditionally writes to binlog. */
     DBUG_RETURN(mysql_discard_or_import_tablespace(thd,table_list,
 						   alter_info->tablespace_op));
   if (!(table=open_ltable(thd,table_list,TL_WRITE_ALLOW_READ)))
@@ -5323,10 +5324,10 @@ bool mysql_alter_table(THD *thd,char *ne
       !table->s->tmp_table) // no need to touch frm
   {
     error=0;
+    VOID(pthread_mutex_lock(&LOCK_open));
     if (new_name != table_name || new_db != db)
     {
       thd->proc_info="rename";
-      VOID(pthread_mutex_lock(&LOCK_open));
       /* Then do a 'simple' rename of the table */
       error=0;
       if (!access(new_name_buff,F_OK))
@@ -5349,7 +5350,6 @@ bool mysql_alter_table(THD *thd,char *ne
           error= -1;
         }
       }
-      VOID(pthread_mutex_unlock(&LOCK_open));
     }
 
     if (!error)
@@ -5358,16 +5358,12 @@ bool mysql_alter_table(THD *thd,char *ne
       case LEAVE_AS_IS:
         break;
       case ENABLE:
-        VOID(pthread_mutex_lock(&LOCK_open));
         wait_while_table_is_used(thd, table, HA_EXTRA_FORCE_REOPEN);
-        VOID(pthread_mutex_unlock(&LOCK_open));
         error= table->file->enable_indexes(HA_KEY_SWITCH_NONUNIQ_SAVE);
         /* COND_refresh will be signaled in close_thread_tables() */
         break;
       case DISABLE:
-        VOID(pthread_mutex_lock(&LOCK_open));
         wait_while_table_is_used(thd, table, HA_EXTRA_FORCE_REOPEN);
-        VOID(pthread_mutex_unlock(&LOCK_open));
         error=table->file->disable_indexes(HA_KEY_SWITCH_NONUNIQ_SAVE);
         /* COND_refresh will be signaled in close_thread_tables() */
         break;
@@ -5392,6 +5388,7 @@ bool mysql_alter_table(THD *thd,char *ne
       table->file->print_error(error, MYF(0));
       error= -1;
     }
+    VOID(pthread_mutex_unlock(&LOCK_open));
     table_list->table=0;				// For query cache
     query_cache_invalidate3(thd, table_list, 0);
     DBUG_RETURN(error);

--- 1.107/sql/sql_view.cc	2006-10-11 10:58:36 -04:00
+++ 1.108/sql/sql_view.cc	2006-10-11 10:58:36 -04:00
@@ -212,6 +212,7 @@ fill_defined_view_parts (THD *thd, TABLE
   SYNOPSIS
     mysql_create_view()
     thd		- thread handler
+    views	- views to create
     mode	- VIEW_CREATE_NEW, VIEW_ALTER, VIEW_CREATE_OR_REPLACE
 
   RETURN VALUE
@@ -219,7 +220,7 @@ fill_defined_view_parts (THD *thd, TABLE
      TRUE  Error
 */
 
-bool mysql_create_view(THD *thd,
+bool mysql_create_view(THD *thd, TABLE_LIST *views, 
                        enum_view_create_mode mode)
 {
   LEX *lex= thd->lex;
@@ -548,6 +549,37 @@ bool mysql_create_view(THD *thd,
   }
   VOID(pthread_mutex_lock(&LOCK_open));
   res= mysql_register_view(thd, view, mode);
+
+  if (mysql_bin_log.is_open())
+  {
+    String buff;
+    const LEX_STRING command[3]=
+      {{(char *)STRING_WITH_LEN("CREATE ")},
+       {(char *)STRING_WITH_LEN("ALTER ")},
+       {(char *)STRING_WITH_LEN("CREATE OR REPLACE ")}};
+
+    buff.append(command[thd->lex->create_view_mode].str,
+                command[thd->lex->create_view_mode].length);
+    view_store_options(thd, views, &buff);
+    buff.append(STRING_WITH_LEN("VIEW "));
+
+    /* Test if user supplied a db (ie: we did not use thd->db) */
+    if (views->db && views->db[0] &&
+        (thd->db == NULL || strcmp(views->db, thd->db)))
+    {
+      append_identifier(thd, &buff, views->db,
+                        views->db_length);
+      buff.append('.');
+    }
+    append_identifier(thd, &buff, views->table_name,
+                      views->table_name_length);
+    buff.append(STRING_WITH_LEN(" AS "));
+    buff.append(views->source.str, views->source.length);
+
+    Query_log_event qinfo(thd, buff.ptr(), buff.length(), 0, FALSE);
+    mysql_bin_log.write(&qinfo);
+  }
+
   VOID(pthread_mutex_unlock(&LOCK_open));
   if (view->revision != 1)
     query_cache_invalidate3(thd, view, 0);
@@ -1318,13 +1350,13 @@ bool mysql_drop_view(THD *thd, TABLE_LIS
   enum legacy_db_type not_used;
   DBUG_ENTER("mysql_drop_view");
 
+  VOID(pthread_mutex_lock(&LOCK_open));
   for (view= views; view; view= view->next_local)
   {
     TABLE_SHARE *share;
     frm_type_enum type= FRMTYPE_ERROR;
     build_table_filename(path, sizeof(path),
                          view->db, view->table_name, reg_ext, 0);
-    VOID(pthread_mutex_lock(&LOCK_open));
 
     if (access(path, F_OK) || 
         FRMTYPE_VIEW != (type= mysql_frm_type(thd, path, &not_used)))
@@ -1336,7 +1368,6 @@ bool mysql_drop_view(THD *thd, TABLE_LIS
 	push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
 			    ER_BAD_TABLE_ERROR, ER(ER_BAD_TABLE_ERROR),
 			    name);
-	VOID(pthread_mutex_unlock(&LOCK_open));
 	continue;
       }
       if (type == FRMTYPE_TABLE)
@@ -1374,8 +1405,16 @@ bool mysql_drop_view(THD *thd, TABLE_LIS
     }
     query_cache_invalidate3(thd, view, 0);
     sp_cache_invalidate();
-    VOID(pthread_mutex_unlock(&LOCK_open));
   }
+
+  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);
+  }
+
+  VOID(pthread_mutex_unlock(&LOCK_open));
   if (error)
   {
     DBUG_RETURN(TRUE);

--- 1.13/sql/sql_view.h	2006-10-11 10:58:36 -04:00
+++ 1.14/sql/sql_view.h	2006-10-11 10:58:36 -04:00
@@ -16,7 +16,7 @@
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
 
-bool mysql_create_view(THD *thd,
+bool mysql_create_view(THD *thd, TABLE_LIST *view,
                        enum_view_create_mode mode);
 
 bool mysql_make_view(THD *thd, File_parser *parser, TABLE_LIST *table,

--- 1.69/sql/sql_trigger.cc	2006-10-11 10:58:36 -04:00
+++ 1.70/sql/sql_trigger.cc	2006-10-11 10:58:36 -04:00
@@ -276,8 +276,6 @@ bool mysql_create_or_drop_trigger(THD *t
            table->triggers->drop_trigger(thd, tables, &stmt_query));
 
 end:
-  VOID(pthread_mutex_unlock(&LOCK_open));
-  start_waiting_global_read_lock(thd);
 
   if (!result)
   {
@@ -290,9 +288,13 @@ end:
                             FALSE);
       mysql_bin_log.write(&qinfo);
     }
+  }
+
+  VOID(pthread_mutex_unlock(&LOCK_open));
+  start_waiting_global_read_lock(thd);
 
+  if (!result)
     send_ok(thd);
-  }
 
   DBUG_RETURN(result);
 }

--- 1.8/BitKeeper/etc/collapsed	2006-10-11 10:58:36 -04:00
+++ 1.11/BitKeeper/etc/collapsed	2006-10-11 10:58:36 -04:00
@@ -5,5 +5,10 @@
 45001f7c3b2hhCXDKfUvzkX9TNe6VA
 45002051rHJfMEXAIMiAZV0clxvKSA
 4513d8e4Af4dQWuk13sArwofRgFDQw
+45143312u0Tz4r0wPXCbUKwdHa2jWA
+45143b90ewOQuTW8-jrB3ZSAQvMRJw
+45184588w9U72A6KX1hUFeAC4shSHA
+45185df8mZbxfp85FbA0VxUXkmDewA
 4519a6c5BVUxEHTf5iJnjZkixMBs8g
 451ab499rgdjXyOnUDqHu-wBDoS-OQ
+451b110a3ZV6MITl93ehXk2wxrbW7g

--- 1.126/sql/sp.cc	2006-10-11 10:58:36 -04:00
+++ 1.127/sql/sp.cc	2006-10-11 10:58:36 -04:00
@@ -653,6 +653,17 @@ db_drop_routine(THD *thd, int type, sp_n
     if (table->file->ha_delete_row(table->record[0]))
       ret= SP_DELETE_ROW_FAILED;
   }
+
+  if (ret == 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);
+    }
+  }
+
   close_thread_tables(thd);
   DBUG_RETURN(ret);
 }
@@ -687,6 +698,17 @@ db_update_routine(THD *thd, int type, sp
     if ((table->file->ha_update_row(table->record[1],table->record[0])))
       ret= SP_WRITE_ROW_FAILED;
   }
+
+  if (ret == 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);
+    }
+  }
+
   close_thread_tables(thd);
   DBUG_RETURN(ret);
 }
@@ -765,6 +787,7 @@ print_field_values(THD *thd, TABLE *tabl
 	return SP_INTERNAL_ERROR;
     }
   }
+
   return SP_OK;
 }
 
Thread
bk commit into 5.1 tree (cmiller:1.2341)Chad MILLER11 Oct