@@ -1266,8 +1266,9 @@ static int get_options(int *argc, char ***argv)
1266
1266
if (opt_slave_data )
1267
1267
{
1268
1268
opt_lock_all_tables = !opt_single_transaction ;
1269
- opt_master_data = 0 ;
1270
1269
opt_delete_master_logs = 0 ;
1270
+ if (opt_slave_data != MYSQL_OPT_SLAVE_DATA_COMMENTED_SQL )
1271
+ opt_master_data = 0 ;
1271
1272
}
1272
1273
1273
1274
/* Ensure consistency of the set of binlog & locking options */
@@ -1280,10 +1281,7 @@ static int get_options(int *argc, char ***argv)
1280
1281
return (EX_USAGE );
1281
1282
}
1282
1283
if (opt_master_data )
1283
- {
1284
1284
opt_lock_all_tables = !opt_single_transaction ;
1285
- opt_slave_data = 0 ;
1286
- }
1287
1285
if (opt_single_transaction || opt_lock_all_tables )
1288
1286
lock_tables = 0 ;
1289
1287
if (enclosed && opt_enclosed )
@@ -6220,17 +6218,12 @@ static int do_show_master_status(MYSQL *mysql_con, int consistent_binlog_pos,
6220
6218
6221
6219
}
6222
6220
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 */
6230
6222
if (have_mariadb_gtid )
6231
6223
{
6232
6224
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" );
6234
6227
if (use_gtid )
6235
6228
fprintf (md_result_file ,
6236
6229
"%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,
6239
6232
"%sSET GLOBAL gtid_slave_pos='%s';\n" ,
6240
6233
(!use_gtid ? "-- " : comment_prefix ), gtid_pos );
6241
6234
}
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 );
6242
6248
check_io (md_result_file );
6243
6249
6244
6250
if (!consistent_binlog_pos )
@@ -6317,7 +6323,6 @@ static int do_show_slave_status(MYSQL *mysql_con, int use_gtid,
6317
6323
(opt_slave_data == MYSQL_OPT_SLAVE_DATA_COMMENTED_SQL ) ? "-- " : "" ;
6318
6324
const char * gtid_comment_prefix = (use_gtid ? comment_prefix : "-- " );
6319
6325
const char * nogtid_comment_prefix = (!use_gtid ? comment_prefix : "-- " );
6320
- int set_gtid_done = 0 ;
6321
6326
6322
6327
if (mysql_query_with_error_report (mysql_con , & slave ,
6323
6328
multi_source ?
@@ -6333,23 +6338,36 @@ static int do_show_slave_status(MYSQL *mysql_con, int use_gtid,
6333
6338
return 1 ;
6334
6339
}
6335
6340
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 )
6337
6351
{
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 ))
6339
6354
{
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 ;
6352
6357
}
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
+ {
6353
6371
if (row [9 + multi_source ] && row [21 + multi_source ])
6354
6372
{
6355
6373
if (use_gtid )
@@ -6363,11 +6381,6 @@ static int do_show_slave_status(MYSQL *mysql_con, int use_gtid,
6363
6381
}
6364
6382
6365
6383
/* 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
-
6371
6384
if (multi_source )
6372
6385
fprintf (md_result_file , "%sCHANGE MASTER '%.80s' TO " ,
6373
6386
nogtid_comment_prefix , row [0 ]);
@@ -6388,6 +6401,7 @@ static int do_show_slave_status(MYSQL *mysql_con, int use_gtid,
6388
6401
check_io (md_result_file );
6389
6402
}
6390
6403
}
6404
+ fprintf (md_result_file , "\n" );
6391
6405
mysql_free_result (slave );
6392
6406
return 0 ;
6393
6407
}
0 commit comments