mariadb/mysql-test/suite/binlog/t
Monty d75d8631ed [MDEV-10570] Add Flashback support
==== Description ====

Flashback can rollback the instances/databases/tables to an old snapshot.
It's implement on Server-Level by full image format binary logs (--binlog-row-image=FULL), so it supports all engines.
Currently, it’s a feature inside mysqlbinlog tool (with --flashback arguments).

Because the flashback binlog events will store in the memory, you should check if there is enough memory in your machine.

==== New Arguments to mysqlbinlog ====

--flashback (-B)
It will let mysqlbinlog to work on FLASHBACK mode.

==== New Arguments to mysqld ====

--flashback

Setup the server to use flashback. This enables binary log in row mode
and will enable extra logging for DDL's needed by flashback feature

==== Example ====

I have a table "t" in database "test", we can compare the output with "--flashback" and without.

#client/mysqlbinlog /data/mysqldata_10.0/binlog/mysql-bin.000001 -vv -d test -T t --start-datetime="2013-03-27 14:54:00" > /tmp/1.sql
#client/mysqlbinlog /data/mysqldata_10.0/binlog/mysql-bin.000001 -vv -d test -T t --start-datetime="2013-03-27 14:54:00" -B > /tmp/2.sql

Then, importing the output flashback file (/tmp/2.log), it can flashback your database/table to the special time (--start-datetime).
And if you know the exact postion, "--start-postion" is also works, mysqlbinlog will output the flashback logs that can flashback to "--start-postion" position.

==== Implement ====

1. As we know, if binlog_format is ROW (binlog-row-image=FULL in 10.1 and later), all columns value are store in the row event, so we can get the data before mis-operation.

2. Just do following things:

  2.1 Change Event Type, INSERT->DELETE, DELETE->INSERT.
  For example:
    INSERT INTO t VALUES (...)  ---> DELETE FROM t WHERE ...
    DELETE FROM t ... ---> INSERT INTO t VALUES (...)

  2.2 For Update_Event, swapping the SET part and WHERE part.
  For example:
    UPDATE t SET cols1 = vals1 WHERE cols2 = vals2
    --->
    UPDATE t SET cols2 = vals2 WHERE cols1 = vals1

  2.3 For Multi-Rows Event, reverse the rows sequence, from the last row to the first row.
  For example:
    DELETE FROM t WHERE id=1; DELETE FROM t WHERE id=2; ...; DELETE FROM t WHERE id=n;
    --->
    DELETE FROM t WHERE id=n; ...; DELETE FROM t WHERE id=2; DELETE FROM t WHERE id=1;

  2.4 Output those events from the last one to the first one which mis-operation happened.
  For example:
