List:Internals« Previous MessageNext Message »
From:dlenev Date:March 15 2005 8:31am
Subject:bk commit into 5.0 tree (dlenev:1.1814)
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of dlenev. When dlenev 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://www.mysql.com/doc/I/n/Installing_source_tree.html

ChangeSet
  1.1814 05/03/15 11:31:32 dlenev@stripped +62 -0
  WL#874 "Extended LOAD DATA"
  
  Merging the patch with current 5.0 tree.
  Not to be pushed as is.

  mysql-test/std_data/loaddata5.dat
    1.1 05/03/15 11:30:33 dlenev@stripped +3 -0

  sql/sql_yacc.yy
    1.330 05/03/15 11:30:33 dlenev@stripped +57 -22
    Commit for merge with current tree only.

  sql/sql_repl.h
    1.36 05/03/15 11:30:33 dlenev@stripped +1 -6
    Commit for merge with current tree only.

  sql/sql_repl.cc
    1.126 05/03/15 11:30:33 dlenev@stripped +6 -7
    Commit for merge with current tree only.

  mysql-test/std_data/loaddata5.dat
    1.0 05/03/15 11:30:33 dlenev@stripped +0 -0
    BitKeeper file /home/dlenev/src/mysql-5.0-874/mysql-test/std_data/loaddata5.dat

  sql/sql_parse.cc
    1.394 05/03/15 11:30:32 dlenev@stripped +9 -3
    Commit for merge with current tree only.

  sql/sql_load.cc
    1.73 05/03/15 11:30:32 dlenev@stripped +184 -81
    Commit for merge with current tree only.

  sql/sql_lex.h
    1.160 05/03/15 11:30:32 dlenev@stripped +6 -0
    Commit for merge with current tree only.

  sql/share/errmsg.txt
    1.7 05/03/15 11:30:32 dlenev@stripped +2 -0
    Commit for merge with current tree only.

  sql/mysql_priv.h
    1.248 05/03/15 11:30:32 dlenev@stripped +4 -2
    Commit for merge with current tree only.

  sql/log_event.h
    1.101 05/03/15 11:30:32 dlenev@stripped +107 -5
    Commit for merge with current tree only.

  sql/log_event.cc
    1.153 05/03/15 11:30:32 dlenev@stripped +329 -53
    Commit for merge with current tree only.

  sql/item_func.h
    1.93 05/03/15 11:30:32 dlenev@stripped +28 -0
    Commit for merge with current tree only.

  sql/item_func.cc
    1.160 05/03/15 11:30:32 dlenev@stripped +101 -10
    Commit for merge with current tree only.

  mysql-test/t/user_var.test
    1.19 05/03/15 11:30:32 dlenev@stripped +1 -1
    Commit for merge with current tree only.

  mysql-test/t/rpl_user_variables.test
    1.9 05/03/15 11:30:32 dlenev@stripped +1 -1
    Commit for merge with current tree only.

  mysql-test/t/rpl_until.test
    1.14 05/03/15 11:30:32 dlenev@stripped +5 -5
    Commit for merge with current tree only.

  mysql-test/t/rpl_log_pos.test
    1.32 05/03/15 11:30:32 dlenev@stripped +1 -1
    Commit for merge with current tree only.

  mysql-test/t/rpl_log.test
    1.24 05/03/15 11:30:32 dlenev@stripped +3 -3
    Commit for merge with current tree only.

  mysql-test/t/rpl_loaddatalocal.test
    1.4 05/03/15 11:30:32 dlenev@stripped +24 -0
    Commit for merge with current tree only.

  mysql-test/t/rpl_loaddata_rule_s.test
    1.5 05/03/15 11:30:32 dlenev@stripped +1 -1
    Commit for merge with current tree only.

  mysql-test/t/rpl_loaddata_rule_m.test
    1.7 05/03/15 11:30:32 dlenev@stripped +4 -1
    Commit for merge with current tree only.

  mysql-test/t/rpl_loaddata.test
    1.15 05/03/15 11:30:32 dlenev@stripped +5 -3
    Commit for merge with current tree only.

  mysql-test/t/rpl_error_ignored_table.test
    1.12 05/03/15 11:30:32 dlenev@stripped +1 -1
    Commit for merge with current tree only.

  mysql-test/t/rpl_charset.test
    1.11 05/03/15 11:30:32 dlenev@stripped +3 -3
    Commit for merge with current tree only.

  mysql-test/t/mysqldump.test
    1.27 05/03/15 11:30:32 dlenev@stripped +1 -1
    Commit for merge with current tree only.

  mysql-test/t/mysqlbinlog2.test
    1.3 05/03/15 11:30:32 dlenev@stripped +8 -8
    Commit for merge with current tree only.

  mysql-test/t/mysqlbinlog.test
    1.13 05/03/15 11:30:32 dlenev@stripped +2 -3
    Commit for merge with current tree only.

  mysql-test/t/mix_innodb_myisam_binlog.test
    1.11 05/03/15 11:30:32 dlenev@stripped +12 -12
    Commit for merge with current tree only.

  mysql-test/t/loaddata.test
    1.8 05/03/15 11:30:32 dlenev@stripped +33 -0
    Commit for merge with current tree only.

  mysql-test/t/ctype_ucs.test
    1.23 05/03/15 11:30:32 dlenev@stripped +1 -1
    Commit for merge with current tree only.

  mysql-test/r/user_var.result
    1.24 05/03/15 11:30:32 dlenev@stripped +6 -6
    Commit for merge with current tree only.

  mysql-test/r/rpl_user_variables.result
    1.11 05/03/15 11:30:32 dlenev@stripped +28 -28
    Commit for merge with current tree only.

  mysql-test/r/rpl_until.result
    1.17 05/03/15 11:30:32 dlenev@stripped +16 -16
    Commit for merge with current tree only.

  mysql-test/r/rpl_timezone.result
    1.5 05/03/15 11:30:32 dlenev@stripped +7 -7
    Commit for merge with current tree only.

  mysql-test/r/rpl_temporary.result
    1.14 05/03/15 11:30:32 dlenev@stripped +13 -13
    Commit for merge with current tree only.

  mysql-test/r/rpl_server_id2.result
    1.7 05/03/15 11:30:32 dlenev@stripped +1 -1
    Commit for merge with current tree only.

  mysql-test/r/rpl_server_id1.result
    1.6 05/03/15 11:30:32 dlenev@stripped +1 -1
    Commit for merge with current tree only.

  mysql-test/r/rpl_rotate_logs.result
    1.59 05/03/15 11:30:32 dlenev@stripped +4 -4
    Commit for merge with current tree only.

  mysql-test/r/rpl_reset_slave.result
    1.12 05/03/15 11:30:32 dlenev@stripped +3 -3
    Commit for merge with current tree only.

  mysql-test/r/rpl_replicate_do.result
    1.25 05/03/15 11:30:31 dlenev@stripped +1 -1
    Commit for merge with current tree only.

  mysql-test/r/rpl_relayrotate.result
    1.11 05/03/15 11:30:31 dlenev@stripped +1 -1
    Commit for merge with current tree only.

  mysql-test/r/rpl_max_relay_size.result
    1.16 05/03/15 11:30:31 dlenev@stripped +6 -6
    Commit for merge with current tree only.

  mysql-test/r/rpl_log_pos.result
    1.41 05/03/15 11:30:31 dlenev@stripped +4 -4
    Commit for merge with current tree only.

  mysql-test/r/rpl_log.result
    1.53 05/03/15 11:30:31 dlenev@stripped +51 -51
    Commit for merge with current tree only.

  mysql-test/r/rpl_loaddatalocal.result
    1.5 05/03/15 11:30:31 dlenev@stripped +17 -0
    Commit for merge with current tree only.

  mysql-test/r/rpl_loaddata_rule_s.result
    1.6 05/03/15 11:30:31 dlenev@stripped +1 -1
    Commit for merge with current tree only.

  mysql-test/r/rpl_loaddata_rule_m.result
    1.10 05/03/15 11:30:31 dlenev@stripped +5 -3
    Commit for merge with current tree only.

  mysql-test/r/rpl_loaddata.result
    1.24 05/03/15 11:30:31 dlenev@stripped +4 -4
    Commit for merge with current tree only.

  mysql-test/r/rpl_flush_tables.result
    1.8 05/03/15 11:30:31 dlenev@stripped +17 -17
    Commit for merge with current tree only.

  mysql-test/r/rpl_flush_log_loop.result
    1.19 05/03/15 11:30:31 dlenev@stripped +1 -1
    Commit for merge with current tree only.

  mysql-test/r/rpl_error_ignored_table.result
    1.16 05/03/15 11:30:31 dlenev@stripped +11 -11
    Commit for merge with current tree only.

  mysql-test/r/rpl_charset.result
    1.12 05/03/15 11:30:31 dlenev@stripped +5 -5
    Commit for merge with current tree only.

  mysql-test/r/rpl_change_master.result
    1.12 05/03/15 11:30:31 dlenev@stripped +2 -2
    Commit for merge with current tree only.

  mysql-test/r/rpl000015.result
    1.33 05/03/15 11:30:31 dlenev@stripped +2 -2
    Commit for merge with current tree only.

  mysql-test/r/mysqldump.result
    1.28 05/03/15 11:30:31 dlenev@stripped +1 -1
    Commit for merge with current tree only.

  mysql-test/r/mysqlbinlog.result
    1.10 05/03/15 11:30:31 dlenev@stripped +16 -11
    Commit for merge with current tree only.

  mysql-test/r/mix_innodb_myisam_binlog.result
    1.13 05/03/15 11:30:31 dlenev@stripped +59 -59
    Commit for merge with current tree only.

  mysql-test/r/loaddata.result
    1.16 05/03/15 11:30:31 dlenev@stripped +46 -0
    Commit for merge with current tree only.

  mysql-test/r/insert_select.result
    1.23 05/03/15 11:30:31 dlenev@stripped +3 -3
    Commit for merge with current tree only.

  mysql-test/r/drop_temp_table.result
    1.11 05/03/15 11:30:31 dlenev@stripped +5 -5
    Commit for merge with current tree only.

  mysql-test/r/ctype_ucs.result
    1.25 05/03/15 11:30:31 dlenev@stripped +3 -3
    Commit for merge with current tree only.

  client/mysqlbinlog.cc
    1.100 05/03/15 11:30:31 dlenev@stripped +124 -47
    Commit for merge with current tree only.

# 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:	dlenev
# Host:	brandersnatch.localdomain
# Root:	/home/dlenev/src/mysql-5.0-874

--- 1.159/sql/item_func.cc	Thu Jan  6 14:31:29 2005
+++ 1.160/sql/item_func.cc	Tue Mar 15 11:30:32 2005
@@ -2522,12 +2522,28 @@
 }
 
 
-bool Item_func_set_user_var::update_hash(void *ptr, uint length,
-					 Item_result type,
-					 CHARSET_INFO *cs,
-					 Derivation dv)
+/*
+  Set value to user variable.
+
+  SYNOPSYS
+    update_hash()
+    entry    - pointer to structure representing variable
+    set_null - should we set NULL value ?
+    ptr      - pointer to buffer with new value
+    length   - length of new value
+    type     - type of new value
+    cs       - charset info for new value
+    dv       - derivation for new value
+
+  RETURN VALUE
+    False - success, True - failure
+*/
+
+static bool
+update_hash(user_var_entry *entry, bool set_null, void *ptr, uint length,
+            Item_result type, CHARSET_INFO *cs, Derivation dv)
 {
-  if ((null_value=args[0]->null_value))
+  if (set_null)
   {
     char *pos= (char*) entry+ ALIGN_SIZE(sizeof(user_var_entry));
     if (entry->value && entry->value != pos)
@@ -2560,7 +2576,7 @@
 	  entry->value=0;
 	if (!(entry->value=(char*) my_realloc(entry->value, length,
 					      MYF(MY_ALLOW_ZERO_PTR))))
-	  goto err;
+	  return 1;
       }
     }
     if (type == STRING_RESULT)
@@ -2574,11 +2590,21 @@
     entry->collation.set(cs, dv);
   }
   return 0;
+}
 
- err:
-  current_thd->fatal_error();			// Probably end of memory
-  null_value= 1;
-  return 1;
+
+bool
+Item_func_set_user_var::update_hash(void *ptr, uint length, Item_result type,
+                                    CHARSET_INFO *cs, Derivation dv)
+{
+  if (::update_hash(entry, (null_value= args[0]->null_value),
+                    ptr, length, type, cs, dv))
+  {
+    current_thd->fatal_error();     // Probably end of memory
+    null_value= 1;
+    return 1;
+  }
+  return 0;
 }
 
 
@@ -3019,6 +3045,71 @@
   Item_func_get_user_var *other=(Item_func_get_user_var*) item;
   return (name.length == other->name.length &&
 	  !memcmp(name.str, other->name.str, name.length));
+}
+
+
+bool Item_user_var_as_out_param::fix_fields(THD *thd, TABLE_LIST *tables,
+                                            Item **ref)
+{
+  DBUG_ASSERT(fixed == 0);
+  if (Item::fix_fields(thd, tables, ref) ||
+      !(entry= get_variable(&thd->user_vars, name, 1)))
+    return TRUE;
+  entry->type= STRING_RESULT;
+  /*
+    Let us set the same collation which is used for loading
+    of fields in LOAD DATA INFILE.
+    (Since Item_user_var_as_out_param is used only there).
+  */
+  entry->collation.set(thd->variables.collation_database);
+  entry->update_query_id= thd->query_id;
+  return FALSE;
+}
+
+
+void Item_user_var_as_out_param::set_null_value(CHARSET_INFO* cs)
+{
+  /* QQ: is coercible best derivation here ? */
+  if (::update_hash(entry, true, 0, 0, STRING_RESULT, cs,
+                    DERIVATION_COERCIBLE))
+    current_thd->fatal_error();			// Probably end of memory
+}
+
+
+void Item_user_var_as_out_param::set_value(const char *str, uint length,
+                                           CHARSET_INFO* cs)
+{
+  if (::update_hash(entry, false, (void*)str, length, STRING_RESULT, cs,
+                    DERIVATION_COERCIBLE))
+    current_thd->fatal_error();			// Probably end of memory
+}
+
+
+double Item_user_var_as_out_param::val_real()
+{
+  DBUG_ASSERT(0);
+  return 0.0;
+}
+
+
+longlong Item_user_var_as_out_param::val_int()
+{
+  DBUG_ASSERT(0);
+  return 0;
+}
+
+
+String* Item_user_var_as_out_param::val_str(String *str)
+{
+  DBUG_ASSERT(0);
+  return 0;
+}
+
+
+void Item_user_var_as_out_param::print(String *str)
+{
+  str->append('@');
+  str->append(name.str,name.length);
 }
 
 

--- 1.92/sql/item_func.h	Sat Jan 15 18:38:38 2005
+++ 1.93/sql/item_func.h	Tue Mar 15 11:30:32 2005
@@ -999,6 +999,34 @@
 };
 
 
+/*
+  This item represents user variable used as out parameter (e.g in LOAD DATA),
+  and it is supposed to be used only for this purprose. So it is simplified
+  a lot. Actually you should never obtain its value.
+
+  The only two reasons for this thing being an Item is possibility to store it
+  in List<Item> and desire to place this code somewhere near other functions
+  working with user variables.
+*/
+class Item_user_var_as_out_param :public Item
+{
+  LEX_STRING name;
+  user_var_entry *entry;
+public:
+  Item_user_var_as_out_param(LEX_STRING a) : name(a) {}
+  /* We should return something different from FIELD_ITEM here */
+  enum Type type() const { return STRING_ITEM;}
+  double val_real();
+  longlong val_int();
+  String *val_str(String *str);
+  /* fix_fields() binds variable name with its entry structure */
+  bool fix_fields(THD *thd, struct st_table_list *tables, Item **ref);
+  void print(String *str);
+  void set_null_value(CHARSET_INFO* cs);
+  void set_value(const char *str, uint length, CHARSET_INFO* cs);
+};
+
+
 class Item_func_inet_aton : public Item_int_func
 {
 public:

--- 1.152/sql/log_event.cc	Sun Jan 16 23:07:22 2005
+++ 1.153/sql/log_event.cc	Tue Mar 15 11:30:32 2005
@@ -271,6 +271,8 @@
   case RAND_EVENT: return "RAND";
   case USER_VAR_EVENT: return "User var";
   case FORMAT_DESCRIPTION_EVENT: return "Format_desc";
+  case BEGIN_LOAD_QUERY_EVENT: return "Begin_load_query";
+  case EXECUTE_LOAD_QUERY_EVENT: return "Execute_load_query";
   default: return "Unknown";				/* impossible */ 
   }
 }
@@ -778,10 +780,10 @@
   
   switch(buf[EVENT_TYPE_OFFSET]) {
   case QUERY_EVENT:
-    ev  = new Query_log_event(buf, event_len, description_event);
+    ev  = new Query_log_event(buf, event_len, description_event, QUERY_EVENT);
     break;
   case LOAD_EVENT:
-    ev = new Create_file_log_event(buf, event_len, description_event);
+    ev = new Load_log_event(buf, event_len, description_event);
     break;
   case NEW_LOAD_EVENT:
     ev = new Load_log_event(buf, event_len, description_event);
@@ -826,6 +828,12 @@
   case FORMAT_DESCRIPTION_EVENT:
     ev = new Format_description_log_event(buf, event_len, description_event); 
     break;
+  case BEGIN_LOAD_QUERY_EVENT:
+    ev = new Begin_load_query_log_event(buf, event_len, description_event);
+    break;
+  case EXECUTE_LOAD_QUERY_EVENT:
+    ev = new Execute_load_query_log_event(buf, event_len, description_event);
+    break;
   default:
     DBUG_PRINT("error",("Unknown evernt code: %d",(int) buf[EVENT_TYPE_OFFSET]));
     ev= NULL;
@@ -1066,10 +1074,13 @@
     Calculate length of whole event
     The "1" below is the \0 in the db's length
   */
-  event_length= (uint) (start-buf) + db_len + 1 + q_len;
+  event_length= (uint) (start-buf) + get_post_header_size_for_derived() + db_len + 1 + q_len;
 
   return (write_header(file, event_length) ||
-          my_b_safe_write(file, (byte*) buf, (uint) (start-buf)) ||
+          my_b_safe_write(file, (byte*) buf, QUERY_HEADER_LEN) ||
+          write_post_header_for_derived(file) ||
+          my_b_safe_write(file, (byte*) start_of_status,
+                          (uint) (start-start_of_status)) ||
   	  my_b_safe_write(file, (db) ? (byte*) db : (byte*)"", db_len + 1) ||
   	  my_b_safe_write(file, (byte*) query, q_len)) ? 1 : 0;
 }
@@ -1126,7 +1137,8 @@
 */
 
 Query_log_event::Query_log_event(const char* buf, uint event_len,
-                                 const Format_description_log_event *description_event)
+                                 const Format_description_log_event *description_event,
+                                 Log_event_type event_type)
   :Log_event(buf, description_event), data_buf(0), query(NullS), catalog(NullS), 
    db(NullS), catalog_len(0), status_vars_len(0),
    flags2_inited(0), sql_mode_inited(0)
@@ -1138,7 +1150,7 @@
   DBUG_ENTER("Query_log_event::Query_log_event(char*,...)");
 
   common_header_len= description_event->common_header_len;
-  post_header_len= description_event->post_header_len[QUERY_EVENT-1]; 
+  post_header_len= description_event->post_header_len[event_type-1];
   DBUG_PRINT("info",("event_len=%ld, common_header_len=%d, post_header_len=%d",
                      event_len, common_header_len, post_header_len));
   
@@ -1173,13 +1185,12 @@
                         (uint) status_vars_len));
     tmp-= 2;
   }
-  /* we have parsed everything we know in the post header */
-#ifndef DBUG_OFF
-  if (tmp) /* this is probably a master newer than us */
-    DBUG_PRINT("info", ("Query_log_event has longer post header than we know\
-  (%d more bytes)", tmp));
-#endif
-  
+  /*
+    We have parsed everything we know in the post header for QUERY_EVENT,
+    the rest of post header is either comes from older version MySQL or
+    dedicated to derived events (e.g. Execute_load_data...)
+  */
+
   /* variable-part: the status vars; only in MySQL 5.0  */
   
   start= (char*) (buf+post_header_len);
@@ -1251,8 +1262,8 @@
 */
 
 #ifdef MYSQL_CLIENT
-void Query_log_event::print(FILE* file, bool short_form,
-                            LAST_EVENT_INFO* last_event_info)
+void Query_log_event::print_query_header(FILE* file, bool short_form,
+                                         LAST_EVENT_INFO* last_event_info)
 {
   // TODO: print the catalog ??
   char buff[40],*end;				// Enough for SET TIMESTAMP
@@ -1262,8 +1273,8 @@
   if (!short_form)
   {
     print_header(file);
-    fprintf(file, "\tQuery\tthread_id=%lu\texec_time=%lu\terror_code=%d\n",
-	    (ulong) thread_id, (ulong) exec_time, error_code);
+    fprintf(file, "\t%s\tthread_id=%lu\texec_time=%lu\terror_code=%d\n",
+	    get_type_str(), (ulong) thread_id, (ulong) exec_time, error_code);
   }
 
   if (!(flags & LOG_EVENT_SUPPRESS_USE_F) && db)
@@ -1347,7 +1358,13 @@
     last_event_info->auto_increment_increment= auto_increment_increment;
     last_event_info->auto_increment_offset=    auto_increment_offset;
   }
+}
+
 
+void Query_log_event::print(FILE* file, bool short_form,
+                            LAST_EVENT_INFO* last_event_info)
+{
+  print_query_header(file, short_form, last_event_info);
   my_fwrite(file, (byte*) query, q_len, MYF(MY_NABP | MY_WME));
   fputs(";\n", file);
 }
@@ -1361,6 +1378,12 @@
 #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
 int Query_log_event::exec_event(struct st_relay_log_info* rli)
 {
+  return exec_event(rli, query, q_len);
+}
+
+
+int Query_log_event::exec_event(struct st_relay_log_info* rli, const char *query_arg, uint32 q_len_arg)
+{
   int expected_error,actual_error= 0;
   /*
     Colleagues: please never free(thd->catalog) in MySQL. This would lead to
@@ -1392,8 +1415,8 @@
   if (db_ok(thd->db, replicate_do_db, replicate_ignore_db))
   {
     thd->set_time((time_t)when);
-    thd->query_length= q_len;
-    thd->query = (char*)query;
+    thd->query_length= q_len_arg;
+    thd->query = (char*)query_arg;
     VOID(pthread_mutex_lock(&LOCK_thread_count));
     thd->query_id = query_id++;
     VOID(pthread_mutex_unlock(&LOCK_thread_count));
@@ -1427,7 +1450,7 @@
     
     if (ignored_error_code((expected_error= error_code)) ||
 	!check_expected_error(thd,rli,expected_error))
-      mysql_parse(thd, thd->query, q_len);
+      mysql_parse(thd, thd->query, thd->query_length);
     else
     {
       /*
@@ -1437,7 +1460,7 @@
         we exit gracefully; otherwise we warn about the bad error and tell DBA
         to check/fix it.
       */
-      if (mysql_test_parse_for_slave(thd, thd->query, q_len))
+      if (mysql_test_parse_for_slave(thd, thd->query, thd->query_length))
         clear_all_errors(thd, rli);        /* Can ignore query */
       else
       {
@@ -1473,7 +1496,7 @@
 			expected_error,
 			actual_error ? thd->net.last_error: "no error",
 			actual_error,
-			print_slave_db_safe(db), query);
+			print_slave_db_safe(db), query_arg);
       thd->query_error= 1;
     }
     /*
@@ -1494,7 +1517,7 @@
 			"Error '%s' on query. Default database: '%s'. Query: '%s'",
 			(actual_error ? thd->net.last_error :
 			 "unexpected success or fatal error"),
-			print_slave_db_safe(thd->db), query);
+			print_slave_db_safe(thd->db), query_arg);
       thd->query_error= 1;
     }
 
@@ -1801,6 +1824,8 @@
       post_header_len[RAND_EVENT-1]= 0;
       post_header_len[USER_VAR_EVENT-1]= 0;
       post_header_len[FORMAT_DESCRIPTION_EVENT-1]= FORMAT_DESCRIPTION_HEADER_LEN;
+      post_header_len[BEGIN_LOAD_QUERY_EVENT-1]= post_header_len[APPEND_BLOCK_EVENT-1];
+      post_header_len[EXECUTE_LOAD_QUERY_EVENT-1]= EXECUTE_LOAD_QUERY_HEADER_LEN;
     }
     break;
 
@@ -1986,12 +2011,9 @@
 */
 
 #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
