List:Commits« Previous MessageNext Message »
From:tim Date:March 7 2007 7:21am
Subject:bk commit into 5.1 tree (tsmith:1.2455)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of tsmith. When tsmith 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-03-07 07:21:24+01:00, tsmith@stripped +28 -0
  Merge tsmith@stripped:/home/bk/mysql-5.1-runtime
  into  quadxeon.mysql.com:/benchmarks/ext3/TOSAVE/tsmith/bk/maint/mrg0306/51
  MERGE: 1.2409.1.85

  client/mysql_upgrade.c@stripped, 2007-03-07 07:17:56+01:00, tsmith@stripped +1 -20
    Manual merge; I chose to keep Magnus' changes
    because they make the code more simple; always
    use *only* the option file created by mysql_
    upgrade.
    MERGE: 1.26.1.1

  client/mysqltest.c@stripped, 2007-03-07 06:06:16+01:00, tsmith@stripped +0 -0
    Auto merged
    MERGE: 1.267.1.3

  include/my_pthread.h@stripped, 2007-03-07 06:06:17+01:00, tsmith@stripped +0 -0
    Auto merged
    MERGE: 1.106.1.2

  mysql-test/extra/binlog_tests/ctype_cp932.test@stripped, 2007-03-07 07:20:50+01:00,
tsmith@stripped +11 -11
    Manual merge
    MERGE: 1.14.1.1

  mysql-test/mysql-test-run.pl@stripped, 2007-03-07 06:06:17+01:00, tsmith@stripped
+0 -0
    Auto merged
    MERGE: 1.270.1.5

  mysql-test/r/binlog_row_ctype_cp932.result@stripped, 2007-03-07 07:20:56+01:00,
tsmith@stripped +10 -10
    Manual merge
    MERGE: 1.5.1.1

  mysql-test/r/binlog_stm_ctype_cp932.result@stripped, 2007-03-07 07:21:00+01:00,
tsmith@stripped +10 -10
    Manual merge
    MERGE: 1.12.1.1

  mysql-test/r/mysqlbinlog.result@stripped, 2007-03-07 07:21:04+01:00,
tsmith@stripped +0 -0
    Manual merge
    MERGE: 1.28.1.3

  mysql-test/r/rpl_switch_stm_row_mixed.result@stripped, 2007-03-07 07:21:08+01:00,
tsmith@stripped +0 -0
    Manual merge
    MERGE: 1.16.1.1

  mysql-test/r/sp.result@stripped, 2007-03-07 06:06:17+01:00, tsmith@stripped +0 -0
    Auto merged
    MERGE: 1.248.1.2

  mysql-test/t/disabled.def@stripped, 2007-03-07 06:06:18+01:00, tsmith@stripped +0
-0
    Auto merged
    MERGE: 1.231.4.1

  mysql-test/t/mysqlbinlog.test@stripped, 2007-03-07 07:21:12+01:00, tsmith@stripped
+5 -6
    Manual merge
    MERGE: 1.35.1.3

  mysql-test/t/rpl_switch_stm_row_mixed.test@stripped, 2007-03-07 07:21:16+01:00,
tsmith@stripped +0 -2
    Manual merge
    MERGE: 1.13.1.2

  mysql-test/t/sp.test@stripped, 2007-03-07 06:06:18+01:00, tsmith@stripped +0 -0
    Auto merged
    MERGE: 1.216.1.1

  mysys/my_wincond.c@stripped, 2007-03-07 06:06:18+01:00, tsmith@stripped +0 -0
    Auto merged
    MERGE: 1.10.1.1

  sql/event_queue.cc@stripped, 2007-03-07 06:06:18+01:00, tsmith@stripped +0 -0
    Auto merged
    MERGE: 1.23.1.1

  sql/field.cc@stripped, 2007-03-07 06:06:18+01:00, tsmith@stripped +0 -0
    Auto merged
    MERGE: 1.372.1.3

  sql/item_cmpfunc.cc@stripped, 2007-03-07 06:06:18+01:00, tsmith@stripped +0 -0
    Auto merged
    MERGE: 1.248.1.1

  sql/item_cmpfunc.h@stripped, 2007-03-07 06:06:19+01:00, tsmith@stripped +0 -0
    Auto merged
    MERGE: 1.151.1.1

  sql/log.cc@stripped, 2007-03-07 06:06:19+01:00, tsmith@stripped +0 -0
    Auto merged
    MERGE: 1.253.1.5

  sql/mysql_priv.h@stripped, 2007-03-07 06:06:19+01:00, tsmith@stripped +0 -0
    Auto merged
    MERGE: 1.470.1.15

  sql/mysqld.cc@stripped, 2007-03-07 06:06:20+01:00, tsmith@stripped +0 -0
    Auto merged
    MERGE: 1.601.20.2

  sql/set_var.cc@stripped, 2007-03-07 06:06:20+01:00, tsmith@stripped +0 -0
    Auto merged
    MERGE: 1.215.1.2

  sql/sql_class.cc@stripped, 2007-03-07 06:06:20+01:00, tsmith@stripped +0 -0
    Auto merged
    MERGE: 1.312.1.5

  sql/sql_class.h@stripped, 2007-03-07 06:06:20+01:00, tsmith@stripped +0 -0
    Auto merged
    MERGE: 1.339.1.5

  sql/sql_load.cc@stripped, 2007-03-07 06:06:20+01:00, tsmith@stripped +0 -0
    Auto merged
    MERGE: 1.114.1.2

  sql/sql_parse.cc@stripped, 2007-03-07 06:06:21+01:00, tsmith@stripped +0 -0
    Auto merged
    MERGE: 1.626.1.2

  sql/sql_trigger.cc@stripped, 2007-03-07 06:06:21+01:00, tsmith@stripped +0 -0
    Auto merged
    MERGE: 1.83.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:	tsmith
