List:Internals« Previous MessageNext Message »
From:Mats Kindahl Date:March 8 2005 6:05pm
Subject:bk commit into 4.0 tree (mats:1.2074) BUG#8368
View as plain text  
Below is the list of changes that have just been committed into a local
4.0 repository of mats. When mats does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.2074 05/03/08 18:05:19 mats@stripped +2 -0
  Bug#8368: Added --slave-data option to mysqldump that will allow a
  slave to be cloned.  The option will append a CHANGE MASTER statement
  to the output with the host, port, log file, and log pos of the slave.
   

  client/mysqldump.c
    1.119 05/03/08 18:05:16 mats@stripped +53 -1
    Added new option --slave-data to show slave status and write SQL
    command to clone slave.

  client/client_priv.h
    1.19 05/03/08 18:05:16 mats@stripped +1 -1
    Added new option --slave-data to show slave status and write SQL
    command to clone slave.

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	mats
# Host:	romeo.kindahl.net
# Root:	/home/bk/b8368-mysql-4.0

--- 1.118/client/mysqldump.c	2004-11-09 18:03:00 +01:00
+++ 1.119/client/mysqldump.c	2005-03-08 18:05:16 +01:00
@@ -76,7 +76,7 @@
   ignore=0,opt_drop=0,opt_keywords=0,opt_lock=0,opt_compress=0,
   opt_delayed=0,create_options=0,opt_quoted=0,opt_databases=0,
   opt_alldbs=0,opt_create_db=0,opt_first_slave=0,
-  opt_autocommit=0,opt_master_data,opt_disable_keys=0,opt_xml=0,
+  opt_autocommit=0,opt_master_data,opt_slave_data,opt_disable_keys=0,opt_xml=0,
   opt_delete_master_logs=0, tty_password=0,
   opt_single_transaction=0, opt_comments= 0,
   opt_hex_blob;
@@ -182,6 +182,9 @@
   {"master-data", OPT_MASTER_DATA,
    "This causes the master position and filename to be appended to your output. This
automatically enables --first-slave.",
    0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
+  {"slave-data", OPT_SLAVE_DATA,
+   "Use the slave position and filename to be appended to your output. (clones the
slave). Automatically enables --first-slave.",
+   0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
   {"no-autocommit", OPT_AUTOCOMMIT,
    "Wrap tables with autocommit/commit statements.",
    (gptr*) &opt_autocommit, (gptr*) &opt_autocommit, 0, GET_BOOL, NO_ARG,
@@ -350,6 +353,10 @@
     opt_master_data=1;
     opt_first_slave=1;
     break;
+  case OPT_SLAVE_DATA:
+    opt_slave_data=1;
+    opt_first_slave=1;
+    break;
   case OPT_DELETE_MASTER_LOGS:
     opt_delete_master_logs=1;
     opt_first_slave=1;
@@ -1618,6 +1625,7 @@
 {
   MYSQL_ROW row;
   MYSQL_RES *master;
+  MYSQL_RES *slave;
 
   MY_INIT(argv[0]);
   if (get_options(&argc, &argv))
@@ -1691,6 +1699,50 @@
 MASTER_LOG_POS=%s ;\n",row[0],row[1]); 
 	}
 	mysql_free_result(master);
+      }
+    }
+    else if (opt_slave_data)
+    {
+      if (mysql_query(sock, "SHOW SLAVE STATUS") ||
+	  !(slave = mysql_store_result(sock)))
+	my_printf_error(0, "Error: Couldn't execute 'SHOW SLAVE STATUS': %s",
+			MYF(0), mysql_error(sock));
+      else
+      {
+	row = mysql_fetch_row(slave);
+	if (row)
+	{
+	  unsigned int f = 0;
+	  int host_idx = -1, port_idx = -1;
+	  int log_file_idx = -1, log_pos_idx = -1;
+	  for (f = 0 ; f < slave->field_count ; ++f)
+	  {
+	    if (strcmp(slave->fields[f].name, "Master_Host") == 0)
+	      host_idx = f;
+	    else if (strcmp(slave->fields[f].name, "Master_Port") == 0)
+	      port_idx = f;
+	    else if (strcmp(slave->fields[f].name, "Master_Log_File") == 0)
+	      log_file_idx = f;
+	    else if (strcmp(slave->fields[f].name, "Exec_master_log_pos") == 0)
+	      log_pos_idx = f;
+	  }
+	  if (host_idx >= 0 && port_idx >= 0 
+	      && log_file_idx >= 0 && log_pos_idx >= 0)
+	  {
+	    if (opt_comments)
+	      fprintf(md_result_file,
+		      "\n--"
+		      "\n-- Position and host to start replication from"
+		      "\n--\n\n");
+	    fprintf(md_result_file,
+		    "CHANGE MASTER TO "
+		    "MASTER_HOST='%s', MASTER_PORT=%s, "
+		    "MASTER_LOG_FILE='%s', MASTER_LOG_POS=%s;\n",
+		    row[host_idx],row[port_idx],
+		    row[log_file_idx],row[log_pos_idx]); 
+	  }
+	}
+	mysql_free_result(slave);
       }
     }
     if (mysql_query(sock, "UNLOCK TABLES"))

--- 1.18/client/client_priv.h	2004-11-05 06:23:25 +01:00
+++ 1.19/client/client_priv.h	2005-03-08 18:05:16 +01:00
@@ -37,6 +37,6 @@
 	       OPT_SELECT_LIMIT, OPT_MAX_JOIN_SIZE, OPT_SSL_SSL,
                OPT_SSL_KEY, OPT_SSL_CERT, OPT_SSL_CA, OPT_SSL_CAPATH,
                OPT_SSL_CIPHER, OPT_SHUTDOWN_TIMEOUT, OPT_LOCAL_INFILE,
-	       OPT_DELETE_MASTER_LOGS,
+	       OPT_DELETE_MASTER_LOGS, OPT_SLAVE_DATA,
                OPT_PROMPT, OPT_IGN_LINES,OPT_TRANSACTION, OPT_FRM,
                OPT_HEXBLOB };
Thread
bk commit into 4.0 tree (mats:1.2074) BUG#8368Mats Kindahl8 Mar
  • Re: bk commit into 4.0 tree (mats:1.2074) BUG#8368Mikael Fridh10 Mar
    • Re: bk commit into 4.0 tree (mats:1.2074) BUG#8368Mats Kindahl10 Mar