mariadb/mysql-test/suite/rpl/t
sven@riska.(none) 5cc348a6a6 BUG#32407: Impossible to do point-in-time recovery from older binlog
Problem: it is unsafe to read base64-printed events without first
reading the Format_description_log_event (FD).  Currently, mysqlbinlog
cannot print the FD.

As a side effect, another bug has also been fixed: When mysqlbinlog
--start-position=X was specified, no ROLLBACK was printed. I changed
this, so that ROLLBACK is always printed.

This patch does several things:

 - Format_description_log_event (FD) now print themselves in base64
   format.

 - mysqlbinlog is now able to print FD events.  It has three modes:
    --base64-output=auto    Print row events in base64 output, and print
                            FD event.  The FD event is printed even if
                            it is outside the range specified with
                            --start-position, because it would not be
                            safe to read row events otherwise. This is
                            the default.

    --base64-output=always  Like --base64-output=auto, but also print
                            base64 output for query events.  This is
                            like the old --base64-output flag, which
                            is also a shorthand for
                            --base64-output=always

    --base64-output=never   Never print base64 output, generate error if
                            row events occur in binlog.  This is
                            useful to suppress the FD event in binlogs
                            known not to contain row events (e.g.,
                            because BINLOG statement is unsafe,
                            requires root privileges, is not SQL, etc)

 - the BINLOG statement now handles FD events correctly, by setting
   the thread's rli's relay log's description_event_for_exec to the
   loaded event.

   In fact, executing a BINLOG statement is almost the same as reading
   an event from a relay log.  Before my patch, the code for this was
   separated (exec_relay_log_event in slave.cc executes events from
   the relay log, mysql_client_binlog_statement in sql_binlog.cc
   executes BINLOG statements).  I needed to augment
   mysql_client_binlog_statement to do parts of what
   exec_relay_log_event does.  Hence, I did a small refactoring and
   moved parts of exec_relay_log_event to a new function, which I
   named apply_event_and_update_pos.  apply_event_and_update_pos is
   called both from exec_relay_log_event and from
   mysql_client_binlog_statement.

 - When a non-FD event is executed in a BINLOG statement, without
   previously executing a FD event in a BINLOG statement, it generates
   an error, because that's unsafe.  I took a new error code for that:
   ER_NO_FORMAT_DESCRIPTION_EVENT_BEFORE_BINLOG_STATEMENTS.

   In order to get a decent error message containing the name of the
   event, I added the class method char*
   Log_event::get_type_str(Log_event_type type), which returns a
   string name for the given Log_event_type.  This is just like the
   existing char* Log_event::get_type_str(), except it is a class
   method that takes the log event type as parameter.

   I also added PRE_GA_*_ROWS_LOG_EVENT to Log_event::get_type_str(),
   so that names of old rows event are properly printed.

 - When reading an event, I added a check that the event type is known
   by the current Format_description_log_event. Without this, it may
   crash on bad input (and I was struck by this several times).

 - I patched the following test cases, which all contain BINLOG
   statements for row events which must be preceded by BINLOG
   statements for FD events:
    - rpl_bug31076

While I was here, I fixed some small things in log_event.cc:

 - replaced hard-coded 4 by EVENT_TYPE_OFFSET in 3 places

 - replaced return by DBUG_VOID_RETURN in one place

 - The name of the logfile can be '-' to indicate stdin.  Before my
   patch, the code just checked if the first character is '-'; now it
   does a full strcmp().  Probably, all arguments that begin with a -
   are already handled somewhere else as flags, but I still think it
   is better that the code reflects what it is supposed to do, with as
   little dependencies as possible on other parts of the code.  If we
   one day implement that all command line arguments after -- are
   files (as most unix tools do), then we need this.

I also fixed the following in slave.cc:

 - next_event() was declared twice, and queue_event was not static but
   should be static (not used outside the file).
