List:Internals« Previous MessageNext Message »
From:Patrick Galbraith Date:October 15 2005 12:17am
Subject:bk commit into 5.0 tree (patg:1.2044) BUG#8368
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of patg. When patg 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.2044 05/10/14 15:17:12 patg@stripped +6 -0
  BUG# 8368
  
  Re-application of patch http://lists.mysql.com/internals/25010 as well as
  some changes to mysql-test-run.pl not included in the orginal patch, plus
  some debug code and cleanups. 
  
  The code runs just fine, but there are warnings that ./mysql-test-run.pl --debug 
  shows which I'm having difficulty in tracking down. See notes in 
  http://bugs.mysql.com/bug.php?id=8368 which give exact details of the 
  problem.

  mysql-test/r/rpl_mysqldump.result
    1.1 05/10/14 15:16:55 patg@stripped +179 -0
    BUG# 8368
    
    New BitKeeper file ``mysql-test/r/rpl_mysqldump.result''

  mysql-test/r/rpl_mysqldump.result
    1.0 05/10/14 15:16:55 patg@stripped +0 -0
    BitKeeper file /home/patg/mysql-build/mysql-5.0/mysql-test/r/rpl_mysqldump.result

  mysql-test/mysql-test-run.sh
    1.275 05/10/14 15:16:55 patg@stripped +3 -0
    BUG# 8368
    
    Added MYSQL_DUMP_MASTER and MYSQL_DUMP_SLAVE command lines

  mysql-test/mysql-test-run.pl
    1.52 05/10/14 15:16:55 patg@stripped +20 -0
    BUG# 8368
    
    Added MYSQL_DUMP_SLAVE and MYSQL_DUMP_MASTER command line strings 

  client/mysqldump.c
    1.208 05/10/14 15:16:55 patg@stripped +419 -61
    BUG# 8368
    
    Added --slave-data option. 

  client/client_priv.h
    1.44 05/10/14 15:16:55 patg@stripped +1 -1
    BUG# 8368
    
    Added new OPT_SLAVE_DATA

  mysql-test/t/rpl_mysqldump.test
    1.1 05/10/14 15:07:29 patg@stripped +60 -0

  mysql-test/t/rpl_mysqldump.test
    1.0 05/10/14 15:07:29 patg@stripped +0 -0
    BitKeeper file /home/patg/mysql-build/mysql-5.0/mysql-test/t/rpl_mysqldump.test

# 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:	patg
# Host:	krsna.patg.net
# Root:	/home/patg/mysql-build/mysql-5.0

--- 1.207/client/mysqldump.c	2005-10-13 13:42:43 -07:00
+++ 1.208/client/mysqldump.c	2005-10-14 15:16:55 -07:00
@@ -70,11 +70,15 @@
 /* Size of buffer for dump's select query */
 #define QUERY_LENGTH 1536
 
+/* Convenience typedef for a show function */
+typedef char const *show_t(char const*);
+
 /* ignore table flags */
 #define IGNORE_NONE 0x00 /* no ignore */
 #define IGNORE_DATA 0x01 /* don't dump data for this table */
 #define IGNORE_INSERT_DELAYED 0x02 /* table doesn't support INSERT DELAYED */
 
