List:Commits« Previous MessageNext Message »
From:Mats Kindahl Date:May 31 2007 6:17pm
Subject:bk commit into 5.1 tree (mats:1.2534)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of mats. When mats 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, 2007-05-31 20:17:31+02:00, mats@stripped +13 -0
  Merge mkindahl@stripped:/home/bk/mysql-5.1-new-rpl
  into  kindahl-laptop.dnsalias.net:/home/bk/b28618-mysql-5.1-rpl
  MERGE: 1.2469.212.11

  sql/item_create.cc@stripped, 2007-05-31 20:06:03+02:00, mats@stripped +0 -0
    Auto merged
    MERGE: 1.76.2.1

  sql/log_event.cc@stripped, 2007-05-31 20:06:04+02:00, mats@stripped +0 -0
    Auto merged
    MERGE: 1.276.2.1

  sql/log_event.h@stripped, 2007-05-31 20:06:04+02:00, mats@stripped +0 -0
    Auto merged
    MERGE: 1.149.1.1

  sql/share/errmsg.txt@stripped, 2007-05-31 20:06:06+02:00, mats@stripped +0 -0
    Auto merged
    MERGE: 1.154.1.1

  sql/sp_head.cc@stripped, 2007-05-31 20:06:04+02:00, mats@stripped +0 -0
    Auto merged
    MERGE: 1.265.1.1

  sql/sp_head.h@stripped, 2007-05-31 20:06:04+02:00, mats@stripped +0 -0
    Auto merged
    MERGE: 1.103.1.1

  sql/sql_base.cc@stripped, 2007-05-31 20:06:05+02:00, mats@stripped +0 -0
    Auto merged
    MERGE: 1.396.3.1

  sql/sql_class.cc@stripped, 2007-05-31 20:06:05+02:00, mats@stripped +0 -0
    Auto merged
    MERGE: 1.331.1.1

  sql/sql_class.h@stripped, 2007-05-31 20:06:05+02:00, mats@stripped +0 -0
    Auto merged
    MERGE: 1.354.1.1

  sql/sql_insert.cc@stripped, 2007-05-31 20:06:05+02:00, mats@stripped +0 -0
    Auto merged
    MERGE: 1.261.3.1

  sql/sql_lex.cc@stripped, 2007-05-31 20:06:05+02:00, mats@stripped +0 -0
    Auto merged
    MERGE: 1.236.2.1

  sql/sql_lex.h@stripped, 2007-05-31 20:17:26+02:00, mats@stripped +7 -7
    Manual merge.
    MERGE: 1.271.3.1

  sql/sql_view.cc@stripped, 2007-05-31 20:06:06+02:00, mats@stripped +0 -0
    Auto merged
    MERGE: 1.129.1.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:	mats
# Host:	kindahl-laptop.dnsalias.net
# Root:	/home/bk/b28618-mysql-5.1-rpl/RESYNC

--- 1.79/sql/item_create.cc	2007-05-31 20:17:42 +02:00
+++ 1.80/sql/item_create.cc	2007-05-31 20:17:42 +02:00
@@ -2341,7 +2341,7 @@
   if (item_list != NULL)
     arg_count= item_list->elements;
 
-  thd->lex->binlog_row_based_if_mixed= TRUE;
+  thd->lex->set_stmt_unsafe();
 
   DBUG_ASSERT(   (udf->type == UDFTYPE_FUNCTION)
               || (udf->type == UDFTYPE_AGGREGATE));
@@ -4528,7 +4528,7 @@
 Item*
 Create_func_uuid::create(THD *thd)
 {
-  thd->lex->binlog_row_based_if_mixed= TRUE;
+  thd->lex->set_stmt_unsafe();
   return new (thd->mem_root) Item_func_uuid();
 }
 

--- 1.281/sql/log_event.cc	2007-05-31 20:17:43 +02:00
+++ 1.282/sql/log_event.cc	2007-05-31 20:17:43 +02:00
@@ -6149,6 +6149,20 @@
   DBUG_RETURN(0);
 }
 
