List:Commits« Previous MessageNext Message »
From:Stewart Smith Date:October 9 2007 7:34am
Subject:bk commit into 5.1 tree (stewart:1.2619)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of stewart. When stewart does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2007-10-09 17:34:41+10:00, stewart@stripped +9 -0
  [PATCH] WL3127 slave side TCP address binding
  
  Add option to CHANGE MASTER TO MASTER_BIND
  Add Master_Bind to SHOW SLAVE STATUS
  Set OPT_BIND_ADDR for client connection in slave thread
  default bind of all interfaces
  
  ===== sql/lex.h 1.148 vs edited =====
  Index: telco/sql/lex.h
  ===================================================================

  sql/lex.h@stripped, 2007-09-04 09:55:02+10:00, stewart@stripped +1 -0
    WL3127 slave side TCP address binding

  sql/log_event.h@stripped, 2007-09-04 09:55:02+10:00, stewart@stripped +1 -0
    WL3127 slave side TCP address binding

  sql/repl_failsafe.cc@stripped, 2007-09-04 09:55:02+10:00, stewart@stripped +6 -0
    WL3127 slave side TCP address binding

  sql/rpl_mi.cc@stripped, 2007-09-04 09:55:03+10:00, stewart@stripped +11 -3
    WL3127 slave side TCP address binding

  sql/rpl_mi.h@stripped, 2007-09-04 09:55:04+10:00, stewart@stripped +1 -0
    WL3127 slave side TCP address binding

  sql/slave.cc@stripped, 2007-09-04 09:55:03+10:00, stewart@stripped +10 -1
    WL3127 slave side TCP address binding

  sql/sql_lex.h@stripped, 2007-09-04 09:55:03+10:00, stewart@stripped +1 -1
    WL3127 slave side TCP address binding

  sql/sql_repl.cc@stripped, 2007-09-04 09:55:03+10:00, stewart@stripped +2 -0
    WL3127 slave side TCP address binding

  sql/sql_yacc.yy@stripped, 2007-09-04 09:55:03+10:00, stewart@stripped +6 -0
    WL3127 slave side TCP address binding