-void Load_log_event::pack_info(Protocol *protocol)
+uint Load_log_event::get_query_buffer_length()
 {
-  char *buf, *pos;
-  uint buf_len;
-
-  buf_len= 
+  return
     5 + db_len + 3 +                        // "use DB; "
     18 + fname_len + 2 +                    // "LOAD DATA INFILE 'file''"
     7 +					    // LOCAL
@@ -2004,11 +2026,15 @@
     19 + sql_ex.line_start_len*4 + 2 +      // " LINES STARTING BY 'str'" 
     15 + 22 +                               // " IGNORE xxx  LINES" 
     3 + (num_fields-1)*2 + field_block_len; // " (field1, field2, ...)"
+}
 
-  if (!(buf= my_malloc(buf_len, MYF(MY_WME))))
-    return;
-  pos= buf;
-  if (db && db_len)
+
+void Load_log_event::print_query(bool need_db, char *buf,
+                                 char **end, char **fn_start, char **fn_end)
+{
+  char *pos= buf;
+
+  if (need_db && db && db_len)
   {
     pos= strmov(pos, "use `");
     memcpy(pos, db, db_len);
@@ -2016,6 +2042,10 @@
   }
 
   pos= strmov(pos, "LOAD DATA ");
+
+  if (fn_start)
+    *fn_start= pos;
+
   if (check_fname_outside_temp_buf())
     pos= strmov(pos, "LOCAL ");
   pos= strmov(pos, "INFILE '");
@@ -2027,7 +2057,12 @@
   else if (sql_ex.opt_flags & IGNORE_FLAG)
     pos= strmov(pos, " IGNORE ");
 
-  pos= strmov(pos ,"INTO TABLE `");
+  pos= strmov(pos ,"INTO");
+
+  if (fn_end)
+    *fn_end= pos;
+
+  pos= strmov(pos ," TABLE `");
   memcpy(pos, table_name, table_name_len);
   pos+= table_name_len;
 
@@ -2076,7 +2111,18 @@
     *pos++= ')';
   }
 
-  protocol->store(buf, pos-buf, &my_charset_bin);
+  *end= pos;
+}
+
+
+void Load_log_event::pack_info(Protocol *protocol)
+{
+  char *buf, *end;
+
+  if (!(buf= my_malloc(get_query_buffer_length(), MYF(MY_WME))))
+    return;
+  print_query(TRUE, buf, &end, 0, 0);
+  protocol->store(buf, end-buf, &my_charset_bin);
   my_free(buf, MYF(0));
 }
 #endif /* defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) */
@@ -2509,21 +2555,27 @@
     else
     {
       char llbuff[22];
+      char *end;
       enum enum_duplicates handle_dup;
       bool ignore= 0;
+
       /*
-        Make a simplified LOAD DATA INFILE query, for the information of the
-        user in SHOW PROCESSLIST. Note that db is known in the 'db' column.
+        Forge LOAD DATA INFILE query which will be used in SHOW PROCESS LIST
+        and written to slave's binlog if binlogging is on.
+        QQ: Is it good idea to use my_alloca() here ?
       */
-      if ((load_data_query= (char *) my_alloca(18 + strlen(fname) + 14 +
-                                               strlen(tables.table_name) + 8)))
+      if (!(load_data_query= (char *)my_alloca(get_query_buffer_length() + 1)))
       {
-        thd->query_length= (uint)(strxmov(load_data_query,
-                                          "LOAD DATA INFILE '", fname,
-                                          "' INTO TABLE `", tables.table_name,
-                                          "` <...>", NullS) - load_data_query);
-        thd->query= load_data_query;
+        /* Also QQ: what is best way to handle error here ? */
+        return 1;
       }
+
+      print_query(FALSE, load_data_query, &end, (char **)&thd->lex->fname_start,
+                  (char **)&thd->lex->fname_end);
+      *end= 0;
+      thd->query_length= end - load_data_query;
+      thd->query= load_data_query;
+
       if (sql_ex.opt_flags & REPLACE_FLAG)
 	handle_dup= DUP_REPLACE;
       else if (sql_ex.opt_flags & IGNORE_FLAG)
@@ -2569,6 +2621,7 @@
       List<Item> field_list;
       set_fields(thd->db,field_list);
       thd->variables.pseudo_thread_id= thread_id;
+      List<Item> set_fields;
       if (net)
       {
 	// mysql_load will use thd->net to read the file
@@ -2578,9 +2631,13 @@
 	*/
 	thd->net.pkt_nr = net->pkt_nr;
       }
-      if (mysql_load(thd, &ex, &tables, field_list, handle_dup, ignore,
-                     net != 0, TL_WRITE))
-	thd->query_error = 1;
+      /*
+        It is safe to use set_fields twice because we are not going to
+        update it inside mysql_load().
+      */
+      if (mysql_load(thd, &ex, &tables, field_list, set_fields, set_fields,
+                     handle_dup, ignore, net != 0, TL_WRITE))
+        thd->query_error = 1;
       if (thd->cuted_fields)
       {
 	/* log_pos is the position of the LOAD event in the master log */
@@ -3803,8 +3860,8 @@
     return;
   print_header(file);
   fputc('\n', file);
-  fprintf(file, "#Append_block: file_id: %d  block_len: %d\n",
-	  file_id, block_len);
+  fprintf(file, "#%s: file_id: %d  block_len: %d\n",
+	  get_type_str(), file_id, block_len);
 }
 #endif /* MYSQL_CLIENT */
 
@@ -3823,14 +3880,21 @@
 			     block_len));
   protocol->store(buf, length, &my_charset_bin);
 }
-#endif /* defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) */
 
 
 /*
+  Append_block_log_event::get_open_mode()
+*/
+
+int Append_block_log_event::get_open_mode() const
+{
+  return O_WRONLY | O_APPEND | O_BINARY;
+}
+
+/*
   Append_block_log_event::exec_event()
 */
 
-#if defined( HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
 int Append_block_log_event::exec_event(struct st_relay_log_info* rli)
 {
   char proc_info[17+FN_REFLEN+10], *fname= proc_info+17;
@@ -3842,14 +3906,18 @@
   memcpy(p, ".data", 6);
   strnmov(proc_info, "Making temp file ", 17); // no end 0
   thd->proc_info= proc_info;
-  if ((fd = my_open(fname, O_WRONLY|O_APPEND|O_BINARY, MYF(MY_WME))) < 0)
+  if ((fd = my_open(fname, get_open_mode(), MYF(MY_WME))) < 0)
   {
-    slave_print_error(rli,my_errno, "Error in Append_block event: could not open file '%s'", fname);
+    slave_print_error(rli, my_errno,
+                      "Error in %s event: could not open file '%s'",
+                      get_type_str(), fname);
     goto err;
   }
   if (my_write(fd, (byte*) block, block_len, MYF(MY_WME+MY_NABP)))
   {
-    slave_print_error(rli,my_errno, "Error in Append_block event: write to '%s' failed", fname);
+    slave_print_error(rli, my_errno,
+                      "Error in %s event: write to '%s' failed",
+                      get_type_str(), fname);
     goto err;
   }
   error=0;
@@ -4119,6 +4187,214 @@
 }
 
 #endif /* defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) */
+
+
+/**************************************************************************
+	Begin_load_query_log_event methods
+**************************************************************************/
+
+#ifndef MYSQL_CLIENT
+Begin_load_query_log_event::
+Begin_load_query_log_event(THD* thd_arg, const char* db_arg, char* block_arg,
+                           uint block_len_arg, bool using_trans)
+  :Append_block_log_event(thd_arg, db_arg, block_arg, block_len_arg,
+                          using_trans)
+{
+   file_id= thd_arg->file_id= mysql_bin_log.next_file_id();
+}
+#endif
+
+
+Begin_load_query_log_event::
+Begin_load_query_log_event(const char* buf, uint len,
+                           const Format_description_log_event* desc_event)
+  :Append_block_log_event(buf, len, desc_event)
+{
+}
+
+
+#if defined( HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
+int Begin_load_query_log_event::get_open_mode() const
+{
+  return O_CREAT | O_WRONLY | O_BINARY | O_TRUNC;
+}
+#endif /* defined( HAVE_REPLICATION) && !defined(MYSQL_CLIENT) */
+
+
+/**************************************************************************
+	Execute_load_query_log_event methods
+**************************************************************************/
+
+
+#ifndef MYSQL_CLIENT
+Execute_load_query_log_event::
+Execute_load_query_log_event(THD* thd_arg, const char* query_arg,
+                     ulong query_length_arg, uint fn_pos_start_arg,
+                     uint fn_pos_end_arg, char dup_handling_arg,
+                     bool using_trans, bool suppress_use):
+  Query_log_event(thd_arg, query_arg, query_length_arg, using_trans,
+                  suppress_use),
+  file_id(thd_arg->file_id), fn_pos_start(fn_pos_start_arg),
+  fn_pos_end(fn_pos_end_arg), dup_handling(dup_handling_arg)
+{
+}
+#endif /* !MYSQL_CLIENT */
+
+
+Execute_load_query_log_event::
+Execute_load_query_log_event(const char* buf, uint event_len,
+                             const Format_description_log_event* desc_event):
+  Query_log_event(buf, event_len, desc_event, EXECUTE_LOAD_QUERY_EVENT),
+  file_id(0), fn_pos_start(0), fn_pos_end(0)
+{
+  if (!Query_log_event::is_valid())
+    return;
+
+  buf+= desc_event->common_header_len;
+
+  fn_pos_start= uint4korr(buf + ELQ_FN_POS_START_OFFSET);
+  fn_pos_end= uint4korr(buf + ELQ_FN_POS_END_OFFSET);
+
+  if (fn_pos_start > q_len || fn_pos_end > q_len)
+    return;
+
+  file_id= uint4korr(buf + ELQ_FILE_ID_OFFSET);
+  dup_handling= *(buf + ELQ_DUP_HANDLING_OFFSET);
+}
+
+
+ulong Execute_load_query_log_event::get_post_header_size_for_derived()
+{
+  return EXECUTE_LOAD_QUERY_EXTRA_HEADER_LEN;
+}
+
+
+bool
+Execute_load_query_log_event::write_post_header_for_derived(IO_CACHE* file)
+{
+  char buf[EXECUTE_LOAD_QUERY_EXTRA_HEADER_LEN];
+  int4store(buf, file_id);
+  int4store(buf + 4, fn_pos_start);
+  int4store(buf + 4 + 4, fn_pos_end);
+  *(buf + 4 + 4 + 4)= dup_handling;
+  return my_b_safe_write(file, (byte*) buf, EXECUTE_LOAD_QUERY_EXTRA_HEADER_LEN);
+}
+
+
+#ifdef MYSQL_CLIENT
+void Execute_load_query_log_event::print(FILE* file, bool short_form,
+                                         LAST_EVENT_INFO* last_event_info)
+{
+  print(file, short_form, last_event_info, 0);
+}
+
+
+void Execute_load_query_log_event::print(FILE* file, bool short_form,
+                                         LAST_EVENT_INFO* last_event_info,
+                                         const char *local_fname)
+{
+  print_query_header(file, short_form, last_event_info);
+
+  if (local_fname)
+  {
+    my_fwrite(file, (byte*) query, fn_pos_start, MYF(MY_NABP | MY_WME));
+    fprintf(file, " LOCAL INFILE \'");
+    fprintf(file, local_fname);
+    fprintf(file, "\'");
+    if (dup_handling == LOAD_DUP_REPLACE)
+      fprintf(file, " REPLACE");
+    fprintf(file, " INTO");
+    my_fwrite(file, (byte*) query + fn_pos_end, q_len-fn_pos_end,
+        MYF(MY_NABP | MY_WME));
+    fprintf(file, ";\n");
+  }
+  else
+  {
+    my_fwrite(file, (byte*) query, q_len, MYF(MY_NABP | MY_WME));
+    fprintf(file, ";\n");
+  }
+
+  if (!short_form)
+    fprintf(file, "# file_id: %d \n", file_id);
+}
+#endif
+
+
+#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
+void Execute_load_query_log_event::pack_info(Protocol *protocol)
+{
+  char *buf, *pos;
+  if (!(buf= my_malloc(9 + db_len + q_len + 10 + 21, MYF(MY_WME))))
+    return;
+  pos= buf;
+  if (db && db_len)
+  {
+    pos= strmov(buf, "use `");
+    memcpy(pos, db, db_len);
+    pos= strmov(pos+db_len, "`; ");
+  }
+  if (query && q_len)
+  {
+    memcpy(pos, query, q_len);
+    pos+= q_len;
+  }
+  pos= strmov(pos, " ;file_id=");
+  pos= int10_to_str((long) file_id, pos, 10);
+  protocol->store(buf, pos-buf, &my_charset_bin);
+  my_free(buf, MYF(MY_ALLOW_ZERO_PTR));
+}
+
+
+int
+Execute_load_query_log_event::exec_event(struct st_relay_log_info* rli)
+{
+  char *p;
+  char *buf;
+  char *fname;
+  char *fname_end;
+  int error;
+
+  /* Replace filename and LOCAL keyword in query before executing it */
+  if (!(buf = my_malloc(q_len + 1 - (fn_pos_end - fn_pos_start) +
+                        (FN_REFLEN + 10) + 10 + 8 + 5, MYF(MY_WME))))
+  {
+    slave_print_error(rli, my_errno, "Not enough memory");
+    return 1;
+  }
+
+  p= buf;
+  memcpy(p, query, fn_pos_start);
+  p+= fn_pos_start;
+  fname= (p= strmake(p, " INFILE \'", 9));
+  p= slave_load_file_stem(p, file_id, server_id);
+  fname_end= (p= strmake(p, ".data", 5));
+  *(p++)='\'';
+  switch (dup_handling)
+  {
+  case LOAD_DUP_IGNORE:
+    p= strmake(p, " IGNORE", 7);
+    break;
+  case LOAD_DUP_REPLACE:
+    p= strmake(p, " REPLACE", 8);
+    break;
+  default:
+    /* Ordinary load data */
+    break;
+  }
+  p= strmake(p, " INTO", 5);
+  p= strmake(p, query+fn_pos_end, q_len-fn_pos_end);
+
+  error= Query_log_event::exec_event(rli, buf, p-buf);
+
+  /* forging fname for deletion in same buf buffer */
+  *fname_end= 0;
+
+  (void) my_delete(fname, MYF(MY_WME));
+
+  my_free(buf, MYF(MY_ALLOW_ZERO_PTR));
+  return error;
+}
+#endif
 
 
 /**************************************************************************

--- 1.100/sql/log_event.h	Mon Jan  3 23:14:11 2005
+++ 1.101/sql/log_event.h	Tue Mar 15 11:30:32 2005
@@ -163,10 +163,12 @@
 
   See the #defines below for the format specifics.
 
-  The events which really update data are Query_log_event and
-  Load_log_event/Create_file_log_event/Execute_load_log_event (these 3 act
-  together to replicate LOAD DATA INFILE, with the help of
-  Append_block_log_event which prepares temporary files to load into the table).
+  The events which really update data are Query_log_event,
+  Execute_load_query_log_event and old Load_log_event and
+  Execute_load_log_event events (Execute_load_query is used together with
+  Begin_load_query and Append_block events to replicate LOAD DATA INFILE.
+  Create_file/Append_block/Execute_load (which includes Load_log_event)
+  were used to replicate LOAD DATA before the 5.0.3).
 
  ****************************************************************************/
 
@@ -194,6 +196,8 @@
 #define EXEC_LOAD_HEADER_LEN   4
 #define DELETE_FILE_HEADER_LEN 4
 #define FORMAT_DESCRIPTION_HEADER_LEN (START_V3_HEADER_LEN+1+LOG_EVENT_TYPES)
+#define EXECUTE_LOAD_QUERY_EXTRA_HEADER_LEN (4 + 4 + 4 + 1)
+#define EXECUTE_LOAD_QUERY_HEADER_LEN  (QUERY_HEADER_LEN + EXECUTE_LOAD_QUERY_EXTRA_HEADER_LEN)
 
 /*
    Event header offsets;
@@ -283,6 +287,12 @@
 /* DF = "Delete File" */
 #define DF_FILE_ID_OFFSET  0
 
+/* ELQ = "Execute Load Query" */
+#define ELQ_FILE_ID_OFFSET QUERY_HEADER_LEN
+#define ELQ_FN_POS_START_OFFSET ELQ_FILE_ID_OFFSET + 4
+#define ELQ_FN_POS_END_OFFSET ELQ_FILE_ID_OFFSET + 8
+#define ELQ_DUP_HANDLING_OFFSET ELQ_FILE_ID_OFFSET + 12
+
 /* 4 bytes which all binlogs should begin with */
 #define BINLOG_MAGIC        "\xfe\x62\x69\x6e"
 
@@ -360,6 +370,8 @@
   NEW_LOAD_EVENT,
   RAND_EVENT, USER_VAR_EVENT,
   FORMAT_DESCRIPTION_EVENT,
+  BEGIN_LOAD_QUERY_EVENT,
+  EXECUTE_LOAD_QUERY_EVENT,
   ENUM_END_EVENT /* end marker */
 };
 
@@ -669,13 +681,17 @@
 #ifdef HAVE_REPLICATION
   void pack_info(Protocol* protocol);
   int exec_event(struct st_relay_log_info* rli);
+  int exec_event(struct st_relay_log_info* rli, const char *query_arg,
+                 uint32 q_len_arg);
 #endif /* HAVE_REPLICATION */
 #else
+  void print_query_header(FILE* file, bool short_form = 0, LAST_EVENT_INFO* last_event_info= 0);
   void print(FILE* file, bool short_form = 0, LAST_EVENT_INFO* last_event_info= 0);
 #endif
 
   Query_log_event(const char* buf, uint event_len,
-                  const Format_description_log_event *description_event);
+                  const Format_description_log_event *description_event,
+                  Log_event_type event_type);
   ~Query_log_event()
   {
     if (data_buf)
@@ -686,6 +702,9 @@
   Log_event_type get_type_code() { return QUERY_EVENT; }
   bool write(IO_CACHE* file);
   bool is_valid() const { return query != 0; }
+
+  virtual ulong get_post_header_size_for_derived() { return 0; }
+  virtual bool write_post_header_for_derived(IO_CACHE* file) { return FALSE; }
 };
 
 #ifdef HAVE_REPLICATION
@@ -737,6 +756,10 @@
  ****************************************************************************/
 class Load_log_event: public Log_event
 {
+private:
+  uint get_query_buffer_length();
+  void print_query(bool need_db, char *buf, char **end,
+                   char **fn_start, char **fn_end);
 protected:
   int copy_log_event(const char *buf, ulong event_len,
                      int body_offset, const Format_description_log_event* description_event);
@@ -1241,6 +1264,7 @@
 #ifdef HAVE_REPLICATION
   int exec_event(struct st_relay_log_info* rli);
   void pack_info(Protocol* protocol);
+  virtual int get_open_mode() const;
 #endif /* HAVE_REPLICATION */
 #else
   void print(FILE* file, bool short_form = 0, LAST_EVENT_INFO* last_event_info= 0);
@@ -1322,6 +1346,84 @@
   bool write(IO_CACHE* file);
   const char* get_db() { return db; }
 };
+
+
+/***************************************************************************
+
+  Begin load query Log Event class
+
+  Event for the first block of file to be loaded, its only difference from
+  Append_block event is that this event creates or truncates existing file
+  before writing data.
+
+****************************************************************************/
+class Begin_load_query_log_event: public Append_block_log_event
+{
+public:
+#ifndef MYSQL_CLIENT
+  Begin_load_query_log_event(THD* thd_arg, const char *db_arg,
+                             char* block_arg, uint block_len_arg,
+                             bool using_trans);
+#ifdef HAVE_REPLICATION
+  Begin_load_query_log_event(THD* thd);
+  int get_open_mode() const;
+#endif /* HAVE_REPLICATION */
+#endif
+  Begin_load_query_log_event(const char* buf, uint event_len,
+                             const Format_description_log_event* description_event);
+  ~Begin_load_query_log_event() {}
+  Log_event_type get_type_code() { return BEGIN_LOAD_QUERY_EVENT; }
+};
+
+
+#define LOAD_DUP_ERROR   0
+#define LOAD_DUP_IGNORE  1
+#define LOAD_DUP_REPLACE 2
+
+/****************************************************************************
+
+  Execute load query Log Event class
+
+  Event responsible for LOAD DATA execution, it similar to Query_log_event
+  but before executing the query it substitutes original filename in LOAD DATA
+  query with name of temporary file.
+
+****************************************************************************/
+class Execute_load_query_log_event: public Query_log_event
+{
+public:
+  uint file_id;       // file_id of temporary file
+  uint fn_pos_start;  // pointer to the part of the query that should
+                      // be substituted
+  uint fn_pos_end;    // pointer to the end of this part of query
+  char dup_handling;  // Type of duplicate handling
+
+#ifndef MYSQL_CLIENT
+  Execute_load_query_log_event(THD* thd, const char* query_arg,
+                       ulong query_length, uint fn_pos_start_arg,
+                       uint fn_pos_end_arg, char dup_handling_arg,
+                       bool using_trans, bool suppress_use);
+#ifdef HAVE_REPLICATION
+  void pack_info(Protocol* protocol);
+  int exec_event(struct st_relay_log_info* rli);
+#endif /* HAVE_REPLICATION */
+#else
+  void print(FILE* file, bool short_form = 0,
+             LAST_EVENT_INFO* last_event_info= 0);
+  /* Prints the query as LOAD DATA LOCAL and with rewritten filename */
+  void print(FILE* file, bool short_form, LAST_EVENT_INFO* last_event_info,
+             const char *local_fname);
+#endif
+  Execute_load_query_log_event(const char* buf, uint event_len,
+                               const Format_description_log_event *description_event);
+  ~Execute_load_query_log_event() {}
+
+  Log_event_type get_type_code() { return EXECUTE_LOAD_QUERY_EVENT; }
+  bool is_valid() const { return Query_log_event::is_valid() && file_id != 0; }
+
+  ulong get_post_header_size_for_derived();
+  bool write_post_header_for_derived(IO_CACHE* file);
+ };
 
 
 #ifdef MYSQL_CLIENT

--- 1.247/sql/mysql_priv.h	Sat Jan 15 15:09:38 2005
+++ 1.248/sql/mysql_priv.h	Tue Mar 15 11:30:32 2005
@@ -884,8 +884,10 @@
 
 /* sql_load.cc */
 bool mysql_load(THD *thd, sql_exchange *ex, TABLE_LIST *table_list,
-	        List<Item> &fields, enum enum_duplicates handle_duplicates,
-                bool ignore, bool local_file, thr_lock_type lock_type);
+	        List<Item> &fields_vars, List<Item> &set_fields,
+                List<Item> &set_values_list,
+                enum enum_duplicates handle_duplicates, bool ignore,
+                bool local_file, thr_lock_type lock_type);
 int write_record(THD *thd, TABLE *table, COPY_INFO *info);
 
 /* sql_manager.cc */

--- 1.99/client/mysqlbinlog.cc	Thu Dec  9 16:44:02 2004
+++ 1.100/client/mysqlbinlog.cc	Tue Mar 15 11:30:31 2005
@@ -101,6 +101,12 @@
 
 class Load_log_processor
 {
+  struct File_name_record
+  {
+    char *fname;
+    Create_file_log_event *event;
+  };
+
   char target_dir_name[FN_REFLEN];
   int target_dir_name_len;
   DYNAMIC_ARRAY file_names;
@@ -144,7 +150,7 @@
 
   int init()
   {
-    return init_dynamic_array(&file_names,sizeof(Create_file_log_event*),
+    return init_dynamic_array(&file_names, sizeof(File_name_record),
 			      100,100 CALLER_INFO);
   }
 
@@ -161,33 +167,54 @@
     }
   void destroy()
     {
-      Create_file_log_event **ptr= (Create_file_log_event**)file_names.buffer;
-      Create_file_log_event **end= ptr + file_names.elements;
+      File_name_record *ptr= (File_name_record *)file_names.buffer;
+      File_name_record *end= ptr + file_names.elements;
       for (; ptr<end; ptr++)
       {
-	if (*ptr)
+	if (ptr->fname)
 	{
-	  my_free((char*)(*ptr)->fname,MYF(MY_WME));
-	  delete *ptr;
-	  *ptr= 0;
+          my_free(ptr->fname, MYF(MY_WME));
+          delete ptr->event;
+          bzero(ptr, sizeof(File_name_record));
 	}
       }
     }
   Create_file_log_event *grab_event(uint file_id)
     {
+      File_name_record *ptr;
+      Create_file_log_event *res;
+
+      if (file_id >= file_names.elements)
+        return 0;
+      ptr= (File_name_record*)file_names.buffer + file_id;
+      if ((res= ptr->event))
+        bzero(ptr, sizeof(File_name_record));
+      return res;
+    }
+  char *grab_fname(uint file_id)
+    {
+      File_name_record *ptr;
+      char *res= 0;
+
       if (file_id >= file_names.elements)
         return 0;
-      Create_file_log_event **ptr= 
-	(Create_file_log_event**)file_names.buffer + file_id;
-      Create_file_log_event *res= *ptr;
-      *ptr= 0;
+      ptr= (File_name_record*)file_names.buffer + file_id;
+      if (!ptr->event)
+      {
+        res= ptr->fname;
+        bzero(ptr, sizeof(File_name_record));
+      }
       return res;
     }
   int process(Create_file_log_event *ce);
+  int process(Begin_load_query_log_event *ce);
   int process(Append_block_log_event *ae);
   File prepare_new_file_for_old_format(Load_log_event *le, char *filename);
   int load_old_format_file(NET* net, const char *server_fname,
 			   uint server_fname_len, File file);
+  int process_first_block(const char *bname, uint blen, const char *block,
+                          uint block_len, uint file_id,
+                          Create_file_log_event *ce);
 };
 
 