+Log_event::enum_skip_reason
+Rows_log_event::do_shall_skip(RELAY_LOG_INFO *rli)
+{
+  /*
+    If the slave skip counter is 1 and this event does not end a
+    statement, then we should not start executing on the next event.
+    Otherwise, we defer the decision to the normal skipping logic.
+  */
+  if (rli->slave_skip_counter == 1 && !get_flags(STMT_END_F))
+    return Log_event::EVENT_SKIP_IGNORE;
+  else
+    return Log_event::do_shall_skip(rli);
+}
+
 int
 Rows_log_event::do_update_pos(RELAY_LOG_INFO *rli)
 {
@@ -6620,6 +6634,19 @@
 err:
   my_free((gptr) memory, MYF(MY_WME));
   DBUG_RETURN(error);
+}
+
+Log_event::enum_skip_reason
+Table_map_log_event::do_shall_skip(RELAY_LOG_INFO *rli)
+{
+  /*
+    If the slave skip counter is 1, then we should not start executing
+    on the next event.
+  */
+  if (rli->slave_skip_counter == 1)
+    return Log_event::EVENT_SKIP_IGNORE;
+  else
+    return Log_event::do_shall_skip(rli);
 }
 
 int Table_map_log_event::do_update_pos(RELAY_LOG_INFO *rli)

--- 1.150/sql/log_event.h	2007-05-31 20:17:43 +02:00
+++ 1.151/sql/log_event.h	2007-05-31 20:17:43 +02:00
@@ -2067,6 +2067,7 @@
 #if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
   virtual int do_apply_event(RELAY_LOG_INFO const *rli);
   virtual int do_update_pos(RELAY_LOG_INFO *rli);
+  virtual enum_skip_reason do_shall_skip(RELAY_LOG_INFO *rli);
 #endif
 
 #ifndef MYSQL_CLIENT
@@ -2245,6 +2246,7 @@
 #if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
   virtual int do_apply_event(RELAY_LOG_INFO const *rli);
   virtual int do_update_pos(RELAY_LOG_INFO *rli);
+  virtual enum_skip_reason do_shall_skip(RELAY_LOG_INFO *rli);
 
   /*
     Primitive to prepare for a sequence of row executions.

--- 1.405/sql/sql_base.cc	2007-05-31 20:17:43 +02:00
+++ 1.406/sql/sql_base.cc	2007-05-31 20:17:43 +02:00
@@ -3992,7 +3992,7 @@
   /*
     CREATE ... SELECT UUID() locks no tables, we have to test here.
   */
-  if (thd->lex->binlog_row_based_if_mixed)
+  if (thd->lex->is_stmt_unsafe())
     thd->set_current_stmt_binlog_row_based_if_mixed();
 
   if (!tables && !thd->lex->requires_prelocking())
@@ -4033,7 +4033,7 @@
       if (thd->variables.binlog_format == BINLOG_FORMAT_MIXED &&
           has_two_write_locked_tables_with_auto_increment(tables))
       {
-        thd->lex->binlog_row_based_if_mixed= TRUE;
+        thd->lex->set_stmt_unsafe();
         thd->set_current_stmt_binlog_row_based_if_mixed();
       }
     }

--- 1.336/sql/sql_class.cc	2007-05-31 20:17:43 +02:00
+++ 1.337/sql/sql_class.cc	2007-05-31 20:17:43 +02:00
@@ -329,7 +329,7 @@
    Open_tables_state(refresh_version), rli_fake(0),
    lock_id(&main_lock_id),
    user_time(0), in_sub_stmt(0),
-   binlog_table_maps(0),
+   binlog_table_maps(0), binlog_flags(0UL),
    arg_of_last_insert_id_function(FALSE),
    first_successful_insert_id_in_prev_stmt(0),
    first_successful_insert_id_in_prev_stmt_for_binlog(0),