# Host:	quadxeon.mysql.com
# Root:	/benchmarks/ext3/TOSAVE/tsmith/bk/maint/mrg0306/51/RESYNC

--- 1.376/sql/field.cc	2007-03-07 07:21:42 +01:00
+++ 1.377/sql/field.cc	2007-03-07 07:21:42 +01:00
@@ -5436,27 +5436,30 @@
 {
   ASSERT_COLUMN_MARKED_FOR_WRITE;
   TIME l_time;
-  long tmp;
   int error;
   THD *thd= table ? table->in_use : current_thd;
-  if (str_to_datetime(from, len, &l_time,
-                      (TIME_FUZZY_DATE |
-                       (thd->variables.sql_mode &
-                        (MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE |
-                         MODE_INVALID_DATES))),
-                      &error) <= MYSQL_TIMESTAMP_ERROR)
+  enum enum_mysql_timestamp_type ret;
+  if ((ret= str_to_datetime(from, len, &l_time,
+                            (TIME_FUZZY_DATE |
+                             (thd->variables.sql_mode &
+                              (MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE |
+                               MODE_INVALID_DATES))),
+                            &error)) <= MYSQL_TIMESTAMP_ERROR)
   {
-    tmp= 0L;
+    int3store(ptr,0L);
     error= 2;
   }
   else
-    tmp= l_time.day + l_time.month*32 + l_time.year*16*32;
+  {
+    int3store(ptr, l_time.day + l_time.month*32 + l_time.year*16*32);
+    if(!error && (ret != MYSQL_TIMESTAMP_DATE))
+      return 2;
+  }
 
   if (error)
     set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED,
                          from, len, MYSQL_TIMESTAMP_DATE, 1);
 
-  int3store(ptr,tmp);
   return error;
 }
 

--- 1.264/sql/log.cc	2007-03-07 07:21:42 +01:00
+++ 1.265/sql/log.cc	2007-03-07 07:21:42 +01:00
@@ -66,7 +66,7 @@
 
 char *make_default_log_name(char *buff,const char* log_ext)
 {
-  strmake(buff, glob_hostname, FN_REFLEN-5);
+  strmake(buff, pidfile_name, FN_REFLEN-5);
   return fn_format(buff, buff, mysql_data_home, log_ext,
                    MYF(MY_UNPACK_FILENAME|MY_APPEND_EXT));
 }
@@ -2290,7 +2290,7 @@
       TODO: The following should be using fn_format();  We just need to
       first change fn_format() to cut the file name if it's too long.
     */
-    strmake(buff, glob_hostname, FN_REFLEN - 5);
+    strmake(buff, pidfile_name, FN_REFLEN - 5);
     strmov(fn_ext(buff), suffix);
     return (const char *)buff;
   }

--- 1.479/sql/mysql_priv.h	2007-03-07 07:21:42 +01:00
+++ 1.480/sql/mysql_priv.h	2007-03-07 07:21:42 +01:00
@@ -1630,6 +1630,7 @@
 extern my_bool opt_readonly, lower_case_file_system;
 extern my_bool opt_enable_named_pipe, opt_sync_frm, opt_allow_suspicious_udfs;
 extern my_bool opt_secure_auth;
+extern char* opt_secure_file_priv;
 extern my_bool opt_log_slow_admin_statements;
 extern my_bool sp_automatic_privileges, opt_noacl;
 extern my_bool opt_old_style_user_limits, trust_function_creators;

--- 1.613/sql/mysqld.cc	2007-03-07 07:21:42 +01:00
+++ 1.614/sql/mysqld.cc	2007-03-07 07:21:42 +01:00
@@ -400,6 +400,7 @@
                innobase_use_native_aio,
                innobase_file_per_table, innobase_locks_unsafe_for_binlog,
                innobase_rollback_on_timeout,