@@ -265,22 +292,18 @@
 }
 
 
-int Load_log_processor::process(Create_file_log_event *ce)
+int Load_log_processor::process_first_block(const char *bname, uint blen,
+                                            const char *block, uint block_len,
+                                            uint file_id,
+                                            Create_file_log_event *ce)
 {
-  const char *bname= ce->fname+dirname_length(ce->fname);
-  uint blen= ce->fname_len - (bname-ce->fname);
   uint full_len= target_dir_name_len + blen + 9 + 9 + 1;
   int error= 0;
   char *fname, *ptr;
   File file;
-  DBUG_ENTER("Load_log_processor::process");
+  File_name_record rec;
+  DBUG_ENTER("Load_log_processor::process_first_block");
 
-  if (set_dynamic(&file_names,(gptr)&ce,ce->file_id))
-  {
-    sql_print_error("Could not construct local filename %s%s",
-		    target_dir_name,bname);
-    DBUG_RETURN(-1);
-  }
   if (!(fname= my_malloc(full_len,MYF(MY_WME))))
     DBUG_RETURN(-1);
 
@@ -296,9 +319,21 @@
 		    target_dir_name,bname);
     DBUG_RETURN(-1);
   }
-  ce->set_fname_outside_temp_buf(fname,strlen(fname));
 
-  if (my_write(file,(byte*) ce->block,ce->block_len,MYF(MY_WME|MY_NABP)))
+  rec.fname= fname;
+  rec.event= ce;
+
+  if (set_dynamic(&file_names, (gptr)&rec, file_id))
+  {
+    sql_print_error("Could not construct local filename %s%s",
+		    target_dir_name, bname);
+    DBUG_RETURN(-1);
+  }
+
+  if (ce)
+    ce->set_fname_outside_temp_buf(fname, strlen(fname));
+
+  if (my_write(file, (byte*)block, block_len, MYF(MY_WME|MY_NABP)))
     error= -1;
   if (my_close(file, MYF(MY_WME)))
     error= -1;
@@ -306,19 +341,35 @@
 }
 
 
+int Load_log_processor::process(Create_file_log_event *ce)
+{
+  const char *bname= ce->fname + dirname_length(ce->fname);
+  uint blen= ce->fname_len - (bname-ce->fname);
+
+  return process_first_block(bname, blen, ce->block, ce->block_len,
+                             ce->file_id, ce);
+}
+
+
+int Load_log_processor::process(Begin_load_query_log_event *blqe)
+{
+  return process_first_block("SQL_LOAD", 8, blqe->block, blqe->block_len,
+                             blqe->file_id, 0);
+}
+
+
 int Load_log_processor::process(Append_block_log_event *ae)
 {
   DBUG_ENTER("Load_log_processor::process");
-  Create_file_log_event* ce= ((ae->file_id < file_names.elements) ?
-			      *((Create_file_log_event**)file_names.buffer +
-				ae->file_id) :
-			      0);
+  const char* fname= ((ae->file_id < file_names.elements) ?
+                       ((File_name_record*)file_names.buffer +
+                         ae->file_id)->fname : 0);
 
-  if (ce)
+  if (fname)
   {
     File file;
     int error= 0;
-    if (((file= my_open(ce->fname,
+    if (((file= my_open(fname,
 			O_APPEND|O_BINARY|O_WRONLY,MYF(MY_WME))) < 0))
       DBUG_RETURN(-1);
     if (my_write(file,(byte*)ae->block,ae->block_len,MYF(MY_WME|MY_NABP)))
@@ -342,6 +393,14 @@
 Load_log_processor load_processor;
 
 
+static bool check_database(const char *log_dbname)
+{
+  return one_database &&
+         (log_dbname != NULL) &&
+         strcmp(log_dbname, database);
+}
+
+
 /*
   Process an event
 
@@ -395,29 +454,21 @@
     
     switch (ev_type) {
     case QUERY_EVENT:
-      if (one_database)
-      {
-	const char * log_dbname = ((Query_log_event*)ev)->db;
-	if ((log_dbname != NULL) && (strcmp(log_dbname, database)))
-	  goto end;
-      }
+      if (check_database(((Query_log_event*)ev)->db))
+        goto end;
       ev->print(result_file, short_form, last_event_info);
       break;
     case CREATE_FILE_EVENT:
     {
       Create_file_log_event* ce= (Create_file_log_event*)ev;
-      if (one_database)
-      {
-	/*
-	  We test if this event has to be ignored. If yes, we don't save 
-	      this event; this will have the good side-effect of ignoring all 
-	      related Append_block and Exec_load.
-	      Note that Load event from 3.23 is not tested.
-	*/
-	const char * log_dbname = ce->db;            
-	if ((log_dbname != NULL) && (strcmp(log_dbname, database)))
-	  goto end;				// Next event
-      }
+      /*
+        We test if this event has to be ignored. If yes, we don't save
+        this event; this will have the good side-effect of ignoring all
+        related Append_block and Exec_load.
+        Note that Load event from 3.23 is not tested.
+      */
+      if (check_database(ce->db))
+        goto end;                // Next event
       /*
 	We print the event, but with a leading '#': this is just to inform 
 	the user of the original command; the command we want to execute 
@@ -473,6 +524,32 @@
       */
       ev= 0;
       break;
+    case BEGIN_LOAD_QUERY_EVENT:
+      ev->print(result_file, short_form, last_event_info);
+      load_processor.process((Begin_load_query_log_event*) ev);
+      break;
+    case EXECUTE_LOAD_QUERY_EVENT:
+    {
+      Execute_load_query_log_event *exlq= (Execute_load_query_log_event*)ev;
+      char *fname= load_processor.grab_fname(exlq->file_id);
+
+      if (check_database(exlq->db))
+      {
+        if (fname)
+          my_free(fname, MYF(MY_WME));
+        goto end;
+      }
+
+      if (fname)
+      {
+	exlq->print(result_file, short_form, last_event_info, fname);
+	my_free(fname, MYF(MY_WME));
+      }
+      else
+	fprintf(stderr,"Warning: ignoring Execute_load_query as there is no \
+Begin_load_query event for file_id: %u\n", exlq->file_id);
+      break;
+    }
     default:
       ev->print(result_file, short_form, last_event_info);
     }

--- 1.159/sql/sql_lex.h	Tue Jan  4 00:04:46 2005
+++ 1.160/sql/sql_lex.h	Tue Mar 15 11:30:32 2005
@@ -764,6 +764,12 @@
   */
   SQL_LIST trg_table_fields;
 
+  /*
+    Pointers to part of LOAD DATA statement that should be rewritten
+    during replication ("LOCAL 'filename' REPLACE INTO" part).
+  */
+  uchar *fname_start, *fname_end;
+
   st_lex() :result(0), sql_command(SQLCOM_END)
   {
     extern byte *sp_lex_spfuns_key(const byte *ptr, uint *plen, my_bool first);

--- 1.72/sql/sql_load.cc	Thu Jan  6 14:00:00 2005
+++ 1.73/sql/sql_load.cc	Tue Mar 15 11:30:32 2005
@@ -72,18 +72,44 @@
 };
 
 static int read_fixed_length(THD *thd, COPY_INFO &info, TABLE_LIST *table_list,
-			     List<Item> &fields, READ_INFO &read_info,
+                             List<Item> &fields_vars, List<Item> &set_fields,
+                             List<Item> &set_values, READ_INFO &read_info,
 			     ulong skip_lines,
 			     bool ignore_check_option_errors);
 static int read_sep_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list,
-			  List<Item> &fields, READ_INFO &read_info,
+                          List<Item> &fields_vars, List<Item> &set_fields,
+                          List<Item> &set_values, READ_INFO &read_info,
 			  String &enclosed, ulong skip_lines,
 			  bool ignore_check_option_errors);
 
+
+/*
+  Execute LOAD DATA query
+
+  SYNOPSYS
+    mysql_load()
+      thd - current thread
+      ex  - sql_exchange object representing source file and its parsing rules
+      table_list  - list of tables to which we are loading data
+      fields_vars - list of fields and variables to which we read
+                    data from file
+      set_fields  - list of fields mentioned in set clause
+      set_values  - expressions to assign to fields in previous list
+      handle_duplicates - indicates whenever we should emit error or
+                          replace row if we will meet duplicates.
+      ignore -          - indicates whenever we should ignore duplicates
+      read_file_from_client - is this LOAD DATA LOCAL ?
+      lock_type - what type of concurrency do we allow then we are inserting data
+
+  RETURN VALUES
+    TRUE - error / FALSE - success
+*/
+
 bool mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
-	       List<Item> &fields, enum enum_duplicates handle_duplicates,
-               bool ignore,
-	       bool read_file_from_client,thr_lock_type lock_type)
+	        List<Item> &fields_vars, List<Item> &set_fields,
+                List<Item> &set_values,
+                enum enum_duplicates handle_duplicates, bool ignore,
+                bool read_file_from_client, thr_lock_type lock_type)
 {
   char name[FN_REFLEN];
   File file;
@@ -131,51 +157,80 @@
     my_error(ER_NON_UPDATABLE_TABLE, MYF(0), table_list->alias, "LOAD");
     DBUG_RETURN(TRUE);
   }
+  /*
+    Let us emit error if we are loading data to table which is used
+    in subselect in SET clause like we do it for INSERT.
+    (QQ: May be we can remove this restriction ?)
+  */
+  if (unique_table(table_list, table_list->next_global))
+  {
+    my_error(ER_UPDATE_TABLE_USED, MYF(0), table_list->table_name);
+    DBUG_RETURN(TRUE);
+  }
+
   table= table_list->table;
   transactional_table= table->file->has_transactions();
   log_delayed= (transactional_table || table->s->tmp_table);
 
-  if (!fields.elements)
+  if (!fields_vars.elements)
   {
     Field **field;
     for (field=table->field; *field ; field++)
-      fields.push_back(new Item_field(*field));
+      fields_vars.push_back(new Item_field(*field));
+    table->timestamp_field_type= TIMESTAMP_NO_AUTO_SET;
+    /*
+      Let us also prepare SET clause, altough it is probably empty
+      in this case.
+    */
+    if (setup_fields(thd, 0, table_list, set_fields, 1, 0, 0) ||
+        setup_fields(thd, 0, table_list, set_values, 1, 0, 0))
+      DBUG_RETURN(TRUE);
   }
   else
   {						// Part field list
-    thd->dupp_field=0;
     /* TODO: use this conds for 'WITH CHECK OPTIONS' */
     Item *unused_conds= 0;
     TABLE_LIST *leaves= 0;
-    if (setup_fields(thd, 0, table_list, fields, 1, 0, 0))
-      DBUG_RETURN(TRUE);
-    if (thd->dupp_field)
-    {
-      my_error(ER_FIELD_SPECIFIED_TWICE, MYF(0), thd->dupp_field->field_name);
+    if (setup_fields(thd, 0, table_list, fields_vars, 1, 0, 0) ||
+        setup_fields(thd, 0, table_list, set_fields, 1, 0, 0) ||
+        check_that_all_fields_are_given_values(thd, table))
       DBUG_RETURN(TRUE);
-    }
-    if (check_that_all_fields_are_given_values(thd, table))
+    /*
+      Check whenever TIMESTAMP field with auto-set feature specified
+      explicitly.
+    */
+    if (table->timestamp_field &&
+        table->timestamp_field->query_id == thd->query_id)
+      table->timestamp_field_type= TIMESTAMP_NO_AUTO_SET;
+    /*
+      Fix the expressions in SET clause. This should be done after
+      check_that_all_fields_are_given_values() and setting use_timestamp
+      since it may update query_id for some fields.
+    */
+    if (setup_fields(thd, 0, table_list, set_values, 1, 0, 0))
       DBUG_RETURN(TRUE);
   }
 
   uint tot_length=0;
-  bool use_blobs=0,use_timestamp=0;
-  List_iterator_fast<Item> it(fields);
+  bool use_blobs= 0, use_vars= 0;
+  List_iterator_fast<Item> it(fields_vars);
+  Item *item;
 
-  Item_field *field;
-  while ((field=(Item_field*) it++))
+  while ((item= it++))
   {
-    if (field->field->flags & BLOB_FLAG)
+    if (item->type() == Item::FIELD_ITEM)
     {
-      use_blobs=1;
-      tot_length+=256;				// Will be extended if needed
+      Field *field= ((Item_field*)item)->field;
+      if (field->flags & BLOB_FLAG)
+      {
+        use_blobs= 1;
+        tot_length+= 256;			// Will be extended if needed
+      }
+      else
+        tot_length+= field->field_length;
     }
     else
-      tot_length+=field->field->field_length;
-    if (!field_term->length() && !(field->field->flags & NOT_NULL_FLAG))
-      field->field->set_notnull();
-    if (field->field == table->timestamp_field)
-      use_timestamp=1;
+      use_vars= 1;
   }
   if (use_blobs && !ex->line_term->length() && !field_term->length())
   {
@@ -183,6 +238,11 @@
 	       MYF(0));
     DBUG_RETURN(TRUE);
   }
+  if (use_vars && !field_term->length() && !enclosed->length())
+  {
+    my_error(ER_LOAD_FROM_FIXED_SIZE_ROWS_TO_VAR, MYF(0));
+    DBUG_RETURN(TRUE);
+  }
 
   /* We can't give an error in the middle when using LOCAL files */
   if (read_file_from_client && handle_duplicates == DUP_ERROR)
@@ -255,12 +315,6 @@
   if (mysql_bin_log.is_open())
   {
     lf_info.thd = thd;
-    lf_info.ex = ex;
-    lf_info.db = db;
-    lf_info.table_name = table_list->table_name;
-    lf_info.fields = &fields;
-    lf_info.ignore= ignore;
-    lf_info.handle_dup = handle_duplicates;
     lf_info.wrote_create_file = 0;
     lf_info.last_pos_in_file = HA_POS_ERROR;
     lf_info.log_delayed= log_delayed;
@@ -268,8 +322,6 @@
   }
 #endif /*!EMBEDDED_LIBRARY*/
 
-  restore_record(table, s->default_values);
-
   thd->count_cuted_fields= CHECK_FIELD_WARN;		/* calc cuted fields */
   thd->cuted_fields=0L;
   /* Skip lines if there is a line terminator */
@@ -286,8 +338,6 @@
 
   if (!(error=test(read_info.error)))
   {
-    if (use_timestamp)
-      table->timestamp_field_type= TIMESTAMP_NO_AUTO_SET;
 
     table->next_number_field=table->found_next_number_field;
     if (ignore ||
@@ -304,12 +354,13 @@
                               MODE_STRICT_ALL_TABLES)));
 
     if (!field_term->length() && !enclosed->length())
-      error= read_fixed_length(thd, info, table_list, fields,read_info,
+      error= read_fixed_length(thd, info, table_list, fields_vars,
+                               set_fields, set_values, read_info,
 			       skip_lines, ignore);
     else
-      error= read_sep_field(thd, info, table_list, fields, read_info,
-			    *enclosed, skip_lines,
-			    ignore);
+      error= read_sep_field(thd, info, table_list, fields_vars,
+                            set_fields, set_values, read_info,
+			    *enclosed, skip_lines, ignore);
     if (table->file->end_bulk_insert())
       error=1;					/* purecov: inspected */
     ha_enable_transaction(thd, TRUE);
@@ -384,13 +435,19 @@
   {
     /*
       As already explained above, we need to call end_io_cache() or the last
-      block will be logged only after Execute_load_log_event (which is wrong),
-      when read_info is destroyed.
+      block will be logged only after Execute_load_query_log_event (which is
+      wrong), when read_info is destroyed.
     */
     read_info.end_io_cache(); 
     if (lf_info.wrote_create_file)
     {
-      Execute_load_log_event e(thd, db, log_delayed);
+      Execute_load_query_log_event e(thd, thd->query, thd->query_length,
+        (char*)thd->lex->fname_start - (char*)thd->query,
+        (char*)thd->lex->fname_end - (char*)thd->query,
+        (handle_duplicates == DUP_REPLACE) ?  LOAD_DUP_REPLACE :
+                                              (ignore ? LOAD_DUP_IGNORE :
+                                                        LOAD_DUP_ERROR),
+        log_delayed, FALSE);
       mysql_bin_log.write(&e);
     }
   }
@@ -414,10 +471,11 @@
 
 static int
 read_fixed_length(THD *thd, COPY_INFO &info, TABLE_LIST *table_list,
-		  List<Item> &fields, READ_INFO &read_info, ulong skip_lines,
-		  bool ignore_check_option_errors)
+                  List<Item> &fields_vars, List<Item> &set_fields,
+                  List<Item> &set_values, READ_INFO &read_info,
+                  ulong skip_lines, bool ignore_check_option_errors)
 {
-  List_iterator_fast<Item> it(fields);
+  List_iterator_fast<Item> it(fields_vars);
   Item_field *sql_field;
   TABLE *table= table_list->table;
   ulonglong id;
@@ -425,11 +483,7 @@
   DBUG_ENTER("read_fixed_length");
 
   id= 0;
-  
-  /* No fields can be null in this format. mark all fields as not null */
-  while ((sql_field= (Item_field*) it++))
-      sql_field->field->set_notnull();
-
+ 
   while (!read_info.read_fixed_length())
   {
     if (thd->killed)
@@ -454,9 +508,22 @@
     read_info.row_end[0]=0;
 #endif
     no_trans_update= !table->file->has_transactions();
+
+    restore_record(table, s->default_values);
+    /*
+      There is no variables in fields_vars list in this format so
+      this conversion is safe.
+    */
     while ((sql_field= (Item_field*) it++))
     {
       Field *field= sql_field->field;                  
+      /*
+        No fields specified in fields_vars list can be null in this format.
+        Mark field as not null, we should do this for each row because of
+        restore_record...
+      */
+      field->set_notnull();
+
       if (pos == read_info.row_end)
       {
         thd->cuted_fields++;			/* Not enough fields */
@@ -487,6 +554,9 @@
                           ER(ER_WARN_TOO_MANY_RECORDS), thd->row_count); 
     }
 
+    if (fill_record(thd, set_fields, set_values, ignore_check_option_errors))
+      DBUG_RETURN(1);
+
     switch (table_list->view_check_option(thd,
                                           ignore_check_option_errors)) {
     case VIEW_CHECK_SKIP:
@@ -531,12 +601,13 @@
 
 static int
 read_sep_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list,
-	       List<Item> &fields, READ_INFO &read_info,
+               List<Item> &fields_vars, List<Item> &set_fields,
+               List<Item> &set_values, READ_INFO &read_info,
 	       String &enclosed, ulong skip_lines,
 	       bool ignore_check_option_errors)
 {
-  List_iterator_fast<Item> it(fields);
-  Item_field *sql_field;
+  List_iterator_fast<Item> it(fields_vars);
+  Item *item;
   TABLE *table= table_list->table;
   uint enclosed_length;
   ulonglong id;
@@ -554,59 +625,91 @@
       thd->send_kill_message();
       DBUG_RETURN(1);
     }
-    while ((sql_field=(Item_field*) it++))
+
+    restore_record(table, s->default_values);
+
+    while ((item= it++))
     {
       uint length;
       byte *pos;
 
       if (read_info.read_field())
 	break;
+
+      /* If this line is to be skipped we don't want to fill field or var */
+      if (skip_lines)
+        continue;
+
       pos=read_info.row_start;
       length=(uint) (read_info.row_end-pos);
-      Field *field=sql_field->field;
 
       if (!read_info.enclosed &&
 	  (enclosed_length && length == 4 && !memcmp(pos,"NULL",4)) ||
 	  (length == 1 && read_info.found_null))
       {
-	field->reset();
-	field->set_null();
-	if (!field->maybe_null())
-	{
-	  if (field->type() == FIELD_TYPE_TIMESTAMP)
-	    ((Field_timestamp*) field)->set_time();
-	  else if (field != table->next_number_field)      
-	    field->set_warning((uint) MYSQL_ERROR::WARN_LEVEL_WARN, 
-			       ER_WARN_NULL_TO_NOTNULL, 1);
+        if (item->type() == Item::FIELD_ITEM)
+        {
+          Field *field= ((Item_field *)item)->field;
+          field->reset();
+          field->set_null();
+          if (!field->maybe_null())
+          {
+            if (field->type() == FIELD_TYPE_TIMESTAMP)
+              ((Field_timestamp*) field)->set_time();
+            else if (field != table->next_number_field)
+              field->set_warning((uint) MYSQL_ERROR::WARN_LEVEL_WARN,
+                                 ER_WARN_NULL_TO_NOTNULL, 1);
+          }
 	}
+        else
+          ((Item_user_var_as_out_param *)item)->set_null_value(
+                                                  read_info.read_charset);
 	continue;
       }
-      field->set_notnull();
-      read_info.row_end[0]=0;			// Safe to change end marker
-      field->store((char*) read_info.row_start,length,read_info.read_charset);
+
+      if (item->type() == Item::FIELD_ITEM)
+      {
+        Field *field= ((Item_field *)item)->field;
+        field->set_notnull();
+        read_info.row_end[0]=0;			// Safe to change end marker
+        field->store((char*) pos, length, read_info.read_charset);
+      }
+      else
+        ((Item_user_var_as_out_param *)item)->set_value((char*) pos, length,
+                                                read_info.read_charset);
     }
     if (read_info.error)
       break;
     if (skip_lines)
     {
-      if (!--skip_lines)
-	thd->cuted_fields= 0L;			// Reset warnings
+      skip_lines--;
       continue;
     }
-    if (sql_field)
-    {						// Last record
-      if (sql_field == (Item_field*) fields.head())
+    if (item)
+    {
+      /* Have not read any field, thus input file is simply ended */
+      if (item == fields_vars.head())
 	break;
-      for (; sql_field ; sql_field=(Item_field*) it++)
+      for (; item ; item= it++)
       {
-	sql_field->field->set_null();
-	sql_field->field->reset();
-	thd->cuted_fields++;
- 	push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 
-                	    ER_WARN_TOO_FEW_RECORDS,
-                	    ER(ER_WARN_TOO_FEW_RECORDS), thd->row_count);
+        if (item->type() == Item::FIELD_ITEM)
+        {
+          Field *field= ((Item_field *)item)->field;
+          field->set_null();
+          field->reset();
+          thd->cuted_fields++;
+          push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+                              ER_WARN_TOO_FEW_RECORDS,
+                              ER(ER_WARN_TOO_FEW_RECORDS), thd->row_count);
+        }
+        else
+          ((Item_user_var_as_out_param *)item)->set_null_value(
+                                                  read_info.read_charset);
       }
     }
+
+    if (fill_record(thd, set_fields, set_values, ignore_check_option_errors))
+      DBUG_RETURN(1);
 
     switch (table_list->view_check_option(thd,
                                           ignore_check_option_errors)) {

--- 1.393/sql/sql_parse.cc	Sat Jan 15 13:37:13 2005
+++ 1.394/sql/sql_parse.cc	Tue Mar 15 11:30:32 2005
@@ -3183,7 +3183,13 @@
 
     if (!lex->local_file)
     {
-      if (check_access(thd, privilege | FILE_ACL, first_table->db, 0, 0, 0))
+      /*
+        We should also check access to tables used in subselects.
+        QQ: Can we use check_one_table_access() here too ?
+      */
+      if (check_access(thd, privilege | FILE_ACL, first_table->db, 0, 0, 0) ||
+          first_table->next_global &&
+          check_table_access(thd, SELECT_ACL, first_table->next_global, 0))
 	goto error;
     }
     else
@@ -3198,8 +3204,8 @@
 	goto error;
     }
     res= mysql_load(thd, lex->exchange, first_table, lex->field_list,
-                    lex->duplicates, lex->ignore, (bool) lex->local_file,
-		    lex->lock_option);
+                    lex->update_list, lex->value_list, lex->duplicates,
+                    lex->ignore, (bool) lex->local_file, lex->lock_option);
     break;
   }
 