2007-12-14 19:02:02 +01:00
..
disabled.def
rpl000010-slave.opt
rpl000010.test
rpl000011.test
rpl000013.test
rpl000017-slave.opt
rpl000017-slave.sh
rpl000017.test
rpl000018-master.opt
rpl000018-slave.opt
rpl_000015-slave.sh
rpl_000015.slave-mi
rpl_000015.test
rpl_alter.test
rpl_alter_db.test
rpl_auto_increment-master.opt
rpl_auto_increment-slave.opt
rpl_auto_increment.test
rpl_auto_increment_11932.test
rpl_binlog_grant.test
rpl_bit.test
rpl_bit_npk.test
rpl_bug31076.test
rpl_change_master.test
rpl_charset_sjis.test
rpl_colSize.test
rpl_commit_after_flush.test
rpl_create_database-master.opt
rpl_create_database-slave.opt
rpl_create_database.test
rpl_critical_errors.test
rpl_ddl.test
rpl_deadlock_innodb-slave.opt
rpl_deadlock_innodb.test
rpl_delete_no_where.test
rpl_do_grant.test
rpl_drop.test
rpl_drop_db.test
rpl_drop_temp-slave.opt
rpl_drop_temp.test
rpl_drop_view.test
rpl_dual_pos_advance-master.opt
rpl_dual_pos_advance.test
rpl_EE_err.test
rpl_empty_master_crash-master.opt
rpl_empty_master_crash.test
rpl_err_ignoredtable-slave.opt
rpl_err_ignoredtable.test
rpl_events.test
rpl_extraCol_innodb-master.opt
rpl_extraCol_innodb-slave.opt
rpl_extraCol_innodb.test
rpl_extraCol_myisam.test
rpl_extraColmaster_innodb-master.opt
rpl_extraColmaster_innodb-slave.opt
rpl_extraColmaster_innodb.test
rpl_extraColmaster_myisam.test
rpl_failed_optimize-master.opt
rpl_failed_optimize.test
rpl_flushlog_loop-master.opt
rpl_flushlog_loop-master.sh
rpl_flushlog_loop-slave.opt
rpl_flushlog_loop-slave.sh
rpl_flushlog_loop.test
rpl_foreign_key_innodb-slave.opt
rpl_foreign_key_innodb.test
rpl_found_rows.test
rpl_free_items-slave.opt
rpl_free_items.test
rpl_get_lock.test
rpl_grant.test
rpl_idempotency-master.opt
rpl_idempotency-slave.opt
rpl_idempotency.test
rpl_ignore_grant-slave.opt
rpl_ignore_grant.test
rpl_ignore_revoke-slave.opt
rpl_ignore_revoke.test
rpl_ignore_table-slave.opt
rpl_ignore_table.test
rpl_ignore_table_update-slave.opt
rpl_ignore_table_update.test
rpl_incident-master.opt
rpl_incident.test
rpl_init_slave-slave.opt
rpl_init_slave.test
rpl_innodb-master.opt
rpl_innodb.test
rpl_innodb_bug28430-master.opt
rpl_innodb_bug28430-slave.opt
rpl_innodb_bug28430.test
rpl_innodb_bug30888.test
rpl_innodb_bug30919-master.opt
rpl_innodb_bug30919.test
rpl_innodb_mixed_ddl.test
rpl_innodb_mixed_dml.test
rpl_insert.test
rpl_insert_id-slave.opt
rpl_insert_id.test
rpl_insert_id_pk-slave.opt
rpl_insert_id_pk.test
rpl_insert_ignore-slave.opt
rpl_insert_ignore.test
rpl_insert_select.test
rpl_invoked_features-master.opt
rpl_invoked_features-slave.opt
rpl_invoked_features.test
rpl_known_bugs_detection-master.opt
rpl_known_bugs_detection.test
rpl_LD_INFILE.test
rpl_load_from_master-slave.opt
rpl_load_from_master.test
rpl_load_table_from_master.test
rpl_loaddata.test
rpl_loaddata_charset.test
rpl_loaddata_fatal-slave.opt
rpl_loaddata_fatal.test
rpl_loaddata_m-master.opt
rpl_loaddata_m.test
rpl_loaddata_s-slave.opt
rpl_loaddata_s.test
rpl_loaddata_simple.test
rpl_loaddatalocal.test
rpl_loadfile.test
rpl_locale.test
rpl_log_pos.test
rpl_many_optimize.test
rpl_master_pos_wait.test
rpl_misc_functions-slave.sh
rpl_misc_functions.test
rpl_mixed_ddl_dml.test
rpl_multi_delete-slave.opt
rpl_multi_delete.test
rpl_multi_delete2-slave.opt
rpl_multi_delete2.test
rpl_multi_engine-slave.opt
rpl_multi_engine.test
rpl_multi_update.test
rpl_multi_update2-slave.opt
rpl_multi_update2.test
rpl_multi_update3.test
rpl_multi_update4-slave.opt
rpl_multi_update4.test
rpl_optimize.test
rpl_packet-master.opt
rpl_packet-slave.opt
rpl_packet.test
rpl_ps.test
rpl_rbr_to_sbr.test
rpl_read_only-slave.opt
rpl_read_only.test
rpl_redirect.test
rpl_relay_space_innodb-master.opt
rpl_relay_space_innodb-slave.opt
rpl_relay_space_innodb.test
rpl_relay_space_myisam.test
rpl_relayrotate-slave.opt
rpl_relayrotate.test
rpl_relayspace-slave.opt
rpl_relayspace.test
rpl_replicate_do-slave.opt
rpl_replicate_do.test
rpl_replicate_ignore_db-slave.opt
rpl_replicate_ignore_db.test
rpl_rewrt_db-slave.opt
rpl_rewrt_db.test
rpl_rotate_logs-master.opt
rpl_rotate_logs-slave.sh
rpl_rotate_logs.slave-mi
rpl_rotate_logs.test
rpl_row_001.test
rpl_row_4_bytes-master.opt
rpl_row_4_bytes.test
rpl_row_basic_2myisam.test
rpl_row_basic_3innodb-slave.opt
rpl_row_basic_3innodb.test
rpl_row_basic_8partition.test
rpl_row_basic_11bugs-master.opt
rpl_row_basic_11bugs-slave.opt
rpl_row_basic_11bugs.test
rpl_row_blob_innodb-slave.opt
rpl_row_blob_innodb.test
rpl_row_blob_myisam.test
rpl_row_charset.test
rpl_row_charset_innodb-master.opt
rpl_row_charset_innodb-slave.opt
rpl_row_charset_innodb.test
rpl_row_colSize.test
rpl_row_create_table-slave.opt
rpl_row_create_table.test
rpl_row_delayed_ins.test
rpl_row_drop.test
rpl_row_err_daisychain-master.opt
rpl_row_err_daisychain-slave.opt
rpl_row_flsh_tbls.test
rpl_row_func001.test
rpl_row_func002.test
rpl_row_func003-slave.opt
rpl_row_func003.test
rpl_row_inexist_tbl-slave.opt
rpl_row_inexist_tbl.test
rpl_row_insert_delayed.test
rpl_row_log-master.opt
rpl_row_log-slave.opt
rpl_row_log.test
rpl_row_log_innodb-master.opt
rpl_row_log_innodb-slave.opt
rpl_row_log_innodb.test
rpl_row_max_relay_size.test
rpl_row_mysqlbinlog-master.opt
rpl_row_mysqlbinlog.test
rpl_row_mystery22.test
rpl_row_NOW.test
rpl_row_reset_slave.test
rpl_row_sp001.test
rpl_row_sp002_innodb-master.opt
rpl_row_sp002_innodb-slave.opt
rpl_row_sp002_innodb.test
rpl_row_sp003-master.opt
rpl_row_sp003-slave.opt
rpl_row_sp003.test
rpl_row_sp005.test
rpl_row_sp006_InnoDB-slave.opt
rpl_row_sp006_InnoDB.test
rpl_row_sp007_innodb-slave.opt
rpl_row_sp007_innodb.test
rpl_row_sp008.test
rpl_row_sp009.test
rpl_row_sp010.test
rpl_row_sp011.test
rpl_row_sp012.test
rpl_row_stop_middle.test
rpl_row_stop_middle_update-master.opt
rpl_row_stop_middle_update-slave.opt
rpl_row_stop_middle_update.test
rpl_row_tabledefs_2myisam.test
rpl_row_tabledefs_3innodb-slave.opt
rpl_row_tabledefs_3innodb.test
rpl_row_trig001.test
rpl_row_trig002.test
rpl_row_trig003.test
rpl_row_trig004.test
rpl_row_unsafe_funcs.test
rpl_row_until.test
rpl_row_USER.test
rpl_row_UUID.test
rpl_row_view01.test
rpl_server_id1.test
rpl_server_id2-slave.opt
rpl_server_id2.test
rpl_session_var.test
rpl_set_charset.test
rpl_sf.test
rpl_skip_error-slave.opt
rpl_skip_error.test
rpl_slave_skip-slave.opt
rpl_slave_skip.test
rpl_slave_status.test
rpl_sp-master.opt
rpl_sp-slave.opt
rpl_sp.test
rpl_sp004.test
rpl_sp_effects-master.opt
rpl_sp_effects-slave.opt
rpl_sp_effects.test
rpl_sporadic_master-master.opt
rpl_sporadic_master.test
rpl_ssl.test
rpl_ssl1.test
rpl_start_stop_slave.test
rpl_stm_000001-slave.opt
rpl_stm_000001.test
rpl_stm_charset.test
rpl_stm_EE_err2.test
rpl_stm_flsh_tbls.test
rpl_stm_insert_delayed.test
rpl_stm_log-master.opt
rpl_stm_log-slave.opt
rpl_stm_log.test
rpl_stm_max_relay_size.test
rpl_stm_multi_query.test
rpl_stm_mystery22.test
rpl_stm_no_op.test
rpl_stm_reset_slave.test
rpl_stm_until.test
rpl_switch_stm_row_mixed.test
rpl_temp_table.test
rpl_temporary.test
rpl_temporary_errors-slave.opt
rpl_temporary_errors.test
rpl_timezone-master.opt
rpl_timezone-slave.opt
rpl_timezone.test
rpl_trigger.test
rpl_trunc_temp.test
rpl_truncate_2myisam.test
rpl_truncate_3innodb.test
rpl_truncate_7ndb_2-master.opt
rpl_truncate_7ndb_2.test
rpl_udf-master.opt
rpl_udf-slave.opt
rpl_udf.test
rpl_user_variables.test
rpl_variables-master.opt
rpl_variables.test
rpl_view-slave.opt
rpl_view.test