+               innobase_stats_on_metadata,
                innobase_create_status_file;
 extern "C" {
 extern ulong srv_max_buf_pool_modified_pct;
@@ -437,6 +438,7 @@
 my_bool opt_readonly, use_temp_pool, relay_log_purge;
 my_bool opt_sync_frm, opt_allow_suspicious_udfs;
 my_bool opt_secure_auth= 0;
+char* opt_secure_file_priv= 0;
 my_bool opt_log_slow_admin_statements= 0;
 my_bool lower_case_file_system= 0;
 my_bool opt_large_pages= 0;
@@ -1245,6 +1247,7 @@
 #endif
   x_free(opt_bin_logname);
   x_free(opt_relay_logname);
+  x_free(opt_secure_file_priv);
   bitmap_free(&temp_pool);
   free_max_user_conn();
 #ifdef HAVE_REPLICATION
@@ -2170,7 +2173,10 @@
 
 extern "C" sig_handler handle_segfault(int sig)
 {
+  time_t curr_time;
+  struct tm tm;
   THD *thd=current_thd;
+
   /*
     Strictly speaking, one needs a mutex here
     but since we have got SIGSEGV already, things are a mess
@@ -2184,11 +2190,17 @@
   }
 
   segfaulted = 1;
+
+  curr_time= time(NULL);
+  localtime_r(&curr_time, &tm);
+
   fprintf(stderr,"\
-mysqld got signal %d;\n\
+%02d%02d%02d %2d:%02d:%02d - mysqld got signal %d;\n\
 This could be because you hit a bug. It is also possible that this binary\n\
 or one of the libraries it was linked against is corrupt, improperly built,\n\
 or misconfigured. This error can also be caused by malfunctioning hardware.\n",
+          tm.tm_year % 100, tm.tm_mon+1, tm.tm_mday,
+          tm.tm_hour, tm.tm_min, tm.tm_sec,
 	  sig);
   fprintf(stderr, "\
 We will try our best to scrape up some info that will hopefully help diagnose\n\
@@ -2747,9 +2759,15 @@
   */
   mysql_bin_log.init_pthread_objects();
 
-  if (gethostname(glob_hostname,sizeof(glob_hostname)-4) < 0)
-    strmov(glob_hostname,"mysql");
-  strmake(pidfile_name, glob_hostname, sizeof(pidfile_name)-5);
+  if (gethostname(glob_hostname,sizeof(glob_hostname)) < 0)
+  {
+    strmake(glob_hostname, STRING_WITH_LEN("localhost"));
+    sql_print_warning("gethostname failed, using '%s' as hostname",
+                      glob_hostname);
+    strmake(pidfile_name, STRING_WITH_LEN("mysql"));
+  }
+  else
+    strmake(pidfile_name, glob_hostname, sizeof(pidfile_name)-5);
   strmov(fn_ext(pidfile_name),".pid");		// Add proper extension
 
   /*
@@ -2846,10 +2864,33 @@
 #ifdef USE_REGEX
   my_regex_init(&my_charset_latin1);
 #endif
-  if (!(default_charset_info= get_charset_by_csname(default_character_set_name,
-						    MY_CS_PRIMARY,
-						    MYF(MY_WME))))
-    return 1;
+  /*
+    Process a comma-separated character set list and choose
+    the first available character set. This is mostly for
+    test purposes, to be able to start "mysqld" even if
+    the requested character set is not available (see bug#18743).
+  */
+  for (;;)
+  {
+    char *next_character_set_name= strchr(default_character_set_name, ',');
+    if (next_character_set_name)
+      *next_character_set_name++= '\0';
+    if (!(default_charset_info=
+          get_charset_by_csname(default_character_set_name,
+                                MY_CS_PRIMARY, MYF(MY_WME))))
+    {
+      if (next_character_set_name)
+      {
+        default_character_set_name= next_character_set_name;
+        default_collation_name= 0;          // Ignore collation
+      }
+      else
+        return 1;                           // Eof of the list
+    }
+    else
+      break;
+  }
+
   if (default_collation_name)
   {
     CHARSET_INFO *default_collation;
@@ -3184,7 +3225,7 @@
   if (opt_error_log)
   {
     if (!log_error_file_ptr[0])
-      fn_format(log_error_file, glob_hostname, mysql_data_home, ".err",
+      fn_format(log_error_file, pidfile_name, mysql_data_home, ".err",
                 MY_REPLACE_EXT); /* replace '.<domain>' by '.err', bug#4997 */
     else
       fn_format(log_error_file, log_error_file_ptr, mysql_data_home, ".err",
@@ -4943,6 +4984,7 @@
   OPT_INNODB_SYNC_SPIN_LOOPS,
   OPT_INNODB_CONCURRENCY_TICKETS,
   OPT_INNODB_THREAD_SLEEP_DELAY,
+  OPT_INNODB_STATS_ON_METADATA,
   OPT_BDB_CACHE_SIZE,
   OPT_BDB_CACHE_PARTS,
   OPT_BDB_LOG_BUFFER_SIZE,
@@ -4994,7 +5036,8 @@
   OPT_SLOW_LOG,
   OPT_MERGE,
   OPT_THREAD_HANDLING,
-  OPT_INNODB_ROLLBACK_ON_TIMEOUT
+  OPT_INNODB_ROLLBACK_ON_TIMEOUT,
+  OPT_SECURE_FILE_PRIV
 };
 
 
@@ -5289,6 +5332,10 @@
    "Enable SHOW INNODB STATUS output in the innodb_status.<pid> file",
    (gptr*) &innobase_create_status_file, (gptr*) &innobase_create_status_file,
    0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0},
+  {"innodb_stats_on_metadata", OPT_INNODB_STATS_ON_METADATA,
+   "Enable statistics gathering for metadata commands such as SHOW TABLE STATUS (on by
default)",
+   (gptr*) &innobase_stats_on_metadata, (gptr*) &innobase_stats_on_metadata,
+   0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
   {"innodb_support_xa", OPT_INNODB_SUPPORT_XA,
    "Enable InnoDB support for the XA two-phase commit",
    (gptr*) &global_system_variables.innodb_support_xa,
@@ -5697,6 +5744,10 @@
   {"secure-auth", OPT_SECURE_AUTH, "Disallow authentication for accounts that have old
(pre-4.1) passwords.",
    (gptr*) &opt_secure_auth, (gptr*) &opt_secure_auth, 0, GET_BOOL, NO_ARG,
    my_bool(0), 0, 0, 0, 0, 0},
+  {"secure-file-priv", OPT_SECURE_FILE_PRIV,
+   "Limit LOAD DATA, SELECT ... OUTFILE, and LOAD_FILE() to files within specified
directory",
+   (gptr*) &opt_secure_file_priv, (gptr*) &opt_secure_file_priv, 0,
+   GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
   {"server-id",	OPT_SERVER_ID,
    "Uniquely identifies the server instance in the community of replication partners.",
    (gptr*) &server_id, (gptr*) &server_id, 0, GET_ULONG, REQUIRED_ARG, 0, 0, 0,
@@ -7073,6 +7124,7 @@
   opt_logname= opt_update_logname= opt_binlog_index_name= opt_slow_logname= 0;
   opt_tc_log_file= (char *)"tc.log";      // no hostname in tc_log file name !
   opt_secure_auth= 0;
+  opt_secure_file_priv= 0;
   opt_bootstrap= opt_myisam_log= 0;
   mqh_used= 0;
   segfaulted= kill_in_progress= 0;
@@ -8139,6 +8191,16 @@
       exit(1);
   }
 #endif /* HAVE_REPLICATION */
+  /*
+    Convert the secure-file-priv option to system format, allowing
+    a quick strcmp to check if read or write is in an allowed dir
+   */
+  if (opt_secure_file_priv)
+  {
+    convert_dirname(buff, opt_secure_file_priv, NullS);
+    my_free(opt_secure_file_priv, MYF(0));
+    opt_secure_file_priv= my_strdup(buff, MYF(MY_FAE));
+  }
 }
 
 
@@ -8334,7 +8396,8 @@
         innobase_use_checksums,
         innobase_file_per_table,
         innobase_locks_unsafe_for_binlog,
-        innobase_rollback_on_timeout;
+        innobase_rollback_on_timeout,
+        innobase_stats_on_metadata;
 
 extern "C" {
 ulong srv_max_buf_pool_modified_pct;

--- 1.315/sql/sql_class.cc	2007-03-07 07:21:42 +01:00
+++ 1.316/sql/sql_class.cc	2007-03-07 07:21:42 +01:00
@@ -311,6 +311,38 @@
   substitute_null_with_insert_id = FALSE;
   thr_lock_info_init(&lock_info); /* safety: will be reset after start */
   thr_lock_owner_init(&main_lock_id, &lock_info);
+
+  m_internal_handler= NULL;
+}
+
+
+void THD::push_internal_handler(Internal_error_handler *handler)
+{
+  /*
+    TODO: The current implementation is limited to 1 handler at a time only.
+    THD and sp_rcontext need to be modified to use a common handler stack.
+  */
+  DBUG_ASSERT(m_internal_handler == NULL);
+  m_internal_handler= handler;
+}
+
+
+bool THD::handle_error(uint sql_errno,
+                       MYSQL_ERROR::enum_warning_level level)
+{
+  if (m_internal_handler)
+  {
+    return m_internal_handler->handle_error(sql_errno, level, this);
+  }
+
+  return FALSE;                                 // 'FALSE', as per coding style
+}
+
+
+void THD::pop_internal_handler()
+{
+  DBUG_ASSERT(m_internal_handler != NULL);
+  m_internal_handler= NULL;
 }
 
 
@@ -356,6 +388,7 @@
 
 void THD::init_for_queries()
 {
+  set_time(); 
   ha_enable_transaction(this,TRUE);
 
   reset_root_defaults(mem_root, variables.query_alloc_block_size,
@@ -998,6 +1031,7 @@
   enclosed=   line_start= &my_empty_string;
   line_term=  &default_line_term;
   escaped=    &default_escaped;
+  cs= NULL;
 }
 
 bool select_send::send_fields(List<Item> &list, uint flags)
@@ -2167,7 +2201,12 @@
       !current_stmt_binlog_row_based)
   {
     options&= ~OPTION_BIN_LOG;
-  }    
+  }
+
+  if ((backup->options & OPTION_BIN_LOG) &&
is_update_query(lex->sql_command)&&
+      !current_stmt_binlog_row_based)
+    mysql_bin_log.start_union_events(this, this->query_id);
+
   /* Disable result sets */
   client_capabilities &= ~CLIENT_MULTI_RESULTS;
   in_sub_stmt|= new_state;
@@ -2210,6 +2249,10 @@
   limit_found_rows= backup->limit_found_rows;
   sent_row_count=   backup->sent_row_count;
   client_capabilities= backup->client_capabilities;
+
+  if ((options & OPTION_BIN_LOG) && is_update_query(lex->sql_command)
&&
+    !current_stmt_binlog_row_based)
+    mysql_bin_log.stop_union_events(this);
 
   /*
     The following is added to the old values as we are interested in the

--- 1.341/sql/sql_class.h	2007-03-07 07:21:42 +01:00
+++ 1.342/sql/sql_class.h	2007-03-07 07:21:42 +01:00
@@ -813,6 +813,49 @@
 };
 
 
+/**
+  This class represents the interface for internal error handlers.
+  Internal error handlers are exception handlers used by the server
+  implementation.
+*/
+class Internal_error_handler
+{
+protected:
+  Internal_error_handler() {}
+  virtual ~Internal_error_handler() {}
+
+public:
+  /**
+    Handle an error condition.
+    This method can be implemented by a subclass to achieve any of the
+    following:
+    - mask an error internally, prevent exposing it to the user,
+    - mask an error and throw another one instead.
+    When this method returns true, the error condition is considered
+    'handled', and will not be propagated to upper layers.
+    It is the responsability of the code installing an internal handler
+    to then check for trapped conditions, and implement logic to recover
+    from the anticipated conditions trapped during runtime.
+
+    This mechanism is similar to C++ try/throw/catch:
+    - 'try' correspond to <code>THD::push_internal_handler()</code>,
+    - 'throw' correspond to <code>my_error()</code>,
+    which invokes <code>my_message_sql()</code>,
+    - 'catch' correspond to checking how/if an internal handler was invoked,
+    before removing it from the exception stack with
+    <code>THD::pop_internal_handler()</code>.
+
+    @param sql_errno the error number
+    @param level the error level
+    @param thd the calling thread
+    @return true if the error is handled
+  */
+  virtual bool handle_error(uint sql_errno,
+                            MYSQL_ERROR::enum_warning_level level,
+                            THD *thd) = 0;
+};
+
+
 /*
   For each client connection we create a separate thread with THD serving as
   a thread/connection descriptor
@@ -1632,6 +1675,31 @@
     return FALSE;
   }
   thd_scheduler scheduler;
+
+public:
+  /**
+    Add an internal error handler to the thread execution context.
+    @param handler the exception handler to add
+  */
+  void push_internal_handler(Internal_error_handler *handler);
+
+  /**
+    Handle an error condition.
+    @param sql_errno the error number
+    @param level the error level
+    @return true if the error is handled
+  */
+  virtual bool handle_error(uint sql_errno,
+                            MYSQL_ERROR::enum_warning_level level);
+
+  /**
+    Remove the error handler last pushed.
+  */
+  void pop_internal_handler();
+
+private:
+  /** The current internal error handler for this thread, or NULL. */
+  Internal_error_handler *m_internal_handler;
 };
 
 
@@ -1656,6 +1724,7 @@
   bool opt_enclosed;
   bool dumpfile;
   ulong skip_lines;
+  CHARSET_INFO *cs;
   sql_exchange(char *name,bool dumpfile_flag);
 };
 

--- 1.115/sql/sql_load.cc	2007-03-07 07:21:42 +01:00
+++ 1.116/sql/sql_load.cc	2007-03-07 07:21:42 +01:00
@@ -325,7 +325,8 @@
   info.handle_duplicates=handle_duplicates;
   info.escape_char=escaped->length() ? (*escaped)[0] : INT_MAX;
 
-  READ_INFO read_info(file,tot_length,thd->variables.collation_database,
+  READ_INFO read_info(file,tot_length,
+                      ex->cs ? ex->cs : thd->variables.collation_database,
 		      *field_term,*ex->line_start, *ex->line_term, *enclosed,
 		      info.escape_char, read_file_from_client, is_fifo);
   if (read_info.error)
@@ -467,7 +468,6 @@
   }
   sprintf(name, ER(ER_LOAD_INFO), (ulong) info.records, (ulong) info.deleted,
 	  (ulong) (info.records - info.copied), (ulong) thd->cuted_fields);
-  send_ok(thd,info.copied+info.deleted,0L,name);
 
   if (!transactional_table)
     thd->options|=OPTION_STATUS_NO_TRANS_UPDATE;
@@ -503,6 +503,8 @@
   if (transactional_table)
     error=ha_autocommit_or_rollback(thd,error);
 
+  /* ok to client sent only after binlog write and engine commit */
+  send_ok(thd, info.copied + info.deleted, 0L, name);
 err:
   table->file->ha_release_auto_increment();
   if (thd->lock)

--- 1.635/sql/sql_parse.cc	2007-03-07 07:21:43 +01:00
+++ 1.636/sql/sql_parse.cc	2007-03-07 07:21:43 +01:00
@@ -369,6 +369,7 @@
     thd->query= thd->memdup_w_gap(buff, length+1, 
 				  thd->db_length+1+QUERY_CACHE_FLAGS_SIZE);
     thd->query[length] = '\0';
+    DBUG_PRINT("query",("%-.4096s",thd->query));
     /*
       We don't need to obtain LOCK_thread_count here because in bootstrap
       mode we have only one thread.
@@ -377,16 +378,26 @@
     thd->set_time();
     mysql_parse(thd,thd->query,length);
     close_thread_tables(thd);			// Free tables
+
     if (thd->is_fatal_error)
       break;
+
+    if (thd->net.report_error)
+    {
+      /* The query failed, send error to log and abort bootstrap */
+      net_send_error(thd);
+      thd->fatal_error();
+      break;
+    }
+
     free_root(thd->mem_root,MYF(MY_KEEP_PREALLOC));
 #ifdef USING_TRANSACTIONS
     free_root(&thd->transaction.mem_root,MYF(MY_KEEP_PREALLOC));
 #endif
   }
 