+
 static char *add_load_option(char *ptr, const char *object,
 			     const char *statement);
 static ulong find_set(TYPELIB *lib, const char *x, uint length,
@@ -108,6 +112,10 @@
 #define MYSQL_OPT_MASTER_DATA_EFFECTIVE_SQL 1
 #define MYSQL_OPT_MASTER_DATA_COMMENTED_SQL 2
 static uint     opt_mysql_port= 0, err_len= 0, opt_master_data;
+#define MYSQL_OPT_SLAVE_DATA_EFFECTIVE_SQL 1
+#define MYSQL_OPT_SLAVE_DATA_COMMENTED_SQL 2
+static uint     opt_slave_data;
+
 static my_string opt_mysql_unix_port=0;
 static int   first_error=0;
 static DYNAMIC_STRING extended_row;
@@ -274,7 +282,7 @@
   {"lines-terminated-by", OPT_LTB, "Lines in the i.file are terminated by ...",
    (gptr*) &lines_terminated, (gptr*) &lines_terminated, 0, GET_STR,
    REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
-  {"lock-all-tables", 'x', "Locks all tables across all databases. This " 
+  {"lock-all-tables", 'x', "Locks all tables across all databases. This "
    "is achieved by taking a global read lock for the duration of the whole "
    "dump. Automatically turns --single-transaction and --lock-tables off.",
    (gptr*) &opt_lock_all_tables, (gptr*) &opt_lock_all_tables, 0, GET_BOOL,
NO_ARG,
@@ -283,9 +291,9 @@
    (gptr*) &lock_tables, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
   {"master-data", OPT_MASTER_DATA,
    "This causes the binary log position and filename to be appended to the "
-   "output. If equal to 1, will print it as a CHANGE MASTER command; if equal"
-   " to 2, that command will be prefixed with a comment symbol. "
-   "This option will turn --lock-all-tables on, unless "
+   "output. If equal to 1 (default), will print it as a CHANGE MASTER "
+   "command; if equal to 2, that command will be prefixed with a comment "
+   "symbol.  This option will turn --lock-all-tables on, unless "
    "--single-transaction is specified too (in which case a "
    "global read lock is only taken a short time at the beginning of the dump "
    "- don't forget to read about --single-transaction below). In all cases "
@@ -293,9 +301,22 @@
    "Option automatically turns --lock-tables off.",
    (gptr*) &opt_master_data, (gptr*) &opt_master_data, 0,
    GET_UINT, OPT_ARG, 0, 0, MYSQL_OPT_MASTER_DATA_COMMENTED_SQL, 0, 0, 0},
+  {"slave-data", OPT_SLAVE_DATA,
+    "This causes the binary log position and filename of the master of this "
+    "slave to be appended to the output. If equal to 1 (default), will "
+    "print it as a CHANGE MASTER command; if equal to 2, that command will "
+    "be prefixed with a comment symbol.  "
+    "This option will turn --lock-all-tables on, unless "
+    "--single-transaction is specified too (in which case a "
+    "global read lock is only taken a short time at the beginning of the dump "
+    "- don't forget to read about --single-transaction below). In all cases "
+    "any action on logs will happen at the exact moment of the dump."
+    "Option automatically turns --lock-tables off.",
+    (gptr*) &opt_slave_data, (gptr*) &opt_slave_data, 0,
+    GET_UINT, OPT_ARG, 0, 0, MYSQL_OPT_SLAVE_DATA_COMMENTED_SQL, 0, 0, 0},
   {"max_allowed_packet", OPT_MAX_ALLOWED_PACKET, "",
     (gptr*) &opt_max_allowed_packet, (gptr*) &opt_max_allowed_packet, 0,
-    GET_ULONG, REQUIRED_ARG, 24*1024*1024, 4096, 
+    GET_ULONG, REQUIRED_ARG, 24*1024*1024, 4096,
    (longlong) 2L*1024L*1024L*1024L, MALLOC_OVERHEAD, 1024, 0},
   {"net_buffer_length", OPT_NET_BUFFER_LENGTH, "",
     (gptr*) &opt_net_buffer_length, (gptr*) &opt_net_buffer_length, 0,
@@ -426,7 +447,7 @@
 
 /*
   exit with message if ferror(file)
-  
+ 
   SYNOPSIS
     check_io()
     file	- checked file
@@ -637,7 +658,7 @@
   case 'V': print_version(); exit(0);
   case 'X':
     opt_xml = 1;
-    extended_insert= opt_drop= opt_lock= 
+    extended_insert= opt_drop= opt_lock=
       opt_disable_keys= opt_autocommit= opt_create_db= 0;
     break;
   case 'I':
@@ -645,9 +666,13 @@
     usage();
     exit(0);
   case (int) OPT_MASTER_DATA:
-    if (!argument) /* work like in old versions */
+    if (!argument) /* If no argument, works as if user supplied 1 */
       opt_master_data= MYSQL_OPT_MASTER_DATA_EFFECTIVE_SQL;
     break;
+  case (int) OPT_SLAVE_DATA:
+    if (!argument) /* If no argument, works as if user supplied 1 */
+      opt_slave_data= MYSQL_OPT_SLAVE_DATA_EFFECTIVE_SQL;
+    break;
   case (int) OPT_OPTIMIZE:
     extended_insert= opt_drop= opt_lock= quick= create_options=
       opt_disable_keys= lock_tables= opt_set_charset= 1;
@@ -719,7 +744,7 @@
       }
       if (end!=compatible_mode_normal_str)
 	end[-1]= 0;
-      /* 
+      /*
         Set charset to the default compiled value if it hasn't
         been reset yet by --default-character-set=xxx.
       */
@@ -775,8 +800,14 @@
     fprintf(stderr, "%s: You can't use --single-transaction and "
             "--lock-all-tables at the same time.\n", my_progname);
     return(1);
-  }  
-  if (opt_master_data)
+  }
+  if (opt_master_data && opt_slave_data)
+  {
+    fprintf(stderr, "%s: You can't use both --slave-data and "
+           "--master-data at the same time.\n", my_progname);
+    return(1);
+  }
+  if (opt_master_data || opt_slave_data)
     opt_lock_all_tables= !opt_single_transaction;
   if (opt_single_transaction || opt_lock_all_tables)
     lock_tables= 0;
@@ -793,7 +824,7 @@
     return(1);
   }
   if (strcmp(default_charset, charset_info->csname) &&
-      !(charset_info= get_charset_by_csname(default_charset, 
+      !(charset_info= get_charset_by_csname(default_charset,
   					    MY_CS_PRIMARY, MYF(MY_WME))))
     exit(1);
   if ((*argc < 1 && !opt_alldbs) || (*argc > 0 && opt_alldbs))
@@ -835,7 +866,7 @@
     0               query sending and (if res!=0) result reading went ok
     1               error
 */
-  
+ 
 static int mysql_query_with_error_report(MYSQL *mysql_con, MYSQL_RES **res,
                                          const char *query)
 {
@@ -876,6 +907,7 @@
     fprintf(stderr, "-- Connecting to %s...\n", host ? host : "localhost");
   }
   mysql_init(&mysql_connection);
+  DBUG_PRINT("info", ("mysql_connection inited %lx", &mysql_connection));
   if (opt_compress)
     mysql_options(&mysql_connection,MYSQL_OPT_COMPRESS,NullS);
 #ifdef HAVE_OPENSSL
@@ -894,9 +926,11 @@
          NULL,opt_mysql_port,opt_mysql_unix_port,
          0)))
   {
+    my_free((gptr) &mysql_connection, MYF(0));
     DB_error(&mysql_connection, "when trying to connect");
     return 1;
   }
+  DBUG_PRINT("info", ("sock connected %lx", sock));
   /*
     Don't dump SET NAMES with a pre-4.1 server (bug#7997).
   */
@@ -910,26 +944,24 @@
   my_snprintf(buff, sizeof(buff), "/*!40100 SET @@SQL_MODE='%s' */",
 	      compatible_mode_normal_str);
   if (mysql_query_with_error_report(sock, 0, buff))
-  {
-    mysql_close(sock);
-    safe_exit(EX_MYSQLERR);
-    return 1;
-  }
+      goto err;
   /*
-    set time_zone to UTC to allow dumping date types between servers with 
+    set time_zone to UTC to allow dumping date types between servers with
     different time zone settings
   */
   if (opt_tz_utc)
   {
     my_snprintf(buff, sizeof(buff), "/*!40103 SET TIME_ZONE='+00:00' */");
     if (mysql_query_with_error_report(sock, 0, buff))
-    {
-      mysql_close(sock);
-      safe_exit(EX_MYSQLERR);
-      return 1;
-    }
+      goto err;
   }
   return 0;