2017-01-20 15:33:28 +02:00
..
binlog_base64_flag.test Merging TO_BASE64() and FROM_BASE64() from MySQL-5.6 2013-09-23 18:58:33 +04:00
binlog_bug23533.test
binlog_bug36391-master.opt
binlog_bug36391.test
binlog_checkpoint.test MDEV-7402 'reset master' hangs, waits for signalled COND_xid_list 2015-01-19 14:32:28 +01:00
binlog_checksum.test
binlog_commit_wait.test MDEV-7802: group commit status variable addition 2015-04-29 11:29:25 +02:00
binlog_database.test
binlog_delete_and_flush_index-master.opt
binlog_delete_and_flush_index.test
binlog_dmls_on_tmp_tables_readonly.test Merge branch '10.0' into 10.1 2016-08-25 12:40:09 +02:00
binlog_drop_if_exists.test
binlog_format_switch_in_tmp_table.test
binlog_grant.test MDEV-6066: Merge new defaults from 5.6 and 5.7 (defaults changed, QC can be stopped with no-zero size) 2015-09-04 10:33:56 +02:00
binlog_implicit_commit.test
binlog_incident.test MDEV-9038 Binlog encryption tests 2016-12-05 20:19:01 +02:00
binlog_index-master.opt
binlog_index.test MDEV-9038 Binlog encryption tests 2016-12-05 20:19:01 +02:00
binlog_innodb.test
binlog_innodb_row.test
binlog_ioerr.test MDEV-9038 Binlog encryption tests 2016-12-05 20:19:01 +02:00
binlog_killed.test 5.5.39 merge 2014-08-07 18:06:56 +02:00
binlog_killed_simulate-master.opt
binlog_killed_simulate.test cleanup: binlog.binlog_killed_simulate 2016-12-29 13:23:42 +01:00
binlog_max_extension.test
binlog_mdev342-master.opt
binlog_mdev342.test MDEV-8859 rpl.rpl_mdev382 sporadically fails to finish due to disappeared expect file 2016-06-12 20:14:51 +03:00
binlog_mdev717.test skip debug_sync test in release builds 2016-05-05 12:35:12 +02:00
binlog_mixed_cache_stat.test
binlog_mixed_load_data.test
binlog_mysqlbinlog-cp932-master.opt
binlog_mysqlbinlog-cp932.test MDEV-9038 Binlog encryption tests 2016-12-05 20:19:01 +02:00
binlog_mysqlbinlog2-master.opt
binlog_mysqlbinlog2.test MDEV-8429: Change binlog_checksum default to match MySQL 5.6.6+ 2016-05-20 09:46:03 +02:00
binlog_mysqlbinlog_base64.test
binlog_mysqlbinlog_row-master.opt
binlog_mysqlbinlog_row.test MDEV-8429: Change binlog_checksum default to match MySQL 5.6.6+ 2016-05-20 09:46:03 +02:00
binlog_mysqlbinlog_row_innodb-master.opt
binlog_mysqlbinlog_row_innodb.test
binlog_mysqlbinlog_row_myisam-master.opt
binlog_mysqlbinlog_row_myisam.test
binlog_mysqlbinlog_row_trans-master.opt
binlog_mysqlbinlog_row_trans.test MDEV-8429: Change binlog_checksum default to match MySQL 5.6.6+ 2016-05-20 09:46:03 +02:00
binlog_old_versions.test MDEV-34 delete storage/ndb and sql/*ndb* (and collateral changes) 2014-10-11 18:53:06 +02:00
binlog_query_filter_rules-master.opt
binlog_query_filter_rules.test
binlog_row_annotate-master.opt
binlog_row_annotate.test MDEV-9038 Binlog encryption tests 2016-12-05 20:19:01 +02:00
binlog_row_binlog-master.opt
binlog_row_binlog.test
binlog_row_cache_stat.test
binlog_row_ctype_cp932.test
binlog_row_ctype_ucs.test
binlog_row_drop_tbl.test
binlog_row_drop_tmp_tbl.test
binlog_row_innodb_stat-master.opt
binlog_row_insert_select.test
binlog_row_mix_innodb_myisam-master.opt
binlog_row_mix_innodb_myisam.test
binlog_row_mysqlbinlog_db_filter.test
binlog_row_mysqlbinlog_options-master.opt
binlog_row_mysqlbinlog_options.test MDEV-8429: Change binlog_checksum default to match MySQL 5.6.6+ 2016-05-20 09:46:03 +02:00
binlog_row_mysqlbinlog_verbose.test MDEV-34 delete storage/ndb and sql/*ndb* (and collateral changes) 2014-10-11 18:53:06 +02:00
binlog_server_id.test
binlog_sf.test
binlog_spurious_ddl_errors-master.opt
binlog_spurious_ddl_errors.test mysql-5.5.31 merge 2013-05-07 13:05:09 +02:00
binlog_sql_mode.test
binlog_start_comment.test
binlog_statement_insert_delayed.test
binlog_stm_binlog-master.opt
binlog_stm_binlog.test
binlog_stm_blackhole.test
binlog_stm_cache_stat.test
binlog_stm_ctype_cp932.test
binlog_stm_ctype_ucs.test
binlog_stm_do_db-master.opt
binlog_stm_do_db.test
binlog_stm_drop_tbl.test
binlog_stm_drop_tmp_tbl.test
binlog_stm_innodb_stat-master.opt
binlog_stm_insert_select.test
binlog_stm_mix_innodb_myisam-master.opt
binlog_stm_mix_innodb_myisam.test
binlog_stm_ps.test MDEV-11360 Dynamic SQL: DEFAULT as a bind parameter 2016-11-27 18:21:18 +04:00
binlog_stm_row.test MDEV-6720 - enable connection log in mysqltest by default 2016-03-31 10:11:16 +04:00
binlog_stm_unsafe_warning-master.opt
binlog_stm_unsafe_warning.test
binlog_stm_user_variables.test
binlog_switch_inside_trans.test Bug #15868071 USING SET GLOBAL SQL_LOG_BIN SHOULD NOT BE ALLOWED 2014-09-24 09:44:48 +08:00
binlog_tmp_table.test
binlog_trigger.test MDEV-6112 multiple triggers per table 2016-10-05 01:11:07 +03:00
binlog_truncate_innodb-master.opt
binlog_truncate_innodb.test
binlog_truncate_kill.test MDEV-6720 - enable connection log in mysqltest by default 2016-03-31 10:11:16 +04:00
binlog_truncate_myisam.test
binlog_unsafe-master.opt
binlog_unsafe.test MDEV-34 delete storage/ndb and sql/*ndb* (and collateral changes) 2014-10-11 18:53:06 +02:00
binlog_variables_log_bin-master.opt MDEV-7110 : Add missing MySQL variable log_bin_basename and log_bin_index 2015-06-09 13:38:29 -04:00
binlog_variables_log_bin.test MDEV-7110 : Add missing MySQL variable log_bin_basename and log_bin_index 2015-06-09 13:38:29 -04:00
binlog_variables_log_bin_index-master.opt MDEV-7110 : Add missing MySQL variable log_bin_basename and log_bin_index 2015-06-09 13:38:29 -04:00
binlog_variables_log_bin_index.test MDEV-7110 : Add missing MySQL variable log_bin_basename and log_bin_index 2015-06-09 13:38:29 -04:00
binlog_variables_relay_log-master.opt MDEV-7110 : Add missing MySQL variable log_bin_basename and log_bin_index 2015-06-09 13:38:29 -04:00
binlog_variables_relay_log.test MDEV-7110 : Add missing MySQL variable log_bin_basename and log_bin_index 2015-06-09 13:38:29 -04:00
binlog_variables_relay_log_index-master.opt MDEV-7110 : Add missing MySQL variable log_bin_basename and log_bin_index 2015-06-09 13:38:29 -04:00
binlog_variables_relay_log_index.test MDEV-7110 : Add missing MySQL variable log_bin_basename and log_bin_index 2015-06-09 13:38:29 -04:00
binlog_write_error.test MDEV-9038 Binlog encryption tests 2016-12-05 20:19:01 +02:00
binlog_xa_recover-master.opt
binlog_xa_recover.test MDEV-9038 Binlog encryption tests 2016-12-05 20:19:01 +02:00
flashback-master.opt [MDEV-10570] Add Flashback support 2017-01-20 15:33:28 +02:00
flashback.test [MDEV-10570] Add Flashback support 2017-01-20 15:33:28 +02:00
load_data_stm_view.test MDEV-3940 Server crash or assertion `item->type() == Item::STRING_ITEM' failure on LOAD DATA through a view with statement binary logging 2014-11-18 15:42:32 +01:00
temptable_uservar_disconnect-7938.test MDEV-7938 MariaDB Crashes Suddenly while writing binlogs 2015-04-27 15:42:12 +02:00