-  /* thd->fatal_error should be set in case something went wrong */
 end:
+  /* Remember the exit code of bootstrap */
   bootstrap_error= thd->is_fatal_error;
 
   net_end(&thd->net);

--- 1.25/sql/event_queue.cc	2007-03-07 07:21:43 +01:00
+++ 1.26/sql/event_queue.cc	2007-03-07 07:21:43 +01:00
@@ -150,13 +150,6 @@
     goto err;
   }
 
-  if (sizeof(my_time_t) != sizeof(time_t))
-  {
-    sql_print_error("SCHEDULER: sizeof(my_time_t) != sizeof(time_t) ."
-                    "The scheduler may not work correctly. Stopping");
-    goto err;
-  }
-
   UNLOCK_QUEUE_DATA();
   DBUG_RETURN(FALSE);
 

--- 1.30/mysql-test/r/mysqlbinlog.result	2007-03-07 07:21:43 +01:00
+++ 1.31/mysql-test/r/mysqlbinlog.result	2007-03-07 07:21:43 +01:00
@@ -255,5 +255,63 @@
 1
 1
 drop procedure p1;
-End of 5.0 tests
 flush logs;
+create table t1 (a varchar(64) character set utf8);
+load data infile '../std_data_ln/loaddata6.dat' into table t1;
+set character_set_database=koi8r;
+load data infile '../std_data_ln/loaddata6.dat' into table t1;
+set character_set_database=latin1;
+load data infile '../std_data_ln/loaddata6.dat' into table t1;
+load data infile '../std_data_ln/loaddata6.dat' into table t1;
+set character_set_database=koi8r;
+load data infile '../std_data_ln/loaddata6.dat' into table t1;
+set character_set_database=latin1;
+load data infile '../std_data_ln/loaddata6.dat' into table t1;
+load data infile '../std_data_ln/loaddata6.dat' into table t1 character set koi8r;
+select hex(a) from t1;
+hex(a)
+C3BF
+D0AA
+C3BF
+C3BF
+D0AA
+C3BF
+D0AA
+drop table t1;
+flush logs;
+/*!40019 SET @@session.max_insert_delayed_threads=0*/;
+/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
+DELIMITER /*!*/;
+use test/*!*/;
+SET TIMESTAMP=1000000000/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1,
@@session.unique_checks=1/*!*/;
+SET @@session.sql_mode=0/*!*/;
+/*!\C latin1 *//*!*/;
+SET
@@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/;
+create table t1 (a varchar(64) character set utf8)/*!*/;
+SET TIMESTAMP=1000000000/*!*/;
+load data LOCAL INFILE 'MYSQL_TMP_DIR/SQL_LOAD_MB-6-0' INTO table t1/*!*/;
+SET TIMESTAMP=1000000000/*!*/;
+SET @@session.collation_database=7/*!*/;
+load data LOCAL INFILE 'MYSQL_TMP_DIR/SQL_LOAD_MB-7-0' INTO table t1/*!*/;
+SET TIMESTAMP=1000000000/*!*/;
+SET @@session.collation_database=DEFAULT/*!*/;
+load data LOCAL INFILE 'MYSQL_TMP_DIR/SQL_LOAD_MB-8-0' INTO table t1/*!*/;
+SET TIMESTAMP=1000000000/*!*/;
+load data LOCAL INFILE 'MYSQL_TMP_DIR/SQL_LOAD_MB-9-0' INTO table t1/*!*/;
+SET TIMESTAMP=1000000000/*!*/;
+SET @@session.collation_database=7/*!*/;
+load data LOCAL INFILE 'MYSQL_TMP_DIR/SQL_LOAD_MB-a-0' INTO table t1/*!*/;
+SET TIMESTAMP=1000000000/*!*/;
+SET @@session.collation_database=DEFAULT/*!*/;
+load data LOCAL INFILE 'MYSQL_TMP_DIR/SQL_LOAD_MB-b-0' INTO table t1/*!*/;
+SET TIMESTAMP=1000000000/*!*/;
+load data LOCAL INFILE 'MYSQL_TMP_DIR/SQL_LOAD_MB-c-0' INTO table t1 character set
koi8r/*!*/;
+SET TIMESTAMP=1000000000/*!*/;
+drop table t1/*!*/;
+DELIMITER ;
+# End of log file
+ROLLBACK /* added by mysqlbinlog */;
+/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
+flush logs;
+End of 5.0 tests