+
+err:
+  mysql_close(sock);
+  mysql_close(&mysql_connection);
+  safe_exit(EX_MYSQLERR);
+  return 1;
 } /* dbConnect */
 
 
@@ -938,9 +970,13 @@
 */
 static void dbDisconnect(char *host)
 {
+  DBUG_ENTER("dbDisconnect");
   if (verbose)
     fprintf(stderr, "-- Disconnecting from %s...\n", host ? host : "localhost");
   mysql_close(sock);
+  mysql_close(&mysql_connection);
+  sock= 0;
+  DBUG_VOID_RETURN;
 } /* dbDisconnect */
 
 
@@ -978,13 +1014,13 @@
 /*
   quote_name(name, buff, force)
 
-  Quotes char string, taking into account compatible mode 
+  Quotes char string, taking into account compatible mode
 
   Args
 
   name                 Unquoted string containing that which will be quoted
   buff                 The buffer that contains the quoted value, also returned
-  force                Flag to make it ignore 'test_if_special_chars' 
+  force                Flag to make it ignore 'test_if_special_chars'
 
   Returns
 
@@ -1057,13 +1093,13 @@
 
 /*
   Quote and print a string.
-  
+ 
   SYNOPSIS
     print_quoted_xml()
     output	- output file
     str		- string to print
     len		- its length
-    
+   
   DESCRIPTION
     Quote '<' '>' '&' '\"' chars and print a string to the xml_file.
 */