--- 1.329/sql/sql_yacc.yy	Tue Jan 18 05:03:23 2005
+++ 1.330/sql/sql_yacc.yy	Tue Mar 15 11:30:33 2005
@@ -685,7 +685,7 @@
 	text_string opt_gconcat_separator
 
 %type <num>
-	type int_type real_type order_dir opt_field_spec lock_option
+	type int_type real_type order_dir lock_option
 	udf_type if_exists opt_local opt_table_options table_options
         table_option opt_if_not_exists opt_no_write_to_binlog opt_var_type
         opt_var_ident_type delete_option opt_temporary all_or_any opt_distinct
@@ -713,6 +713,7 @@
 	signed_literal now_or_signed_literal opt_escape
 	sp_opt_default
 	simple_ident_nospvar simple_ident_q
+        field_or_var
 
 %type <item_num>
 	NUM_literal
@@ -808,6 +809,7 @@
         prepare prepare_src execute deallocate 
 	statement sp_suid opt_view_list view_list or_replace algorithm
 	sp_c_chistics sp_a_chistics sp_chistic sp_c_chistic
+        load_data opt_field_or_var_spec fields_or_vars opt_load_data_set_spec
 END_OF_INPUT
 
 %type <NONE> call sp_proc_stmts sp_proc_stmts1 sp_proc_stmt
@@ -5643,11 +5645,6 @@
 	   }
 	   ident_eq_list;
 
-opt_field_spec:
-	/* empty */	  { }
-	| '(' fields ')'  { }
-	| '(' ')'	  { };
-
 fields:
 	fields ',' insert_ident { Lex->field_list.push_back($3); }
 	| insert_ident		{ Lex->field_list.push_back($1); };
@@ -6356,34 +6353,49 @@
 
 /* import, export of files */
 
-load:	LOAD DATA_SYM load_data_lock opt_local INFILE TEXT_STRING_sys
+load:   LOAD DATA_SYM 
+        {
+          LEX *lex=Lex;
+          lex->fname_start= lex->ptr;
+        }
+        load_data
+        {}
+        |
+        LOAD TABLE_SYM table_ident FROM MASTER_SYM
+        {
+          Lex->sql_command = SQLCOM_LOAD_MASTER_TABLE;
+          if (!Select->add_table_to_list(YYTHD, $3, NULL, TL_OPTION_UPDATING))
+            YYABORT;
+        };
+
+load_data:
+	load_data_lock opt_local INFILE TEXT_STRING_sys
 	{
 	  LEX *lex=Lex;
 	  lex->sql_command= SQLCOM_LOAD;
-	  lex->lock_option= $3;
-	  lex->local_file=  $4;
+	  lex->lock_option= $1;
+	  lex->local_file=  $2;
 	  lex->duplicates= DUP_ERROR;
 	  lex->ignore= 0;
-	  if (!(lex->exchange= new sql_exchange($6.str,0)))
+	  if (!(lex->exchange= new sql_exchange($4.str, 0)))
 	    YYABORT;
+        }
+        opt_duplicate INTO
+        {
+	  LEX *lex=Lex;
+	  lex->fname_end= lex->ptr;
 	  lex->field_list.empty();
+	  lex->update_list.empty();
+	  lex->value_list.empty();
 	}
-	opt_duplicate INTO TABLE_SYM table_ident opt_field_term opt_line_term
-	opt_ignore_lines opt_field_spec
+	TABLE_SYM table_ident opt_field_term opt_line_term
+	opt_ignore_lines opt_field_or_var_spec opt_load_data_set_spec
 	{
-	  if (!Select->add_table_to_list(YYTHD, $11, NULL, TL_OPTION_UPDATING))
+	  if (!Select->add_table_to_list(YYTHD, $10, NULL, TL_OPTION_UPDATING))
 	    YYABORT;
 	}
         |
-	LOAD TABLE_SYM table_ident FROM MASTER_SYM
-        {
-	  Lex->sql_command = SQLCOM_LOAD_MASTER_TABLE;
-	  if (!Select->add_table_to_list(YYTHD, $3, NULL, TL_OPTION_UPDATING))
-	    YYABORT;
-
-        }
-        |
-	LOAD DATA_SYM FROM MASTER_SYM
+	FROM MASTER_SYM
         {
 	  Lex->sql_command = SQLCOM_LOAD_MASTER_DATA;
         };
@@ -6462,6 +6474,29 @@
             DBUG_ASSERT(Lex->exchange);
             Lex->exchange->skip_lines= atol($2.str);
           };
+
+opt_field_or_var_spec:
+	/* empty */	          { }
+	| '(' fields_or_vars ')'  { }
+	| '(' ')'	          { };
+
+fields_or_vars:
+        fields_or_vars ',' field_or_var
+          { Lex->field_list.push_back($3); }
+        | field_or_var
+          { Lex->field_list.push_back($1); }
+        ;
+        
+field_or_var:
+        simple_ident_nospvar {$$= $1;}
+        | '@' ident_or_text
+          { $$= new Item_user_var_as_out_param($2); }
+        ;
+
+opt_load_data_set_spec:
+        /* empty */           { }
+        | SET insert_update_list  { };
+
 
 /* Common definitions */
 

--- 1.6/sql/share/errmsg.txt	Thu Jan 13 20:09:25 2005
+++ 1.7/sql/share/errmsg.txt	Tue Mar 15 11:30:32 2005
@@ -5210,3 +5210,5 @@
 	eng "Failed to grant EXECUTE and ALTER ROUTINE privileges"
 ER_PROC_AUTO_REVOKE_FAIL
 	eng "Failed to revoke all privileges to dropped routine"
+ER_LOAD_FROM_FIXED_SIZE_ROWS_TO_VAR
+        eng "Can't load value from file with fixed size rows to variable"

--- 1.24/mysql-test/r/ctype_ucs.result	Sun Jan 16 23:07:22 2005
+++ 1.25/mysql-test/r/ctype_ucs.result	Tue Mar 15 11:30:31 2005
@@ -523,10 +523,10 @@
 set @v=convert('abc' using ucs2);
 reset master;
 insert into t2 values (@v);
-show binlog events from 95;
+show binlog events from 97;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
-master-bin.000001	95	User var	1	135	@`v`=_ucs2 0x006100620063 COLLATE ucs2_general_ci
-master-bin.000001	135	Query	1	218	use `test`; insert into t2 values (@v)
+master-bin.000001	97	User var	1	137	@`v`=_ucs2 0x006100620063 COLLATE ucs2_general_ci
+master-bin.000001	137	Query	1	220	use `test`; insert into t2 values (@v)
 /*!40019 SET @@session.max_insert_delayed_threads=0*/;
 SET @`v`:=_ucs2 0x006100620063 COLLATE `ucs2_general_ci`;
 use test;

--- 1.22/mysql-test/t/ctype_ucs.test	Sat Jan 15 15:37:04 2005
+++ 1.23/mysql-test/t/ctype_ucs.test	Tue Mar 15 11:30:32 2005
@@ -338,7 +338,7 @@
 set @v=convert('abc' using ucs2);
 reset master;
 insert into t2 values (@v);
-show binlog events from 95;
+show binlog events from 97;
 # more important than SHOW BINLOG EVENTS, mysqlbinlog (where we
 # absolutely need variables names to be quoted and strings to be
 # escaped).

--- 1.4/mysql-test/r/rpl_timezone.result	Wed Oct 20 05:04:25 2004
+++ 1.5/mysql-test/r/rpl_timezone.result	Tue Mar 15 11:30:32 2005
@@ -32,13 +32,13 @@
 2004-06-11 09:39:02
 show binlog events;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
-master-bin.000001	4	Format_desc	1	95	Server ver: VERSION, Binlog ver: 4
-master-bin.000001	95	Query	1	181	use `test`; create table t1 (t timestamp)
-master-bin.000001	181	Query	1	266	use `test`; create table t2 (t char(32))
-master-bin.000001	266	Query	1	351	use `test`; SET ONE_SHOT TIME_ZONE='UTC'
-master-bin.000001	351	Query	1	468	use `test`; insert into t1 values ('20040101000000'), ('20040611093902')
-master-bin.000001	468	Query	1	539	use `test`; delete from t1
-master-bin.000001	539	Query	1	656	use `test`; insert into t1 values ('20040101000000'), ('20040611093902')
+master-bin.000001	4	Format_desc	1	97	Server ver: VERSION, Binlog ver: 4
+master-bin.000001	97	Query	1	183	use `test`; create table t1 (t timestamp)
+master-bin.000001	183	Query	1	268	use `test`; create table t2 (t char(32))
+master-bin.000001	268	Query	1	353	use `test`; SET ONE_SHOT TIME_ZONE='UTC'
+master-bin.000001	353	Query	1	470	use `test`; insert into t1 values ('20040101000000'), ('20040611093902')
+master-bin.000001	470	Query	1	541	use `test`; delete from t1
+master-bin.000001	541	Query	1	658	use `test`; insert into t1 values ('20040101000000'), ('20040611093902')
 set time_zone='MET';
 insert into t2 (select t from t1);
 select * from t1;

--- 1.9/mysql-test/r/mysqlbinlog.result	Thu Jul 15 05:18:42 2004
+++ 1.10/mysql-test/r/mysqlbinlog.result	Tue Mar 15 11:30:31 2005
@@ -9,7 +9,6 @@
 load data infile '../../std_data/words.dat' into table t1;
 load data infile '../../std_data/words.dat' into table t1;
 load data infile '../../std_data/words.dat' into table t1;
-load data infile '../../std_data/words.dat' into table t1;
 insert into t1 values ("Alas");
 flush logs;
 
@@ -29,11 +28,14 @@
 SET INSERT_ID=1;
 SET TIMESTAMP=1000000000;
 insert into t2 values ();
-LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-1-0' INTO TABLE `t1` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word);
-LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-2-0' INTO TABLE `t1` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word);
-LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-3-0' INTO TABLE `t1` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word);
-LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-4-0' INTO TABLE `t1` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word);
-LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-5-0' INTO TABLE `t1` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word);
+SET TIMESTAMP=1000000000;
+load data LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/SQL_LOAD-1-0' INTO table t1;
+SET TIMESTAMP=1000000000;
+load data LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/SQL_LOAD-2-0' INTO table t1;
+SET TIMESTAMP=1000000000;
+load data LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/SQL_LOAD-3-0' INTO table t1;
+SET TIMESTAMP=1000000000;
+load data LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/SQL_LOAD-4-0' INTO table t1;
 
 --- Broken LOAD DATA --
 /*!40019 SET @@session.max_insert_delayed_threads=0*/;
@@ -71,11 +73,14 @@
 SET INSERT_ID=1;
 SET TIMESTAMP=1000000000;
 insert into t2 values ();
-LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-1-1' INTO TABLE `t1` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word);
-LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-2-1' INTO TABLE `t1` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word);
-LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-3-1' INTO TABLE `t1` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word);
-LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-4-1' INTO TABLE `t1` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word);
-LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-5-1' INTO TABLE `t1` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word);
+SET TIMESTAMP=1000000000;
+load data LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/SQL_LOAD-1-2' INTO table t1;
+SET TIMESTAMP=1000000000;
+load data LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/SQL_LOAD-2-2' INTO table t1;
+SET TIMESTAMP=1000000000;
+load data LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/SQL_LOAD-3-2' INTO table t1;
+SET TIMESTAMP=1000000000;
+load data LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/SQL_LOAD-4-2' INTO table t1;
 
 --- Broken LOAD DATA --
 /*!40019 SET @@session.max_insert_delayed_threads=0*/;

--- 1.16/mysql-test/r/rpl_until.result	Tue Jul  6 15:34:02 2004
+++ 1.17/mysql-test/r/rpl_until.result	Tue Mar 15 11:30:32 2005
@@ -14,15 +14,15 @@
 drop table t2;
 show binlog events;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
-master-bin.000001	4	Format_desc	1	95	Server ver: VERSION, Binlog ver: 4
-master-bin.000001	95	Query	1	210	use `test`; create table t1(n int not null auto_increment primary key)
-master-bin.000001	210	Query	1	304	use `test`; insert into t1 values (1),(2),(3),(4)
-master-bin.000001	304	Query	1	374	use `test`; drop table t1
-master-bin.000001	374	Query	1	489	use `test`; create table t2(n int not null auto_increment primary key)
-master-bin.000001	489	Query	1	575	use `test`; insert into t2 values (1),(2)
-master-bin.000001	575	Query	1	661	use `test`; insert into t2 values (3),(4)
-master-bin.000001	661	Query	1	731	use `test`; drop table t2
-start slave until master_log_file='master-bin.000001', master_log_pos=304;
+master-bin.000001	4	Format_desc	1	97	Server ver: VERSION, Binlog ver: 4
+master-bin.000001	97	Query	1	212	use `test`; create table t1(n int not null auto_increment primary key)
+master-bin.000001	212	Query	1	306	use `test`; insert into t1 values (1),(2),(3),(4)
+master-bin.000001	306	Query	1	376	use `test`; drop table t1
+master-bin.000001	376	Query	1	491	use `test`; create table t2(n int not null auto_increment primary key)
+master-bin.000001	491	Query	1	577	use `test`; insert into t2 values (1),(2)
+master-bin.000001	577	Query	1	663	use `test`; insert into t2 values (3),(4)
+master-bin.000001	663	Query	1	733	use `test`; drop table t2
+start slave until master_log_file='master-bin.000001', master_log_pos=306;
 select * from t1;
 n
 1
@@ -31,7 +31,7 @@
 4
 show slave status;
 Slave_IO_State	Master_Host	Master_User	Master_Port	Connect_Retry	Master_Log_File	Read_Master_Log_Pos	Relay_Log_File	Relay_Log_Pos	Relay_Master_Log_File	Slave_IO_Running	Slave_SQL_Running	Replicate_Do_DB	Replicate_Ignore_DB	Replicate_Do_Table	Replicate_Ignore_Table	Replicate_Wild_Do_Table	Replicate_Wild_Ignore_Table	Last_Errno	Last_Error	Skip_Counter	Exec_Master_Log_Pos	Relay_Log_Space	Until_Condition	Until_Log_File	Until_Log_Pos	Master_SSL_Allowed	Master_SSL_CA_File	Master_SSL_CA_Path	Master_SSL_Cert	Master_SSL_Cipher	Master_SSL_Key	Seconds_Behind_Master
-#	127.0.0.1	root	MASTER_MYPORT	1	master-bin.000001	731	slave-relay-bin.000004	#	master-bin.000001	Yes	No							0		0	304	#	Master	master-bin.000001	304	No						#
+#	127.0.0.1	root	MASTER_MYPORT	1	master-bin.000001	733	slave-relay-bin.000004	#	master-bin.000001	Yes	No							0		0	306	#	Master	master-bin.000001	306	No						#
 start slave until master_log_file='master-no-such-bin.000001', master_log_pos=291;
 select * from t1;
 n
@@ -41,21 +41,21 @@
 4
 show slave status;
 Slave_IO_State	Master_Host	Master_User	Master_Port	Connect_Retry	Master_Log_File	Read_Master_Log_Pos	Relay_Log_File	Relay_Log_Pos	Relay_Master_Log_File	Slave_IO_Running	Slave_SQL_Running	Replicate_Do_DB	Replicate_Ignore_DB	Replicate_Do_Table	Replicate_Ignore_Table	Replicate_Wild_Do_Table	Replicate_Wild_Ignore_Table	Last_Errno	Last_Error	Skip_Counter	Exec_Master_Log_Pos	Relay_Log_Space	Until_Condition	Until_Log_File	Until_Log_Pos	Master_SSL_Allowed	Master_SSL_CA_File	Master_SSL_CA_Path	Master_SSL_Cert	Master_SSL_Cipher	Master_SSL_Key	Seconds_Behind_Master
-#	127.0.0.1	root	MASTER_MYPORT	1	master-bin.000001	731	slave-relay-bin.000004	#	master-bin.000001	Yes	No							0		0	304	#	Master	master-no-such-bin.000001	291	No						#
-start slave until relay_log_file='slave-relay-bin.000004', relay_log_pos=710;
+#	127.0.0.1	root	MASTER_MYPORT	1	master-bin.000001	733	slave-relay-bin.000004	#	master-bin.000001	Yes	No							0		0	306	#	Master	master-no-such-bin.000001	291	No						#
+start slave until relay_log_file='slave-relay-bin.000004', relay_log_pos=712;
 select * from t2;
 n
 1
 2
 show slave status;
 Slave_IO_State	Master_Host	Master_User	Master_Port	Connect_Retry	Master_Log_File	Read_Master_Log_Pos	Relay_Log_File	Relay_Log_Pos	Relay_Master_Log_File	Slave_IO_Running	Slave_SQL_Running	Replicate_Do_DB	Replicate_Ignore_DB	Replicate_Do_Table	Replicate_Ignore_Table	Replicate_Wild_Do_Table	Replicate_Wild_Ignore_Table	Last_Errno	Last_Error	Skip_Counter	Exec_Master_Log_Pos	Relay_Log_Space	Until_Condition	Until_Log_File	Until_Log_Pos	Master_SSL_Allowed	Master_SSL_CA_File	Master_SSL_CA_Path	Master_SSL_Cert	Master_SSL_Cipher	Master_SSL_Key	Seconds_Behind_Master
-#	127.0.0.1	root	MASTER_MYPORT	1	master-bin.000001	731	slave-relay-bin.000004	#	master-bin.000001	Yes	No							0		0	575	#	Relay	slave-relay-bin.000004	710	No						#
+#	127.0.0.1	root	MASTER_MYPORT	1	master-bin.000001	733	slave-relay-bin.000004	#	master-bin.000001	Yes	No							0		0	577	#	Relay	slave-relay-bin.000004	712	No						#
 start slave;
 stop slave;
-start slave until master_log_file='master-bin.000001', master_log_pos=710;
+start slave until master_log_file='master-bin.000001', master_log_pos=733;
 show slave status;
 Slave_IO_State	Master_Host	Master_User	Master_Port	Connect_Retry	Master_Log_File	Read_Master_Log_Pos	Relay_Log_File	Relay_Log_Pos	Relay_Master_Log_File	Slave_IO_Running	Slave_SQL_Running	Replicate_Do_DB	Replicate_Ignore_DB	Replicate_Do_Table	Replicate_Ignore_Table	Replicate_Wild_Do_Table	Replicate_Wild_Ignore_Table	Last_Errno	Last_Error	Skip_Counter	Exec_Master_Log_Pos	Relay_Log_Space	Until_Condition	Until_Log_File	Until_Log_Pos	Master_SSL_Allowed	Master_SSL_CA_File	Master_SSL_CA_Path	Master_SSL_Cert	Master_SSL_Cipher	Master_SSL_Key	Seconds_Behind_Master
-#	127.0.0.1	root	MASTER_MYPORT	1	master-bin.000001	731	slave-relay-bin.000004	#	master-bin.000001	Yes	No							0		0	731	#	Master	master-bin.000001	710	No						#
+#	127.0.0.1	root	MASTER_MYPORT	1	master-bin.000001	733	slave-relay-bin.000004	#	master-bin.000001	Yes	No							0		0	733	#	Master	master-bin.000001	733	No						#
 start slave until master_log_file='master-bin', master_log_pos=561;
 ERROR HY000: Incorrect parameter or combination of parameters for START SLAVE UNTIL
 start slave until master_log_file='master-bin.000001', master_log_pos=561, relay_log_pos=12;
@@ -67,6 +67,6 @@
 start slave until relay_log_file='slave-relay-bin.000002', master_log_pos=561;
 ERROR HY000: Incorrect parameter or combination of parameters for START SLAVE UNTIL
 start slave sql_thread;
-start slave until master_log_file='master-bin.000001', master_log_pos=710;
+start slave until master_log_file='master-bin.000001', master_log_pos=733;
 Warnings:
 Note	1254	Slave is already running
--- New file ---
+++ mysql-test/std_data/loaddata5.dat	05/03/15 11:30:33
1          2          
3          4          
5          6          


--- 1.12/mysql-test/t/mysqlbinlog.test	Tue Jul  6 15:34:09 2004
+++ 1.13/mysql-test/t/mysqlbinlog.test	Tue Mar 15 11:30:32 2005
@@ -24,7 +24,6 @@
 load data infile '../../std_data/words.dat' into table t1;
 load data infile '../../std_data/words.dat' into table t1;
 load data infile '../../std_data/words.dat' into table t1;
-load data infile '../../std_data/words.dat' into table t1;
 # simple query to show more in second binlog
 insert into t1 values ("Alas");
 flush logs;
@@ -61,7 +60,7 @@
 select "--- --position --" as "";
 --enable_query_log
 --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
---exec $MYSQL_BINLOG --short-form --local-load=$MYSQL_TEST_DIR/var/tmp/ --position=118 $MYSQL_TEST_DIR/var/log/master-bin.000002
+--exec $MYSQL_BINLOG --short-form --local-load=$MYSQL_TEST_DIR/var/tmp/ --position=224 $MYSQL_TEST_DIR/var/log/master-bin.000002
 
 # These are tests for remote binlog.
 # They should return the same as previous test.
@@ -93,7 +92,7 @@
 select "--- --position --" as "";
 --enable_query_log
 --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
---exec $MYSQL_BINLOG --short-form --local-load=$MYSQL_TEST_DIR/var/tmp/ --read-from-remote-server --position=118 --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000002
+--exec $MYSQL_BINLOG --short-form --local-load=$MYSQL_TEST_DIR/var/tmp/ --read-from-remote-server --position=224 --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000002
 
 # clean up
 drop table t1, t2;

--- 1.13/mysql-test/t/rpl_until.test	Mon Dec  6 03:05:21 2004
+++ 1.14/mysql-test/t/rpl_until.test	Tue Mar 15 11:30:32 2005
@@ -24,7 +24,7 @@
 
 # try to replicate all queries until drop of t1
 connection slave;
-start slave until master_log_file='master-bin.000001', master_log_pos=304;
+start slave until master_log_file='master-bin.000001', master_log_pos=306;
 sleep 2;
 # here table should be still not deleted
 select * from t1;
@@ -42,7 +42,7 @@
 show slave status;
 
 # try replicate all until second insert to t2;
-start slave until relay_log_file='slave-relay-bin.000004', relay_log_pos=710;
+start slave until relay_log_file='slave-relay-bin.000004', relay_log_pos=712;
 sleep 4;
 select * from t2;
 --replace_result $MASTER_MYPORT MASTER_MYPORT
@@ -58,7 +58,7 @@
 stop slave;
 
 # this should stop immediately as we are already there
-start slave until master_log_file='master-bin.000001', master_log_pos=710;
+start slave until master_log_file='master-bin.000001', master_log_pos=733;
 # 2 is not enough when running with valgrind
 real_sleep 4
 # here the sql slave thread should be stopped
@@ -77,6 +77,6 @@
 start slave until relay_log_file='slave-relay-bin.000002';
 --error 1277
 start slave until relay_log_file='slave-relay-bin.000002', master_log_pos=561;
-
+# Warning should be given for second command
 start slave sql_thread;
-start slave until master_log_file='master-bin.000001', master_log_pos=710;
+start slave until master_log_file='master-bin.000001', master_log_pos=733;

--- 1.10/mysql-test/r/rpl_user_variables.result	Thu Jul 15 05:18:46 2004
+++ 1.11/mysql-test/r/rpl_user_variables.result	Tue Mar 15 11:30:32 2005
@@ -76,34 +76,34 @@
 NULL
 NULL
 NULL