--- 1.39/mysql-test/t/mysqlbinlog.test	2007-03-07 07:21:43 +01:00
+++ 1.40/mysql-test/t/mysqlbinlog.test	2007-03-07 07:21:43 +01:00
@@ -182,6 +182,31 @@
 --exec $MYSQL_BINLOG --version 2>&1 > /dev/null
 --exec $MYSQL_BINLOG --help 2>&1 > /dev/null
 --enable_query_log
+
+#
+# Bug#15126 character_set_database is not replicated
+# (LOAD DATA INFILE need it)
+#
+
+flush logs;
+create table t1 (a varchar(64) character set utf8);
+load data infile '../std_data_ln/loaddata6.dat' into table t1;
+set character_set_database=koi8r;
+load data infile '../std_data_ln/loaddata6.dat' into table t1;
+set character_set_database=latin1;
+load data infile '../std_data_ln/loaddata6.dat' into table t1;
+load data infile '../std_data_ln/loaddata6.dat' into table t1;
+set character_set_database=koi8r;
+load data infile '../std_data_ln/loaddata6.dat' into table t1;
+set character_set_database=latin1;
+load data infile '../std_data_ln/loaddata6.dat' into table t1;
+load data infile '../std_data_ln/loaddata6.dat' into table t1 character set koi8r;
+select hex(a) from t1;
+drop table t1;
+flush logs;
+--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
+--exec $MYSQL_BINLOG --short-form $MYSQLTEST_VARDIR/log/master-bin.000010
+
 --echo End of 5.0 tests
 
 #
