=== modified file 'client/mysqlbinlog.cc' --- client/mysqlbinlog.cc revid:aditya.a@oracle.com-20140701112950-1kp3fc8vycqm9g1r +++ client/mysqlbinlog.cc revid:venkatesh.duggirala@oracle.com-20140701115254-bjv5vbir0agq2e28 @@ -232,7 +232,9 @@ const char* logname); static Exit_status dump_remote_log_entries(PRINT_EVENT_INFO *print_event_info, const char* logname); -static Exit_status dump_log_entries(const char* logname); +static Exit_status dump_single_log(PRINT_EVENT_INFO *print_event_info, + const char* logname); +static Exit_status dump_multiple_logs(int argc, char **argv); static Exit_status safe_connect(); struct buff_event_info buff_event; @@ -953,9 +955,20 @@ { in_transaction= false; print_event_info->skipped_event_in_transaction= false; + if (print_event_info->is_gtid_next_set) + print_event_info->is_gtid_next_valid= false; } else if (starts_group) in_transaction= true; + else + { + /* + We are not in a transaction and are not seeing a BEGIN or + COMMIT. So this is an implicitly committing DDL. + */ + if (print_event_info->is_gtid_next_set && !in_transaction) + print_event_info->is_gtid_next_valid= false; + } ev->print(result_file, print_event_info); if (head->error == -1) @@ -1296,6 +1309,8 @@ case GTID_LOG_EVENT: { seen_gtids= true; + print_event_info->is_gtid_next_set= true; + print_event_info->is_gtid_next_valid= true; if (print_event_info->skipped_event_in_transaction == true) fprintf(result_file, "COMMIT /* added by mysqlbinlog */%s\n", print_event_info->delimiter); print_event_info->skipped_event_in_transaction= false; @@ -1309,6 +1324,8 @@ { in_transaction= false; print_event_info->skipped_event_in_transaction= false; + if (print_event_info->is_gtid_next_set) + print_event_info->is_gtid_next_valid= false; ev->print(result_file, print_event_info); if (head->error == -1) goto err; @@ -1331,9 +1348,11 @@ since there may be no gtids on the next one. */ seen_gtids= false; - fprintf(result_file, "SET @@SESSION.GTID_NEXT= 'AUTOMATIC' " - "/* added by mysqlbinlog */ %s\n", - print_event_info->delimiter); + fprintf(result_file, "%sAUTOMATIC' /* added by mysqlbinlog */ %s\n", + Gtid_log_event::SET_STRING_PREFIX, + print_event_info->delimiter); + print_event_info->is_gtid_next_set= false; + print_event_info->is_gtid_next_valid= true; } } ev->print(result_file, print_event_info); @@ -1936,11 +1955,35 @@ @retval OK_STOP No error, but the end of the specified range of events to process has been reached and the program should terminate. */ -static Exit_status dump_log_entries(const char* logname) -{ - DBUG_ENTER("dump_log_entries"); - - Exit_status rc= OK_CONTINUE; +static Exit_status dump_single_log(PRINT_EVENT_INFO *print_event_info, + const char* logname) +{ + DBUG_ENTER("dump_single_log"); + + Exit_status rc= OK_CONTINUE; + + switch (opt_remote_proto) + { + case BINLOG_LOCAL: + rc= dump_local_log_entries(print_event_info, logname); + break; + case BINLOG_DUMP_NON_GTID: + case BINLOG_DUMP_GTID: + rc= dump_remote_log_entries(print_event_info, logname); + break; + default: + DBUG_ASSERT(0); + break; + } + DBUG_RETURN(rc); +} + + +static Exit_status dump_multiple_logs(int argc, char **argv) +{ + DBUG_ENTER("dump_multiple_logs"); + Exit_status rc= OK_CONTINUE; + PRINT_EVENT_INFO print_event_info; if (!print_event_info.init_ok()) DBUG_RETURN(ERROR_STOP); @@ -1959,18 +2002,18 @@ print_event_info.base64_output_mode= opt_base64_output_mode; print_event_info.skip_gtids= opt_skip_gtids; - switch (opt_remote_proto) + // Dump all logs. + my_off_t save_stop_position= stop_position; + stop_position= ~(my_off_t)0; + for (int i= 0; i < argc; i++) { - case BINLOG_LOCAL: - rc= dump_local_log_entries(&print_event_info, logname); - break; - case BINLOG_DUMP_NON_GTID: - case BINLOG_DUMP_GTID: - rc= dump_remote_log_entries(&print_event_info, logname); - break; - default: - DBUG_ASSERT(0); - break; + if (i == argc - 1) // last log, --stop-position applies + stop_position= save_stop_position; + if ((rc= dump_single_log(&print_event_info, argv[i])) != OK_CONTINUE) + break; + + // For next log, --start-position does not apply + start_position= BIN_LOG_HEADER_SIZE; } if (!buff_ev->empty()) @@ -1997,6 +2040,14 @@ if (print_event_info.skipped_event_in_transaction) fprintf(result_file, "COMMIT /* added by mysqlbinlog */%s\n", print_event_info.delimiter); + if (!print_event_info.is_gtid_next_valid) + { + fprintf(result_file, "%sAUTOMATIC' /* added by mysqlbinlog */%s\n", + Gtid_log_event::SET_STRING_PREFIX, + print_event_info.delimiter); + print_event_info.is_gtid_next_set= false; + print_event_info.is_gtid_next_valid= true; + } fprintf(result_file, "DELIMITER ;\n"); my_stpcpy(print_event_info.delimiter, ";"); } @@ -2920,7 +2971,6 @@ { char **defaults_argv; Exit_status retval= OK_CONTINUE; - ulonglong save_stop_position; MY_INIT(argv[0]); DBUG_ENTER("main"); DBUG_PROCESS(argv[0]); @@ -3016,17 +3066,7 @@ fprintf(result_file, "/*!50700 SET @@SESSION.RBR_EXEC_MODE=IDEMPOTENT*/;\n\n"); - for (save_stop_position= stop_position, stop_position= ~(my_off_t)0 ; - (--argc >= 0) ; ) - { - if (argc == 0) // last log, --stop-position applies - stop_position= save_stop_position; - if ((retval= dump_log_entries(*argv++)) != OK_CONTINUE) - break; - - // For next log, --start-position does not apply - start_position= BIN_LOG_HEADER_SIZE; - } + retval= dump_multiple_logs(argc, argv); if (!raw_mode) { === modified file 'mysql-test/suite/binlog/r/binlog_gtid_mysqlbinlog_start_stop.result' --- mysql-test/suite/binlog/r/binlog_gtid_mysqlbinlog_start_stop.result revid:aditya.a@oracle.com-20140701112950-1kp3fc8vycqm9g1r +++ mysql-test/suite/binlog/r/binlog_gtid_mysqlbinlog_start_stop.result revid:venkatesh.duggirala@oracle.com-20140701115254-bjv5vbir0agq2e28 @@ -174,6 +174,7 @@ INSERT INTO t1 VALUES(2) /*!*/; COMMIT/*!*/; +SET @@SESSION.GTID_NEXT= 'GTID' /* added by mysqlbinlog *//*!*/; DELIMITER ; # End of log file ROLLBACK /* added by mysqlbinlog */; @@ -202,6 +203,7 @@ INSERT INTO t1 VALUES(2) /*!*/; COMMIT/*!*/; +SET @@SESSION.GTID_NEXT= 'GTID' /* added by mysqlbinlog *//*!*/; DELIMITER ; # End of log file ROLLBACK /* added by mysqlbinlog */; @@ -276,6 +278,7 @@ INSERT INTO t1 VALUES(1) /*!*/; COMMIT/*!*/; +SET @@SESSION.GTID_NEXT= 'GTID' /* added by mysqlbinlog *//*!*/; DELIMITER ; # End of log file ROLLBACK /* added by mysqlbinlog */; @@ -304,6 +307,7 @@ INSERT INTO t1 VALUES(1) /*!*/; COMMIT/*!*/; +SET @@SESSION.GTID_NEXT= 'GTID' /* added by mysqlbinlog *//*!*/; DELIMITER ; # End of log file ROLLBACK /* added by mysqlbinlog */; @@ -352,22 +356,11 @@ /*!*/; COMMIT/*!*/; SET @@SESSION.GTID_NEXT= 'GTID' /* added by mysqlbinlog */ /*!*/; -DELIMITER ; -DELIMITER /*!*/; # UUID:#-# SET @@SESSION.GTID_NEXT= 'GTID'/*!*/; SET TIMESTAMP=2019718800/*!*/; -SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; -SET @@session.sql_mode=1073741824/*!*/; -SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; -/*!\C latin1 *//*!*/; -SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/; -SET @@session.lc_time_names=0/*!*/; -SET @@session.collation_database=DEFAULT/*!*/; BEGIN /*!*/; -use `test`/*!*/; SET TIMESTAMP=2019718800/*!*/; INSERT INTO t1 VALUES(4) /*!*/; @@ -426,22 +419,11 @@ /*!*/; COMMIT/*!*/; SET @@SESSION.GTID_NEXT= 'GTID' /* added by mysqlbinlog */ /*!*/; -DELIMITER ; -DELIMITER /*!*/; # UUID:#-# SET @@SESSION.GTID_NEXT= 'GTID'/*!*/; SET TIMESTAMP=2019718800/*!*/; -SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; -SET @@session.sql_mode=1073741824/*!*/; -SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; -/*!\C latin1 *//*!*/; -SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/; -SET @@session.lc_time_names=0/*!*/; -SET @@session.collation_database=DEFAULT/*!*/; BEGIN /*!*/; -use `test`/*!*/; SET TIMESTAMP=2019718800/*!*/; INSERT INTO t1 VALUES(4) /*!*/; @@ -492,22 +474,11 @@ /*!*/; COMMIT/*!*/; SET @@SESSION.GTID_NEXT= 'GTID' /* added by mysqlbinlog */ /*!*/; -DELIMITER ; -DELIMITER /*!*/; # UUID:#-# SET @@SESSION.GTID_NEXT= 'GTID'/*!*/; SET TIMESTAMP=2019718800/*!*/; -SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; -SET @@session.sql_mode=1073741824/*!*/; -SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; -/*!\C latin1 *//*!*/; -SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/; -SET @@session.lc_time_names=0/*!*/; -SET @@session.collation_database=DEFAULT/*!*/; BEGIN /*!*/; -use `test`/*!*/; SET TIMESTAMP=2019718800/*!*/; INSERT INTO t1 VALUES(4) /*!*/; @@ -567,26 +538,16 @@ /*!*/; COMMIT/*!*/; SET @@SESSION.GTID_NEXT= 'GTID' /* added by mysqlbinlog */ /*!*/; -DELIMITER ; -DELIMITER /*!*/; # UUID:#-# SET @@SESSION.GTID_NEXT= 'GTID'/*!*/; SET TIMESTAMP=2019718800/*!*/; -SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; -SET @@session.sql_mode=1073741824/*!*/; -SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; -/*!\C latin1 *//*!*/; -SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/; -SET @@session.lc_time_names=0/*!*/; -SET @@session.collation_database=DEFAULT/*!*/; BEGIN /*!*/; -use `test`/*!*/; SET TIMESTAMP=2019718800/*!*/; INSERT INTO t1 VALUES(4) /*!*/; COMMIT/*!*/; +SET @@SESSION.GTID_NEXT= 'GTID' /* added by mysqlbinlog *//*!*/; DELIMITER ; # End of log file ROLLBACK /* added by mysqlbinlog */; @@ -624,26 +585,16 @@ /*!*/; COMMIT/*!*/; SET @@SESSION.GTID_NEXT= 'GTID' /* added by mysqlbinlog */ /*!*/; -DELIMITER ; -DELIMITER /*!*/; # UUID:#-# SET @@SESSION.GTID_NEXT= 'GTID'/*!*/; SET TIMESTAMP=2019718800/*!*/; -SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; -SET @@session.sql_mode=1073741824/*!*/; -SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; -/*!\C latin1 *//*!*/; -SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/; -SET @@session.lc_time_names=0/*!*/; -SET @@session.collation_database=DEFAULT/*!*/; BEGIN /*!*/; -use `test`/*!*/; SET TIMESTAMP=2019718800/*!*/; INSERT INTO t1 VALUES(4) /*!*/; COMMIT/*!*/; +SET @@SESSION.GTID_NEXT= 'GTID' /* added by mysqlbinlog *//*!*/; DELIMITER ; # End of log file ROLLBACK /* added by mysqlbinlog */; @@ -689,22 +640,11 @@ /*!*/; COMMIT/*!*/; SET @@SESSION.GTID_NEXT= 'GTID' /* added by mysqlbinlog */ /*!*/; -DELIMITER ; -DELIMITER /*!*/; # UUID:#-# SET @@SESSION.GTID_NEXT= 'GTID'/*!*/; SET TIMESTAMP=2019718800/*!*/; -SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; -SET @@session.sql_mode=1073741824/*!*/; -SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; -/*!\C latin1 *//*!*/; -SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/; -SET @@session.lc_time_names=0/*!*/; -SET @@session.collation_database=DEFAULT/*!*/; BEGIN /*!*/; -use `test`/*!*/; SET TIMESTAMP=2019718800/*!*/; INSERT INTO t1 VALUES(4) /*!*/; @@ -764,26 +704,16 @@ /*!*/; COMMIT/*!*/; SET @@SESSION.GTID_NEXT= 'GTID' /* added by mysqlbinlog */ /*!*/; -DELIMITER ; -DELIMITER /*!*/; # UUID:#-# SET @@SESSION.GTID_NEXT= 'GTID'/*!*/; SET TIMESTAMP=2019718800/*!*/; -SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; -SET @@session.sql_mode=1073741824/*!*/; -SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; -/*!\C latin1 *//*!*/; -SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/; -SET @@session.lc_time_names=0/*!*/; -SET @@session.collation_database=DEFAULT/*!*/; BEGIN /*!*/; -use `test`/*!*/; SET TIMESTAMP=2019718800/*!*/; INSERT INTO t1 VALUES(4) /*!*/; COMMIT/*!*/; +SET @@SESSION.GTID_NEXT= 'GTID' /* added by mysqlbinlog *//*!*/; DELIMITER ; # End of log file ROLLBACK /* added by mysqlbinlog */; @@ -829,26 +759,16 @@ /*!*/; COMMIT/*!*/; SET @@SESSION.GTID_NEXT= 'GTID' /* added by mysqlbinlog */ /*!*/; -DELIMITER ; -DELIMITER /*!*/; # UUID:#-# SET @@SESSION.GTID_NEXT= 'GTID'/*!*/; SET TIMESTAMP=2019718800/*!*/; -SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; -SET @@session.sql_mode=1073741824/*!*/; -SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; -/*!\C latin1 *//*!*/; -SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/; -SET @@session.lc_time_names=0/*!*/; -SET @@session.collation_database=DEFAULT/*!*/; BEGIN /*!*/; -use `test`/*!*/; SET TIMESTAMP=2019718800/*!*/; INSERT INTO t1 VALUES(4) /*!*/; COMMIT/*!*/; +SET @@SESSION.GTID_NEXT= 'GTID' /* added by mysqlbinlog *//*!*/; DELIMITER ; # End of log file ROLLBACK /* added by mysqlbinlog */; @@ -1015,6 +935,7 @@ INSERT INTO t1 VALUES(2) /*!*/; COMMIT/*!*/; +SET @@SESSION.GTID_NEXT= 'GTID' /* added by mysqlbinlog *//*!*/; DELIMITER ; # End of log file ROLLBACK /* added by mysqlbinlog */; @@ -1042,6 +963,7 @@ INSERT INTO t1 VALUES(2) /*!*/; COMMIT/*!*/; +SET @@SESSION.GTID_NEXT= 'GTID' /* added by mysqlbinlog *//*!*/; DELIMITER ; # End of log file ROLLBACK /* added by mysqlbinlog */; @@ -1116,6 +1038,7 @@ INSERT INTO t1 VALUES(1) /*!*/; COMMIT/*!*/; +SET @@SESSION.GTID_NEXT= 'GTID' /* added by mysqlbinlog *//*!*/; DELIMITER ; # End of log file ROLLBACK /* added by mysqlbinlog */; @@ -1144,6 +1067,7 @@ INSERT INTO t1 VALUES(1) /*!*/; COMMIT/*!*/; +SET @@SESSION.GTID_NEXT= 'GTID' /* added by mysqlbinlog *//*!*/; DELIMITER ; # End of log file ROLLBACK /* added by mysqlbinlog */; @@ -1192,22 +1116,11 @@ /*!*/; COMMIT/*!*/; SET @@SESSION.GTID_NEXT= 'GTID' /* added by mysqlbinlog */ /*!*/; -DELIMITER ; -DELIMITER /*!*/; # UUID:#-# SET @@SESSION.GTID_NEXT= 'GTID'/*!*/; SET TIMESTAMP=2019718800/*!*/; -SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; -SET @@session.sql_mode=1073741824/*!*/; -SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; -/*!\C latin1 *//*!*/; -SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/; -SET @@session.lc_time_names=0/*!*/; -SET @@session.collation_database=DEFAULT/*!*/; BEGIN /*!*/; -use `test`/*!*/; SET TIMESTAMP=2019718800/*!*/; INSERT INTO t1 VALUES(4) /*!*/; @@ -1266,22 +1179,11 @@ /*!*/; COMMIT/*!*/; SET @@SESSION.GTID_NEXT= 'GTID' /* added by mysqlbinlog */ /*!*/; -DELIMITER ; -DELIMITER /*!*/; # UUID:#-# SET @@SESSION.GTID_NEXT= 'GTID'/*!*/; SET TIMESTAMP=2019718800/*!*/; -SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; -SET @@session.sql_mode=1073741824/*!*/; -SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; -/*!\C latin1 *//*!*/; -SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/; -SET @@session.lc_time_names=0/*!*/; -SET @@session.collation_database=DEFAULT/*!*/; BEGIN /*!*/; -use `test`/*!*/; SET TIMESTAMP=2019718800/*!*/; INSERT INTO t1 VALUES(4) /*!*/; @@ -1331,22 +1233,11 @@ /*!*/; COMMIT/*!*/; SET @@SESSION.GTID_NEXT= 'GTID' /* added by mysqlbinlog */ /*!*/; -DELIMITER ; -DELIMITER /*!*/; # UUID:#-# SET @@SESSION.GTID_NEXT= 'GTID'/*!*/; SET TIMESTAMP=2019718800/*!*/; -SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; -SET @@session.sql_mode=1073741824/*!*/; -SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; -/*!\C latin1 *//*!*/; -SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/; -SET @@session.lc_time_names=0/*!*/; -SET @@session.collation_database=DEFAULT/*!*/; BEGIN /*!*/; -use `test`/*!*/; SET TIMESTAMP=2019718800/*!*/; INSERT INTO t1 VALUES(4) /*!*/; @@ -1406,26 +1297,16 @@ /*!*/; COMMIT/*!*/; SET @@SESSION.GTID_NEXT= 'GTID' /* added by mysqlbinlog */ /*!*/; -DELIMITER ; -DELIMITER /*!*/; # UUID:#-# SET @@SESSION.GTID_NEXT= 'GTID'/*!*/; SET TIMESTAMP=2019718800/*!*/; -SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; -SET @@session.sql_mode=1073741824/*!*/; -SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; -/*!\C latin1 *//*!*/; -SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/; -SET @@session.lc_time_names=0/*!*/; -SET @@session.collation_database=DEFAULT/*!*/; BEGIN /*!*/; -use `test`/*!*/; SET TIMESTAMP=2019718800/*!*/; INSERT INTO t1 VALUES(4) /*!*/; COMMIT/*!*/; +SET @@SESSION.GTID_NEXT= 'GTID' /* added by mysqlbinlog *//*!*/; DELIMITER ; # End of log file ROLLBACK /* added by mysqlbinlog */; @@ -1462,26 +1343,16 @@ /*!*/; COMMIT/*!*/; SET @@SESSION.GTID_NEXT= 'GTID' /* added by mysqlbinlog */ /*!*/; -DELIMITER ; -DELIMITER /*!*/; # UUID:#-# SET @@SESSION.GTID_NEXT= 'GTID'/*!*/; SET TIMESTAMP=2019718800/*!*/; -SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; -SET @@session.sql_mode=1073741824/*!*/; -SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; -/*!\C latin1 *//*!*/; -SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/; -SET @@session.lc_time_names=0/*!*/; -SET @@session.collation_database=DEFAULT/*!*/; BEGIN /*!*/; -use `test`/*!*/; SET TIMESTAMP=2019718800/*!*/; INSERT INTO t1 VALUES(4) /*!*/; COMMIT/*!*/; +SET @@SESSION.GTID_NEXT= 'GTID' /* added by mysqlbinlog *//*!*/; DELIMITER ; # End of log file ROLLBACK /* added by mysqlbinlog */; @@ -1527,22 +1398,11 @@ /*!*/; COMMIT/*!*/; SET @@SESSION.GTID_NEXT= 'GTID' /* added by mysqlbinlog */ /*!*/; -DELIMITER ; -DELIMITER /*!*/; # UUID:#-# SET @@SESSION.GTID_NEXT= 'GTID'/*!*/; SET TIMESTAMP=2019718800/*!*/; -SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; -SET @@session.sql_mode=1073741824/*!*/; -SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; -/*!\C latin1 *//*!*/; -SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/; -SET @@session.lc_time_names=0/*!*/; -SET @@session.collation_database=DEFAULT/*!*/; BEGIN /*!*/; -use `test`/*!*/; SET TIMESTAMP=2019718800/*!*/; INSERT INTO t1 VALUES(4) /*!*/; @@ -1602,26 +1462,16 @@ /*!*/; COMMIT/*!*/; SET @@SESSION.GTID_NEXT= 'GTID' /* added by mysqlbinlog */ /*!*/; -DELIMITER ; -DELIMITER /*!*/; # UUID:#-# SET @@SESSION.GTID_NEXT= 'GTID'/*!*/; SET TIMESTAMP=2019718800/*!*/; -SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; -SET @@session.sql_mode=1073741824/*!*/; -SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; -/*!\C latin1 *//*!*/; -SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/; -SET @@session.lc_time_names=0/*!*/; -SET @@session.collation_database=DEFAULT/*!*/; BEGIN /*!*/; -use `test`/*!*/; SET TIMESTAMP=2019718800/*!*/; INSERT INTO t1 VALUES(4) /*!*/; COMMIT/*!*/; +SET @@SESSION.GTID_NEXT= 'GTID' /* added by mysqlbinlog *//*!*/; DELIMITER ; # End of log file ROLLBACK /* added by mysqlbinlog */; @@ -1667,26 +1517,16 @@ /*!*/; COMMIT/*!*/; SET @@SESSION.GTID_NEXT= 'GTID' /* added by mysqlbinlog */ /*!*/; -DELIMITER ; -DELIMITER /*!*/; # UUID:#-# SET @@SESSION.GTID_NEXT= 'GTID'/*!*/; SET TIMESTAMP=2019718800/*!*/; -SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; -SET @@session.sql_mode=1073741824/*!*/; -SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; -/*!\C latin1 *//*!*/; -SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/; -SET @@session.lc_time_names=0/*!*/; -SET @@session.collation_database=DEFAULT/*!*/; BEGIN /*!*/; -use `test`/*!*/; SET TIMESTAMP=2019718800/*!*/; INSERT INTO t1 VALUES(4) /*!*/; COMMIT/*!*/; +SET @@SESSION.GTID_NEXT= 'GTID' /* added by mysqlbinlog *//*!*/; DELIMITER ; # End of log file ROLLBACK /* added by mysqlbinlog */; === added file 'mysql-test/suite/binlog/r/binlog_mysqlbinlog_concat.result' --- mysql-test/suite/binlog/r/binlog_mysqlbinlog_concat.result 1970-01-01 00:00:00 +0000 +++ mysql-test/suite/binlog/r/binlog_mysqlbinlog_concat.result revid:venkatesh.duggirala@oracle.com-20140701115254-bjv5vbir0agq2e28 @@ -0,0 +1,20 @@ +include/rpl_init.inc [topology=none] +include/rpl_default_connections.inc +CREATE TABLE t1(i INT); +INSERT INTO t1 values (1); +include/rpl_restart_server.inc [server_number=1 parameters: --gtid-mode=off] +CREATE TABLE t2(i INT); +INSERT INTO t2 values (2); +include/rpl_restart_server.inc [server_number=1 parameters: --gtid-mode=on] +CREATE TABLE t3(i INT); +INSERT INTO t3 values (3); +FLUSH LOGS; +DROP TABLE t1,t2,t3; +RESET MASTER; +SELECT * FROM t1; +i +1 +SELECT * FROM t2; +i +2 +DROP TABLE t1,t2; === modified file 'mysql-test/suite/binlog/r/binlog_mysqlbinlog_start_stop.result' --- mysql-test/suite/binlog/r/binlog_mysqlbinlog_start_stop.result revid:aditya.a@oracle.com-20140701112950-1kp3fc8vycqm9g1r +++ mysql-test/suite/binlog/r/binlog_mysqlbinlog_start_stop.result revid:venkatesh.duggirala@oracle.com-20140701115254-bjv5vbir0agq2e28 @@ -321,20 +321,9 @@ INSERT INTO t1 VALUES(3) /*!*/; COMMIT/*!*/; -DELIMITER ; -DELIMITER /*!*/; SET TIMESTAMP=2019718800/*!*/; -SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; -SET @@session.sql_mode=1073741824/*!*/; -SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; -/*!\C latin1 *//*!*/; -SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/; -SET @@session.lc_time_names=0/*!*/; -SET @@session.collation_database=DEFAULT/*!*/; BEGIN /*!*/; -use `test`/*!*/; SET TIMESTAMP=2019718800/*!*/; INSERT INTO t1 VALUES(4) /*!*/; @@ -384,20 +373,9 @@ INSERT INTO t1 VALUES(3) /*!*/; COMMIT/*!*/; -DELIMITER ; -DELIMITER /*!*/; SET TIMESTAMP=2019718800/*!*/; -SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; -SET @@session.sql_mode=1073741824/*!*/; -SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; -/*!\C latin1 *//*!*/; -SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/; -SET @@session.lc_time_names=0/*!*/; -SET @@session.collation_database=DEFAULT/*!*/; BEGIN /*!*/; -use `test`/*!*/; SET TIMESTAMP=2019718800/*!*/; INSERT INTO t1 VALUES(4) /*!*/; @@ -443,20 +421,9 @@ INSERT INTO t1 VALUES(3) /*!*/; COMMIT/*!*/; -DELIMITER ; -DELIMITER /*!*/; SET TIMESTAMP=2019718800/*!*/; -SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; -SET @@session.sql_mode=1073741824/*!*/; -SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; -/*!\C latin1 *//*!*/; -SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/; -SET @@session.lc_time_names=0/*!*/; -SET @@session.collation_database=DEFAULT/*!*/; BEGIN /*!*/; -use `test`/*!*/; SET TIMESTAMP=2019718800/*!*/; INSERT INTO t1 VALUES(4) /*!*/; @@ -509,20 +476,9 @@ INSERT INTO t1 VALUES(3) /*!*/; COMMIT/*!*/; -DELIMITER ; -DELIMITER /*!*/; SET TIMESTAMP=2019718800/*!*/; -SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; -SET @@session.sql_mode=1073741824/*!*/; -SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; -/*!\C latin1 *//*!*/; -SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/; -SET @@session.lc_time_names=0/*!*/; -SET @@session.collation_database=DEFAULT/*!*/; BEGIN /*!*/; -use `test`/*!*/; SET TIMESTAMP=2019718800/*!*/; INSERT INTO t1 VALUES(4) /*!*/; @@ -561,20 +517,9 @@ INSERT INTO t1 VALUES(3) /*!*/; COMMIT/*!*/; -DELIMITER ; -DELIMITER /*!*/; SET TIMESTAMP=2019718800/*!*/; -SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; -SET @@session.sql_mode=1073741824/*!*/; -SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; -/*!\C latin1 *//*!*/; -SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/; -SET @@session.lc_time_names=0/*!*/; -SET @@session.collation_database=DEFAULT/*!*/; BEGIN /*!*/; -use `test`/*!*/; SET TIMESTAMP=2019718800/*!*/; INSERT INTO t1 VALUES(4) /*!*/; @@ -620,20 +565,9 @@ INSERT INTO t1 VALUES(3) /*!*/; COMMIT/*!*/; -DELIMITER ; -DELIMITER /*!*/; SET TIMESTAMP=2019718800/*!*/; -SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; -SET @@session.sql_mode=1073741824/*!*/; -SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; -/*!\C latin1 *//*!*/; -SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/; -SET @@session.lc_time_names=0/*!*/; -SET @@session.collation_database=DEFAULT/*!*/; BEGIN /*!*/; -use `test`/*!*/; SET TIMESTAMP=2019718800/*!*/; INSERT INTO t1 VALUES(4) /*!*/; @@ -686,20 +620,9 @@ INSERT INTO t1 VALUES(3) /*!*/; COMMIT/*!*/; -DELIMITER ; -DELIMITER /*!*/; SET TIMESTAMP=2019718800/*!*/; -SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; -SET @@session.sql_mode=1073741824/*!*/; -SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; -/*!\C latin1 *//*!*/; -SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/; -SET @@session.lc_time_names=0/*!*/; -SET @@session.collation_database=DEFAULT/*!*/; BEGIN /*!*/; -use `test`/*!*/; SET TIMESTAMP=2019718800/*!*/; INSERT INTO t1 VALUES(4) /*!*/; @@ -745,20 +668,9 @@ INSERT INTO t1 VALUES(3) /*!*/; COMMIT/*!*/; -DELIMITER ; -DELIMITER /*!*/; SET TIMESTAMP=2019718800/*!*/; -SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; -SET @@session.sql_mode=1073741824/*!*/; -SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; -/*!\C latin1 *//*!*/; -SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/; -SET @@session.lc_time_names=0/*!*/; -SET @@session.collation_database=DEFAULT/*!*/; BEGIN /*!*/; -use `test`/*!*/; SET TIMESTAMP=2019718800/*!*/; INSERT INTO t1 VALUES(4) /*!*/; @@ -1075,20 +987,9 @@ INSERT INTO t1 VALUES(3) /*!*/; COMMIT/*!*/; -DELIMITER ; -DELIMITER /*!*/; SET TIMESTAMP=2019718800/*!*/; -SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; -SET @@session.sql_mode=1073741824/*!*/; -SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; -/*!\C latin1 *//*!*/; -SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/; -SET @@session.lc_time_names=0/*!*/; -SET @@session.collation_database=DEFAULT/*!*/; BEGIN /*!*/; -use `test`/*!*/; SET TIMESTAMP=2019718800/*!*/; INSERT INTO t1 VALUES(4) /*!*/; @@ -1138,20 +1039,9 @@ INSERT INTO t1 VALUES(3) /*!*/; COMMIT/*!*/; -DELIMITER ; -DELIMITER /*!*/; SET TIMESTAMP=2019718800/*!*/; -SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; -SET @@session.sql_mode=1073741824/*!*/; -SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; -/*!\C latin1 *//*!*/; -SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/; -SET @@session.lc_time_names=0/*!*/; -SET @@session.collation_database=DEFAULT/*!*/; BEGIN /*!*/; -use `test`/*!*/; SET TIMESTAMP=2019718800/*!*/; INSERT INTO t1 VALUES(4) /*!*/; @@ -1196,20 +1086,9 @@ INSERT INTO t1 VALUES(3) /*!*/; COMMIT/*!*/; -DELIMITER ; -DELIMITER /*!*/; SET TIMESTAMP=2019718800/*!*/; -SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; -SET @@session.sql_mode=1073741824/*!*/; -SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; -/*!\C latin1 *//*!*/; -SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/; -SET @@session.lc_time_names=0/*!*/; -SET @@session.collation_database=DEFAULT/*!*/; BEGIN /*!*/; -use `test`/*!*/; SET TIMESTAMP=2019718800/*!*/; INSERT INTO t1 VALUES(4) /*!*/; @@ -1262,20 +1141,9 @@ INSERT INTO t1 VALUES(3) /*!*/; COMMIT/*!*/; -DELIMITER ; -DELIMITER /*!*/; SET TIMESTAMP=2019718800/*!*/; -SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; -SET @@session.sql_mode=1073741824/*!*/; -SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; -/*!\C latin1 *//*!*/; -SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/; -SET @@session.lc_time_names=0/*!*/; -SET @@session.collation_database=DEFAULT/*!*/; BEGIN /*!*/; -use `test`/*!*/; SET TIMESTAMP=2019718800/*!*/; INSERT INTO t1 VALUES(4) /*!*/; @@ -1313,20 +1181,9 @@ INSERT INTO t1 VALUES(3) /*!*/; COMMIT/*!*/; -DELIMITER ; -DELIMITER /*!*/; SET TIMESTAMP=2019718800/*!*/; -SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; -SET @@session.sql_mode=1073741824/*!*/; -SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; -/*!\C latin1 *//*!*/; -SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/; -SET @@session.lc_time_names=0/*!*/; -SET @@session.collation_database=DEFAULT/*!*/; BEGIN /*!*/; -use `test`/*!*/; SET TIMESTAMP=2019718800/*!*/; INSERT INTO t1 VALUES(4) /*!*/; @@ -1372,20 +1229,9 @@ INSERT INTO t1 VALUES(3) /*!*/; COMMIT/*!*/; -DELIMITER ; -DELIMITER /*!*/; SET TIMESTAMP=2019718800/*!*/; -SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; -SET @@session.sql_mode=1073741824/*!*/; -SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; -/*!\C latin1 *//*!*/; -SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/; -SET @@session.lc_time_names=0/*!*/; -SET @@session.collation_database=DEFAULT/*!*/; BEGIN /*!*/; -use `test`/*!*/; SET TIMESTAMP=2019718800/*!*/; INSERT INTO t1 VALUES(4) /*!*/; @@ -1438,20 +1284,9 @@ INSERT INTO t1 VALUES(3) /*!*/; COMMIT/*!*/; -DELIMITER ; -DELIMITER /*!*/; SET TIMESTAMP=2019718800/*!*/; -SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; -SET @@session.sql_mode=1073741824/*!*/; -SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; -/*!\C latin1 *//*!*/; -SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/; -SET @@session.lc_time_names=0/*!*/; -SET @@session.collation_database=DEFAULT/*!*/; BEGIN /*!*/; -use `test`/*!*/; SET TIMESTAMP=2019718800/*!*/; INSERT INTO t1 VALUES(4) /*!*/; @@ -1497,20 +1332,9 @@ INSERT INTO t1 VALUES(3) /*!*/; COMMIT/*!*/; -DELIMITER ; -DELIMITER /*!*/; SET TIMESTAMP=2019718800/*!*/; -SET @@session.pseudo_thread_id=999999999/*!*/; -SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; -SET @@session.sql_mode=1073741824/*!*/; -SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; -/*!\C latin1 *//*!*/; -SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/; -SET @@session.lc_time_names=0/*!*/; -SET @@session.collation_database=DEFAULT/*!*/; BEGIN /*!*/; -use `test`/*!*/; SET TIMESTAMP=2019718800/*!*/; INSERT INTO t1 VALUES(4) /*!*/; === added file 'mysql-test/suite/binlog/t/binlog_mysqlbinlog_concat.test' --- mysql-test/suite/binlog/t/binlog_mysqlbinlog_concat.test 1970-01-01 00:00:00 +0000 +++ mysql-test/suite/binlog/t/binlog_mysqlbinlog_concat.test revid:venkatesh.duggirala@oracle.com-20140701115254-bjv5vbir0agq2e28 @@ -0,0 +1,103 @@ +################################################################# +# Bug#18258933 CONCATENATION OF MYSQLBINLOG OUTPUT DOES NOT +# WORK WITH GTID + +# Problem: When mysqlbinlog processes and concatenates +# multiple binary log files into one output file, this +# output file is not in useful state. When it is later +# used for point-in-time recovery, it is producing +# ER_GTID_NEXT_TYPE_UNDEFINED_GROUP "ERROR 1837: When +# @@SESSION.GTID_NEXT is set to a GTID, you must explicitly +# set it to a different value after a COMMIT or ROLLBACK. +# Please check GTID_NEXT variable manual page for detailed +# explanation. Current @@SESSION.GTID_NEXT is 'xyz'" + +# Solution: When mysqlbinlog processes second binary log's +# start_log_event, it can output +# "SET GTID_NEXT=AUTOMATIC" if required i.e., if +# previous binary log is leaving the GTID_NEXT state +# in 'undefined' state. + +# Steps to verify the case: +# 1) On a Gtid enabled server, generate some dummy statements +# in binary log ( to generate GTID_NEXT events in binary log 1) +# 2) Restart server with gtid-mode OFF +# 3) On a Gtid disabled sever, generate some dummy statements +# in binary log ( to generate anonymous events in binary log 2) +# 4) Restart server again with gtid-mode ON. +# 5) On a Gtid enabled server, generate some dummy statements +# in binary log ( to generate GTID_NEXT events in binary log 3) +# 6) Concat all three binary logs 1,2 and 3 and apply the generated +# sql against mysql command line tool and it should not cause +# any error (i.e., no ER_GTID_NEXT_TYPE_UNDEFINED_GROUP error) +################################################################# +--source include/have_binlog_format_statement.inc +--source include/have_gtid.inc + +# Use this so that we can use rpl_restart_server.inc later. +--let $rpl_server_count= 1 +--let $rpl_topology= none +--source include/rpl_init.inc +--source include/rpl_default_connections.inc + + +#Initial setup +--let $datadir= `SELECT @@datadir` +--let $binlog_file1= query_get_value(SHOW MASTER STATUS, File, 1) + +# Step 1 : Dummy statements to generate gtid transactions (gtid-mode is ON) +# in binlog_file1 +CREATE TABLE t1(i INT); +INSERT INTO t1 values (1); + +# Step 2: Restart server with gtid-mode off (binlog will be rotated) +--let $rpl_server_number= 1 +--let $rpl_server_parameters= --gtid-mode=off +--source include/rpl_restart_server.inc +--let $binlog_file2= query_get_value(SHOW MASTER STATUS, File, 1) + +# Step 3: Dummy statements to generate anonymous transactions +# (gtid-mode is OFF) +CREATE TABLE t2(i INT); +INSERT INTO t2 values (2); + +# Step 4: Restart server with gtid-mode ON (binlog will be rotated) +--let $rpl_server_number= 1 +--let $rpl_server_parameters= --gtid-mode=on +--source include/rpl_restart_server.inc +--let $binlog_file3= query_get_value(SHOW MASTER STATUS, File, 1) + +# Step 5 : Dummy statements to generate gtid transactions (gtid-mode is ON) +# in binlog_file3 +CREATE TABLE t3(i INT); +INSERT INTO t3 values (3); + +# Clean up command (let DROP TABLE be in binary log 4, when we apply +# all three binary logs, we can select the data and verify that the +# data is there. +FLUSH LOGS; +DROP TABLE t1,t2,t3; + +# Step 6: Combine binlog_file1, binlog_file2, binlog_file3 and generate +# a .sql file. +--exec $MYSQL_BINLOG --force-if-open $datadir/$binlog_file1 $datadir/$binlog_file2 $datadir/$binlog_file3 > $MYSQLTEST_VARDIR/tmp/concat_three_files.sql + +# Execute reset master, so that when we are applying gtid transactions, +# they should not skipped. +RESET MASTER; + +# Step 7: Apply the generated .sql through mysql command line tool +# and it should not cause any issues +--exec $MYSQL --user=root --host=127.0.0.1 --port=$MASTER_MYPORT < $MYSQLTEST_VARDIR/tmp/concat_three_files.sql + +# Step 8: Verify the data in t1 and t2 +# [NOTE] there will not be table t3 created because CREATE TABLE t2, INSERT INTO t2 +# (originally anonymous transactions) now occupies gtid numbers 3 and 4, +# hence CREATE TABLE t3, INSERT INTO t3(which has originally gtid numbers 3 +# and 4) will be skipped when we are reapplying them. +SELECT * FROM t1; +SELECT * FROM t2; + +# Clean up +DROP TABLE t1,t2; +--remove_file $MYSQLTEST_VARDIR/tmp/concat_three_files.sql === modified file 'sql/log_event.cc' --- sql/log_event.cc revid:aditya.a@oracle.com-20140701112950-1kp3fc8vycqm9g1r +++ sql/log_event.cc revid:venkatesh.duggirala@oracle.com-20140701115254-bjv5vbir0agq2e28 @@ -5398,8 +5398,19 @@ my_b_printf(head,"RESET CONNECTION%s\n", print_event_info->delimiter); #else my_b_printf(head,"ROLLBACK%s\n", print_event_info->delimiter); + if (print_event_info->is_gtid_next_set) + print_event_info->is_gtid_next_valid= false; #endif } + // set gtid_next=automatic if we have previously set it to uuid:number + if (!print_event_info->is_gtid_next_valid) + { + my_b_printf(head, "%sAUTOMATIC'%s\n", + Gtid_log_event::SET_STRING_PREFIX, + print_event_info->delimiter); + print_event_info->is_gtid_next_set= false; + print_event_info->is_gtid_next_valid= true; + } if (temp_buf && print_event_info->base64_output_mode != BASE64_OUTPUT_NEVER && !print_event_info->short_form) @@ -13957,7 +13968,8 @@ charset_database_number(ILLEGAL_CHARSET_INFO_NUMBER), thread_id(0), thread_id_printed(false), base64_output_mode(BASE64_OUTPUT_UNSPEC), printed_fd_event(FALSE), - have_unflushed_events(FALSE), skipped_event_in_transaction(false) + have_unflushed_events(false), skipped_event_in_transaction(false), + is_gtid_next_set(false), is_gtid_next_valid(true) { /* Currently we only use static PRINT_EVENT_INFO objects, so zeroed at === modified file 'sql/log_event.h' --- sql/log_event.h revid:aditya.a@oracle.com-20140701112950-1kp3fc8vycqm9g1r +++ sql/log_event.h revid:venkatesh.duggirala@oracle.com-20140701115254-bjv5vbir0agq2e28 @@ -876,6 +876,23 @@ False, otherwise. */ bool skipped_event_in_transaction; + + /* true if gtid_next is set with a value */ + bool is_gtid_next_set; + + /* + Determines if the current value of gtid_next needs to be restored + to AUTOMATIC if the binary log would end after the current event. + + If the log ends after a transaction, then this should be false. + If the log ends in the middle of a transaction, then this should + be true; this can happen for relay logs where transactions are + split over multiple logs. + + Set to true initially, and after a Gtid_log_event is processed. + Set to false if is_gtid_next_set is true. + */ + bool is_gtid_next_valid; } PRINT_EVENT_INFO; #endif @@ -5139,9 +5156,9 @@ /// Return true if this is the last group of the transaction, else false. bool get_commit_flag() const { return commit_flag; } -private: /// string holding the text "SET @@GLOBAL.GTID_NEXT = '" static const char *SET_STRING_PREFIX; +private: /// Length of SET_STRING_PREFIX static const size_t SET_STRING_PREFIX_LENGTH= 26; /// The maximal length of the entire "SET ..." query.