-show binlog events from 179;
+show binlog events from 181;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
-slave-bin.000001	179	User var	2	222	@`i1`=12345678901234
-slave-bin.000001	222	User var	2	265	@`i2`=-12345678901234
-slave-bin.000001	265	User var	2	308	@`i3`=0
-slave-bin.000001	308	User var	2	351	@`i4`=-1
-slave-bin.000001	351	Query	1	456	use `test`; insert into t1 values (@i1), (@i2), (@i3), (@i4)
-slave-bin.000001	456	User var	2	499	@`r1`=12.5
-slave-bin.000001	499	User var	2	542	@`r2`=-12.5
-slave-bin.000001	542	Query	1	633	use `test`; insert into t1 values (@r1), (@r2)
-slave-bin.000001	633	User var	2	682	@`s1`=_latin1 0x5468697320697320612074657374 COLLATE latin1_swedish_ci
-slave-bin.000001	682	User var	2	717	@`s2`=_latin1 "" COLLATE latin1_swedish_ci
-slave-bin.000001	717	User var	2	759	@`s3`=_latin1 0x61626327646566 COLLATE latin1_swedish_ci
-slave-bin.000001	759	User var	2	801	@`s4`=_latin1 0x6162635C646566 COLLATE latin1_swedish_ci
-slave-bin.000001	801	User var	2	843	@`s5`=_latin1 0x61626327646566 COLLATE latin1_swedish_ci
-slave-bin.000001	843	Query	1	955	use `test`; insert into t1 values (@s1), (@s2), (@s3), (@s4), (@s5)
-slave-bin.000001	955	User var	2	981	@`n1`=NULL
-slave-bin.000001	981	Query	1	1065	use `test`; insert into t1 values (@n1)
-slave-bin.000001	1065	User var	2	1091	@`n2`=NULL
-slave-bin.000001	1091	Query	1	1175	use `test`; insert into t1 values (@n2)
-slave-bin.000001	1175	Query	1	1285	use `test`; insert into t1 values (@a:=0), (@a:=@a+1), (@a:=@a+1)
-slave-bin.000001	1285	User var	2	1327	@`a`=2
-slave-bin.000001	1327	Query	1	1421	use `test`; insert into t1 values (@a+(@b:=@a+1))
-slave-bin.000001	1421	User var	2	1458	@`q`=_latin1 0x616263 COLLATE latin1_swedish_ci
-slave-bin.000001	1458	Query	1	1584	use `test`; insert t1 values (@q), (@q:=concat(@q, 'n1')), (@q:=concat(@q, 'n2'))
-slave-bin.000001	1584	User var	2	1626	@`a`=5
-slave-bin.000001	1626	Query	1	1714	use `test`; insert into t1 values (@a),(@a)
-slave-bin.000001	1714	User var	2	1739	@`a`=NULL
-slave-bin.000001	1739	Query	1	1834	use `test`; insert into t1 values (@a),(@a),(@a*5)
+slave-bin.000001	181	User var	2	224	@`i1`=12345678901234
+slave-bin.000001	224	User var	2	267	@`i2`=-12345678901234
+slave-bin.000001	267	User var	2	310	@`i3`=0
+slave-bin.000001	310	User var	2	353	@`i4`=-1
+slave-bin.000001	353	Query	1	458	use `test`; insert into t1 values (@i1), (@i2), (@i3), (@i4)
+slave-bin.000001	458	User var	2	501	@`r1`=12.5
+slave-bin.000001	501	User var	2	544	@`r2`=-12.5
+slave-bin.000001	544	Query	1	635	use `test`; insert into t1 values (@r1), (@r2)
+slave-bin.000001	635	User var	2	684	@`s1`=_latin1 0x5468697320697320612074657374 COLLATE latin1_swedish_ci
+slave-bin.000001	684	User var	2	719	@`s2`=_latin1 "" COLLATE latin1_swedish_ci
+slave-bin.000001	719	User var	2	761	@`s3`=_latin1 0x61626327646566 COLLATE latin1_swedish_ci
+slave-bin.000001	761	User var	2	803	@`s4`=_latin1 0x6162635C646566 COLLATE latin1_swedish_ci
+slave-bin.000001	803	User var	2	845	@`s5`=_latin1 0x61626327646566 COLLATE latin1_swedish_ci
+slave-bin.000001	845	Query	1	957	use `test`; insert into t1 values (@s1), (@s2), (@s3), (@s4), (@s5)
+slave-bin.000001	957	User var	2	983	@`n1`=NULL
+slave-bin.000001	983	Query	1	1067	use `test`; insert into t1 values (@n1)
+slave-bin.000001	1067	User var	2	1093	@`n2`=NULL
+slave-bin.000001	1093	Query	1	1177	use `test`; insert into t1 values (@n2)
+slave-bin.000001	1177	Query	1	1287	use `test`; insert into t1 values (@a:=0), (@a:=@a+1), (@a:=@a+1)
+slave-bin.000001	1287	User var	2	1329	@`a`=2
+slave-bin.000001	1329	Query	1	1423	use `test`; insert into t1 values (@a+(@b:=@a+1))
+slave-bin.000001	1423	User var	2	1460	@`q`=_latin1 0x616263 COLLATE latin1_swedish_ci
+slave-bin.000001	1460	Query	1	1586	use `test`; insert t1 values (@q), (@q:=concat(@q, 'n1')), (@q:=concat(@q, 'n2'))
+slave-bin.000001	1586	User var	2	1628	@`a`=5
+slave-bin.000001	1628	Query	1	1716	use `test`; insert into t1 values (@a),(@a)
+slave-bin.000001	1716	User var	2	1741	@`a`=NULL
+slave-bin.000001	1741	Query	1	1836	use `test`; insert into t1 values (@a),(@a),(@a*5)
 drop table t1;
 stop slave;

--- 1.8/mysql-test/t/rpl_user_variables.test	Fri Oct 29 20:26:41 2004
+++ 1.9/mysql-test/t/rpl_user_variables.test	Tue Mar 15 11:30:32 2005
@@ -46,7 +46,7 @@
 connection slave;
 sync_with_master;
 select * from t1;
-show binlog events from 179;
+show binlog events from 181;
 connection master;
 drop table t1;
 save_master_pos;

--- 1.10/mysql-test/r/drop_temp_table.result	Mon Dec  6 18:15:48 2004
+++ 1.11/mysql-test/r/drop_temp_table.result	Tue Mar 15 11:30:31 2005
@@ -10,9 +10,9 @@
 1
 show binlog events;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
-master-bin.000001	4	Format_desc	1	95	Server ver: VERSION, Binlog ver: 4
-master-bin.000001	95	Query	1	206	create database `drop-temp+table-test`
-master-bin.000001	206	Query	1	322	use `drop-temp+table-test`; create temporary table `table:name` (a int)
-master-bin.000001	322	Query	1	473	use `drop-temp+table-test`; DROP /*!40005 TEMPORARY */ TABLE IF EXISTS `drop-temp+table-test`.`table:name`
-master-bin.000001	473	Query	1	566	use `drop-temp+table-test`; DO RELEASE_LOCK("a")
+master-bin.000001	4	Format_desc	1	97	Server ver: VERSION, Binlog ver: 4
+master-bin.000001	97	Query	1	208	create database `drop-temp+table-test`
+master-bin.000001	208	Query	1	324	use `drop-temp+table-test`; create temporary table `table:name` (a int)
+master-bin.000001	324	Query	1	475	use `drop-temp+table-test`; DROP /*!40005 TEMPORARY */ TABLE IF EXISTS `drop-temp+table-test`.`table:name`
+master-bin.000001	475	Query	1	568	use `drop-temp+table-test`; DO RELEASE_LOCK("a")
 drop database `drop-temp+table-test`;

--- 1.12/mysql-test/r/mix_innodb_myisam_binlog.result	Fri Nov 12 22:24:12 2004
+++ 1.13/mysql-test/r/mix_innodb_myisam_binlog.result	Tue Mar 15 11:30:31 2005
@@ -6,12 +6,12 @@
 insert into t1 values(1);
 insert into t2 select * from t1;
 commit;
-show binlog events from 95;
+show binlog events from 97;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
-master-bin.000001	95	Query	1	#	use `test`; BEGIN
-master-bin.000001	157	Query	1	#	use `test`; insert into t1 values(1)
-master-bin.000001	238	Query	1	#	use `test`; insert into t2 select * from t1
-master-bin.000001	326	Query	1	#	use `test`; COMMIT
+master-bin.000001	97	Query	1	#	use `test`; BEGIN
+master-bin.000001	159	Query	1	#	use `test`; insert into t1 values(1)
+master-bin.000001	240	Query	1	#	use `test`; insert into t2 select * from t1
+master-bin.000001	328	Query	1	#	use `test`; COMMIT
 delete from t1;
 delete from t2;
 reset master;
@@ -21,12 +21,12 @@
 rollback;
 Warnings:
 Warning	1196	Some non-transactional changed tables couldn't be rolled back
-show binlog events from 95;
+show binlog events from 97;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
-master-bin.000001	95	Query	1	#	use `test`; BEGIN
-master-bin.000001	157	Query	1	#	use `test`; insert into t1 values(2)
-master-bin.000001	238	Query	1	#	use `test`; insert into t2 select * from t1
-master-bin.000001	326	Query	1	#	use `test`; ROLLBACK
+master-bin.000001	97	Query	1	#	use `test`; BEGIN
+master-bin.000001	159	Query	1	#	use `test`; insert into t1 values(2)
+master-bin.000001	240	Query	1	#	use `test`; insert into t2 select * from t1
+master-bin.000001	328	Query	1	#	use `test`; ROLLBACK
 delete from t1;
 delete from t2;
 reset master;
@@ -39,15 +39,15 @@
 Warnings:
 Warning	1196	Some non-transactional changed tables couldn't be rolled back
 commit;
-show binlog events from 95;
+show binlog events from 97;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
-master-bin.000001	95	Query	1	#	use `test`; BEGIN
-master-bin.000001	157	Query	1	#	use `test`; insert into t1 values(3)
-master-bin.000001	238	Query	1	#	use `test`; savepoint my_savepoint
-master-bin.000001	317	Query	1	#	use `test`; insert into t1 values(4)
-master-bin.000001	398	Query	1	#	use `test`; insert into t2 select * from t1
-master-bin.000001	486	Query	1	#	use `test`; rollback to savepoint my_savepoint
-master-bin.000001	577	Query	1	#	use `test`; COMMIT
+master-bin.000001	97	Query	1	#	use `test`; BEGIN
+master-bin.000001	159	Query	1	#	use `test`; insert into t1 values(3)
+master-bin.000001	240	Query	1	#	use `test`; savepoint my_savepoint
+master-bin.000001	319	Query	1	#	use `test`; insert into t1 values(4)
+master-bin.000001	400	Query	1	#	use `test`; insert into t2 select * from t1
+master-bin.000001	488	Query	1	#	use `test`; rollback to savepoint my_savepoint
+master-bin.000001	579	Query	1	#	use `test`; COMMIT
 delete from t1;
 delete from t2;
 reset master;
@@ -65,16 +65,16 @@
 a
 5
 7
-show binlog events from 95;
+show binlog events from 97;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
-master-bin.000001	95	Query	1	#	use `test`; BEGIN
-master-bin.000001	157	Query	1	#	use `test`; insert into t1 values(5)
-master-bin.000001	238	Query	1	#	use `test`; savepoint my_savepoint
-master-bin.000001	317	Query	1	#	use `test`; insert into t1 values(6)
-master-bin.000001	398	Query	1	#	use `test`; insert into t2 select * from t1
-master-bin.000001	486	Query	1	#	use `test`; rollback to savepoint my_savepoint
-master-bin.000001	577	Query	1	#	use `test`; insert into t1 values(7)
-master-bin.000001	658	Query	1	#	use `test`; COMMIT
+master-bin.000001	97	Query	1	#	use `test`; BEGIN
+master-bin.000001	159	Query	1	#	use `test`; insert into t1 values(5)
+master-bin.000001	240	Query	1	#	use `test`; savepoint my_savepoint
+master-bin.000001	319	Query	1	#	use `test`; insert into t1 values(6)
+master-bin.000001	400	Query	1	#	use `test`; insert into t2 select * from t1
+master-bin.000001	488	Query	1	#	use `test`; rollback to savepoint my_savepoint
+master-bin.000001	579	Query	1	#	use `test`; insert into t1 values(7)
+master-bin.000001	660	Query	1	#	use `test`; COMMIT
 delete from t1;
 delete from t2;
 reset master;
@@ -87,40 +87,40 @@
 select get_lock("a",10);
 get_lock("a",10)
 1
-show binlog events from 95;
+show binlog events from 97;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
-master-bin.000001	95	Query	1	#	use `test`; BEGIN
-master-bin.000001	157	Query	1	#	use `test`; insert into t1 values(8)
-master-bin.000001	238	Query	1	#	use `test`; insert into t2 select * from t1
-master-bin.000001	326	Query	1	#	use `test`; ROLLBACK
+master-bin.000001	97	Query	1	#	use `test`; BEGIN
+master-bin.000001	159	Query	1	#	use `test`; insert into t1 values(8)
+master-bin.000001	240	Query	1	#	use `test`; insert into t2 select * from t1
+master-bin.000001	328	Query	1	#	use `test`; ROLLBACK
 delete from t1;
 delete from t2;
 reset master;
 insert into t1 values(9);
 insert into t2 select * from t1;
-show binlog events from 95;
+show binlog events from 97;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
-master-bin.000001	95	Query	1	#	use `test`; insert into t1 values(9)
-master-bin.000001	176	Query	1	#	use `test`; insert into t2 select * from t1
+master-bin.000001	97	Query	1	#	use `test`; insert into t1 values(9)
+master-bin.000001	178	Query	1	#	use `test`; insert into t2 select * from t1
 delete from t1;
 delete from t2;
 reset master;
 insert into t1 values(10);
 begin;
 insert into t2 select * from t1;
-show binlog events from 95;
+show binlog events from 97;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
-master-bin.000001	95	Query	1	#	use `test`; insert into t1 values(10)
-master-bin.000001	177	Query	1	#	use `test`; insert into t2 select * from t1
+master-bin.000001	97	Query	1	#	use `test`; insert into t1 values(10)
+master-bin.000001	179	Query	1	#	use `test`; insert into t2 select * from t1
 insert into t1 values(11);
 commit;
-show binlog events from 95;
+show binlog events from 97;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
-master-bin.000001	95	Query	1	#	use `test`; insert into t1 values(10)
-master-bin.000001	177	Query	1	#	use `test`; insert into t2 select * from t1
-master-bin.000001	265	Query	1	#	use `test`; BEGIN
-master-bin.000001	327	Query	1	#	use `test`; insert into t1 values(11)
-master-bin.000001	409	Query	1	#	use `test`; COMMIT
+master-bin.000001	97	Query	1	#	use `test`; insert into t1 values(10)
+master-bin.000001	179	Query	1	#	use `test`; insert into t2 select * from t1
+master-bin.000001	267	Query	1	#	use `test`; BEGIN
+master-bin.000001	329	Query	1	#	use `test`; insert into t1 values(11)
+master-bin.000001	411	Query	1	#	use `test`; COMMIT
 alter table t2 engine=INNODB;
 delete from t1;
 delete from t2;
@@ -129,12 +129,12 @@
 insert into t1 values(12);
 insert into t2 select * from t1;
 commit;
-show binlog events from 95;
+show binlog events from 97;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
-master-bin.000001	95	Query	1	#	use `test`; BEGIN
-master-bin.000001	157	Query	1	#	use `test`; insert into t1 values(12)
-master-bin.000001	239	Query	1	#	use `test`; insert into t2 select * from t1
-master-bin.000001	327	Query	1	#	use `test`; COMMIT
+master-bin.000001	97	Query	1	#	use `test`; BEGIN
+master-bin.000001	159	Query	1	#	use `test`; insert into t1 values(12)
+master-bin.000001	241	Query	1	#	use `test`; insert into t2 select * from t1
+master-bin.000001	329	Query	1	#	use `test`; COMMIT
 delete from t1;
 delete from t2;
 reset master;
@@ -142,7 +142,7 @@
 insert into t1 values(13);
 insert into t2 select * from t1;
 rollback;
-show binlog events from 95;
+show binlog events from 97;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 delete from t1;
 delete from t2;
@@ -154,11 +154,11 @@
 insert into t2 select * from t1;
 rollback to savepoint my_savepoint;
 commit;
-show binlog events from 95;
+show binlog events from 97;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
-master-bin.000001	95	Query	1	#	use `test`; BEGIN
-master-bin.000001	157	Query	1	#	use `test`; insert into t1 values(14)
-master-bin.000001	239	Query	1	#	use `test`; COMMIT
+master-bin.000001	97	Query	1	#	use `test`; BEGIN
+master-bin.000001	159	Query	1	#	use `test`; insert into t1 values(14)
+master-bin.000001	241	Query	1	#	use `test`; COMMIT
 delete from t1;
 delete from t2;
 reset master;
@@ -174,12 +174,12 @@
 a
 16
 18
-show binlog events from 95;
+show binlog events from 97;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
-master-bin.000001	95	Query	1	#	use `test`; BEGIN
-master-bin.000001	157	Query	1	#	use `test`; insert into t1 values(16)
-master-bin.000001	239	Query	1	#	use `test`; insert into t1 values(18)
-master-bin.000001	321	Query	1	#	use `test`; COMMIT
+master-bin.000001	97	Query	1	#	use `test`; BEGIN
+master-bin.000001	159	Query	1	#	use `test`; insert into t1 values(16)
+master-bin.000001	241	Query	1	#	use `test`; insert into t1 values(18)
+master-bin.000001	323	Query	1	#	use `test`; COMMIT
 delete from t1;
 delete from t2;
 alter table t2 type=MyISAM;

--- 1.11/mysql-test/r/rpl_change_master.result	Wed Apr  7 17:12:36 2004
+++ 1.12/mysql-test/r/rpl_change_master.result	Tue Mar 15 11:30:31 2005
@@ -16,11 +16,11 @@
 1
 show slave status;
 Slave_IO_State	Master_Host	Master_User	Master_Port	Connect_Retry	Master_Log_File	Read_Master_Log_Pos	Relay_Log_File	Relay_Log_Pos	Relay_Master_Log_File	Slave_IO_Running	Slave_SQL_Running	Replicate_Do_DB	Replicate_Ignore_DB	Replicate_Do_Table	Replicate_Ignore_Table	Replicate_Wild_Do_Table	Replicate_Wild_Ignore_Table	Last_Errno	Last_Error	Skip_Counter	Exec_Master_Log_Pos	Relay_Log_Space	Until_Condition	Until_Log_File	Until_Log_Pos	Master_SSL_Allowed	Master_SSL_CA_File	Master_SSL_CA_Path	Master_SSL_Cert	Master_SSL_Cipher	Master_SSL_Key	Seconds_Behind_Master
-#	127.0.0.1	root	MASTER_MYPORT	1	master-bin.000001	355	#	#	master-bin.000001	No	No							0		0	274	#	None		0	No						#
+#	127.0.0.1	root	MASTER_MYPORT	1	master-bin.000001	357	#	#	master-bin.000001	No	No							0		0	276	#	None		0	No						#
 change master to master_user='root';
 show slave status;
 Slave_IO_State	Master_Host	Master_User	Master_Port	Connect_Retry	Master_Log_File	Read_Master_Log_Pos	Relay_Log_File	Relay_Log_Pos	Relay_Master_Log_File	Slave_IO_Running	Slave_SQL_Running	Replicate_Do_DB	Replicate_Ignore_DB	Replicate_Do_Table	Replicate_Ignore_Table	Replicate_Wild_Do_Table	Replicate_Wild_Ignore_Table	Last_Errno	Last_Error	Skip_Counter	Exec_Master_Log_Pos	Relay_Log_Space	Until_Condition	Until_Log_File	Until_Log_Pos	Master_SSL_Allowed	Master_SSL_CA_File	Master_SSL_CA_Path	Master_SSL_Cert	Master_SSL_Cipher	Master_SSL_Key	Seconds_Behind_Master
-#	127.0.0.1	root	MASTER_MYPORT	1	master-bin.000001	274	#	#	master-bin.000001	No	No							0		0	274	#	None		0	No						#
+#	127.0.0.1	root	MASTER_MYPORT	1	master-bin.000001	276	#	#	master-bin.000001	No	No							0		0	276	#	None		0	No						#
 select release_lock("a");
 release_lock("a")
 1

--- 1.11/mysql-test/r/rpl_charset.result	Mon Dec  6 18:15:48 2004
+++ 1.12/mysql-test/r/rpl_charset.result	Tue Mar 15 11:30:31 2005
@@ -103,7 +103,7 @@
 1	cp850_general_ci
 drop database mysqltest2;
 drop database mysqltest3;
-show binlog events from 95;
+show binlog events from 97;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	1	#	drop database if exists mysqltest2
 master-bin.000001	#	Query	1	#	drop database if exists mysqltest3
@@ -147,10 +147,10 @@
 master-bin.000001	#	Query	1	#	use `mysqltest2`; SET ONE_SHOT CHARACTER_SET_CLIENT=8,COLLATION_CONNECTION=31,COLLATION_DATABASE=9,COLLATION_SERVER=64
 master-bin.000001	#	Intvar	1	#	INSERT_ID=74
-master-bin.000001	#	Create_file	1	#	db=mysqltest2;table=t1;file_id=1;block_len=581
+master-bin.000001	#	Begin_load_query	1	#	;file_id=1;block_len=581
 master-bin.000001	#	Query	1	#	use `mysqltest2`; SET ONE_SHOT CHARACTER_SET_CLIENT=8,COLLATION_CONNECTION=31,COLLATION_DATABASE=9,COLLATION_SERVER=64
 master-bin.000001	#	Intvar	1	#	INSERT_ID=5
-master-bin.000001	#	Exec_load	1	#	;file_id=1
+master-bin.000001	#	Execute_load_query	1	#	use `mysqltest2`; load data infile '../../std_data/words.dat' into table t1 (b) ;file_id=1
 master-bin.000001	#	Query	1	#	use `mysqltest2`; SET ONE_SHOT CHARACTER_SET_CLIENT=8,COLLATION_CONNECTION=31,COLLATION_DATABASE=9,COLLATION_SERVER=64
 master-bin.000001	#	Query	1	#	use `mysqltest2`; truncate table t1
 master-bin.000001	#	Query	1	#	use `mysqltest2`; SET ONE_SHOT CHARACTER_SET_CLIENT=8,COLLATION_CONNECTION=31,COLLATION_DATABASE=9,COLLATION_SERVER=64
@@ -200,8 +200,8 @@
 CDF32C20E7E020F0FBE1E0EBEAF3	CDF32C20E7E020F0FBE1E0EBEAF3
 stop slave;
 delete from t1;
-change master to master_log_pos=6809;
-start slave until master_log_file='master-bin.000001', master_log_pos=6967;
+change master to master_log_pos=6856;
+start slave until master_log_file='master-bin.000001', master_log_pos=7014;
 start slave;
 select hex(c1), hex(c2) from t1;
 hex(c1)	hex(c2)

--- 1.15/mysql-test/r/rpl_error_ignored_table.result	Sun Oct 10 14:15:09 2004
+++ 1.16/mysql-test/r/rpl_error_ignored_table.result	Tue Mar 15 11:30:31 2005
@@ -9,7 +9,7 @@
 ERROR 23000: Duplicate entry '1' for key 1
 show slave status;
 Slave_IO_State	Master_Host	Master_User	Master_Port	Connect_Retry	Master_Log_File	Read_Master_Log_Pos	Relay_Log_File	Relay_Log_Pos	Relay_Master_Log_File	Slave_IO_Running	Slave_SQL_Running	Replicate_Do_DB	Replicate_Ignore_DB	Replicate_Do_Table	Replicate_Ignore_Table	Replicate_Wild_Do_Table	Replicate_Wild_Ignore_Table	Last_Errno	Last_Error	Skip_Counter	Exec_Master_Log_Pos	Relay_Log_Space	Until_Condition	Until_Log_File	Until_Log_Pos	Master_SSL_Allowed	Master_SSL_CA_File	Master_SSL_CA_Path	Master_SSL_Cert	Master_SSL_Cipher	Master_SSL_Key	Seconds_Behind_Master
-#	127.0.0.1	root	MASTER_PORT	1	master-bin.000001	273	#	#	master-bin.000001	Yes	Yes				test.t3,test.t1,test.t2			0		0	273	#	None		0	No						#
+#	127.0.0.1	root	MASTER_PORT	1	master-bin.000001	275	#	#	master-bin.000001	Yes	Yes				test.t3,test.t1,test.t2			0		0	275	#	None		0	No						#
 show tables like 't1';
 Tables_in_test (t1)
 drop table t1;
@@ -26,14 +26,14 @@
 0
 kill @id;
 drop table t2,t3;
-show binlog events from 95;
+show binlog events from 97;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
-master-bin.000001	95	Query	1	187	use `test`; create table t1 (a int primary key)
-master-bin.000001	187	Query	1	273	use `test`; insert into t1 values (1),(1)
-master-bin.000001	273	Query	1	343	use `test`; drop table t1
-master-bin.000001	343	Query	1	435	use `test`; create table t2 (a int primary key)
-master-bin.000001	435	Query	1	516	use `test`; insert into t2 values(1)
-master-bin.000001	516	Query	1	597	use `test`; create table t3 (id int)
-master-bin.000001	597	Query	1	692	use `test`; insert into t3 values(connection_id())
-master-bin.000001	692	Query	1	805	use `test`; update t2 set a = a + 1 + get_lock('crash_lock%20C', 10)
-master-bin.000001	805	Query	1	878	use `test`; drop table t2,t3
+master-bin.000001	97	Query	1	189	use `test`; create table t1 (a int primary key)
+master-bin.000001	189	Query	1	275	use `test`; insert into t1 values (1),(1)
+master-bin.000001	275	Query	1	345	use `test`; drop table t1
+master-bin.000001	345	Query	1	437	use `test`; create table t2 (a int primary key)
+master-bin.000001	437	Query	1	518	use `test`; insert into t2 values(1)
+master-bin.000001	518	Query	1	599	use `test`; create table t3 (id int)
+master-bin.000001	599	Query	1	694	use `test`; insert into t3 values(connection_id())
+master-bin.000001	694	Query	1	807	use `test`; update t2 set a = a + 1 + get_lock('crash_lock%20C', 10)
+master-bin.000001	807	Query	1	880	use `test`; drop table t2,t3