@@ -189,7 +214,7 @@
 #
 flush logs;
 --error 1
---exec $MYSQL_BINLOG $MYSQLTEST_VARDIR/log/master-bin.000010 >/dev/null 2>/dev/null
---exec $MYSQL_BINLOG --force-if-open $MYSQLTEST_VARDIR/log/master-bin.000010
>/dev/null 2>/dev/null
+--exec $MYSQL_BINLOG $MYSQLTEST_VARDIR/log/master-bin.000014 >/dev/null 2>/dev/null
+--exec $MYSQL_BINLOG --force-if-open $MYSQLTEST_VARDIR/log/master-bin.000012
>/dev/null 2>/dev/null
 
-# End of 5.1 tests
+--echo End of 5.1 tests

--- 1.84/sql/sql_trigger.cc	2007-03-07 07:21:43 +01:00
+++ 1.85/sql/sql_trigger.cc	2007-03-07 07:21:43 +01:00
@@ -106,10 +106,6 @@
 };
 
 
-static int
-add_table_for_trigger(THD *thd, sp_name *trig, bool if_exists,
-                      TABLE_LIST ** table);
-
 class Handle_old_incorrect_sql_modes_hook: public Unknown_key_hook
 {
 private:
@@ -1180,7 +1176,7 @@
     1 Error
 */
 
-static int
+int
 add_table_for_trigger(THD *thd, sp_name *trig, bool if_exists,
                       TABLE_LIST **table)
 {

--- 1.17/mysql-test/r/rpl_switch_stm_row_mixed.result	2007-03-07 07:21:44 +01:00
+++ 1.18/mysql-test/r/rpl_switch_stm_row_mixed.result	2007-03-07 07:21:43 +01:00
@@ -7,6 +7,7 @@
 drop database if exists mysqltest1;
 create database mysqltest1;
 use mysqltest1;
+set @my_binlog_format= @@global.binlog_format;
 set session binlog_format=mixed;
 show session variables like "binlog_format%";
 Variable_name	Value
@@ -1025,3 +1026,4 @@
 master-bin.000001	#	Table_map	1	#	table_id: # (mysqltest1.t12)
 master-bin.000001	#	Write_rows	1	#	table_id: # flags: STMT_END_F
 drop database mysqltest1;
+set global binlog_format =@my_binlog_format;

--- 1.14/mysql-test/t/rpl_switch_stm_row_mixed.test	2007-03-07 07:21:44 +01:00
+++ 1.15/mysql-test/t/rpl_switch_stm_row_mixed.test	2007-03-07 07:21:44 +01:00
@@ -19,6 +19,8 @@
 --enable_warnings
 use mysqltest1;
 
+# Save binlog format
+set @my_binlog_format= @@global.binlog_format;
 
 #  play with switching
 set session binlog_format=mixed;
@@ -531,7 +533,7 @@
 # will be created. You will need to go to the mysql-test dir and diff
 # the files your self to see what is not matching
 
---exec diff $MYSQLTEST_VARDIR/tmp/rpl_switch_stm_row_mixed_master.sql
$MYSQLTEST_VARDIR/tmp/rpl_switch_stm_row_mixed_slave.sql;
+diff_files $MYSQLTEST_VARDIR/tmp/rpl_switch_stm_row_mixed_master.sql
$MYSQLTEST_VARDIR/tmp/rpl_switch_stm_row_mixed_slave.sql;
 
 connection master;
 --replace_column 2 # 5 #
@@ -559,8 +561,12 @@
 --exec $MYSQL_DUMP --compact --order-by-primary --skip-extended-insert --no-create-info
mysqltest1 > $MYSQLTEST_VARDIR/tmp/rpl_switch_stm_row_mixed_master.sql
 # the old mysqldump output on slave is the same as what it was on
 # master before restoring on master.
---exec diff $MYSQLTEST_VARDIR/tmp/rpl_switch_stm_row_mixed_master.sql
$MYSQLTEST_VARDIR/tmp/rpl_switch_stm_row_mixed_slave.sql;
+diff_files $MYSQLTEST_VARDIR/tmp/rpl_switch_stm_row_mixed_master.sql
$MYSQLTEST_VARDIR/tmp/rpl_switch_stm_row_mixed_slave.sql;
 }
 
 drop database mysqltest1;
 sync_slave_with_master;
+
+connection master;
+# Restore binlog format setting
+set global binlog_format =@my_binlog_format;

--- 1.27/client/mysql_upgrade.c	2007-03-07 07:21:44 +01:00
+++ 1.28/client/mysql_upgrade.c	2007-03-07 07:21:44 +01:00
@@ -173,7 +173,7 @@
       }
 
       d= (extra_default_t *)my_malloc(sizeof(extra_default_t), 
-                           MYF(MY_FAE|MY_ZEROFILL));
+                                      MYF(MY_FAE | MY_ZEROFILL));
       d->id= id;
       d->name= opt->name;
       d->n_len= strlen(opt->name);
