List:Internals« Previous MessageNext Message »
From:sasha Date:November 18 2001 12:23am
Subject:bk commit into 4.0 tree
View as plain text  
Below is the list of changes that have just been committed into a
4.0 repository of sasha. When sasha does a push, they will be propogated 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@stripped, 2001-11-17 17:23:46-07:00, sasha@stripped
  use env vars for socket/port in connect in mysqltest
  --local-master option in mysql-test-run
  do not log CREATE TABLE when doing table dump
  fix replication to slave off 3.23 master

  sql/log_event.h
    1.58 01/11/17 17:23:45 sasha@stripped +2 -1
    fixes to slave off 3.23 master

  sql/slave.cc
    1.138 01/11/17 17:23:45 sasha@stripped +7 -1
    do not log CREATE TABLE when doing table dump

  client/mysqltest.c
    1.69 01/11/17 17:23:44 sasha@stripped +25 -4
    fix to be able to use env vars for socket and port in connect

  mysql-test/include/master-slave.inc
    1.7 01/11/17 17:23:44 sasha@stripped +4 -4
    connect to port specified in environment

  mysql-test/mysql-test-run.sh
    1.123 01/11/17 17:23:44 sasha@stripped +8 -1
    added --local-master option - will assume master is on port 3306 on localhost

  sql/log_event.cc
    1.65 01/11/17 17:23:44 sasha@stripped +60 -34
    fixes to slave off 3.23 master

# 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:	sasha
# Host:	mysql.sashanet.com
# Root:	/home/sasha/src/bk/mysql-4.0

--- 1.122/mysql-test/mysql-test-run.sh	Sat Nov 10 22:24:10 2001
+++ 1.123/mysql-test/mysql-test-run.sh	Sat Nov 17 17:23:44 2001
@@ -151,6 +151,11 @@
     --verbose-manager)  MANAGER_QUIET_OPT="" ;;
     --local)   USE_RUNNING_SERVER="" ;;
     --tmpdir=*) MYSQL_TMP_DIR=`$ECHO "$1" | $SED -e "s;--tmpdir=;;"` ;;
+    --local-master)
+      MASTER_MYPORT=3306;
+      EXTRA_MYSQL_TEST_OPT="$EXTRA_MYSQL_TEST_OPT --host=127.0.0.1 \
+      --port=$MYSQL_MYPORT"
+      LOCAL_MASTER=1 ;;
     --master_port=*) MASTER_MYPORT=`$ECHO "$1" | $SED -e "s;--master_port=;;"` ;;
     --slave_port=*) SLAVE_MYPORT=`$ECHO "$1" | $SED -e "s;--slave_port=;;"` ;;
     --manager-port=*) MYSQL_MANAGER_PORT=`$ECHO "$1" | $SED -e "s;--manager_port=;;"` ;;