--- 1.7/mysql-test/r/rpl_flush_tables.result	Wed Apr  7 17:12:37 2004
+++ 1.8/mysql-test/r/rpl_flush_tables.result	Tue Mar 15 11:30:31 2005
@@ -14,27 +14,27 @@
 flush no_write_to_binlog tables;
 show binlog events;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
-master-bin.000001	4	Format_desc	1	95	Server ver: SERVER_VERSION, Binlog ver: 4
-master-bin.000001	95	Query	1	175	use `test`; create table t1 (a int)
-master-bin.000001	175	Query	1	258	use `test`; insert into t1 values (10)
-master-bin.000001	258	Query	1	338	use `test`; create table t2 (a int)
-master-bin.000001	338	Query	1	441	use `test`; create table t3 (a int) engine=merge union(t1)
-master-bin.000001	441	Query	1	521	use `test`; create table t4 (a int)
-master-bin.000001	521	Query	1	609	use `test`; insert into t4 select * from t3
-master-bin.000001	609	Query	1	697	use `test`; rename table t1 to t5, t2 to t1
+master-bin.000001	4	Format_desc	1	97	Server ver: SERVER_VERSION, Binlog ver: 4
+master-bin.000001	97	Query	1	177	use `test`; create table t1 (a int)
+master-bin.000001	177	Query	1	260	use `test`; insert into t1 values (10)
+master-bin.000001	260	Query	1	340	use `test`; create table t2 (a int)
+master-bin.000001	340	Query	1	443	use `test`; create table t3 (a int) engine=merge union(t1)
+master-bin.000001	443	Query	1	523	use `test`; create table t4 (a int)
+master-bin.000001	523	Query	1	611	use `test`; insert into t4 select * from t3
+master-bin.000001	611	Query	1	699	use `test`; rename table t1 to t5, t2 to t1
 select * from t3;
 a
 flush tables;
 show binlog events;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
-master-bin.000001	4	Format_desc	1	95	Server ver: SERVER_VERSION, Binlog ver: 4
-master-bin.000001	95	Query	1	175	use `test`; create table t1 (a int)
-master-bin.000001	175	Query	1	258	use `test`; insert into t1 values (10)
-master-bin.000001	258	Query	1	338	use `test`; create table t2 (a int)
-master-bin.000001	338	Query	1	441	use `test`; create table t3 (a int) engine=merge union(t1)
-master-bin.000001	441	Query	1	521	use `test`; create table t4 (a int)
-master-bin.000001	521	Query	1	609	use `test`; insert into t4 select * from t3
-master-bin.000001	609	Query	1	697	use `test`; rename table t1 to t5, t2 to t1
-master-bin.000001	697	Query	1	766	use `test`; flush tables
+master-bin.000001	4	Format_desc	1	97	Server ver: SERVER_VERSION, Binlog ver: 4
+master-bin.000001	97	Query	1	177	use `test`; create table t1 (a int)
+master-bin.000001	177	Query	1	260	use `test`; insert into t1 values (10)
+master-bin.000001	260	Query	1	340	use `test`; create table t2 (a int)
+master-bin.000001	340	Query	1	443	use `test`; create table t3 (a int) engine=merge union(t1)
+master-bin.000001	443	Query	1	523	use `test`; create table t4 (a int)
+master-bin.000001	523	Query	1	611	use `test`; insert into t4 select * from t3
+master-bin.000001	611	Query	1	699	use `test`; rename table t1 to t5, t2 to t1
+master-bin.000001	699	Query	1	768	use `test`; flush tables
 select * from t3;
 a

--- 1.9/mysql-test/r/rpl_loaddata_rule_m.result	Mon Dec  6 18:15:48 2004
+++ 1.10/mysql-test/r/rpl_loaddata_rule_m.result	Tue Mar 15 11:30:31 2005
@@ -10,8 +10,10 @@
 create table t1(a int, b int, unique(b));
 use mysqltest;
 load data infile '../../std_data/rpl_loaddata.dat' into table test.t1;
-show binlog events from 95;
+show binlog events from 97;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
-master-bin.000001	95	Query	1	190	drop database if exists mysqltest
-master-bin.000001	190	Query	1	277	create database mysqltest
+master-bin.000001	97	Query	1	192	drop database if exists mysqltest
+master-bin.000001	192	Query	1	279	create database mysqltest
+master-bin.000001	279	Begin_load_query	1	314	;file_id=1;block_len=12
+master-bin.000001	314	Execute_load_query	1	458	use `mysqltest`; load data infile '../../std_data/rpl_loaddata.dat' into table test.t1 ;file_id=1
 drop database mysqltest;

--- 1.5/mysql-test/r/rpl_loaddata_rule_s.result	Wed Apr  7 17:12:37 2004
+++ 1.6/mysql-test/r/rpl_loaddata_rule_s.result	Tue Mar 15 11:30:31 2005
@@ -10,5 +10,5 @@
 select count(*) from t1;
 count(*)
 2
-show binlog events from 95;
+show binlog events from 97;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info

--- 1.15/mysql-test/r/rpl_max_relay_size.result	Wed Apr  7 17:12:37 2004
+++ 1.16/mysql-test/r/rpl_max_relay_size.result	Tue Mar 15 11:30:31 2005
@@ -16,7 +16,7 @@
 start slave;
 show slave status;
 Slave_IO_State	Master_Host	Master_User	Master_Port	Connect_Retry	Master_Log_File	Read_Master_Log_Pos	Relay_Log_File	Relay_Log_Pos	Relay_Master_Log_File	Slave_IO_Running	Slave_SQL_Running	Replicate_Do_DB	Replicate_Ignore_DB	Replicate_Do_Table	Replicate_Ignore_Table	Replicate_Wild_Do_Table	Replicate_Wild_Ignore_Table	Last_Errno	Last_Error	Skip_Counter	Exec_Master_Log_Pos	Relay_Log_Space	Until_Condition	Until_Log_File	Until_Log_Pos	Master_SSL_Allowed	Master_SSL_CA_File	Master_SSL_CA_Path	Master_SSL_Cert	Master_SSL_Cipher	Master_SSL_Key	Seconds_Behind_Master
-#	127.0.0.1	root	MASTER_PORT	1	master-bin.000001	68137	#	#	master-bin.000001	Yes	Yes							0		0	68137	#	None		0	No						#
+#	127.0.0.1	root	MASTER_PORT	1	master-bin.000001	68139	#	#	master-bin.000001	Yes	Yes							0		0	68139	#	None		0	No						#
 stop slave;
 reset slave;
 set global max_relay_log_size=(5*4096);
@@ -26,7 +26,7 @@
 start slave;
 show slave status;
 Slave_IO_State	Master_Host	Master_User	Master_Port	Connect_Retry	Master_Log_File	Read_Master_Log_Pos	Relay_Log_File	Relay_Log_Pos	Relay_Master_Log_File	Slave_IO_Running	Slave_SQL_Running	Replicate_Do_DB	Replicate_Ignore_DB	Replicate_Do_Table	Replicate_Ignore_Table	Replicate_Wild_Do_Table	Replicate_Wild_Ignore_Table	Last_Errno	Last_Error	Skip_Counter	Exec_Master_Log_Pos	Relay_Log_Space	Until_Condition	Until_Log_File	Until_Log_Pos	Master_SSL_Allowed	Master_SSL_CA_File	Master_SSL_CA_Path	Master_SSL_Cert	Master_SSL_Cipher	Master_SSL_Key	Seconds_Behind_Master
-#	127.0.0.1	root	MASTER_PORT	1	master-bin.000001	68137	#	#	master-bin.000001	Yes	Yes							0		0	68137	#	None		0	No						#
+#	127.0.0.1	root	MASTER_PORT	1	master-bin.000001	68139	#	#	master-bin.000001	Yes	Yes							0		0	68139	#	None		0	No						#
 stop slave;
 reset slave;
 set global max_relay_log_size=0;
@@ -36,7 +36,7 @@
 start slave;
 show slave status;
 Slave_IO_State	Master_Host	Master_User	Master_Port	Connect_Retry	Master_Log_File	Read_Master_Log_Pos	Relay_Log_File	Relay_Log_Pos	Relay_Master_Log_File	Slave_IO_Running	Slave_SQL_Running	Replicate_Do_DB	Replicate_Ignore_DB	Replicate_Do_Table	Replicate_Ignore_Table	Replicate_Wild_Do_Table	Replicate_Wild_Ignore_Table	Last_Errno	Last_Error	Skip_Counter	Exec_Master_Log_Pos	Relay_Log_Space	Until_Condition	Until_Log_File	Until_Log_Pos	Master_SSL_Allowed	Master_SSL_CA_File	Master_SSL_CA_Path	Master_SSL_Cert	Master_SSL_Cipher	Master_SSL_Key	Seconds_Behind_Master
-#	127.0.0.1	root	MASTER_PORT	1	master-bin.000001	68137	#	#	master-bin.000001	Yes	Yes							0		0	68137	#	None		0	No						#
+#	127.0.0.1	root	MASTER_PORT	1	master-bin.000001	68139	#	#	master-bin.000001	Yes	Yes							0		0	68139	#	None		0	No						#
 stop slave;
 reset slave;
 flush logs;
@@ -49,13 +49,13 @@
 create table t1 (a int);
 show slave status;
 Slave_IO_State	Master_Host	Master_User	Master_Port	Connect_Retry	Master_Log_File	Read_Master_Log_Pos	Relay_Log_File	Relay_Log_Pos	Relay_Master_Log_File	Slave_IO_Running	Slave_SQL_Running	Replicate_Do_DB	Replicate_Ignore_DB	Replicate_Do_Table	Replicate_Ignore_Table	Replicate_Wild_Do_Table	Replicate_Wild_Ignore_Table	Last_Errno	Last_Error	Skip_Counter	Exec_Master_Log_Pos	Relay_Log_Space	Until_Condition	Until_Log_File	Until_Log_Pos	Master_SSL_Allowed	Master_SSL_CA_File	Master_SSL_CA_Path	Master_SSL_Cert	Master_SSL_Cipher	Master_SSL_Key	Seconds_Behind_Master
-#	127.0.0.1	root	MASTER_PORT	1	master-bin.000001	68217	#	#	master-bin.000001	Yes	Yes							0		0	68217	#	None		0	No						#
+#	127.0.0.1	root	MASTER_PORT	1	master-bin.000001	68219	#	#	master-bin.000001	Yes	Yes							0		0	68219	#	None		0	No						#
 flush logs;
 drop table t1;
 show slave status;
 Slave_IO_State	Master_Host	Master_User	Master_Port	Connect_Retry	Master_Log_File	Read_Master_Log_Pos	Relay_Log_File	Relay_Log_Pos	Relay_Master_Log_File	Slave_IO_Running	Slave_SQL_Running	Replicate_Do_DB	Replicate_Ignore_DB	Replicate_Do_Table	Replicate_Ignore_Table	Replicate_Wild_Do_Table	Replicate_Wild_Ignore_Table	Last_Errno	Last_Error	Skip_Counter	Exec_Master_Log_Pos	Relay_Log_Space	Until_Condition	Until_Log_File	Until_Log_Pos	Master_SSL_Allowed	Master_SSL_CA_File	Master_SSL_CA_Path	Master_SSL_Cert	Master_SSL_Cipher	Master_SSL_Key	Seconds_Behind_Master
-#	127.0.0.1	root	MASTER_PORT	1	master-bin.000001	68287	#	#	master-bin.000001	Yes	Yes							0		0	68287	#	None		0	No						#
+#	127.0.0.1	root	MASTER_PORT	1	master-bin.000001	68289	#	#	master-bin.000001	Yes	Yes							0		0	68289	#	None		0	No						#
 flush logs;
 show master status;
 File	Position	Binlog_Do_DB	Binlog_Ignore_DB
-master-bin.000002	95		
+master-bin.000002	97		

--- 1.10/mysql-test/r/rpl_relayrotate.result	Wed May 26 19:04:40 2004
+++ 1.11/mysql-test/r/rpl_relayrotate.result	Tue Mar 15 11:30:31 2005
@@ -18,5 +18,5 @@
 8000
 show slave status;
 Slave_IO_State	Master_Host	Master_User	Master_Port	Connect_Retry	Master_Log_File	Read_Master_Log_Pos	Relay_Log_File	Relay_Log_Pos	Relay_Master_Log_File	Slave_IO_Running	Slave_SQL_Running	Replicate_Do_DB	Replicate_Ignore_DB	Replicate_Do_Table	Replicate_Ignore_Table	Replicate_Wild_Do_Table	Replicate_Wild_Ignore_Table	Last_Errno	Last_Error	Skip_Counter	Exec_Master_Log_Pos	Relay_Log_Space	Until_Condition	Until_Log_File	Until_Log_Pos	Master_SSL_Allowed	Master_SSL_CA_File	Master_SSL_CA_Path	Master_SSL_Cert	Master_SSL_Cipher	Master_SSL_Key	Seconds_Behind_Master
-#	127.0.0.1	root	MASTER_MYPORT	1	master-bin.000001	687207	#	#	master-bin.000001	Yes	Yes							0		0	687207	#	None		0	No						#
+#	127.0.0.1	root	MASTER_MYPORT	1	master-bin.000001	687209	#	#	master-bin.000001	Yes	Yes							0		0	687209	#	None		0	No						#
 drop table t1;

--- 1.11/mysql-test/r/rpl_reset_slave.result	Wed Apr  7 17:12:37 2004
+++ 1.12/mysql-test/r/rpl_reset_slave.result	Tue Mar 15 11:30:32 2005
@@ -6,12 +6,12 @@
 start slave;
 show slave status;
 Slave_IO_State	Master_Host	Master_User	Master_Port	Connect_Retry	Master_Log_File	Read_Master_Log_Pos	Relay_Log_File	Relay_Log_Pos	Relay_Master_Log_File	Slave_IO_Running	Slave_SQL_Running	Replicate_Do_DB	Replicate_Ignore_DB	Replicate_Do_Table	Replicate_Ignore_Table	Replicate_Wild_Do_Table	Replicate_Wild_Ignore_Table	Last_Errno	Last_Error	Skip_Counter	Exec_Master_Log_Pos	Relay_Log_Space	Until_Condition	Until_Log_File	Until_Log_Pos	Master_SSL_Allowed	Master_SSL_CA_File	Master_SSL_CA_Path	Master_SSL_Cert	Master_SSL_Cipher	Master_SSL_Key	Seconds_Behind_Master
-#	127.0.0.1	root	MASTER_PORT	1	master-bin.000001	95	#	#	master-bin.000001	Yes	Yes							0		0	95	#	None		0	No						#
+#	127.0.0.1	root	MASTER_PORT	1	master-bin.000001	97	#	#	master-bin.000001	Yes	Yes							0		0	97	#	None		0	No						#
 stop slave;
 change master to master_user='test';
 show slave status;
 Slave_IO_State	Master_Host	Master_User	Master_Port	Connect_Retry	Master_Log_File	Read_Master_Log_Pos	Relay_Log_File	Relay_Log_Pos	Relay_Master_Log_File	Slave_IO_Running	Slave_SQL_Running	Replicate_Do_DB	Replicate_Ignore_DB	Replicate_Do_Table	Replicate_Ignore_Table	Replicate_Wild_Do_Table	Replicate_Wild_Ignore_Table	Last_Errno	Last_Error	Skip_Counter	Exec_Master_Log_Pos	Relay_Log_Space	Until_Condition	Until_Log_File	Until_Log_Pos	Master_SSL_Allowed	Master_SSL_CA_File	Master_SSL_CA_Path	Master_SSL_Cert	Master_SSL_Cipher	Master_SSL_Key	Seconds_Behind_Master
-#	127.0.0.1	test	MASTER_PORT	1	master-bin.000001	95	#	#	master-bin.000001	No	No							0		0	95	#	None		0	No						#
+#	127.0.0.1	test	MASTER_PORT	1	master-bin.000001	97	#	#	master-bin.000001	No	No							0		0	97	#	None		0	No						#
 reset slave;
 show slave status;
 Slave_IO_State	Master_Host	Master_User	Master_Port	Connect_Retry	Master_Log_File	Read_Master_Log_Pos	Relay_Log_File	Relay_Log_Pos	Relay_Master_Log_File	Slave_IO_Running	Slave_SQL_Running	Replicate_Do_DB	Replicate_Ignore_DB	Replicate_Do_Table	Replicate_Ignore_Table	Replicate_Wild_Do_Table	Replicate_Wild_Ignore_Table	Last_Errno	Last_Error	Skip_Counter	Exec_Master_Log_Pos	Relay_Log_Space	Until_Condition	Until_Log_File	Until_Log_Pos	Master_SSL_Allowed	Master_SSL_CA_File	Master_SSL_CA_Path	Master_SSL_Cert	Master_SSL_Cipher	Master_SSL_Key	Seconds_Behind_Master
@@ -19,7 +19,7 @@
 start slave;
 show slave status;
 Slave_IO_State	Master_Host	Master_User	Master_Port	Connect_Retry	Master_Log_File	Read_Master_Log_Pos	Relay_Log_File	Relay_Log_Pos	Relay_Master_Log_File	Slave_IO_Running	Slave_SQL_Running	Replicate_Do_DB	Replicate_Ignore_DB	Replicate_Do_Table	Replicate_Ignore_Table	Replicate_Wild_Do_Table	Replicate_Wild_Ignore_Table	Last_Errno	Last_Error	Skip_Counter	Exec_Master_Log_Pos	Relay_Log_Space	Until_Condition	Until_Log_File	Until_Log_Pos	Master_SSL_Allowed	Master_SSL_CA_File	Master_SSL_CA_Path	Master_SSL_Cert	Master_SSL_Cipher	Master_SSL_Key	Seconds_Behind_Master
-#	127.0.0.1	root	MASTER_PORT	1	master-bin.000001	95	#	#	master-bin.000001	Yes	Yes							0		0	95	#	None		0	No						#
+#	127.0.0.1	root	MASTER_PORT	1	master-bin.000001	97	#	#	master-bin.000001	Yes	Yes							0		0	97	#	None		0	No						#
 stop slave;
 reset slave;
 start slave;

--- 1.5/mysql-test/r/rpl_server_id1.result	Tue Jul  6 15:34:00 2004
+++ 1.6/mysql-test/r/rpl_server_id1.result	Tue Mar 15 11:30:32 2005
@@ -10,7 +10,7 @@
 change master to master_port=SLAVE_PORT;
 show slave status;
 Slave_IO_State	Master_Host	Master_User	Master_Port	Connect_Retry	Master_Log_File	Read_Master_Log_Pos	Relay_Log_File	Relay_Log_Pos	Relay_Master_Log_File	Slave_IO_Running	Slave_SQL_Running	Replicate_Do_DB	Replicate_Ignore_DB	Replicate_Do_Table	Replicate_Ignore_Table	Replicate_Wild_Do_Table	Replicate_Wild_Ignore_Table	Last_Errno	Last_Error	Skip_Counter	Exec_Master_Log_Pos	Relay_Log_Space	Until_Condition	Until_Log_File	Until_Log_Pos	Master_SSL_Allowed	Master_SSL_CA_File	Master_SSL_CA_Path	Master_SSL_Cert	Master_SSL_Cipher	Master_SSL_Key	Seconds_Behind_Master
-	127.0.0.1	root	SLAVE_PORT	1		4	slave-relay-bin.000001	4		No	No						#	0		0	0	95	None		0	No						NULL
+	127.0.0.1	root	SLAVE_PORT	1		4	slave-relay-bin.000001	4		No	No						#	0		0	0	97	None		0	No						NULL
 start slave;
 insert into t1 values (1);
 show status like "slave_running";

--- 1.6/mysql-test/r/rpl_server_id2.result	Wed May 26 18:10:51 2004
+++ 1.7/mysql-test/r/rpl_server_id2.result	Tue Mar 15 11:30:32 2005
@@ -10,7 +10,7 @@
 change master to master_port=SLAVE_PORT;
 show slave status;
 Slave_IO_State	Master_Host	Master_User	Master_Port	Connect_Retry	Master_Log_File	Read_Master_Log_Pos	Relay_Log_File	Relay_Log_Pos	Relay_Master_Log_File	Slave_IO_Running	Slave_SQL_Running	Replicate_Do_DB	Replicate_Ignore_DB	Replicate_Do_Table	Replicate_Ignore_Table	Replicate_Wild_Do_Table	Replicate_Wild_Ignore_Table	Last_Errno	Last_Error	Skip_Counter	Exec_Master_Log_Pos	Relay_Log_Space	Until_Condition	Until_Log_File	Until_Log_Pos	Master_SSL_Allowed	Master_SSL_CA_File	Master_SSL_CA_Path	Master_SSL_Cert	Master_SSL_Cipher	Master_SSL_Key	Seconds_Behind_Master
-	127.0.0.1	root	SLAVE_PORT	1		4	slave-relay-bin.000001	4		No	No						#	0		0	0	95	None		0	No						NULL
+	127.0.0.1	root	SLAVE_PORT	1		4	slave-relay-bin.000001	4		No	No						#	0		0	0	97	None		0	No						NULL
 start slave;
 insert into t1 values (1);
 select * from t1;

--- 1.10/mysql-test/t/mix_innodb_myisam_binlog.test	Fri Nov 12 20:15:43 2004
+++ 1.11/mysql-test/t/mix_innodb_myisam_binlog.test	Tue Mar 15 11:30:32 2005
@@ -26,7 +26,7 @@
 commit;
 
 --replace_column 5 #
-show binlog events from 95;
+show binlog events from 97;
 
 delete from t1;
 delete from t2;
@@ -39,7 +39,7 @@
 rollback;
 
 --replace_column 5 #
-show binlog events from 95;
+show binlog events from 97;
 
 delete from t1;
 delete from t2;
@@ -54,7 +54,7 @@
 commit;
 
 --replace_column 5 #
-show binlog events from 95;
+show binlog events from 97;
 
 delete from t1;
 delete from t2;
@@ -71,7 +71,7 @@
 select a from t1 order by a; # check that savepoints work :)
 
 --replace_column 5 #
-show binlog events from 95;
+show binlog events from 97;
 
 # and when ROLLBACK is not explicit?
 delete from t1;
@@ -92,7 +92,7 @@
 # logging has been done, we use a user lock.
 select get_lock("a",10);
 --replace_column 5 #
-show binlog events from 95;
+show binlog events from 97;
 
 # and when not in a transact1on?
 delete from t1;
@@ -103,7 +103,7 @@
 insert into t2 select * from t1;
 
 --replace_column 5 #
-show binlog events from 95;
+show binlog events from 97;
 
 # Check that when the query updat1ng the MyISAM table is the first in the
 # transaction, we log it immediately.
@@ -115,12 +115,12 @@
 begin;
 insert into t2 select * from t1;
 --replace_column 5 #
-show binlog events from 95;
+show binlog events from 97;
 insert into t1 values(11);
 commit;
 
 --replace_column 5 #
-show binlog events from 95;
+show binlog events from 97;
 
 
 # Check that things work like before this BEGIN/ROLLBACK code was added,
@@ -138,7 +138,7 @@
 commit;
 
 --replace_column 5 #
-show binlog events from 95;
+show binlog events from 97;
 
 delete from t1;
 delete from t2;
@@ -150,7 +150,7 @@
 rollback;
 
 --replace_column 5 #
-show binlog events from 95;
+show binlog events from 97;
 
 delete from t1;
 delete from t2;
@@ -165,7 +165,7 @@
 commit;
 
 --replace_column 5 #
-show binlog events from 95;
+show binlog events from 97;
 
 delete from t1;
 delete from t2;
@@ -182,7 +182,7 @@
 select a from t1 order by a; # check that savepoints work :)
 
 --replace_column 5 #
-show binlog events from 95;
+show binlog events from 97;
 
 # Test for BUG#5714, where a MyISAM update in the transaction used to
 # release row-level locks in InnoDB