diff -Nrup a/sql/lex.h b/sql/lex.h
--- a/sql/lex.h	2007-08-09 08:13:42 +10:00
+++ b/sql/lex.h	2007-09-04 09:55:02 +10:00
@@ -302,6 +302,7 @@ static SYMBOL symbols[] = {
   { "MASTER",           SYM(MASTER_SYM)},
   { "MASTER_CONNECT_RETRY",           SYM(MASTER_CONNECT_RETRY_SYM)},
   { "MASTER_HOST",           SYM(MASTER_HOST_SYM)},
+  { "MASTER_BIND",           SYM(MASTER_BIND_SYM)},
   { "MASTER_LOG_FILE",           SYM(MASTER_LOG_FILE_SYM)},
   { "MASTER_LOG_POS",           SYM(MASTER_LOG_POS_SYM)},
   { "MASTER_PASSWORD",           SYM(MASTER_PASSWORD_SYM)},
diff -Nrup a/sql/log_event.h b/sql/log_event.h
--- a/sql/log_event.h	2007-08-28 23:49:00 +10:00
+++ b/sql/log_event.h	2007-09-04 09:55:02 +10:00
@@ -1132,6 +1132,7 @@ public:
   int master_host_len;
   int master_log_len;
   uint16 master_port;
+  /* TODO add mysql_bind_addr here ? */
 
 #ifndef MYSQL_CLIENT
   Slave_log_event(THD* thd_arg, RELAY_LOG_INFO* rli);
diff -Nrup a/sql/repl_failsafe.cc b/sql/repl_failsafe.cc
--- a/sql/repl_failsafe.cc	2007-05-10 19:59:28 +10:00
+++ b/sql/repl_failsafe.cc	2007-09-04 09:55:02 +10:00
@@ -691,6 +691,12 @@ int connect_to_master(THD *thd, MYSQL* m
   mysql_options(mysql, MYSQL_OPT_CONNECT_TIMEOUT, (char *) &slave_net_timeout);
   mysql_options(mysql, MYSQL_OPT_READ_TIMEOUT, (char *) &slave_net_timeout);
 
+  if (mi->bind_addr && !strcmp(mi->bind_addr,"0.0.0.0"))
+  {
+    DBUG_PRINT("info",("rpl failsafe BIND ADDR: %s",mi->bind_addr));
+    mysql_options(mysql, MYSQL_OPT_BIND, mi->bind_addr);
+  }
+
 #ifdef HAVE_OPENSSL
   if (mi->ssl)
   {
diff -Nrup a/sql/rpl_mi.cc b/sql/rpl_mi.cc
--- a/sql/rpl_mi.cc	2007-10-09 05:54:54 +10:00
+++ b/sql/rpl_mi.cc	2007-09-04 09:55:03 +10:00
@@ -33,7 +33,7 @@ MASTER_INFO::MASTER_INFO()
    abort_slave(0),slave_running(0),
    ssl_verify_server_cert(0), slave_run_id(0)
 {
-  host[0] = 0; user[0] = 0; password[0] = 0;
+  host[0] = 0; user[0] = 0; password[0] = 0; bind_addr[0] = 0;
   ssl_ca[0]= 0; ssl_capath[0]= 0; ssl_cert[0]= 0;
   ssl_cipher[0]= 0; ssl_key[0]= 0;
 
@@ -65,6 +65,8 @@ void init_master_info_with_options(MASTE
   mi->master_log_name[0] = 0;
   mi->master_log_pos = BIN_LOG_HEADER_SIZE;             // skip magic number
 
+  strmake(mi->bind_addr, "0.0.0.0", sizeof(mi->bind_addr));
+
   if (master_host)
     strmake(mi->host, master_host, sizeof(mi->host) - 1);
   if (master_user)
@@ -97,8 +99,10 @@ enum {
   /* 5.1.16 added value of master_ssl_verify_server_cert */
   LINE_FOR_MASTER_SSL_VERIFY_SERVER_CERT= 15,
 
+  LINES_IN_MASTER_INFO_WITH_SSL_AND_BIND_ADDR= 16,
+
   /* Number of lines currently used when saving master info file */
-  LINES_IN_MASTER_INFO= LINE_FOR_MASTER_SSL_VERIFY_SERVER_CERT
+  LINES_IN_MASTER_INFO= LINES_IN_MASTER_INFO_WITH_SSL_AND_BIND_ADDR
 };
 
 int init_master_info(MASTER_INFO* mi, const char* master_info_fname,
@@ -285,6 +289,11 @@ file '%s')", fname);
           init_intvar_from_file(&ssl_verify_server_cert, &mi->file, 0))
         goto errwithmsg;
 
+      if (lines >= LINES_IN_MASTER_INFO_WITH_SSL_AND_BIND_ADDR &&
+          init_strvar_from_file(mi->bind_addr, sizeof(mi->bind_addr),
+                                &mi->file, ""))
+        goto errwithmsg;
+
     }
 
 #ifndef HAVE_OPENSSL
@@ -293,7 +302,6 @@ file '%s')", fname);
                       "('%s') are ignored because this MySQL slave was compiled "
                       "without SSL support.", fname);
 #endif /* HAVE_OPENSSL */
-
     /*
       This has to be handled here as init_intvar_from_file can't handle
       my_off_t types
diff -Nrup a/sql/rpl_mi.h b/sql/rpl_mi.h
--- a/sql/rpl_mi.h	2007-10-09 05:54:54 +10:00
+++ b/sql/rpl_mi.h	2007-09-04 09:55:04 +10:00
@@ -64,6 +64,7 @@ class MASTER_INFO : public Slave_reporti
   /* the variables below are needed because we can change masters on the fly */
   char master_log_name[FN_REFLEN];
   char host[HOSTNAME_LENGTH+1];
+  char bind_addr[HOSTNAME_LENGTH+1];
   char user[USERNAME_LENGTH+1];
   char password[MAX_PASSWORD_LENGTH+1];
   my_bool ssl; // enables use of SSL connection if true
diff -Nrup a/sql/slave.cc b/sql/slave.cc
--- a/sql/slave.cc	2007-10-09 05:54:55 +10:00
+++ b/sql/slave.cc	2007-09-04 09:55:03 +10:00
@@ -1306,7 +1306,8 @@ bool show_master_info(THD* thd, MASTER_I
   field_list.push_back(new Item_empty_string("Last_IO_Error", 20));
   field_list.push_back(new Item_return_int("Last_SQL_Errno", 4, MYSQL_TYPE_LONG));
   field_list.push_back(new Item_empty_string("Last_SQL_Error", 20));
-
+  field_list.push_back(new Item_empty_string("Master_Bind",
+                                             sizeof(mi->bind_addr)));
   if (protocol->send_fields(&field_list,
                             Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
     DBUG_RETURN(TRUE);
@@ -1425,6 +1426,8 @@ bool show_master_info(THD* thd, MASTER_I
     // Last_SQL_Error
     protocol->store(mi->rli.last_error().message, &my_charset_bin);
 
+    protocol->store(mi->bind_addr, &my_charset_bin);
+
     pthread_mutex_unlock(&mi->rli.data_lock);
     pthread_mutex_unlock(&mi->data_lock);
 
@@ -3272,6 +3275,12 @@ static int connect_to_master(THD* thd, M
 
   mysql_options(mysql, MYSQL_OPT_CONNECT_TIMEOUT, (char *) &slave_net_timeout);
   mysql_options(mysql, MYSQL_OPT_READ_TIMEOUT, (char *) &slave_net_timeout);
+
+  if (mi->bind_addr[0])
+  {
+    DBUG_PRINT("info",("BIND ADDR: %s",mi->bind_addr));
+    mysql_options(mysql, MYSQL_OPT_BIND, mi->bind_addr);
+  }
 
 #ifdef HAVE_OPENSSL
   if (mi->ssl)
diff -Nrup a/sql/sql_lex.h b/sql/sql_lex.h
--- a/sql/sql_lex.h	2007-08-24 20:22:30 +10:00
+++ b/sql/sql_lex.h	2007-09-04 09:55:03 +10:00
@@ -185,7 +185,7 @@ typedef struct st_lex_server_options
 
 typedef struct st_lex_master_info
 {
-  char *host, *user, *password, *log_file_name;
+  char *host, *user, *password, *log_file_name, *bind_addr;
   uint port, connect_retry;
   ulonglong pos;
   ulong server_id;
diff -Nrup a/sql/sql_repl.cc b/sql/sql_repl.cc
--- a/sql/sql_repl.cc	2007-07-07 17:04:08 +10:00
+++ b/sql/sql_repl.cc	2007-09-04 09:55:03 +10:00
@@ -1122,6 +1122,8 @@ bool change_master(THD* thd, MASTER_INFO
 
   if (lex_mi->host)
     strmake(mi->host, lex_mi->host, sizeof(mi->host)-1);
+  if (lex_mi->bind_addr)
+    strmake(mi->bind_addr, lex_mi->bind_addr, sizeof(mi->bind_addr)-1);
   if (lex_mi->user)
     strmake(mi->user, lex_mi->user, sizeof(mi->user)-1);
   if (lex_mi->password)
diff -Nrup a/sql/sql_yacc.yy b/sql/sql_yacc.yy
--- a/sql/sql_yacc.yy	2007-09-20 19:28:51 +10:00
+++ b/sql/sql_yacc.yy	2007-09-04 09:55:03 +10:00
@@ -773,6 +773,7 @@ bool my_yyoverflow(short **a, YYSTYPE **
 %token  LT                            /* OPERATOR */
 %token  MASTER_CONNECT_RETRY_SYM
 %token  MASTER_HOST_SYM
+%token  MASTER_BIND_SYM
 %token  MASTER_LOG_FILE_SYM
 %token  MASTER_LOG_POS_SYM
 %token  MASTER_PASSWORD_SYM
@@ -1481,6 +1482,11 @@ master_def:
        MASTER_HOST_SYM EQ TEXT_STRING_sys
        {
 	 Lex->mi.host = $3.str;
+       }
+       |
+       MASTER_BIND_SYM EQ TEXT_STRING_sys
+       {
+	 Lex->mi.bind_addr = $3.str;
        }
        |
        MASTER_USER_SYM EQ TEXT_STRING_sys
Thread
bk commit into 5.1 tree (stewart:1.2619)Stewart Smith9 Oct