@@ -639,7 +644,9 @@
 
 start_master()
 {
-    [ x$MASTER_RUNNING = 1 ] && return
+    if [ x$MASTER_RUNNING = x1 ] || [ x$LOCAL_MASTER = x1 ] ; then
+      return
+    fi
     # Remove old berkeley db log files that can confuse the server
     $RM -f $MASTER_MYDDIR/log.*
     # Remove stale binary logs

--- 1.64/sql/log_event.cc	Sat Nov 10 22:24:10 2001
+++ 1.65/sql/log_event.cc	Sat Nov 17 17:23:44 2001
@@ -467,8 +467,10 @@
 #endif  
 {
   char head[LOG_EVENT_HEADER_LEN];
+  uint header_size = old_format ? OLD_HEADER_LEN :
+    LOG_EVENT_HEADER_LEN;
   LOCK_MUTEX;
-  if (my_b_read(file, (byte *) head, sizeof(head)))
+  if (my_b_read(file, (byte *) head, header_size ))
   {
     UNLOCK_MUTEX;
     return 0;
@@ -485,7 +487,7 @@
     goto err;
   }
 
-  if (data_len < LOG_EVENT_HEADER_LEN)
+  if (data_len < header_size)
   {
     error = "Event too small";
     goto err;
@@ -498,9 +500,9 @@
     goto err;
   }
   buf[data_len] = 0;
-  memcpy(buf, head, LOG_EVENT_HEADER_LEN);
-  if(my_b_read(file, (byte*) buf + LOG_EVENT_HEADER_LEN,
-	       data_len - LOG_EVENT_HEADER_LEN))
+  memcpy(buf, head, header_size);
+  if(my_b_read(file, (byte*) buf + header_size,
+	       data_len - header_size))
   {
     error = "read error";
     goto err;
@@ -653,11 +655,11 @@
 Start_log_event::Start_log_event(const char* buf,
 				 bool old_format) :Log_event(buf, old_format)
 {
-  binlog_version = uint2korr(buf + LOG_EVENT_HEADER_LEN +
-			     ST_BINLOG_VER_OFFSET);
-  memcpy(server_version, buf + ST_SERVER_VER_OFFSET + LOG_EVENT_HEADER_LEN,
+  buf += (old_format) ? OLD_HEADER_LEN : LOG_EVENT_HEADER_LEN;
+  binlog_version = uint2korr(buf+ST_BINLOG_VER_OFFSET);
+  memcpy(server_version, buf+ST_SERVER_VER_OFFSET,
 	 ST_SERVER_VER_LEN);
-  created = uint4korr(buf + ST_CREATED_OFFSET + LOG_EVENT_HEADER_LEN);
+  created = uint4korr(buf+ST_CREATED_OFFSET);
 }
 
 int Start_log_event::write_data(IO_CACHE* file)
@@ -675,13 +677,24 @@
 {
   // the caller will ensure that event_len is what we have at
   // EVENT_LEN_OFFSET
-  if(event_len < ROTATE_EVENT_OVERHEAD)
+  int header_size = (old_format) ? OLD_HEADER_LEN : LOG_EVENT_HEADER_LEN;
+  uint ident_offset;
+  if(event_len < header_size)
     return;
-
-  pos = uint8korr(buf + R_POS_OFFSET + LOG_EVENT_HEADER_LEN);
-  ident_len = (uchar)(event_len - ROTATE_EVENT_OVERHEAD);
-  if (!(new_log_ident = (char*) my_memdup((byte*) buf + R_IDENT_OFFSET
-					  + LOG_EVENT_HEADER_LEN,
+  buf += header_size;
+  if (old_format)
+  {
+    ident_len = (uchar)(event_len - OLD_HEADER_LEN);
+    pos = 4;
+    ident_offset = 0;
+  }
+  else
+  {
+    ident_len = (uchar)(event_len - ROTATE_EVENT_OVERHEAD);
+    pos = uint8korr(buf + R_POS_OFFSET);
+    ident_offset = ROTATE_HEADER_LEN;
+  }
+  if (!(new_log_ident = (char*) my_memdup((byte*) buf + ident_offset,
 					  (uint) ident_len, MYF(MY_WME))))
     return;
 
@@ -717,22 +730,32 @@
 				 bool old_format):
   Log_event(buf, old_format),data_buf(0), query(NULL), db(NULL)
 {
-  if ((uint)event_len < QUERY_EVENT_OVERHEAD)
-    return;				
   ulong data_len;
-  data_len = event_len - QUERY_EVENT_OVERHEAD;
- 
+  if (old_format)
+  {
+    if ((uint)event_len < OLD_HEADER_LEN + QUERY_HEADER_LEN)
+      return;				
+    data_len = event_len - (QUERY_HEADER_LEN + OLD_HEADER_LEN);
+    buf += OLD_HEADER_LEN;
+  }
+  else
+  {
+    if ((uint)event_len < QUERY_EVENT_OVERHEAD)
+      return;				
+    data_len = event_len - QUERY_EVENT_OVERHEAD;
+    buf += LOG_EVENT_HEADER_LEN;
+  }
 
-  exec_time = uint4korr(buf + LOG_EVENT_HEADER_LEN + Q_EXEC_TIME_OFFSET);
-  error_code = uint2korr(buf + LOG_EVENT_HEADER_LEN + Q_ERR_CODE_OFFSET);
+  exec_time = uint4korr(buf + Q_EXEC_TIME_OFFSET);
+  error_code = uint2korr(buf + Q_ERR_CODE_OFFSET);
 
   if (!(data_buf = (char*) my_malloc(data_len + 1, MYF(MY_WME))))
     return;
 
-  memcpy(data_buf, buf + LOG_EVENT_HEADER_LEN + Q_DATA_OFFSET, data_len);
-  thread_id = uint4korr(buf + LOG_EVENT_HEADER_LEN + Q_THREAD_ID_OFFSET);
+  memcpy(data_buf, buf + Q_DATA_OFFSET, data_len);
+  thread_id = uint4korr(buf + Q_THREAD_ID_OFFSET);
   db = data_buf;
-  db_len = (uint)buf[LOG_EVENT_HEADER_LEN + Q_DB_LEN_OFFSET];
+  db_len = (uint)buf[Q_DB_LEN_OFFSET];
   query=data_buf + db_len + 1;
   q_len = data_len - 1 - db_len;
   *((char*)query+q_len) = 0;
@@ -788,7 +811,7 @@
 Intvar_log_event::Intvar_log_event(const char* buf, bool old_format):
   Log_event(buf, old_format)
 {
-  buf += LOG_EVENT_HEADER_LEN;
+  buf += (old_format) ? OLD_HEADER_LEN : LOG_EVENT_HEADER_LEN;
   type = buf[I_TYPE_OFFSET];
   val = uint8korr(buf+I_VAL_OFFSET);
 }
@@ -1031,19 +1054,22 @@
 {
   if (!event_len) // derived class, will call copy_log_event() itself
     return;
-  copy_log_event(buf, event_len);
+  copy_log_event(buf, event_len, old_format);
 }
 
-int Load_log_event::copy_log_event(const char *buf, ulong event_len)
+int Load_log_event::copy_log_event(const char *buf, ulong event_len,
+				   bool old_format)
 {
   uint data_len;
   char* buf_end = (char*)buf + event_len;
-  thread_id = uint4korr(buf + L_THREAD_ID_OFFSET + LOG_EVENT_HEADER_LEN);
-  exec_time = uint4korr(buf + L_EXEC_TIME_OFFSET + LOG_EVENT_HEADER_LEN);
-  skip_lines = uint4korr(buf + L_SKIP_LINES_OFFSET + LOG_EVENT_HEADER_LEN);
-  table_name_len = (uint)buf[L_TBL_LEN_OFFSET + LOG_EVENT_HEADER_LEN];
-  db_len = (uint)buf[L_DB_LEN_OFFSET + LOG_EVENT_HEADER_LEN];
-  num_fields = uint4korr(buf + L_NUM_FIELDS_OFFSET + LOG_EVENT_HEADER_LEN);
+  const char* data_head = buf + ((old_format) ?
+			   OLD_HEADER_LEN : LOG_EVENT_HEADER_LEN);
+  thread_id = uint4korr(data_head + L_THREAD_ID_OFFSET);
+  exec_time = uint4korr(data_head + L_EXEC_TIME_OFFSET);
+  skip_lines = uint4korr(data_head + L_SKIP_LINES_OFFSET);
+  table_name_len = (uint)data_head[L_TBL_LEN_OFFSET];
+  db_len = (uint)data_head[L_DB_LEN_OFFSET];
+  num_fields = uint4korr(data_head + L_NUM_FIELDS_OFFSET);
 	  
   int body_offset = get_data_body_offset();
   if ((int) event_len < body_offset)
@@ -1315,7 +1341,7 @@
   Load_log_event(buf,0,0),fake_base(0),block(0)
 {
   int block_offset;
-  if (copy_log_event(buf,len))
+  if (copy_log_event(buf,len,0))
     return;
   file_id = uint4korr(buf + LOG_EVENT_HEADER_LEN +
 		      + LOAD_HEADER_LEN + CF_FILE_ID_OFFSET);

--- 1.57/sql/log_event.h	Sat Nov 10 22:24:10 2001
+++ 1.58/sql/log_event.h	Sat Nov 17 17:23:45 2001
@@ -105,6 +105,7 @@
 
 /* event-specific post-header sizes */
 #define LOG_EVENT_HEADER_LEN 19
+#define OLD_HEADER_LEN       13
 #define QUERY_HEADER_LEN     (4 + 4 + 1 + 2)
 #define LOAD_HEADER_LEN      (4 + 4 + 4 + 1 +1 + 4)
 #define START_HEADER_LEN     (2 + ST_SERVER_VER_LEN + 4)
@@ -378,7 +379,7 @@
 class Load_log_event: public Log_event
 {
 protected:
-  int copy_log_event(const char *buf, ulong event_len);
+  int copy_log_event(const char *buf, ulong event_len, bool old_format);
 
 public:
   ulong thread_id;

--- 1.137/sql/slave.cc	Sat Nov 10 22:24:10 2001
+++ 1.138/sql/slave.cc	Sat Nov 17 17:23:45 2001
@@ -393,6 +393,7 @@
   TABLE_LIST tables;
   int error= 1;
   handler *file;
+  uint save_options;
   
   if (packet_len == packet_error)
   {
@@ -418,12 +419,17 @@
   thd->current_tablenr = 0;
   thd->query_error = 0;
   thd->net.no_send_ok = 1;
+  
+  /* we do not want to log create table statement */
+  save_options = thd->options;
+  thd->options &= ~OPTION_BIN_LOG;
   thd->proc_info = "Creating table from master dump";
   // save old db in case we are creating in a different database
   char* save_db = thd->db;
   thd->db = (char*)db;
   mysql_parse(thd, thd->query, packet_len); // run create table
   thd->db = save_db;		// leave things the way the were before
+  thd->options = save_options;
   
   if (thd->query_error)
     goto err;			// mysql_parse took care of the error send
@@ -1000,7 +1006,7 @@
     int type_code = ev->get_type_code();
     int exec_res;
     if (ev->server_id == ::server_id ||
-	(slave_skip_counter && ev->get_type_code() != ROTATE_EVENT))
+	(slave_skip_counter && type_code != ROTATE_EVENT))
     {
       if(type_code == LOAD_EVENT)
 	skip_load_data_infile(net);

--- 1.68/client/mysqltest.c	Sun Nov  4 18:43:00 2001
+++ 1.69/client/mysqltest.c	Sat Nov 17 17:23:44 2001
@@ -1280,6 +1280,7 @@
   char buff[FN_REFLEN];
   int con_port;
   int con_error;
+  int free_con_sock = 0;
   
   DBUG_ENTER("do_connect");
   DBUG_PRINT("enter",("connect: %s",p));
@@ -1299,10 +1300,29 @@
   }
   else
   {
+    VAR* var_port, *var_sock;
     p = safe_get_param(p, &con_port_str, "missing connection port");
-    con_port=atoi(con_port_str);
+    if (*con_port_str == '$')
+    {
+      if (!(var_port = var_get(con_port_str, 0, 0)))
+	die("Unknown variable '%s'", con_port_str+1);
+      con_port = var_port->int_val;
+    }
+    else
+     con_port=atoi(con_port_str);
     p = safe_get_param(p, &con_sock, "missing connection socket");
+    if (*con_sock == '$')
+    {
+      if (!(var_sock = var_get(con_sock, 0, 0)))
+	die("Unknown variable '%s'", con_sock+1);
+      if (!(con_sock = (char*)my_malloc(var_sock->str_val_len+1, MYF(0))))
+	die("Out of memory");
+      free_con_sock = 1;
+      memcpy(con_sock, var_sock->str_val, var_sock->str_val_len);
+      con_sock[var_sock->str_val_len] = 0;
+    }
   }
+  
   if (next_con == cons_end)
     die("Connection limit exhausted - increase MAX_CONS in mysqltest.c");
 
@@ -1310,20 +1330,21 @@
     die("Failed on mysql_init()");
   if (opt_compress)
     mysql_options(&next_con->mysql,MYSQL_OPT_COMPRESS,NullS);
-  if (con_sock)
+  if (con_sock && !free_con_sock && *con_sock && *con_sock != FN_LIBCHAR)
     con_sock=fn_format(buff, con_sock, TMPDIR, "",0);
   if (!con_db[0])
     con_db=db;
   if((con_error = safe_connect(&next_con->mysql, con_host,
 			    con_user, con_pass,
-			    con_db, con_port, con_sock)))
+			    con_db, con_port, *con_sock ? con_sock: 0)))
     die("Could not open connection '%s': %s", con_name,
 	mysql_error(&next_con->mysql));
 
   if (!(next_con->name = my_strdup(con_name, MYF(MY_WME))))
     die(NullS);
   cur_con = next_con++;
-
+  if (free_con_sock)
+    my_free(con_sock, MYF(MY_WME));
   DBUG_RETURN(0);
 }
 

--- 1.6/mysql-test/include/master-slave.inc	Sun Nov  4 06:43:40 2001
+++ 1.7/mysql-test/include/master-slave.inc	Sat Nov 17 17:23:44 2001
@@ -1,7 +1,7 @@
-connect (master,localhost,root,,test,0,master.sock);
-connect (master1,localhost,root,,test,0,master.sock);
-connect (slave,localhost,root,,test,0,slave.sock);
-connect (slave1,localhost,root,,test,0,slave.sock);
+connect (master,127.0.0.1,root,,test,$MASTER_MYPORT,);
+connect (master1,127.0.0.1,root,,test,$MASTER_MYPORT,);
+connect (slave,127.0.0.1,root,,test,$SLAVE_MYPORT,);
+connect (slave1,127.0.0.1,root,,test,$SLAVE_MYPORT,);
 connection slave;
 --error 0,1199
 !slave stop;
Thread
bk commit into 4.0 treesasha18 Nov