--- 1.2/mysql-test/t/mysqlbinlog2.test	Thu Sep  9 07:59:21 2004
+++ 1.3/mysql-test/t/mysqlbinlog2.test	Tue Mar 15 11:30:32 2005
@@ -46,11 +46,11 @@
 --disable_query_log
 select "--- start-position --" as "";
 --enable_query_log
---exec $MYSQL_BINLOG --short-form --start-position=601 $MYSQL_TEST_DIR/var/log/master-bin.000001 
+--exec $MYSQL_BINLOG --short-form --start-position=603 $MYSQL_TEST_DIR/var/log/master-bin.000001 
 --disable_query_log
 select "--- stop-position --" as "";
 --enable_query_log
---exec $MYSQL_BINLOG --short-form --stop-position=601 $MYSQL_TEST_DIR/var/log/master-bin.000001 
+--exec $MYSQL_BINLOG --short-form --stop-position=603 $MYSQL_TEST_DIR/var/log/master-bin.000001 
 --disable_query_log
 select "--- start-datetime --" as "";
 --enable_query_log
@@ -75,11 +75,11 @@
 --disable_query_log
 select "--- start-position --" as "";
 --enable_query_log
---exec $MYSQL_BINLOG --short-form --start-position=601 $MYSQL_TEST_DIR/var/log/master-bin.000001 $MYSQL_TEST_DIR/var/log/master-bin.000002
+--exec $MYSQL_BINLOG --short-form --start-position=603 $MYSQL_TEST_DIR/var/log/master-bin.000001 $MYSQL_TEST_DIR/var/log/master-bin.000002
 --disable_query_log
 select "--- stop-position --" as "";
 --enable_query_log
---exec $MYSQL_BINLOG --short-form --stop-position=123 $MYSQL_TEST_DIR/var/log/master-bin.000001 $MYSQL_TEST_DIR/var/log/master-bin.000002
+--exec $MYSQL_BINLOG --short-form --stop-position=125 $MYSQL_TEST_DIR/var/log/master-bin.000001 $MYSQL_TEST_DIR/var/log/master-bin.000002
 --disable_query_log
 select "--- start-datetime --" as "";
 --enable_query_log
@@ -102,11 +102,11 @@
 --disable_query_log
 select "--- start-position --" as "";
 --enable_query_log
---exec $MYSQL_BINLOG --short-form --start-position=601 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 
+--exec $MYSQL_BINLOG --short-form --start-position=603 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 
 --disable_query_log
 select "--- stop-position --" as "";
 --enable_query_log
---exec $MYSQL_BINLOG --short-form --stop-position=601 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 
+--exec $MYSQL_BINLOG --short-form --stop-position=603 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 
 --disable_query_log
 select "--- start-datetime --" as "";
 --enable_query_log
@@ -129,11 +129,11 @@
 --disable_query_log
 select "--- start-position --" as "";
 --enable_query_log
---exec $MYSQL_BINLOG --short-form --start-position=601 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001  master-bin.000002
+--exec $MYSQL_BINLOG --short-form --start-position=603 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001  master-bin.000002
 --disable_query_log
 select "--- stop-position --" as "";
 --enable_query_log
---exec $MYSQL_BINLOG --short-form --stop-position=123 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001  master-bin.000002
+--exec $MYSQL_BINLOG --short-form --stop-position=125 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001  master-bin.000002
 --disable_query_log
 select "--- start-datetime --" as "";
 --enable_query_log

--- 1.10/mysql-test/t/rpl_charset.test	Mon Dec  6 18:15:48 2004
+++ 1.11/mysql-test/t/rpl_charset.test	Tue Mar 15 11:30:32 2005
@@ -107,7 +107,7 @@
 drop database mysqltest2;
 drop database mysqltest3;
 --replace_column 2 # 5 #
-show binlog events from 95;
+show binlog events from 97;
 sync_slave_with_master;
 
 # Check that we can't change global.collation_server
@@ -163,14 +163,14 @@
 # command just before the INSERT.
 # You can find it by doing:
 # ../client/mysqlbinlog var/log/master-bin.000001 | grep -3 CHARACTER_SET | tail -7
-change master to master_log_pos=6809;
+change master to master_log_pos=6856;
 
 # This position should be position of the INSERT command.
 # You can find it by doing:
 #
 # ../client/mysqlbinlog var/log/master-bin.000001 | grep -3 INSERT | tail -4
 
-start slave until master_log_file='master-bin.000001', master_log_pos=6967;
+start slave until master_log_file='master-bin.000001', master_log_pos=7014;
 
 # Slave is supposed to stop _after_ the INSERT, even though 'master_log_pos' is
 # the position of the beginning of the INSERT; after SET slave is not

--- 1.11/mysql-test/t/rpl_error_ignored_table.test	Wed May 26 18:10:51 2004
+++ 1.12/mysql-test/t/rpl_error_ignored_table.test	Tue Mar 15 11:30:32 2005
@@ -48,7 +48,7 @@
 --error 0,1053;
 reap;
 connection master1;
-show binlog events from 95;
+show binlog events from 97;
 save_master_pos;
 connection slave;
 # SQL slave thread should not have stopped (because table of the killed

--- 1.6/mysql-test/t/rpl_loaddata_rule_m.test	Wed Apr  7 17:12:39 2004
+++ 1.7/mysql-test/t/rpl_loaddata_rule_m.test	Tue Mar 15 11:30:32 2005
@@ -19,5 +19,8 @@
 create table t1(a int, b int, unique(b));
 use mysqltest;
 load data infile '../../std_data/rpl_loaddata.dat' into table test.t1;
-show binlog events from 95; # should be nothing
+# Starting from 5.0.3 LOAD DATA is replicated much in the same way as ordinary
+# query so "show binlog ..." should show two events (before 5.0.3 no events
+# were returned).
+show binlog events from 97;
 drop database mysqltest;

--- 1.4/mysql-test/t/rpl_loaddata_rule_s.test	Wed Apr  7 17:12:39 2004
+++ 1.5/mysql-test/t/rpl_loaddata_rule_s.test	Tue Mar 15 11:30:32 2005
@@ -17,4 +17,4 @@
 connection slave;
 sync_with_master;
 select count(*) from t1; # check that LOAD was replicated
-show binlog events from 95; # should be nothing
+show binlog events from 97; # should be nothing

--- 1.22/mysql-test/r/insert_select.result	Mon Dec  6 18:15:48 2004
+++ 1.23/mysql-test/r/insert_select.result	Tue Mar 15 11:30:31 2005
@@ -74,8 +74,8 @@
 ERROR 23000: Duplicate entry '2' for key 1
 show binlog events;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
-master-bin.000001	4	Format_desc	1	95	Server ver: VERSION, Binlog ver: 4
-master-bin.000001	95	Query	1	183	use `test`; insert into t1 select * from t2
+master-bin.000001	4	Format_desc	1	97	Server ver: VERSION, Binlog ver: 4
+master-bin.000001	97	Query	1	185	use `test`; insert into t1 select * from t2
 select * from t1;
 a
 1
@@ -88,7 +88,7 @@
 ERROR 23000: Duplicate entry '1' for key 1
 show binlog events;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
-master-bin.000001	4	Format_desc	1	95	Server ver: VERSION, Binlog ver: 4
+master-bin.000001	4	Format_desc	1	97	Server ver: VERSION, Binlog ver: 4
 drop table t1;
 create table t1 (a int not null);
 create table t2 (a int not null);

--- 1.18/mysql-test/r/rpl_flush_log_loop.result	Thu Jul 15 05:18:45 2004
+++ 1.19/mysql-test/r/rpl_flush_log_loop.result	Tue Mar 15 11:30:31 2005
@@ -14,4 +14,4 @@
 flush logs;
 show slave status;
 Slave_IO_State	Master_Host	Master_User	Master_Port	Connect_Retry	Master_Log_File	Read_Master_Log_Pos	Relay_Log_File	Relay_Log_Pos	Relay_Master_Log_File	Slave_IO_Running	Slave_SQL_Running	Replicate_Do_DB	Replicate_Ignore_DB	Replicate_Do_Table	Replicate_Ignore_Table	Replicate_Wild_Do_Table	Replicate_Wild_Ignore_Table	Last_Errno	Last_Error	Skip_Counter	Exec_Master_Log_Pos	Relay_Log_Space	Until_Condition	Until_Log_File	Until_Log_Pos	Master_SSL_Allowed	Master_SSL_CA_File	Master_SSL_CA_Path	Master_SSL_Cert	Master_SSL_Cipher	Master_SSL_Key	Seconds_Behind_Master
-#	127.0.0.1	root	SLAVE_PORT	60	slave-bin.000001	199	#	#	slave-bin.000001	Yes	Yes							0		0	199	#	None		0	No						#
+#	127.0.0.1	root	SLAVE_PORT	60	slave-bin.000001	201	#	#	slave-bin.000001	Yes	Yes							0		0	201	#	None		0	No						#

--- 1.23/mysql-test/r/rpl_loaddata.result	Wed Apr  7 17:12:37 2004
+++ 1.24/mysql-test/r/rpl_loaddata.result	Tue Mar 15 11:30:31 2005
@@ -22,7 +22,7 @@
 2003-03-22	2416	a	bbbbb
 show master status;
 File	Position	Binlog_Do_DB	Binlog_Ignore_DB
-slave-bin.000001	1068		
+slave-bin.000001	1249		
 drop table t1;
 drop table t2;
 drop table t3;
@@ -33,7 +33,7 @@
 start slave;
 show slave status;
 Slave_IO_State	Master_Host	Master_User	Master_Port	Connect_Retry	Master_Log_File	Read_Master_Log_Pos	Relay_Log_File	Relay_Log_Pos	Relay_Master_Log_File	Slave_IO_Running	Slave_SQL_Running	Replicate_Do_DB	Replicate_Ignore_DB	Replicate_Do_Table	Replicate_Ignore_Table	Replicate_Wild_Do_Table	Replicate_Wild_Ignore_Table	Last_Errno	Last_Error	Skip_Counter	Exec_Master_Log_Pos	Relay_Log_Space	Until_Condition	Until_Log_File	Until_Log_Pos	Master_SSL_Allowed	Master_SSL_CA_File	Master_SSL_CA_Path	Master_SSL_Cert	Master_SSL_Cipher	Master_SSL_Key	Seconds_Behind_Master
-#	127.0.0.1	root	MASTER_PORT	1	master-bin.000001	1503	#	#	master-bin.000001	Yes	Yes							0		0	1503	#	None		0	No						#
+#	127.0.0.1	root	MASTER_PORT	1	master-bin.000001	1722	#	#	master-bin.000001	Yes	Yes							0		0	1722	#	None		0	No						#
 set sql_log_bin=0;
 delete from t1;
 set sql_log_bin=1;
@@ -43,7 +43,7 @@
 change master to master_user='root';
 show slave status;
 Slave_IO_State	Master_Host	Master_User	Master_Port	Connect_Retry	Master_Log_File	Read_Master_Log_Pos	Relay_Log_File	Relay_Log_Pos	Relay_Master_Log_File	Slave_IO_Running	Slave_SQL_Running	Replicate_Do_DB	Replicate_Ignore_DB	Replicate_Do_Table	Replicate_Ignore_Table	Replicate_Wild_Do_Table	Replicate_Wild_Ignore_Table	Last_Errno	Last_Error	Skip_Counter	Exec_Master_Log_Pos	Relay_Log_Space	Until_Condition	Until_Log_File	Until_Log_Pos	Master_SSL_Allowed	Master_SSL_CA_File	Master_SSL_CA_Path	Master_SSL_Cert	Master_SSL_Cipher	Master_SSL_Key	Seconds_Behind_Master
-#	127.0.0.1	root	MASTER_PORT	1	master-bin.000001	1611	#	#	master-bin.000001	No	No							0		0	1611	#	None		0	No						#
+#	127.0.0.1	root	MASTER_PORT	1	master-bin.000001	1757	#	#	master-bin.000001	No	No							0		0	1757	#	None		0	No						#
 set global sql_slave_skip_counter=1;
 start slave;
 set sql_log_bin=0;
@@ -64,5 +64,5 @@
 ERROR 23000: Duplicate entry '2003-03-22' for key 1
 show master status;
 File	Position	Binlog_Do_DB	Binlog_Ignore_DB
-master-bin.000001	529		
+master-bin.000001	433		
 drop table t2;

--- 1.14/mysql-test/t/rpl_loaddata.test	Wed Apr  7 17:12:39 2004
+++ 1.15/mysql-test/t/rpl_loaddata.test	Tue Mar 15 11:30:32 2005
@@ -36,8 +36,7 @@
 # But we can't simply read this binlog, because as the slave has not been
 # restarted for this test, the file_id is uncertain (would cause test
 # failures). So instead, we test if the binlog looks long enough to
-# contain LOAD DATA. That is, I (Guilhem) have done SHOW BINLOG EVENTS on my
-# machine, saw that the binlog is of size 1068 (in 5.0.0) when things go fine.
+# contain LOAD DATA. Since 5.0.3 we assume that binlog of 1249 is ok.
 # If LOAD DATA was not logged, the binlog would be shorter.
 show master status;
 
@@ -84,7 +83,9 @@
 load data infile '../../std_data/rpl_loaddata.dat' into table t1;
 save_master_pos;
 connection slave;
-# The SQL slave thread should be stopped now.
+# The SQL slave thread should be stopped now. 
+# Exec_Master_Log_Pos should point to the start of Execute event
+# for last load data.
 wait_for_slave_to_stop;
 
 # CHANGE MASTER and see if error is cleared in SHOW SLAVE STATUS.
@@ -108,6 +109,7 @@
 save_master_pos;
 connection slave;
 # The SQL slave thread should be stopped now.
+# 
 wait_for_slave_to_stop;
 
 # RESET SLAVE and see if error is cleared in SHOW SLAVE STATUS.

--- 1.15/mysql-test/r/loaddata.result	Tue Sep 28 21:07:50 2004
+++ 1.16/mysql-test/r/loaddata.result	Tue Mar 15 11:30:31 2005
@@ -66,3 +66,49 @@
 3	row 3
 0	
 drop table t1;
+create table t1 (a int default 100, b int, c varchar(60));
+load data infile '../../std_data/rpl_loaddata.dat' into table t1 (a, @b) set b=@b+10, c=concat("b=",@b);
+select * from t1;
+a	b	c
+NULL	20	b=10
+NULL	25	b=15
+truncate table t1;
+load data infile '../../std_data/rpl_loaddata.dat' into table t1 (a, @b) set c= if(a is null,"oops",a);
+select * from t1;
+a	b	c
+NULL	NULL	oops
+NULL	NULL	oops
+truncate table t1;
+set @c:=123;
+load data infile '../../std_data/rpl_loaddata.dat' into table t1 (@a, b) set c= if(@a is null,@c,b);
+select * from t1;
+a	b	c
+100	10	123
+100	15	123
+load data infile '../../std_data/rpl_loaddata.dat' into table t1 (@a, @b);
+select * from t1;
+a	b	c
+100	10	123
+100	15	123
+100	NULL	NULL
+100	NULL	NULL
+select @a, @b;
+@a	@b
+NULL	15
+truncate table t1;
+load data infile '../../std_data/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (a, b) set c="Wow";
+select * from t1;
+a	b	c
+1	2	Wow
+3	4	Wow
+5	6	Wow
+truncate table t1;
+load data infile '../../std_data/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (a, b) set c=concat(a,"+",b,"+",@c,"+",b,"+",if(c is null,"NIL",c));
+select * from t1;
+a	b	c
+1	2	1+2+123+2+NIL
+3	4	3+4+123+4+NIL
+5	6	5+6+123+6+NIL
+load data infile '../../std_data/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (a, @b);
+ERROR HY000: Can't load value from file with fixed size rows to variable
+drop table t1;

--- 1.4/mysql-test/r/rpl_loaddatalocal.result	Sat Mar 20 13:31:15 2004
+++ 1.5/mysql-test/r/rpl_loaddatalocal.result	Tue Mar 15 11:30:31 2005
@@ -12,3 +12,20 @@
 a	count(*)
 1	10000
 drop table t1;
+create table t1(a int);
+insert into t1 values (1), (2), (2), (3);
+select * into outfile '../../var/master-data/rpl_loaddatalocal.select_outfile' from t1;
+drop table t1;
+create table t1(a int primary key);
+load data local infile './var/master-data/rpl_loaddatalocal.select_outfile' into table t1;
+select * from t1;
+a
+1
+2
+3
+select * from t1;
+a
+1
+2
+3
+drop table t1;

--- 1.7/mysql-test/t/loaddata.test	Sat Mar 20 13:29:41 2004
+++ 1.8/mysql-test/t/loaddata.test	Tue Mar 15 11:30:32 2005
@@ -31,3 +31,36 @@
 select * from t1;
 drop table t1;
 
+#
+# Let us test extended LOAD DATA features
+#
+create table t1 (a int default 100, b int, c varchar(60));
+# we can do something like this
+load data infile '../../std_data/rpl_loaddata.dat' into table t1 (a, @b) set b=@b+10, c=concat("b=",@b);
+select * from t1;
+truncate table t1;
+# we can use filled fields expressions 
+load data infile '../../std_data/rpl_loaddata.dat' into table t1 (a, @b) set c= if(a is null,"oops",a);
+select * from t1;
+truncate table t1;
+# we even can use variables in set clause, and missed columns will be set
+# with default values
+set @c:=123;
+load data infile '../../std_data/rpl_loaddata.dat' into table t1 (@a, b) set c= if(@a is null,@c,b);
+select * from t1;
+# let us test side-effect of such load
+load data infile '../../std_data/rpl_loaddata.dat' into table t1 (@a, @b);
+select * from t1;
+select @a, @b;
+truncate table t1;
+# now going to test fixed field-row file format
+load data infile '../../std_data/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (a, b) set c="Wow";
+select * from t1;
+truncate table t1;
+# this also should work
+load data infile '../../std_data/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (a, b) set c=concat(a,"+",b,"+",@c,"+",b,"+",if(c is null,"NIL",c));
+select * from t1;
+# and this should bark
+--error 1400 
+load data infile '../../std_data/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (a, @b);
+drop table t1;

--- 1.3/mysql-test/t/rpl_loaddatalocal.test	Sat Mar 20 13:29:41 2004
+++ 1.4/mysql-test/t/rpl_loaddatalocal.test	Tue Mar 15 11:30:32 2005
@@ -34,3 +34,27 @@
 save_master_pos;
 connection slave;
 sync_with_master;
+
+#
+# Now let us test how well we replicate LOAD DATA LOCAL in situation when
+# we met duplicates in tables to which we are adding rows.
+# (It supposed that LOAD DATA LOCAL ignores such errors)
+#
+connection master;
+create table t1(a int);
+insert into t1 values (1), (2), (2), (3);
+select * into outfile '../../var/master-data/rpl_loaddatalocal.select_outfile' from t1;
+drop table t1;
+create table t1(a int primary key);
+load data local infile './var/master-data/rpl_loaddatalocal.select_outfile' into table t1;
+system rm ./var/master-data/rpl_loaddatalocal.select_outfile ;
+select * from t1;
+save_master_pos;
+connection slave;
+sync_with_master;
+select * from t1;
+connection master;
+drop table t1;
+save_master_pos;
+connection slave;
+sync_with_master;

--- 1.27/mysql-test/r/mysqldump.result	Mon Jan  3 22:04:27 2005
+++ 1.28/mysql-test/r/mysqldump.result	Tue Mar 15 11:30:31 2005
@@ -1,4 +1,4 @@
-DROP TABLE IF EXISTS t1, `"t"1`, t1aa,t2aa;
+DROP TABLE IF EXISTS t1, `"t"1`, t1aa, t2, t2aa;
 drop database if exists mysqldump_test_db;
 CREATE TABLE t1(a int);
 INSERT INTO t1 VALUES (1), (2);

--- 1.26/mysql-test/t/mysqldump.test	Mon Jan  3 22:04:27 2005
+++ 1.27/mysql-test/t/mysqldump.test	Tue Mar 15 11:30:32 2005
@@ -1,5 +1,5 @@
 --disable_warnings
-DROP TABLE IF EXISTS t1, `"t"1`, t1aa,t2aa;
+DROP TABLE IF EXISTS t1, `"t"1`, t1aa, t2, t2aa;
 drop database if exists mysqldump_test_db;
 --enable_warnings
 

--- 1.24/mysql-test/r/rpl_replicate_do.result	Thu Jul 15 05:18:45 2004
+++ 1.25/mysql-test/r/rpl_replicate_do.result	Tue Mar 15 11:30:31 2005
@@ -28,4 +28,4 @@
 drop table if exists t1,t2,t11;
 show slave status;
 Slave_IO_State	Master_Host	Master_User	Master_Port	Connect_Retry	Master_Log_File	Read_Master_Log_Pos	Relay_Log_File	Relay_Log_Pos	Relay_Master_Log_File	Slave_IO_Running	Slave_SQL_Running	Replicate_Do_DB	Replicate_Ignore_DB	Replicate_Do_Table	Replicate_Ignore_Table	Replicate_Wild_Do_Table	Replicate_Wild_Ignore_Table	Last_Errno	Last_Error	Skip_Counter	Exec_Master_Log_Pos	Relay_Log_Space	Until_Condition	Until_Log_File	Until_Log_Pos	Master_SSL_Allowed	Master_SSL_CA_File	Master_SSL_CA_Path	Master_SSL_Cert	Master_SSL_Cipher	Master_SSL_Key	Seconds_Behind_Master
-#	127.0.0.1	root	MASTER_PORT	1	master-bin.000001	1554	#	#	master-bin.000001	Yes	Yes			test.t1				0		0	1554	#	None		0	No						#
+#	127.0.0.1	root	MASTER_PORT	1	master-bin.000001	1597	#	#	master-bin.000001	Yes	Yes			test.t1				0		0	1597	#	None		0	No						#

--- 1.40/mysql-test/r/rpl_log_pos.result	Mon Nov 22 22:54:41 2004
+++ 1.41/mysql-test/r/rpl_log_pos.result	Tue Mar 15 11:30:31 2005
@@ -6,10 +6,10 @@
 start slave;
 show master status;
 File	Position	Binlog_Do_DB	Binlog_Ignore_DB
-master-bin.000001	95		
+master-bin.000001	97		
 show slave status;
 Slave_IO_State	Master_Host	Master_User	Master_Port	Connect_Retry	Master_Log_File	Read_Master_Log_Pos	Relay_Log_File	Relay_Log_Pos	Relay_Master_Log_File	Slave_IO_Running	Slave_SQL_Running	Replicate_Do_DB	Replicate_Ignore_DB	Replicate_Do_Table	Replicate_Ignore_Table	Replicate_Wild_Do_Table	Replicate_Wild_Ignore_Table	Last_Errno	Last_Error	Skip_Counter	Exec_Master_Log_Pos	Relay_Log_Space	Until_Condition	Until_Log_File	Until_Log_Pos	Master_SSL_Allowed	Master_SSL_CA_File	Master_SSL_CA_Path	Master_SSL_Cert	Master_SSL_Cipher	Master_SSL_Key	Seconds_Behind_Master
-#	127.0.0.1	root	MASTER_PORT	1	master-bin.000001	95	#	#	master-bin.000001	Yes	Yes							0		0	95	#	None		0	No						#
+#	127.0.0.1	root	MASTER_PORT	1	master-bin.000001	97	#	#	master-bin.000001	Yes	Yes							0		0	97	#	None		0	No						#
 stop slave;
 change master to master_log_pos=73;
 start slave;
@@ -30,13 +30,13 @@
 #	127.0.0.1	root	MASTER_PORT	1	master-bin.000001	173	#	#	master-bin.000001	No	Yes							0		0	173	#	None		0	No						#
 show master status;
 File	Position	Binlog_Do_DB	Binlog_Ignore_DB
-master-bin.000001	95		
+master-bin.000001	97		
 create table if not exists t1 (n int);
 drop table if exists t1;
 create table t1 (n int);
 insert into t1 values (1),(2),(3);
 stop slave;
-change master to master_log_pos=95;
+change master to master_log_pos=97;
 start slave;
 select * from t1;
 n

--- 1.32/mysql-test/r/rpl000015.result	Mon Nov 22 22:54:41 2004
+++ 1.33/mysql-test/r/rpl000015.result	Tue Mar 15 11:30:31 2005
@@ -1,7 +1,7 @@
 reset master;
 show master status;
 File	Position	Binlog_Do_DB	Binlog_Ignore_DB