@@ -366,7 +366,7 @@
       goto error;
     }
     DBUG_PRINT("info", ("%s", buf.str));
-    my_free((gptr)d, MYF(0));
+    my_free((gptr) d, MYF(0));
     list_pop(extra_defaults);                   /* pop off the head */
   }
   if (my_write(defaults_file, buf.str, buf.length, MYF(MY_FNABP | MY_WME)))

--- 1.280/mysql-test/mysql-test-run.pl	2007-03-07 07:21:45 +01:00
+++ 1.281/mysql-test/mysql-test-run.pl	2007-03-07 07:21:47 +01:00
@@ -3065,6 +3065,7 @@
 character-sets-dir  = $path_charsetsdir
 basedir             = $path_my_basedir
 server_id           = $server_id
+shutdown-delay      = 10
 skip-stack-trace
 skip-innodb
 skip-ndbcluster

--- 1.235/mysql-test/t/disabled.def	2007-03-07 07:21:47 +01:00
+++ 1.236/mysql-test/t/disabled.def	2007-03-07 07:21:47 +01:00
@@ -35,7 +35,6 @@
 #ndb_binlog_discover      : bug#21806 2006-08-24
 #ndb_autodiscover3        : bug#21806
 
-mysql_upgrade            : Bug#25074 mysql_upgrade gives inconsisten results
 plugin                   : Bug#25659 memory leak via "plugins" test
 rpl_ndb_dd_advance	 : Bug#25913 rpl_ndb_dd_advance fails randomly
 ndb_alter_table		 : Bug##25774 ndb_alter_table.test fails in DBUG_ASSERT() on Linux x64

--- 1.6/mysql-test/r/binlog_row_ctype_cp932.result	2007-03-07 07:21:47 +01:00
+++ 1.7/mysql-test/r/binlog_row_ctype_cp932.result	2007-03-07 07:21:47 +01:00
@@ -11365,3 +11365,13 @@
 hex(a)
 82A0
 drop table t1;
+ソ
+ソ
+c_cp932
+ソ
+ソ
+ソ
+繧ス
+繧ス
+ソ
+ソ

