@@ -1266,8 +1266,9 @@ static int get_options(int *argc, char ***argv)
12661266 if (opt_slave_data )
12671267 {
12681268 opt_lock_all_tables = !opt_single_transaction ;
1269- opt_master_data = 0 ;
12701269 opt_delete_master_logs = 0 ;
1270+ if (opt_slave_data != MYSQL_OPT_SLAVE_DATA_COMMENTED_SQL )
1271+ opt_master_data = 0 ;
12711272 }
12721273
12731274 /* Ensure consistency of the set of binlog & locking options */
@@ -1280,10 +1281,7 @@ static int get_options(int *argc, char ***argv)
12801281 return (EX_USAGE );
12811282 }
12821283 if (opt_master_data )
1283- {
12841284 opt_lock_all_tables = !opt_single_transaction ;
1285- opt_slave_data = 0 ;
1286- }
12871285 if (opt_single_transaction || opt_lock_all_tables )
12881286 lock_tables = 0 ;
12891287 if (enclosed && opt_enclosed )
@@ -6220,17 +6218,12 @@ static int do_show_master_status(MYSQL *mysql_con, int consistent_binlog_pos,
62206218
62216219 }
62226220
6223- /* SHOW MASTER STATUS reports file and position */
6224- print_comment (md_result_file , 0 ,
6225- "\n--\n-- Position to start replication or point-in-time "
6226- "recovery from\n--\n\n" );
6227- fprintf (md_result_file ,
6228- "%sCHANGE MASTER TO MASTER_LOG_FILE='%s', MASTER_LOG_POS=%s;\n" ,
6229- (use_gtid ? "-- " : comment_prefix ), file , offset );
6221+ /* gtid */
62306222 if (have_mariadb_gtid )
62316223 {
62326224 print_comment (md_result_file , 0 ,
6233- "\n--\n-- GTID to start replication from\n--\n\n" );
6225+ "\n-- Preferably use GTID to start replication from GTID "
6226+ "position:\n\n" );
62346227 if (use_gtid )
62356228 fprintf (md_result_file ,
62366229 "%sCHANGE MASTER TO MASTER_USE_GTID=slave_pos;\n" ,
@@ -6239,6 +6232,19 @@ static int do_show_master_status(MYSQL *mysql_con, int consistent_binlog_pos,
62396232 "%sSET GLOBAL gtid_slave_pos='%s';\n" ,
62406233 (!use_gtid ? "-- " : comment_prefix ), gtid_pos );
62416234 }
6235+
6236+ /* SHOW MASTER STATUS reports file and position */
6237+ print_comment (md_result_file , 0 ,
6238+ "\n--\n-- Alternately, following is the position of the binary "
6239+ "logging from SHOW MASTER STATUS at point of backup."
6240+ "\n-- Use this when creating a replica of the primary server "
6241+ "where the backup was made."
6242+ "\n-- The new server will be connecting to the primary server "
6243+ "where the backup was taken."
6244+ "\n--\n\n" );
6245+ fprintf (md_result_file ,
6246+ "%sCHANGE MASTER TO MASTER_LOG_FILE='%s', MASTER_LOG_POS=%s;\n" ,
6247+ (use_gtid ? "-- " : comment_prefix ), file , offset );
62426248 check_io (md_result_file );
62436249
62446250 if (!consistent_binlog_pos )
@@ -6317,7 +6323,6 @@ static int do_show_slave_status(MYSQL *mysql_con, int use_gtid,
63176323 (opt_slave_data == MYSQL_OPT_SLAVE_DATA_COMMENTED_SQL ) ? "-- " : "" ;
63186324 const char * gtid_comment_prefix = (use_gtid ? comment_prefix : "-- " );
63196325 const char * nogtid_comment_prefix = (!use_gtid ? comment_prefix : "-- " );
6320- int set_gtid_done = 0 ;
63216326
63226327 if (mysql_query_with_error_report (mysql_con , & slave ,
63236328 multi_source ?
@@ -6333,23 +6338,36 @@ static int do_show_slave_status(MYSQL *mysql_con, int use_gtid,
63336338 return 1 ;
63346339 }
63356340
6336- while ((row = mysql_fetch_row (slave )))
6341+ print_comment (md_result_file , 0 ,
6342+ "\n--\n-- The following is the SQL position of the replication "
6343+ "taken from SHOW SLAVE STATUS at the time of backup.\n"
6344+ "-- Use this position when creating a clone of, or replacement "
6345+ "server, from where the backup was taken."
6346+ "\n-- This new server will connects to the same primary "
6347+ "server%s.\n--\n" ,
6348+ multi_source ? "(s)" : "" );
6349+
6350+ if (multi_source )
63376351 {
6338- if (multi_source && !set_gtid_done )
6352+ char gtid_pos [MAX_GTID_LENGTH ];
6353+ if (have_mariadb_gtid && get_gtid_pos (gtid_pos , 0 ))
63396354 {
6340- char gtid_pos [MAX_GTID_LENGTH ];
6341- if (have_mariadb_gtid && get_gtid_pos (gtid_pos , 0 ))
6342- {
6343- mysql_free_result (slave );
6344- return 1 ;
6345- }
6346- if (opt_comments )
6347- fprintf (md_result_file , "\n--\n-- Gtid position to start replication "
6348- "from\n--\n\n" );
6349- fprintf (md_result_file , "%sSET GLOBAL gtid_slave_pos='%s';\n" ,
6350- gtid_comment_prefix , gtid_pos );
6351- set_gtid_done = 1 ;
6355+ mysql_free_result (slave );
6356+ return 1 ;
63526357 }
6358+ print_comment (md_result_file , 0 ,
6359+ "-- GTID position to start replication:\n" );
6360+ fprintf (md_result_file , "%sSET GLOBAL gtid_slave_pos='%s';\n" ,
6361+ gtid_comment_prefix , gtid_pos );
6362+ }
6363+ if (use_gtid )
6364+ print_comment (md_result_file , 0 ,
6365+ "\n-- Use only the MASTER_USE_GTID=slave_pos or "
6366+ "MASTER_LOG_FILE/MASTER_LOG_POS in the statements below."
6367+ "\n\n" );
6368+
6369+ while ((row = mysql_fetch_row (slave )))
6370+ {
63536371 if (row [9 + multi_source ] && row [21 + multi_source ])
63546372 {
63556373 if (use_gtid )
@@ -6363,11 +6381,6 @@ static int do_show_slave_status(MYSQL *mysql_con, int use_gtid,
63636381 }
63646382
63656383 /* SHOW MASTER STATUS reports file and position */
6366- if (opt_comments )
6367- fprintf (md_result_file ,
6368- "\n--\n-- Position to start replication or point-in-time "
6369- "recovery from (the master of this slave)\n--\n\n" );
6370-
63716384 if (multi_source )
63726385 fprintf (md_result_file , "%sCHANGE MASTER '%.80s' TO " ,
63736386 nogtid_comment_prefix , row [0 ]);
@@ -6388,6 +6401,7 @@ static int do_show_slave_status(MYSQL *mysql_con, int use_gtid,
63886401 check_io (md_result_file );
63896402 }
63906403 }
6404+ fprintf (md_result_file , "\n" );
63916405 mysql_free_result (slave );
63926406 return 0 ;
63936407}
0 commit comments