-master-bin.000001	95		
+master-bin.000001	97		
 reset slave;
 show slave status;
 Slave_IO_State	Master_Host	Master_User	Master_Port	Connect_Retry	Master_Log_File	Read_Master_Log_Pos	Relay_Log_File	Relay_Log_Pos	Relay_Master_Log_File	Slave_IO_Running	Slave_SQL_Running	Replicate_Do_DB	Replicate_Ignore_DB	Replicate_Do_Table	Replicate_Ignore_Table	Replicate_Wild_Do_Table	Replicate_Wild_Ignore_Table	Last_Errno	Last_Error	Skip_Counter	Exec_Master_Log_Pos	Relay_Log_Space	Until_Condition	Until_Log_File	Until_Log_Pos	Master_SSL_Allowed	Master_SSL_CA_File	Master_SSL_CA_Path	Master_SSL_Cert	Master_SSL_Cipher	Master_SSL_Key	Seconds_Behind_Master
@@ -17,7 +17,7 @@
 start slave;
 show slave status;
 Slave_IO_State	Master_Host	Master_User	Master_Port	Connect_Retry	Master_Log_File	Read_Master_Log_Pos	Relay_Log_File	Relay_Log_Pos	Relay_Master_Log_File	Slave_IO_Running	Slave_SQL_Running	Replicate_Do_DB	Replicate_Ignore_DB	Replicate_Do_Table	Replicate_Ignore_Table	Replicate_Wild_Do_Table	Replicate_Wild_Ignore_Table	Last_Errno	Last_Error	Skip_Counter	Exec_Master_Log_Pos	Relay_Log_Space	Until_Condition	Until_Log_File	Until_Log_Pos	Master_SSL_Allowed	Master_SSL_CA_File	Master_SSL_CA_Path	Master_SSL_Cert	Master_SSL_Cipher	Master_SSL_Key	Seconds_Behind_Master
-#	127.0.0.1	root	MASTER_PORT	7	master-bin.000001	95	#	#	master-bin.000001	Yes	Yes							0		0	95	#	None		0	No						#
+#	127.0.0.1	root	MASTER_PORT	7	master-bin.000001	97	#	#	master-bin.000001	Yes	Yes							0		0	97	#	None		0	No						#
 drop table if exists t1;
 create table t1 (n int);
 insert into t1 values (10),(45),(90);

--- 1.58/mysql-test/r/rpl_rotate_logs.result	Mon Nov 22 22:54:41 2004
+++ 1.59/mysql-test/r/rpl_rotate_logs.result	Tue Mar 15 11:30:32 2005
@@ -16,7 +16,7 @@
 insert into t1 values('Could not break slave'),('Tried hard');
 show slave status;
 Slave_IO_State	Master_Host	Master_User	Master_Port	Connect_Retry	Master_Log_File	Read_Master_Log_Pos	Relay_Log_File	Relay_Log_Pos	Relay_Master_Log_File	Slave_IO_Running	Slave_SQL_Running	Replicate_Do_DB	Replicate_Ignore_DB	Replicate_Do_Table	Replicate_Ignore_Table	Replicate_Wild_Do_Table	Replicate_Wild_Ignore_Table	Last_Errno	Last_Error	Skip_Counter	Exec_Master_Log_Pos	Relay_Log_Space	Until_Condition	Until_Log_File	Until_Log_Pos	Master_SSL_Allowed	Master_SSL_CA_File	Master_SSL_CA_Path	Master_SSL_Cert	Master_SSL_Cipher	Master_SSL_Key	Seconds_Behind_Master
-#	127.0.0.1	root	MASTER_PORT	60	master-bin.000001	521	#	#	master-bin.000001	Yes	Yes							0		0	521	#	None		0	No						#
+#	127.0.0.1	root	MASTER_PORT	60	master-bin.000001	523	#	#	master-bin.000001	Yes	Yes							0		0	523	#	None		0	No						#
 select * from t1;
 s
 Could not break slave
@@ -57,7 +57,7 @@
 insert into t2 values (65);
 show slave status;
 Slave_IO_State	Master_Host	Master_User	Master_Port	Connect_Retry	Master_Log_File	Read_Master_Log_Pos	Relay_Log_File	Relay_Log_Pos	Relay_Master_Log_File	Slave_IO_Running	Slave_SQL_Running	Replicate_Do_DB	Replicate_Ignore_DB	Replicate_Do_Table	Replicate_Ignore_Table	Replicate_Wild_Do_Table	Replicate_Wild_Ignore_Table	Last_Errno	Last_Error	Skip_Counter	Exec_Master_Log_Pos	Relay_Log_Space	Until_Condition	Until_Log_File	Until_Log_Pos	Master_SSL_Allowed	Master_SSL_CA_File	Master_SSL_CA_Path	Master_SSL_Cert	Master_SSL_Cipher	Master_SSL_Key	Seconds_Behind_Master
-#	127.0.0.1	root	MASTER_PORT	60	master-bin.000003	469	#	#	master-bin.000003	Yes	Yes							0		0	469	#	None		0	No						#
+#	127.0.0.1	root	MASTER_PORT	60	master-bin.000003	471	#	#	master-bin.000003	Yes	Yes							0		0	471	#	None		0	No						#
 select * from t2;
 m
 34
@@ -79,13 +79,13 @@
 master-bin.000005
 show master status;
 File	Position	Binlog_Do_DB	Binlog_Ignore_DB
-master-bin.000005	1387		
+master-bin.000005	1389		
 select * from t4;
 a
 testing temporary tables part 2
 show slave status;
 Slave_IO_State	Master_Host	Master_User	Master_Port	Connect_Retry	Master_Log_File	Read_Master_Log_Pos	Relay_Log_File	Relay_Log_Pos	Relay_Master_Log_File	Slave_IO_Running	Slave_SQL_Running	Replicate_Do_DB	Replicate_Ignore_DB	Replicate_Do_Table	Replicate_Ignore_Table	Replicate_Wild_Do_Table	Replicate_Wild_Ignore_Table	Last_Errno	Last_Error	Skip_Counter	Exec_Master_Log_Pos	Relay_Log_Space	Until_Condition	Until_Log_File	Until_Log_Pos	Master_SSL_Allowed	Master_SSL_CA_File	Master_SSL_CA_Path	Master_SSL_Cert	Master_SSL_Cipher	Master_SSL_Key	Seconds_Behind_Master
-#	127.0.0.1	root	MASTER_PORT	60	master-bin.000005	1387	#	#	master-bin.000005	Yes	Yes							0		0	1387	#	None		0	No						#
+#	127.0.0.1	root	MASTER_PORT	60	master-bin.000005	1389	#	#	master-bin.000005	Yes	Yes							0		0	1389	#	None		0	No						#
 lock tables t3 read;
 select count(*) from t3 where n >= 4;
 count(*)

--- 1.52/mysql-test/r/rpl_log.result	Wed Apr  7 17:12:37 2004
+++ 1.53/mysql-test/r/rpl_log.result	Tue Mar 15 11:30:31 2005
@@ -19,25 +19,25 @@
 drop table t1;
 show binlog events;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
-master-bin.000001	4	Format_desc	1	95	Server ver: VERSION, Binlog ver: 4
-master-bin.000001	95	Query	1	210	use `test`; create table t1(n int not null auto_increment primary key)
-master-bin.000001	210	Intvar	1	238	INSERT_ID=1
-master-bin.000001	238	Query	1	323	use `test`; insert into t1 values (NULL)
-master-bin.000001	323	Query	1	393	use `test`; drop table t1
-master-bin.000001	393	Query	1	490	use `test`; create table t1 (word char(20) not null)
-master-bin.000001	490	Create_file	1	1160	db=test;table=t1;file_id=1;block_len=581
-master-bin.000001	1160	Exec_load	1	1183	;file_id=1
-master-bin.000001	1183	Query	1	1253	use `test`; drop table t1
-show binlog events from 95 limit 1;
-Log_name	Pos	Event_type	Server_id	End_log_pos	Info
-master-bin.000001	95	Query	1	210	use `test`; create table t1(n int not null auto_increment primary key)
-show binlog events from 95 limit 2;
-Log_name	Pos	Event_type	Server_id	End_log_pos	Info
-master-bin.000001	95	Query	1	210	use `test`; create table t1(n int not null auto_increment primary key)
-master-bin.000001	210	Intvar	1	238	INSERT_ID=1
-show binlog events from 95 limit 2,1;
+master-bin.000001	4	Format_desc	1	97	Server ver: VERSION, Binlog ver: 4
+master-bin.000001	97	Query	1	212	use `test`; create table t1(n int not null auto_increment primary key)
+master-bin.000001	212	Intvar	1	240	INSERT_ID=1
+master-bin.000001	240	Query	1	325	use `test`; insert into t1 values (NULL)
+master-bin.000001	325	Query	1	395	use `test`; drop table t1
+master-bin.000001	395	Query	1	492	use `test`; create table t1 (word char(20) not null)
+master-bin.000001	492	Begin_load_query	1	1096	;file_id=1;block_len=581
+master-bin.000001	1096	Execute_load_query	1	1238	use `test`; load data infile '../../std_data/words.dat' into table t1 ignore 1 lines ;file_id=1
+master-bin.000001	1238	Query	1	1308	use `test`; drop table t1
+show binlog events from 97 limit 1;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	97	Query	1	212	use `test`; create table t1(n int not null auto_increment primary key)
+show binlog events from 97 limit 2;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	97	Query	1	212	use `test`; create table t1(n int not null auto_increment primary key)
+master-bin.000001	212	Intvar	1	240	INSERT_ID=1
+show binlog events from 97 limit 2,1;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
-master-bin.000001	238	Query	1	323	use `test`; insert into t1 values (NULL)
+master-bin.000001	240	Query	1	325	use `test`; insert into t1 values (NULL)
 flush logs;
 create table t5 (a int);
 drop table t5;
@@ -49,24 +49,24 @@
 drop table t1;
 show binlog events;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
-master-bin.000001	4	Format_desc	1	95	Server ver: VERSION, Binlog ver: 4
-master-bin.000001	95	Query	1	210	use `test`; create table t1(n int not null auto_increment primary key)
-master-bin.000001	210	Intvar	1	238	INSERT_ID=1
-master-bin.000001	238	Query	1	323	use `test`; insert into t1 values (NULL)
-master-bin.000001	323	Query	1	393	use `test`; drop table t1
-master-bin.000001	393	Query	1	490	use `test`; create table t1 (word char(20) not null)
-master-bin.000001	490	Create_file	1	1160	db=test;table=t1;file_id=1;block_len=581
-master-bin.000001	1160	Exec_load	1	1183	;file_id=1
-master-bin.000001	1183	Query	1	1253	use `test`; drop table t1
-master-bin.000001	1253	Rotate	1	1297	master-bin.000002;pos=4
+master-bin.000001	4	Format_desc	1	97	Server ver: VERSION, Binlog ver: 4
+master-bin.000001	97	Query	1	212	use `test`; create table t1(n int not null auto_increment primary key)
+master-bin.000001	212	Intvar	1	240	INSERT_ID=1
+master-bin.000001	240	Query	1	325	use `test`; insert into t1 values (NULL)
+master-bin.000001	325	Query	1	395	use `test`; drop table t1
+master-bin.000001	395	Query	1	492	use `test`; create table t1 (word char(20) not null)
+master-bin.000001	492	Begin_load_query	1	1096	;file_id=1;block_len=581
+master-bin.000001	1096	Execute_load_query	1	1238	use `test`; load data infile '../../std_data/words.dat' into table t1 ignore 1 lines ;file_id=1
+master-bin.000001	1238	Query	1	1308	use `test`; drop table t1
+master-bin.000001	1308	Rotate	1	1352	master-bin.000002;pos=4
 show binlog events in 'master-bin.000002';
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
-master-bin.000002	4	Format_desc	1	95	Server ver: VERSION, Binlog ver: 4
-master-bin.000002	95	Query	1	175	use `test`; create table t5 (a int)
-master-bin.000002	175	Query	1	245	use `test`; drop table t5
-master-bin.000002	245	Query	1	325	use `test`; create table t1 (n int)
-master-bin.000002	325	Query	1	407	use `test`; insert into t1 values (1)
-master-bin.000002	407	Query	1	477	use `test`; drop table t1
+master-bin.000002	4	Format_desc	1	97	Server ver: VERSION, Binlog ver: 4
+master-bin.000002	97	Query	1	177	use `test`; create table t5 (a int)
+master-bin.000002	177	Query	1	247	use `test`; drop table t5
+master-bin.000002	247	Query	1	327	use `test`; create table t1 (n int)
+master-bin.000002	327	Query	1	409	use `test`; insert into t1 values (1)
+master-bin.000002	409	Query	1	479	use `test`; drop table t1
 show binary logs;
 Log_name
 master-bin.000001
@@ -78,26 +78,26 @@
 slave-bin.000002
 show binlog events in 'slave-bin.000001' from 4;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
-slave-bin.000001	4	Format_desc	2	95	Server ver: VERSION, Binlog ver: 4
-slave-bin.000001	95	Query	1	210	use `test`; create table t1(n int not null auto_increment primary key)
-slave-bin.000001	210	Intvar	1	238	INSERT_ID=1
-slave-bin.000001	238	Query	1	323	use `test`; insert into t1 values (NULL)
-slave-bin.000001	323	Query	1	393	use `test`; drop table t1
-slave-bin.000001	393	Query	1	490	use `test`; create table t1 (word char(20) not null)
-slave-bin.000001	490	Create_file	1	1169	db=test;table=t1;file_id=1;block_len=581
-slave-bin.000001	1169	Exec_load	1	1192	;file_id=1
-slave-bin.000001	1192	Query	1	1262	use `test`; drop table t1
-slave-bin.000001	1262	Query	1	1342	use `test`; create table t5 (a int)
-slave-bin.000001	1342	Query	1	1412	use `test`; drop table t5
-slave-bin.000001	1412	Rotate	2	1455	slave-bin.000002;pos=4
+slave-bin.000001	4	Format_desc	2	97	Server ver: VERSION, Binlog ver: 4
+slave-bin.000001	97	Query	1	212	use `test`; create table t1(n int not null auto_increment primary key)
+slave-bin.000001	212	Intvar	1	240	INSERT_ID=1
+slave-bin.000001	240	Query	1	325	use `test`; insert into t1 values (NULL)
+slave-bin.000001	325	Query	1	395	use `test`; drop table t1
+slave-bin.000001	395	Query	1	492	use `test`; create table t1 (word char(20) not null)
+slave-bin.000001	492	Begin_load_query	1	1096	;file_id=1;block_len=581
+slave-bin.000001	1096	Execute_load_query	1	1247	use `test`; load data INFILE '../../var/tmp/SQL_LOAD-2-1-1.data' INTO table t1 ignore 1 lines ;file_id=1
+slave-bin.000001	1247	Query	1	1317	use `test`; drop table t1
+slave-bin.000001	1317	Query	1	1397	use `test`; create table t5 (a int)
+slave-bin.000001	1397	Query	1	1467	use `test`; drop table t5
+slave-bin.000001	1467	Rotate	2	1510	slave-bin.000002;pos=4
 show binlog events in 'slave-bin.000002' from 4;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
-slave-bin.000002	4	Format_desc	2	95	Server ver: VERSION, Binlog ver: 4
-slave-bin.000002	95	Query	1	175	use `test`; create table t1 (n int)
-slave-bin.000002	175	Query	1	257	use `test`; insert into t1 values (1)
-slave-bin.000002	257	Query	1	327	use `test`; drop table t1
+slave-bin.000002	4	Format_desc	2	97	Server ver: VERSION, Binlog ver: 4
+slave-bin.000002	97	Query	1	177	use `test`; create table t1 (n int)
+slave-bin.000002	177	Query	1	259	use `test`; insert into t1 values (1)
+slave-bin.000002	259	Query	1	329	use `test`; drop table t1
 show slave status;
 Slave_IO_State	Master_Host	Master_User	Master_Port	Connect_Retry	Master_Log_File	Read_Master_Log_Pos	Relay_Log_File	Relay_Log_Pos	Relay_Master_Log_File	Slave_IO_Running	Slave_SQL_Running	Replicate_Do_DB	Replicate_Ignore_DB	Replicate_Do_Table	Replicate_Ignore_Table	Replicate_Wild_Do_Table	Replicate_Wild_Ignore_Table	Last_Errno	Last_Error	Skip_Counter	Exec_Master_Log_Pos	Relay_Log_Space	Until_Condition	Until_Log_File	Until_Log_Pos	Master_SSL_Allowed	Master_SSL_CA_File	Master_SSL_CA_Path	Master_SSL_Cert	Master_SSL_Cipher	Master_SSL_Key	Seconds_Behind_Master
-#	127.0.0.1	root	MASTER_PORT	1	master-bin.000002	477	#	#	master-bin.000002	Yes	Yes							0		0	477	#	None		0	No						#
+#	127.0.0.1	root	MASTER_PORT	1	master-bin.000002	479	#	#	master-bin.000002	Yes	Yes							0		0	479	#	None		0	No						#
 show binlog events in 'slave-bin.000005' from 4;
 ERROR HY000: Error when executing command SHOW BINLOG EVENTS: Could not find target log

--- 1.23/mysql-test/r/user_var.result	Mon Jan 17 12:57:54 2005
+++ 1.24/mysql-test/r/user_var.result	Tue Mar 15 11:30:32 2005
@@ -174,13 +174,13 @@
 set @var1= "';aaa";
 SET @var2=char(ascii('a'));
 insert into t1 values (@var1),(@var2);
-show binlog events from 95;
+show binlog events from 97;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
-master-bin.000001	95	User var	1	136	@`a b`=_latin1 0x68656C6C6F COLLATE latin1_swedish_ci
-master-bin.000001	136	Query	1	222	use `test`; INSERT INTO t1 VALUES(@`a b`)
-master-bin.000001	222	User var	1	264	@`var1`=_latin1 0x273B616161 COLLATE latin1_swedish_ci
-master-bin.000001	264	User var	1	302	@`var2`=_latin1 0x61 COLLATE latin1_swedish_ci
-master-bin.000001	302	Query	1	396	use `test`; insert into t1 values (@var1),(@var2)
+master-bin.000001	97	User var	1	138	@`a b`=_latin1 0x68656C6C6F COLLATE latin1_swedish_ci
+master-bin.000001	138	Query	1	224	use `test`; INSERT INTO t1 VALUES(@`a b`)
+master-bin.000001	224	User var	1	266	@`var1`=_latin1 0x273B616161 COLLATE latin1_swedish_ci
+master-bin.000001	266	User var	1	304	@`var2`=_latin1 0x61 COLLATE latin1_swedish_ci
+master-bin.000001	304	Query	1	398	use `test`; insert into t1 values (@var1),(@var2)
 /*!40019 SET @@session.max_insert_delayed_threads=0*/;
 SET @`a b`:=_latin1 0x68656C6C6F COLLATE `latin1_swedish_ci`;
 use test;

--- 1.31/mysql-test/t/rpl_log_pos.test	Mon Nov 22 22:54:42 2004
+++ 1.32/mysql-test/t/rpl_log_pos.test	Tue Mar 15 11:30:32 2005
@@ -38,7 +38,7 @@
 save_master_pos;
 connection slave;
 stop slave;
-change master to master_log_pos=95;
+change master to master_log_pos=97;
 start slave;
 sync_with_master;
 select * from t1;

--- 1.23/mysql-test/t/rpl_log.test	Wed May 26 18:10:51 2004
+++ 1.24/mysql-test/t/rpl_log.test	Tue Mar 15 11:30:32 2005
@@ -38,9 +38,9 @@
 drop table t1;
 --replace_result $VERSION VERSION
 show binlog events;
-show binlog events from 95 limit 1;
-show binlog events from 95 limit 2;
-show binlog events from 95 limit 2,1;
+show binlog events from 97 limit 1;
+show binlog events from 97 limit 2;
+show binlog events from 97 limit 2,1;
 flush logs;
 
 # We need an extra update before doing save_master_pos.

--- 1.18/mysql-test/t/user_var.test	Sun Jan 16 23:07:22 2005
+++ 1.19/mysql-test/t/user_var.test	Tue Mar 15 11:30:32 2005
@@ -110,7 +110,7 @@
 set @var1= "';aaa";
 SET @var2=char(ascii('a'));
 insert into t1 values (@var1),(@var2);
-show binlog events from 95;
+show binlog events from 97;
 # more important than SHOW BINLOG EVENTS, mysqlbinlog (where we
 # absolutely need variables names to be quoted and strings to be
 # escaped).

--- 1.125/sql/sql_repl.cc	Mon Jan  3 23:14:11 2005
+++ 1.126/sql/sql_repl.cc	Tue Mar 15 11:30:33 2005
@@ -1524,17 +1524,16 @@
   lf_info->last_pos_in_file = file->pos_in_file;
   if (lf_info->wrote_create_file)
   {
-    Append_block_log_event a(lf_info->thd, lf_info->db, buffer, block_len,
-			     lf_info->log_delayed);
+    Append_block_log_event a(lf_info->thd, lf_info->thd->db, buffer,
+                             block_len, lf_info->log_delayed);
     mysql_bin_log.write(&a);
   }
   else
   {
-    Create_file_log_event c(lf_info->thd,lf_info->ex,lf_info->db,
-			    lf_info->table_name, *lf_info->fields,
-			    lf_info->handle_dup, lf_info->ignore, buffer,
-			    block_len, lf_info->log_delayed);
-    mysql_bin_log.write(&c);
+    Begin_load_query_log_event b(lf_info->thd, lf_info->thd->db,
+                                 buffer, block_len,
+                                 lf_info->log_delayed);
+    mysql_bin_log.write(&b);
     lf_info->wrote_create_file = 1;
     DBUG_SYNC_POINT("debug_lock.created_file_event",10);
   }

--- 1.35/sql/sql_repl.h	Mon Jan  3 23:14:11 2005
+++ 1.36/sql/sql_repl.h	Tue Mar 15 11:30:33 2005
@@ -62,12 +62,7 @@
 {
   THD* thd;
   my_off_t last_pos_in_file;
-  sql_exchange* ex;
-  List <Item> *fields;
-  enum enum_duplicates handle_dup;
-  char* db;
-  char* table_name;
-  bool wrote_create_file, log_delayed, ignore;
+  bool wrote_create_file, log_delayed;
 } LOAD_FILE_INFO;
 
 int log_loaded_block(IO_CACHE* file);

--- 1.13/mysql-test/r/rpl_temporary.result	Thu Jul 15 05:18:45 2004
+++ 1.14/mysql-test/r/rpl_temporary.result	Tue Mar 15 11:30:32 2005
@@ -38,19 +38,19 @@
 7
 show binlog events;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
-master-bin.000001	4	Format_desc	1	95	Server ver: VERSION, Binlog ver: 4
-master-bin.000001	95	Query	1	178	use `test`; drop table if exists t1,t2
-master-bin.000001	178	Query	1	257	use `test`; create table t1(f int)
-master-bin.000001	257	Query	1	336	use `test`; create table t2(f int)
-master-bin.000001	336	Query	1	455	use `test`; insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10)
-master-bin.000001	455	Query	1	544	use `test`; create temporary table t3(f int)
-master-bin.000001	544	Query	1	642	use `test`; insert into t3 select * from t1 where f<6
-master-bin.000001	642	Query	1	731	use `test`; create temporary table t3(f int)
-master-bin.000001	731	Query	1	826	use `test`; insert into t2 select count(*) from t3
-master-bin.000001	826	Query	1	925	use `test`; insert into t3 select * from t1 where f>=4
-master-bin.000001	925	Query	1	1005	use `test`; drop temporary table t3
-master-bin.000001	1005	Query	1	1100	use `test`; insert into t2 select count(*) from t3
-master-bin.000001	1100	Query	1	1180	use `test`; drop temporary table t3
+master-bin.000001	4	Format_desc	1	97	Server ver: VERSION, Binlog ver: 4
+master-bin.000001	97	Query	1	180	use `test`; drop table if exists t1,t2
+master-bin.000001	180	Query	1	259	use `test`; create table t1(f int)
+master-bin.000001	259	Query	1	338	use `test`; create table t2(f int)
+master-bin.000001	338	Query	1	457	use `test`; insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10)
+master-bin.000001	457	Query	1	546	use `test`; create temporary table t3(f int)
+master-bin.000001	546	Query	1	644	use `test`; insert into t3 select * from t1 where f<6
+master-bin.000001	644	Query	1	733	use `test`; create temporary table t3(f int)
+master-bin.000001	733	Query	1	828	use `test`; insert into t2 select count(*) from t3
+master-bin.000001	828	Query	1	927	use `test`; insert into t3 select * from t1 where f>=4
+master-bin.000001	927	Query	1	1007	use `test`; drop temporary table t3
+master-bin.000001	1007	Query	1	1102	use `test`; insert into t2 select count(*) from t3
+master-bin.000001	1102	Query	1	1182	use `test`; drop temporary table t3
 drop table t1, t2;
 use test;
 SET TIMESTAMP=1040323920;
Thread
bk commit into 5.0 tree (dlenev:1.1814)dlenev15 Mar