--- 1.219/sql/set_var.cc	2007-03-07 07:21:47 +01:00
+++ 1.220/sql/set_var.cc	2007-03-07 07:21:47 +01:00
@@ -2635,7 +2635,7 @@
   {
     switch (log_type) {
     case QUERY_LOG_SLOW:
-      file_log->open_slow_log(sys_var_general_log_path.value);
+      file_log->open_slow_log(sys_var_slow_log_path.value);
       break;
     case QUERY_LOG_GENERAL:
       file_log->open_query_log(sys_var_general_log_path.value);

--- 1.251/mysql-test/r/sp.result	2007-03-07 07:21:48 +01:00
+++ 1.252/mysql-test/r/sp.result	2007-03-07 07:21:48 +01:00
@@ -1155,9 +1155,13 @@
 return (select count(*) from t3)|
 drop temporary table t3|
 select f12_1()|
-ERROR 42S02: Table 'test.t3' doesn't exist
+f12_1()
+3
+Warnings:
+Note	1051	Unknown table 't3'
 select f12_1() from t1 limit 1|
-ERROR 42S02: Table 'test.t3' doesn't exist
+f12_1()
+3
 drop function f0|
 drop function f1|
 drop function f2|
@@ -5819,4 +5823,38 @@
 CALL bug24117()|
 DROP PROCEDURE bug24117|
 DROP TABLE t3|
+drop function if exists func_8407_a|
+drop function if exists func_8407_b|
+create function func_8407_a() returns int
+begin
+declare x int;
+declare continue handler for sqlexception
+begin
+end;
+select 1 from no_such_view limit 1 into x;
+return x;
+end|
+create function func_8407_b() returns int
+begin
+declare x int default 0;
+declare continue handler for sqlstate '42S02'
+  begin
+set x:= x+1000;
+end;
+case (select 1 from no_such_view limit 1)
+when 1 then set x:= x+1;
+when 2 then set x:= x+2;
+else set x:= x+100;
+end case;
+set x:=x + 500;
+return x;
+end|
+select func_8407_a()|
+func_8407_a()
+NULL
+select func_8407_b()|
+func_8407_b()
+1500
+drop function func_8407_a|
+drop function func_8407_b|
 drop table t1,t2;

--- 1.219/mysql-test/t/sp.test	2007-03-07 07:21:48 +01:00
+++ 1.220/mysql-test/t/sp.test	2007-03-07 07:21:48 +01:00
@@ -1371,7 +1371,7 @@
 select f11()|
 --error ER_CANT_REOPEN_TABLE
 select f11() from t1|
-# We don't handle temporary tables used by nested functions well
+# Test that using a single table instance at a time works
 create function f12_1() returns int
 begin
   drop temporary table if exists t3;
@@ -1381,11 +1381,9 @@
 end|
 create function f12_2() returns int
   return (select count(*) from t3)|
-# We need clean start to get error
+
 drop temporary table t3|
---error ER_NO_SUCH_TABLE
 select f12_1()|
---error ER_NO_SUCH_TABLE
 select f12_1() from t1 limit 1|
 
 # Cleanup
@@ -6781,6 +6779,53 @@
 CALL bug24117()|
 DROP PROCEDURE bug24117|
 DROP TABLE t3|
+
+#
+# Bug#8407(Stored functions/triggers ignore exception handler)
+#
+
+--disable_warnings
+drop function if exists func_8407_a|
+drop function if exists func_8407_b|
+--enable_warnings
+
+create function func_8407_a() returns int
+begin
+  declare x int;
+
+  declare continue handler for sqlexception
+  begin
+  end;
+
+  select 1 from no_such_view limit 1 into x;
+
+  return x;
+end|
+
+create function func_8407_b() returns int
+begin
+  declare x int default 0;
+
+  declare continue handler for sqlstate '42S02'
+  begin
+    set x:= x+1000;
+  end;
+
+  case (select 1 from no_such_view limit 1)
+    when 1 then set x:= x+1;
+    when 2 then set x:= x+2;
+    else set x:= x+100;
+  end case;
+  set x:=x + 500;
+  
+  return x;
+end|
+
+select func_8407_a()|
+select func_8407_b()|
+
+drop function func_8407_a|
+drop function func_8407_b|
 
 #
 # NOTE: The delimiter is `|`, and not `;`. It is changed to `;`

--- 1.13/mysql-test/r/binlog_stm_ctype_cp932.result	2007-03-07 07:21:48 +01:00
+++ 1.14/mysql-test/r/binlog_stm_ctype_cp932.result	2007-03-07 07:21:48 +01:00
@@ -11365,3 +11365,13 @@
 hex(a)
 82A0
 drop table t1;
+ソ
+ソ
+c_cp932
+ソ
+ソ
+ソ
+繧ス
+繧ス
+ソ
+ソ

--- 1.15/mysql-test/extra/binlog_tests/ctype_cp932.test	2007-03-07 07:21:48 +01:00
+++ 1.16/mysql-test/extra/binlog_tests/ctype_cp932.test	2007-03-07 07:21:48 +01:00
@@ -424,3 +424,17 @@
 select * from t1;
 select hex(a) from t1;
 drop table t1;
+
+#
+# BUG#16217 - MySQL client misinterpretes multi-byte char as escape `\' 
+#
+
+# new command \C or charset
+--exec $MYSQL --default-character-set=utf8 test -e "\C cp932 \g"
+--exec $MYSQL --default-character-set=cp932 test -e "charset utf8;"
+
+# its usage to switch internally in mysql to requested charset
+--exec $MYSQL --default-character-set=utf8 test -e "charset cp932; select 'ソ'; create
table t1 (c_cp932 TEXT CHARACTER SET cp932); insert into t1 values('ソ'); select * from
t1;  drop table t1;"
+--exec $MYSQL --default-character-set=utf8 test -e "charset cp932; select 'ソ'"
+--exec $MYSQL --default-character-set=utf8 test -e "/*charset cp932 */; set
character_set_client= cp932; select 'ソ'"
+--exec $MYSQL --default-character-set=utf8 test -e "/*!\C cp932 */; set
character_set_client= cp932; select 'ソ'"
Thread
bk commit into 5.1 tree (tsmith:1.2455)tim7 Mar