@@ -1071,7 +1107,7 @@
 static void print_quoted_xml(FILE *xml_file, const char *str, ulong len)
 {
   const char *end;
-  
+ 
   for (end= str + len; str != end; str++)
   {
     switch (*str) {
@@ -1098,7 +1134,7 @@
 
 /*
   Print xml tag with one attribute.
-  
+ 
   SYNOPSIS
     print_xml_tag1()
     xml_file	- output file
@@ -1106,7 +1142,7 @@
     stag_atr	- tag and attribute
     sval	- value of attribute
     send	- line ending
-    
+   
   DESCRIPTION
     Print tag with one attribute to the xml_file. Format is:
       sbeg<stag_atr="sval">send
@@ -1173,7 +1209,7 @@
     row_name	- xml tag name
     tableRes	- query result
     row		- result row
-    
+   
   DESCRIPTION
     Print tag with many attribute to the xml_file. Format is:
       \t\t<row_name Atr1="Val1" Atr2="Val2"... />
@@ -1359,7 +1395,10 @@
   {
     complete_insert= opt_complete_insert;
     if (!insert_pat_inited)
-      insert_pat_inited= init_dynamic_string(&insert_pat, "", 1024, 1024);
+    {
+      init_dynamic_string(&insert_pat, "", 1024, 1024);
+      insert_pat_inited= 1;
+    }
     else
       dynstr_set(&insert_pat, "");
   }
@@ -1844,7 +1883,7 @@
             "/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE */;\n");
   mysql_free_result(result);
   /*
-    make sure to set back opt_compatible mode to 
+    make sure to set back opt_compatible mode to
     original value
   */
   opt_compatible_mode=old_opt_compatible_mode;
@@ -2000,7 +2039,7 @@
     my_delete(filename, MYF(0)); /* 'INTO OUTFILE' doesn't work, if
 				    filename wasn't deleted */
     to_unix_path(filename);
-    my_snprintf(query, QUERY_LENGTH, 
+    my_snprintf(query, QUERY_LENGTH,
 		"SELECT /*!40001 SQL_NO_CACHE */ * INTO OUTFILE '%s'",
 		filename);
     end= strend(query);
@@ -2152,7 +2191,7 @@
 
 	/*
 	   63 is my_charset_bin. If charsetnr is not 63,
-	   we have not a BLOB but a TEXT column. 
+	   we have not a BLOB but a TEXT column.
 	   we'll dump in hex only BLOB columns.
 	*/
         is_blob= (opt_hex_blob && field->charsetnr == 63 &&
@@ -2194,7 +2233,7 @@
                 if (opt_hex_blob && is_blob)
                 {
                   dynstr_append(&extended_row, "0x");
-                  extended_row.length+= mysql_hex_string(extended_row.str + 
+                  extended_row.length+= mysql_hex_string(extended_row.str +
                                                          extended_row.length,
                                                          row[i], length);
                   extended_row.str[extended_row.length]= '\0';
@@ -2477,7 +2516,7 @@
 {
   if (mysql_get_server_version(sock) >= 50003 &&
       !my_strcasecmp(&my_charset_latin1, database, "information_schema"))
-    return 1; 
+    return 1;
 
   if (mysql_select_db(sock, database))
   {
@@ -2504,7 +2543,7 @@
         MYSQL_ROW row;
         MYSQL_RES *dbinfo;
 
-        my_snprintf(qbuf, sizeof(qbuf), 
+        my_snprintf(qbuf, sizeof(qbuf),
 		    "SHOW CREATE DATABASE IF NOT EXISTS %s",
 		    qdatabase);
 
@@ -2673,17 +2712,17 @@
 
 
 /*
-  get_actual_table_name -- executes a SHOW TABLES LIKE '%s' to get the actual 
-  table name from the server for the table name given on the command line.  
-  we do this because the table name given on the command line may be a 
+  get_actual_table_name -- executes a SHOW TABLES LIKE '%s' to get the actual
+  table name from the server for the table name given on the command line. 
+  we do this because the table name given on the command line may be a
   different case (e.g.  T1 vs t1)
-  
+ 
   RETURN
     int - 0 if a tablename was retrieved.  1 if not
 */
 
-static int get_actual_table_name(const char *old_table_name, 
-                                  char *new_table_name, 
+static int get_actual_table_name(const char *old_table_name,
+                                  char *new_table_name,
                                   int buf_size)
 {
   int retval;
@@ -2695,7 +2734,7 @@
 
   /* Check memory for quote_for_like() */
   DBUG_ASSERT(2*sizeof(old_table_name) < sizeof(show_name_buff));
-  my_snprintf(query, sizeof(query), "SHOW TABLES LIKE %s", 
+  my_snprintf(query, sizeof(query), "SHOW TABLES LIKE %s",
 	      quote_for_like(old_table_name, show_name_buff));
 
   if (mysql_query_with_error_report(sock, 0, query))
@@ -2704,7 +2743,7 @@
   }
 
   retval = 1;
-  
+ 
   if ((table_res= mysql_store_result(sock)))
   {
     my_ulonglong num_rows= mysql_num_rows(table_res);
@@ -2855,13 +2894,13 @@
                 "recovery from\n--\n\n");
       fprintf(md_result_file,
               "%sCHANGE MASTER TO MASTER_LOG_FILE='%s', MASTER_LOG_POS=%s;\n",
-              comment_prefix, row[0], row[1]); 
+              comment_prefix, row[0], row[1]);
       check_io(md_result_file);
     }
     else if (!ignore_errors)
     {
       /* SHOW MASTER STATUS reports nothing and --force is not enabled */
-      my_printf_error(0, "Error: Binlogging on server not active", 
+      my_printf_error(0, "Error: Binlogging on server not active",
 		      MYF(0));
       mysql_free_result(master);
       return 1;
@@ -2871,8 +2910,300 @@
   return 0;
 }
 
+/*
+  Struct for handling field data.
+*/
+struct st_field_data
+{
+  /*
+     Name of the field as given by the SHOW SLAVE STATUS statement.
+  */
+  char const *const name;
 
-static int do_flush_tables_read_lock(MYSQL *mysql_con)
+  /*
+     Corresponding name of the variable to use to the CHANGE MASTER
+     statement
+  */
+  char const *const var;
+
+  /*
+     Pointer to function that optionally will change the appearance of
+     the data into something else.
+  */
+  show_t *const f_show;
+
+  /*
+    Pointer to the value in the row data
+  */
+  char const *value;
+};
+/*
+  The show functions below can all assume that the function will not
+  be passed a NULL argument.  However, it might be a good idea to add
+  an assert if the function depends on this for correct behaviour.
+*/
+
+static char const *show_same(char const *str)
+{
+  return str;
+}
+
+
+char const *show_ssl_allowed(char const *str)
+{
+  DBUG_ASSERT(strcmp(str, "Yes") == 0 ||
+              strcmp(str, "No") == 0 ||
+              strcmp(str,"Ignored") == 0);
+  if (strcmp(str, "No") == 0)
+    return "0";                 /* 'No' */
+  return "1";                   /* 'Yes' and 'Ignore' */
+}
+
+
+char const *show_empty_as_null(char const *str)
+{
+  DBUG_ASSERT(str != NULL);
+  if (*str == '\0')
+    return NULL;
+  return str;
+}
+
+/*
+   It is very important that the order of the enumeration constants
+   match the order in the field[] array below.  Also, the IDX_COUNT
+   should *always* be last in the list of enumeration constants.
+*/
+enum enum_field_index
+{
+  /* Exec_Master_Log_Pos */   LOG_POS_IDX,
+  /* Master_Host */           HOST_IDX,
+  /* Master_Port */           PORT_IDX,
+  /* Master_SSL_Allowed */    SSL_ALLOWED_IDX,
+  /* Master_SSL_CA_File */    SSL_CA_FILE_IDX,
+  /* Master_SSL_CA_Path */    SSL_CA_PATH_IDX,
+  /* Master_SSL_Cert */       SSL_CERT_IDX,
+  /* Master_SSL_Cipher */     SSL_CIPHER_IDX,
+  /* Master_SSL_Key */        SSL_KEY_IDX,
+  /* Relay_Master_Log_File */ LOG_FILE_IDX,
+  /* ZZZ */                   IDX_COUNT
+};
+
+/*
+  Array of information about the fields from the SHOW SLAVE STATUS
+  statement that should be extracted and what they should be
+  translated to in the CHANGE MASTER command.  Three of the fields are
+  constant, the last one is not constant and will be set to the
+  correct index in the code below.
+
+  The entries are sorted alphabetically on the field name since we are
+  using bsearch() below. Please keep the entries sorted this way.
+*/
+static struct st_field_data field_data[]=
+{
+  { "Exec_Master_Log_Pos",   "MASTER_LOG_POS",    show_same,          NULL },
+  { "Master_Host",           "MASTER_HOST",       show_same,          NULL },
+  { "Master_Port",           "MASTER_PORT",       show_same,          NULL },
+  { "Master_SSL_Allowed",    "MASTER_SSL",        show_ssl_allowed,   NULL },
+  { "Master_SSL_CA_File",    "MASTER_SSL_CA",     show_empty_as_null, NULL },
+  { "Master_SSL_CA_Path",    "MASTER_SSL_CAPATH", show_empty_as_null, NULL },
+  { "Master_SSL_Cert",       "MASTER_SSL_CERT",   show_empty_as_null, NULL },
+  { "Master_SSL_Cipher",     "MASTER_SSL_KEY",    show_empty_as_null, NULL },
+  { "Master_SSL_Key",        "MASTER_SSL_CIPHER", show_empty_as_null, NULL },
+  { "Relay_Master_Log_File", "MASTER_LOG_FILE",   show_same,          NULL },
+};
+
+static my_ptrdiff_t const field_order[]=
+{
+  /* Master_Host */           HOST_IDX,
+  /* Master_Port */           PORT_IDX,
+  /* Relay_Master_Log_File */ LOG_FILE_IDX,
+  /* Exec_Master_Log_Pos */   LOG_POS_IDX,
+  /* Master_SSL_Allowed */    SSL_ALLOWED_IDX,
+  /* Master_SSL_CA_File */    SSL_CA_FILE_IDX,
+  /* Master_SSL_CA_Path */    SSL_CA_PATH_IDX,
+  /* Master_SSL_Cert */       SSL_CERT_IDX,
+  /* Master_SSL_Cipher */     SSL_CIPHER_IDX,
+  /* Master_SSL_Key */        SSL_KEY_IDX,
+};
+
+static int
+compare_field_with_field_data(void const* sfield_ptr,
+                              void const* dfield_ptr)
+{
+  MYSQL_FIELD const *slave_field_ptr= sfield_ptr;
+  struct st_field_data const *field_data_ptr= dfield_ptr;
+  return strcmp(slave_field_ptr->name, field_data_ptr->name);
+}
+
+static int do_show_slave_status(MYSQL *mysql_con)
+{
+  MYSQL_ROW row;
+  MYSQL_RES *slave;
+  ulong fields_found= 0UL;
+
+  const char *comment_prefix=
+    (opt_slave_data == MYSQL_OPT_SLAVE_DATA_COMMENTED_SQL) ? "-- " : "";
+
+  DBUG_ASSERT(sizeof(field_data) / sizeof(field_data[0]) == IDX_COUNT);
+
+  if (mysql_query_with_error_report(mysql_con, &slave, "SHOW SLAVE STATUS"))
+  {
+    my_printf_error(0, "Error: Couldn't execute 'SHOW SLAVE STATUS': %s",
+                    MYF(0), mysql_error(mysql_con));
+    return 1;
+  }
+
+  if ((row= mysql_fetch_row(slave)))
+  {
+    MYSQL_FIELD* slave_field_ptr;
+    MYSQL_FIELD *const slave_field_end = slave->fields + slave->field_count;
+
+    for (slave_field_ptr= slave->fields ;
+         slave_field_ptr < slave_field_end ;
+         slave_field_ptr++)
+    {
+      struct st_field_data *field_data_ptr;
+      my_ptrdiff_t column;
+      DBUG_PRINT("info", ("Looking for '%s'", slave_field_ptr->name));
+      field_data_ptr= bsearch(slave_field_ptr,
+                              field_data,
+                              IDX_COUNT,
+                              sizeof(field_data[0]),
+                              compare_field_with_field_data);
+
+      column= slave_field_ptr - slave->fields;
+      if (field_data_ptr && row[column])
+      {
+        ulong const fieldno= field_data_ptr - field_data;
+        DBUG_PRINT("info", ("Found #%d '%s' at index %d with value '%s'",
+                            fieldno,
+                            field_data_ptr->name,
+                            column,
+                            row[column]));
+        fields_found|= (1 << fieldno);
+        field_data_ptr->value= row[column];
+      }
+    }
+
+    if (fields_found & ((1 << HOST_IDX) | (1 << PORT_IDX) |
+                        (1 << LOG_FILE_IDX) | (1 << LOG_POS_IDX)))
+    {
+      uint i;
+      char const *separator= "";
+       if (opt_comments)
+       fprintf(md_result_file,
+               "\n--"
+               "\n-- Position to start replication or point-in-time recovery from"
+               "\n-- [extracted from SHOW SLAVE STATUS output on slave]"
+               "\n--"
+               "\n\n");
+      fprintf(md_result_file, "%sCHANGE MASTER TO", comment_prefix);
+      for (i= 0 ; i < sizeof(field_order)/sizeof(field_order[0]) ; i++)
+      {
+        struct st_field_data const *const field_ptr=
+          &field_data[field_order[i]];
+        uint field_index= field_ptr - field_data;
+       if (fields_found & (1 << field_index))
+       {
+          uint j;
+          char const* quoting= "";
+
+          /*
+            Apply the field's show function to the actual column data
+            to get the data that might be printed.
+          */
+          char const *const the_row= (*field_ptr->f_show)(field_ptr->value);
+
+          DBUG_PRINT("info", ("Display '%s' as '%s'",
+                              field_ptr->value, the_row))
+
+          /*
+             If the show function decided this is NULL, the field
+             shouldn't be shown and we skip the field.
+          */
+          if (the_row != NULL)
+          {
+            /*
+               Decide if this is a string or a number.
+
+               We need to call strlen() here since we don't know the
+               length of the string returned by the show function.  We
+               can add more advanced logic to save some cycles, but
+               since this program is I/O bound, we will not save much
+               time anyway.
+             */
+            for (j= strlen(the_row) ; j-- > 0 ; )
+            {
+              if (!my_isdigit(charset_info, the_row[j]))
+              {
+                quoting= "'";
+                break;
+              }
+            }
+
+            fprintf(md_result_file, "%s\n%s    %s=%s%s%s",
+                    separator,
+                    comment_prefix,
+                    field_ptr->var,
+                    quoting,
+                    the_row,
+                    quoting);
+
+            /*
+               First lap the separator is an empty string, remaining
+               laps the separator is is ","
+            */
+            separator= ",";
+          }
+        }
+      }
+      fprintf(md_result_file, ";\n");
+       check_io(md_result_file);
+     }
+   }
+  else
+  {
+    fprintf(stderr, "Warning: SHOW SLAVE STATUS missing fields ");
+    if (fields_found & (1 << HOST_IDX))
+    {
+      fprintf(stderr, "%s ", field_data[HOST_IDX].name);
+    }
+
+    if (fields_found & (1 << PORT_IDX))
+    {
+      fprintf(stderr, "%s ", field_data[PORT_IDX].name);
+    }
+
+    if (fields_found & (1 << LOG_FILE_IDX))
+    {
+      fprintf(stderr, "%s ", field_data[LOG_FILE_IDX].name);
+    }
+
+    if (fields_found & (1 << LOG_POS_IDX))
+    {
+      fprintf(stderr, "%s ", field_data[LOG_POS_IDX].name);
+    }
+  }
+  mysql_free_result(slave);
+  slave=0;
+
+  return 0;
+}
+
+static int do_stop_sql_thread(MYSQL *mysql_con)
+{
+  return mysql_query_with_error_report(mysql_con, 0,
+                                       "STOP SLAVE SQL_THREAD");
+}
+
+
+static int do_start_sql_thread(MYSQL *mysql_con)
+{
+  return mysql_query_with_error_report(mysql_con, 0,
+                                       "START SLAVE SQL_THREAD");
+}
+
+static int do_flush_tables_read_lock(MYSQL *mysql_con, int stop_sql_thread)
 {
   /*
     We do first a FLUSH TABLES. If a long update is running, the FLUSH TABLES
@@ -2881,17 +3212,34 @@
     FLUSH TABLES is to lower the probability of a stage where both mysqldump
     and most client connections are stalled. Of course, if a second long
     update starts between the two FLUSHes, we have that bad stall.
+
+    If we are doing a flush because we are going to extract the slave
+    status, we stop the SQL thread after flushing the tables the first
+    time.  This will prevent the slave status from changing (it can
+    change even though tables are locked, since we might be either
+    reading from the relay log or updating the Exec_master_log_pos).
+
+    We stop the slave thread after doing the first flush to prevent an
+    unnecessarily long queue of events when starting the slave again:
+    the slave has enough problems keeping up with the master anyway.
+
+    The slave thread is started again when calling do_unlock_tables()
+    below, so make sure that stop_slave_thread == start_slave_thread
+    in the calls of these two functions.
   */
-  return 
+  return
     ( mysql_query_with_error_report(mysql_con, 0, "FLUSH TABLES") ||
+      (stop_sql_thread && do_stop_sql_thread(mysql_con)) ||
       mysql_query_with_error_report(mysql_con, 0,
                                     "FLUSH TABLES WITH READ LOCK") );
 }
 
 
-static int do_unlock_tables(MYSQL *mysql_con)
+static int do_unlock_tables(MYSQL *mysql_con, int start_sql_thread)
 {
-  return mysql_query_with_error_report(mysql_con, 0, "UNLOCK TABLES");
+  return
+      mysql_query_with_error_report(mysql_con, 0, "UNLOCK TABLES") ||
+      (start_sql_thread && do_start_sql_thread(mysql_con));
 }
 
 
@@ -3000,8 +3348,8 @@
   Check if we the table is one of the table types that should be ignored:
   MRG_ISAM, MRG_MYISAM, if opt_delayed, if that table supports delayed inserts.
   If the table should be altogether ignored, it returns a TRUE, FALSE if it
-  should not be ignored. If the user has selected to use INSERT DELAYED, it 
-  sets the value of the bool pointer supports_delayed_inserts to 0 if not 
+  should not be ignored. If the user has selected to use INSERT DELAYED, it
+  sets the value of the bool pointer supports_delayed_inserts to 0 if not
   supported, 1 if it is supported.
 
   ARGS
@@ -3108,7 +3456,7 @@
   uint result_length = 0;
   char *result = 0;
 
-  my_snprintf(show_keys_buff, sizeof(show_keys_buff), 
+  my_snprintf(show_keys_buff, sizeof(show_keys_buff),
 	      "SHOW KEYS FROM %s", table_name);
   if (mysql_query(sock, show_keys_buff) ||
       !(res = mysql_store_result(sock)))
@@ -3270,22 +3618,27 @@
 
   if (get_options(&argc, &argv))
   {
+    my_free(opt_password,MYF(MY_ALLOW_ZERO_PTR));
     my_end(0);
     exit(EX_USAGE);
   }
   if (dbConnect(current_host, current_user, opt_password))
+  {
+    my_free(opt_password,MYF(MY_ALLOW_ZERO_PTR));
     exit(EX_MYSQLERR);
+  }
   if (!path)
     write_header(md_result_file, *argv);
 
-  if ((opt_lock_all_tables || opt_master_data) &&
-      do_flush_tables_read_lock(sock))
+  if ((opt_lock_all_tables || opt_master_data || opt_slave_data) &&
+      do_flush_tables_read_lock(sock, opt_slave_data))
     goto err;
-  if (opt_single_transaction && start_transaction(sock, test(opt_master_data)))
+  if (opt_single_transaction
+      && start_transaction(sock, test(opt_master_data || opt_slave_data)))
       goto err;
   if (opt_delete_master_logs && do_reset_master(sock))
     goto err;
-  if (opt_lock_all_tables || opt_master_data)
+  if (opt_lock_all_tables || opt_master_data || opt_slave_data)
   {
     if (flush_logs && mysql_refresh(sock, REFRESH_LOG))
       goto err;
@@ -3293,7 +3646,11 @@
   }
   if (opt_master_data && do_show_master_status(sock))
     goto err;
-  if (opt_single_transaction && do_unlock_tables(sock)) /* unlock but no commit!
*/
+  if (opt_slave_data && do_show_slave_status(sock))
+    goto err;
+
+  /* unlock but no commit! */
+  if (opt_single_transaction && do_unlock_tables(sock, opt_slave_data))
     goto err;
 
   if (opt_alldbs)
@@ -3324,6 +3681,7 @@
   if (md_result_file != stdout)
     my_fclose(md_result_file, MYF(0));
   my_free(opt_password, MYF(MY_ALLOW_ZERO_PTR));
+  opt_password=0;
   if (hash_inited(&ignore_table))
     hash_free(&ignore_table);
   if (extended_insert)

--- 1.274/mysql-test/mysql-test-run.sh	2005-09-13 15:41:36 -07:00
+++ 1.275/mysql-test/mysql-test-run.sh	2005-10-14 15:16:55 -07:00
@@ -720,12 +720,15 @@
 # Save path and name of mysqldump
 MYSQL_DUMP_DIR="$MYSQL_DUMP"
 export MYSQL_DUMP_DIR
+MYSQL_DUMP_SLAVE="$MYSQL_DUMP --no-defaults -uroot --socket=$SLAVE_MYSOCK
--password=$DBPASSWD $EXTRA_MYSQLDUMP_OPT"
+MYSQL_DUMP_MASTER="$MYSQL_DUMP --no-defaults -uroot --socket=$MASTER_MYSOCK
--password=$DBPASSWD $EXTRA_MYSQLDUMP_OPT"
 MYSQL_DUMP="$MYSQL_DUMP --no-defaults -uroot --socket=$MASTER_MYSOCK --password=$DBPASSWD
$EXTRA_MYSQLDUMP_OPT"
 MYSQL_SHOW="$MYSQL_SHOW -uroot --socket=$MASTER_MYSOCK --password=$DBPASSWD
$EXTRA_MYSQLSHOW_OPT"
 MYSQL_BINLOG="$MYSQL_BINLOG --no-defaults --local-load=$MYSQL_TMP_DIR 
--character-sets-dir=$CHARSETSDIR $EXTRA_MYSQLBINLOG_OPT"
 MYSQL_FIX_SYSTEM_TABLES="$MYSQL_FIX_SYSTEM_TABLES --no-defaults --host=localhost
--port=$MASTER_MYPORT --socket=$MASTER_MYSOCK --user=root --password=$DBPASSWD
--basedir=$BASEDIR --bindir=$CLIENT_BINDIR --verbose"
 MYSQL="$MYSQL --no-defaults --host=localhost --port=$MASTER_MYPORT
--socket=$MASTER_MYSOCK --user=root --password=$DBPASSWD"
 export MYSQL MYSQL_DUMP MYSQL_SHOW MYSQL_BINLOG MYSQL_FIX_SYSTEM_TABLES
+export MYSQL_DUMP_MASTER MYSQL_DUMP_SLAVE
 export CLIENT_BINDIR MYSQL_CLIENT_TEST CHARSETSDIR MYSQL_MY_PRINT_DEFAULTS
 export NDB_TOOLS_DIR
 export NDB_MGM

--- 1.51/mysql-test/mysql-test-run.pl	2005-10-01 09:03:36 -07:00
+++ 1.52/mysql-test/mysql-test-run.pl	2005-10-14 15:16:55 -07:00
@@ -2363,12 +2363,30 @@
   my $cmdline_mysqldump= "$exe_mysqldump --no-defaults -uroot " .
                          "--port=$master->[0]->{'path_myport'} " .
                          "--socket=$master->[0]->{'path_mysock'} --password=";
+
   if ( $opt_debug )
   {
     $cmdline_mysqldump .=
       " --debug=d:t:A,$opt_vardir/log/mysqldump.trace";
   }
 
+  my $cmdline_mysqldump_slave= "$exe_mysqldump --no-defaults -uroot " .
+                         "--port=$slave->[0]->{'path_myport'} " .
+                         "--socket=$slave->[0]->{'path_mysock'} --password=";
+  if ( $opt_debug )
+  {
+    $cmdline_mysqldump_slave .=
+      " --debug=d:t:A,$opt_vardir/log/mysqldump_slave.trace";
+  }
+  my $cmdline_mysqldump_master= "$exe_mysqldump --no-defaults -uroot " .
+                         "--port=$master->[0]->{'path_myport'} " .
+                         "--socket=$master->[0]->{'path_mysock'} --password=";
+  if ( $opt_debug )
+  {
+    $cmdline_mysqldump_master .=
+      " --debug=d:t:A,$opt_vardir/log/mysqldump_master.trace";
+  }
+
   my $cmdline_mysqlshow= "$exe_mysqlshow -uroot " .
                          "--port=$master->[0]->{'path_myport'} " .
                          "--socket=$master->[0]->{'path_mysock'} --password=";
@@ -2420,6 +2438,8 @@
 
   $ENV{'MYSQL'}=                    $cmdline_mysql;
   $ENV{'MYSQL_DUMP'}=               $cmdline_mysqldump;
+  $ENV{'MYSQL_DUMP_SLAVE'}=         $cmdline_mysqldump_slave;
+  $ENV{'MYSQL_DUMP_MASTER'}=        $cmdline_mysqldump_master;
   $ENV{'MYSQL_SHOW'}=               $cmdline_mysqlshow;
   $ENV{'MYSQL_BINLOG'}=             $cmdline_mysqlbinlog;
   $ENV{'MYSQL_FIX_SYSTEM_TABLES'}=  $cmdline_mysql_fix_system_tables;

--- 1.43/client/client_priv.h	2005-10-12 22:44:16 -07:00
+++ 1.44/client/client_priv.h	2005-10-14 15:16:55 -07:00
@@ -51,5 +51,5 @@
 #endif
   OPT_TRIGGERS,
   OPT_IGNORE_TABLE,OPT_INSERT_IGNORE,OPT_SHOW_WARNINGS,OPT_DROP_DATABASE,
-  OPT_TZ_UTC, OPT_AUTO_CLOSE
+  OPT_TZ_UTC, OPT_AUTO_CLOSE, OPT_SLAVE_DATA
 };
--- New file ---
+++ mysql-test/r/rpl_mysqldump.result	05/10/14 15:16:55
stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
CREATE TABLE t1 (a INT, b INT) ENGINE=MyISAM;
INSERT INTO t1 VALUES (1,2), (2,3);

### No CHANGE MASTER statement ###

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
DROP TABLE IF EXISTS `t1`;
CREATE TABLE `t1` (
  `a` int(11) default NULL,
  `b` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;


/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
LOCK TABLES `t1` WRITE;
INSERT INTO `t1` VALUES (1,2),(2,3);
UNLOCK TABLES;
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;


### Show CHANGE MASTER statement ###

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
CHANGE MASTER TO
    MASTER_HOST='127.0.0.1',
    MASTER_PORT=MASTER_MYPORT,
    MASTER_LOG_FILE='master-bin.000001',
    MASTER_LOG_POS=302,
    MASTER_SSL=0;
DROP TABLE IF EXISTS `t1`;
CREATE TABLE `t1` (
  `a` int(11) default NULL,
  `b` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;


/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
LOCK TABLES `t1` WRITE;
INSERT INTO `t1` VALUES (1,2),(2,3);
UNLOCK TABLES;
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;


### Show CHANGE MASTER statement as comment ###

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
-- CHANGE MASTER TO
--     MASTER_HOST='127.0.0.1',
--     MASTER_PORT=MASTER_MYPORT,
--     MASTER_LOG_FILE='master-bin.000001',
--     MASTER_LOG_POS=302,
--     MASTER_SSL=0;
DROP TABLE IF EXISTS `t1`;
CREATE TABLE `t1` (
  `a` int(11) default NULL,
  `b` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;


/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
LOCK TABLES `t1` WRITE;
INSERT INTO `t1` VALUES (1,2),(2,3);
UNLOCK TABLES;
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;


### Error to supply both --master-data and --slave-data ###
mysqldump: You can't use both --slave-data and --master-data at the same time.
STOP SLAVE;
GRANT REPLICATION SLAVE ON *.* TO replssl@'%' REQUIRE SSL;
CHANGE MASTER TO MASTER_SSL=1, 
MASTER_SSL_CA ='MYSQL_TEST_DIR/std_data/cacert.pem', 
MASTER_SSL_CERT='MYSQL_TEST_DIR/std_data/client-cert.pem', 
MASTER_SSL_KEY='MYSQL_TEST_DIR/std_data/client-key.pem';
START SLAVE;

### Show CHANGE MASTER statement ###

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
CHANGE MASTER TO
    MASTER_HOST='127.0.0.1',
    MASTER_PORT=MASTER_MYPORT,
    MASTER_LOG_FILE='master-bin.000001',
    MASTER_LOG_POS=422,
    MASTER_SSL=1,
    MASTER_SSL_CA='MYSQL_TEST_DIR/std_data/cacert.pem',
    MASTER_SSL_CERT='MYSQL_TEST_DIR/std_data/client-cert.pem',
    MASTER_SSL_CIPHER='MYSQL_TEST_DIR/std_data/client-key.pem';
DROP TABLE IF EXISTS `t1`;
CREATE TABLE `t1` (
  `a` int(11) default NULL,
  `b` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;


/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
LOCK TABLES `t1` WRITE;
INSERT INTO `t1` VALUES (1,2),(2,3);
UNLOCK TABLES;
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;


--- New file ---
+++ mysql-test/t/rpl_mysqldump.test	05/10/14 15:07:29
source include/master-slave.inc;

#
# Bug#8368: mysqldump needs --slave-data option
#

connection master;
CREATE TABLE t1 (a INT, b INT) ENGINE=MyISAM;
INSERT INTO t1 VALUES (1,2), (2,3);
sync_slave_with_master;

--disable_query_log
select "### No CHANGE MASTER statement ###" as "";
--enable_query_log
--exec $MYSQL_DUMP_SLAVE --skip-comments --slave-data=0 test t1

--disable_query_log
select "### Show CHANGE MASTER statement ###" as "";
--enable_query_log
--replace_result $SLAVE_MYPORT SLAVE_MYPORT $MASTER_MYPORT MASTER_MYPORT
--exec $MYSQL_DUMP_SLAVE --skip-comments --slave-data=1 test t1

--disable_query_log
select "### Show CHANGE MASTER statement as comment ###" as "";
--enable_query_log
--replace_result $SLAVE_MYPORT SLAVE_MYPORT $MASTER_MYPORT MASTER_MYPORT
--exec $MYSQL_DUMP_SLAVE --skip-comments --slave-data=2 test t1

--disable_query_log
select "### Error to supply both --master-data and --slave-data ###" as "";
--enable_query_log
--replace_result $SLAVE_MYPORT SLAVE_MYPORT $MASTER_MYPORT MASTER_MYPORT $MYSQL_TEST_DIR
MYSQL_TEST_DIR
--exec $MYSQL_DUMP_SLAVE --skip-comments --master-data --slave-data test t1 2>&1 ||
true  

STOP SLAVE;

connection master;
GRANT REPLICATION SLAVE ON *.* TO replssl@'%' REQUIRE SSL;

save_master_pos;

connection slave;

--disable_warnings
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
eval CHANGE MASTER TO MASTER_SSL=1, 
     MASTER_SSL_CA ='$MYSQL_TEST_DIR/std_data/cacert.pem', 
     MASTER_SSL_CERT='$MYSQL_TEST_DIR/std_data/client-cert.pem', 
     MASTER_SSL_KEY='$MYSQL_TEST_DIR/std_data/client-key.pem';
--enable_warnings
START SLAVE;

sync_with_master;
# No need to test all alternatives, we just want to check that the
# data for the CHANGE MASTER statement is correct.
--disable_query_log
select "### Show CHANGE MASTER statement ###" as "";
--enable_query_log
--replace_result $SLAVE_MYPORT SLAVE_MYPORT $MASTER_MYPORT MASTER_MYPORT $MYSQL_TEST_DIR
MYSQL_TEST_DIR
--exec $MYSQL_DUMP_SLAVE --skip-comments --slave-data=1 test t1

Thread
bk commit into 5.0 tree (patg:1.2044) BUG#8368Patrick Galbraith15 Oct