@@ -3118,6 +3118,23 @@
       to how you treat this.
     */
   case THD::STMT_QUERY_TYPE:
+    if (lex->is_stmt_unsafe())
+    {
+      DBUG_ASSERT(this->query != NULL);
+      push_warning(this, MYSQL_ERROR::WARN_LEVEL_WARN,
+                   ER_BINLOG_UNSAFE_STATEMENT,
+                   ER(ER_BINLOG_UNSAFE_STATEMENT));
+      if (!(binlog_flags & BINLOG_FLAG_UNSAFE_STMT_PRINTED))
+      {
+        
+        char warn_buf[MYSQL_ERRMSG_SIZE];
+        my_snprintf(warn_buf, MYSQL_ERRMSG_SIZE, "%s Statement: %s",
+                    ER(ER_BINLOG_UNSAFE_STATEMENT), this->query);
+        sql_print_warning(warn_buf);
+        binlog_flags|= BINLOG_FLAG_UNSAFE_STMT_PRINTED;
+      }
+    }
+
     /*
       The MYSQL_LOG::write() function will set the STMT_END_F flag and
       flush the pending rows event if necessary.

--- 1.364/sql/sql_class.h	2007-05-31 20:17:43 +02:00
+++ 1.365/sql/sql_class.h	2007-05-31 20:17:43 +02:00
@@ -1110,6 +1110,17 @@
 
 private:
   uint binlog_table_maps; // Number of table maps currently in the binlog
+
+  enum enum_binlog_flag {
+    BINLOG_FLAG_UNSAFE_STMT_PRINTED,
+    BINLOG_FLAG_COUNT
+  };
+
+  /**
+     Flags with per-thread information regarding the status of the
+     binary log.
+   */
+  uint32 binlog_flags;
 public:
   uint get_binlog_table_maps() const {
     return binlog_table_maps;
@@ -1680,6 +1691,7 @@
   void restore_sub_statement_state(Sub_statement_state *backup);
   void set_n_backup_active_arena(Query_arena *set, Query_arena *backup);
   void restore_active_arena(Query_arena *set, Query_arena *backup);
+
   inline void set_current_stmt_binlog_row_based_if_mixed()
   {
     /*

--- 1.272/sql/sql_insert.cc	2007-05-31 20:17:43 +02:00
+++ 1.273/sql/sql_insert.cc	2007-05-31 20:17:43 +02:00
@@ -1664,6 +1664,7 @@
       Statement-based replication of INSERT DELAYED has problems with RAND()
       and user vars, so in mixed mode we go to row-based.
     */
+    thd.lex->set_stmt_unsafe();
     thd.set_current_stmt_binlog_row_based_if_mixed();
 
     bzero((char*) &thd.net, sizeof(thd.net));		// Safety

--- 1.246/sql/sql_lex.cc	2007-05-31 20:17:43 +02:00
+++ 1.247/sql/sql_lex.cc	2007-05-31 20:17:43 +02:00
@@ -1782,7 +1782,7 @@
   sroutines_list.empty();
   sroutines_list_own_last= sroutines_list.next;
   sroutines_list_own_elements= 0;
-  binlog_row_based_if_mixed= FALSE;
+  binlog_stmt_flags= 0;
 }
 
 

--- 1.280/sql/sql_lex.h	2007-05-31 20:17:43 +02:00
+++ 1.281/sql/sql_lex.h	2007-05-31 20:17:43 +02:00
@@ -951,14 +951,6 @@
   uint     sroutines_list_own_elements;
 
   /*
-    Tells if the parsing stage detected that some items require row-based
-    binlogging to give a reliable binlog/replication, or if we will use
-    stored functions or triggers which themselves need require row-based
-    binlogging.
-  */
-  bool binlog_row_based_if_mixed;
-
-  /*
     These constructor and destructor serve for creation/destruction
     of Query_tables_list instances which are used as backup storage.
   */
@@ -1005,12 +997,48 @@
       query_tables_own_last= 0;
     }
   }
+
+  /**
+     Has the parser/scanner detected that this statement is unsafe?
+   */
+  inline bool is_stmt_unsafe() const {
+    return binlog_stmt_flags & (1U << BINLOG_STMT_FLAG_UNSAFE);
+  }
+
+  /**
+     Flag the current (top-level) statement as unsafe.
+
+     The flag will be reset after the statement has finished.
+
+   */
+  inline void set_stmt_unsafe() {
+    binlog_stmt_flags|= (1U << BINLOG_STMT_FLAG_UNSAFE);
+  }
+
+  inline void clear_stmt_unsafe() {
+    binlog_stmt_flags&= ~(1U << BINLOG_STMT_FLAG_UNSAFE);
+  }
+
   /**
     true if the parsed tree contains references to stored procedures
     or functions, false otherwise
   */
   bool uses_stored_routines() const
   { return sroutines_list.elements != 0; }
+
+private:
+  enum enum_binlog_stmt_flag {
+    BINLOG_STMT_FLAG_UNSAFE,
+    BINLOG_STMT_FLAG_COUNT
+  };
+
+  /*
+    Tells if the parsing stage detected properties of the statement,
+    for example: that some items require row-based binlogging to give
+    a reliable binlog/replication, or if we will use stored functions
+    or triggers which themselves need require row-based binlogging.
+  */
+  uint32 binlog_stmt_flags;
 };
 
 

--- 1.155/sql/share/errmsg.txt	2007-05-31 20:17:43 +02:00
+++ 1.156/sql/share/errmsg.txt	2007-05-31 20:17:43 +02:00
@@ -6059,3 +6059,6 @@
         eng "The incident %s occured on the master. Message: %-.64s"
 ER_NO_PARTITION_FOR_GIVEN_VALUE_SILENT
         eng "Table has no partition for some existing values"
+ER_BINLOG_UNSAFE_STATEMENT
+        eng "Statement is not safe to log in statement format."

--- 1.135/sql/sql_view.cc	2007-05-31 20:17:43 +02:00
+++ 1.136/sql/sql_view.cc	2007-05-31 20:17:43 +02:00
@@ -1118,8 +1118,8 @@
       If the view's body needs row-based binlogging (e.g. the VIEW is created
       from SELECT UUID()), the top statement also needs it.
     */
-    if (lex->binlog_row_based_if_mixed)
-      old_lex->binlog_row_based_if_mixed= TRUE;
+    if (lex->is_stmt_unsafe())
+      old_lex->set_stmt_unsafe();
     view_is_mergeable= (table->algorithm != VIEW_ALGORITHM_TMPTABLE &&
                         lex->can_be_merged());
     LINT_INIT(view_main_select_tables);

--- 1.275/sql/sp_head.cc	2007-05-31 20:17:43 +02:00
+++ 1.276/sql/sp_head.cc	2007-05-31 20:17:43 +02:00
@@ -1855,7 +1855,7 @@
     cannot switch from statement-based to row-based only for this
     substatement).
   */
-  if (sublex->binlog_row_based_if_mixed)
+  if (sublex->is_stmt_unsafe())
     m_flags|= BINLOG_ROW_BASED_IF_MIXED;
 
   /*

--- 1.107/sql/sp_head.h	2007-05-31 20:17:43 +02:00
+++ 1.108/sql/sp_head.h	2007-05-31 20:17:43 +02:00
@@ -378,7 +378,7 @@
       the substatements not).
     */
     if (m_flags & BINLOG_ROW_BASED_IF_MIXED)
-      lex->binlog_row_based_if_mixed= TRUE;
+      lex->set_stmt_unsafe();
   }
 
 
Thread
bk commit into 5.1 tree (mats:1.2534)Mats Kindahl31 May