summaryrefslogtreecommitdiff
path: root/mysql-test/suite/rpl/t
diff options
context:
space:
mode:
authorunknown <msvensson@pilot.(none)>2007-06-27 14:29:10 +0200
committerunknown <msvensson@pilot.(none)>2007-06-27 14:29:10 +0200
commit7f452a07dc874d309168afd534d96622dd4cc40d (patch)
treedebebff96f1c161c8be517c5b808b2d22c2e4ee2 /mysql-test/suite/rpl/t
parent0314c73ad8f159018fc0f1d51e0253f011894de1 (diff)
parenta40e44efed0794ed91e7d454743fdaa7d6099f45 (diff)
downloadmariadb-git-7f452a07dc874d309168afd534d96622dd4cc40d.tar.gz
Merge pilot.(none):/data/msvensson/mysql/wl3933/my51-wl3933-new2
into pilot.(none):/data/msvensson/mysql/mysql-5.1-new-maint mysql-test/lib/mtr_report.pl: Auto merged mysql-test/mysql-test-run.pl: Auto merged mysql-test/suite/binlog/r/binlog_stm_binlog.result: Auto merged mysql-test/suite/binlog/t/binlog_row_mix_innodb_myisam.test: Auto merged mysql-test/suite/ndb/r/ndb_backup_print.result: Auto merged mysql-test/suite/ndb/t/loaddata_autocom_ndb.test: Auto merged mysql-test/suite/ndb/t/ndb_alter_table.test: Auto merged mysql-test/suite/ndb/t/ndb_alter_table2.test: Auto merged mysql-test/suite/ndb/t/ndb_alter_table3.test: Auto merged mysql-test/suite/ndb/t/ndb_autodiscover.test: Auto merged mysql-test/suite/ndb/t/ndb_autodiscover2.test: Auto merged mysql-test/suite/ndb/t/ndb_autodiscover3.test: Auto merged mysql-test/suite/ndb/t/ndb_backup_print.test: Auto merged mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result: Auto merged mysql-test/suite/ndb/t/ndb_basic.test: Auto merged mysql-test/suite/ndb/t/ndb_binlog_log_bin.test: Auto merged mysql-test/suite/ndb/t/ndb_binlog_multi.test: Auto merged mysql-test/suite/ndb/t/ndb_bitfield.test: Auto merged mysql-test/suite/ndb/t/ndb_blob.test: Auto merged mysql-test/suite/ndb/t/ndb_blob_partition.test: Auto merged mysql-test/suite/ndb/t/ndb_cache.test: Auto merged mysql-test/suite/ndb/t/ndb_cache2.test: Auto merged mysql-test/suite/ndb/t/ndb_cache_multi.test: Auto merged mysql-test/suite/ndb/t/ndb_cache_multi2.test: Auto merged mysql-test/suite/ndb/t/ndb_charset.test: Auto merged mysql-test/suite/ndb/t/ndb_condition_pushdown.test: Auto merged mysql-test/suite/ndb/t/ndb_config.test: Auto merged mysql-test/suite/ndb/t/ndb_config2.test: Auto merged mysql-test/suite/ndb/t/ndb_cursor.test: Auto merged mysql-test/suite/ndb/t/ndb_database.test: Auto merged mysql-test/suite/ndb/t/ndb_dd_alter.test: Auto merged mysql-test/suite/ndb/t/ndb_dd_backuprestore.test: Auto merged mysql-test/suite/ndb/t/ndb_dd_basic.test: Auto merged mysql-test/suite/ndb/t/ndb_dd_ddl.test: Auto merged mysql-test/suite/ndb/t/ndb_dd_disk2memory.test: Auto merged mysql-test/suite/ndb/t/ndb_dd_dump.test: Auto merged mysql-test/suite/ndb/t/ndb_dd_sql_features.test: Auto merged mysql-test/suite/ndb/t/ndb_gis.test: Auto merged mysql-test/suite/ndb/t/ndb_index.test: Auto merged mysql-test/suite/ndb/t/ndb_index_ordered.test: Auto merged mysql-test/suite/ndb/t/ndb_index_unique.test: Auto merged mysql-test/suite/ndb/t/ndb_insert.test: Auto merged mysql-test/suite/ndb/t/ndb_limit.test: Auto merged mysql-test/suite/ndb/t/ndb_loaddatalocal.test: Auto merged mysql-test/suite/ndb/t/ndb_lock.test: Auto merged mysql-test/suite/ndb/t/ndb_minmax.test: Auto merged mysql-test/suite/ndb/t/ndb_multi.test: Auto merged mysql-test/suite/ndb/t/ndb_partition_error.test: Auto merged mysql-test/suite/ndb/t/ndb_partition_key.test: Auto merged mysql-test/suite/ndb/t/ndb_partition_list.test: Auto merged mysql-test/suite/ndb/t/ndb_partition_range.test: Auto merged mysql-test/suite/ndb/t/ndb_read_multi_range.test: Auto merged mysql-test/suite/ndb/t/ndb_rename.test: Auto merged mysql-test/suite/ndb/t/ndb_replace.test: Auto merged mysql-test/suite/ndb/t/ndb_restore.test: Auto merged mysql-test/suite/ndb/t/ndb_restore_partition.test: Auto merged mysql-test/suite/ndb/t/ndb_restore_print.test: Auto merged mysql-test/suite/ndb/t/ndb_row_format.test: Auto merged mysql-test/suite/ndb/t/ndb_single_user.test: Auto merged mysql-test/suite/ndb/t/ndb_sp.test: Auto merged mysql-test/suite/ndb/t/ndb_subquery.test: Auto merged mysql-test/suite/ndb/t/ndb_temporary.test: Auto merged mysql-test/suite/ndb/t/ndb_transaction.test: Auto merged mysql-test/suite/ndb/t/ndb_trigger.test: Auto merged mysql-test/suite/ndb/t/ndb_truncate.test: Auto merged mysql-test/suite/ndb/t/ndb_types.test: Auto merged mysql-test/suite/ndb/t/ndb_update.test: Auto merged mysql-test/suite/ndb/t/ndb_view.test: Auto merged mysql-test/suite/ndb/t/ndbapi.test: Auto merged mysql-test/suite/ndb/t/ps_7ndb.test: Auto merged mysql-test/suite/ndb/t/strict_autoinc_5ndb.test: Auto merged mysql-test/suite/rpl/r/rpl_000015.result: Auto merged mysql-test/suite/rpl/r/rpl_change_master.result: Auto merged mysql-test/suite/rpl/r/rpl_deadlock_innodb.result: Auto merged mysql-test/suite/rpl/r/rpl_empty_master_crash.result: Auto merged mysql-test/suite/rpl/r/rpl_extraCol_innodb.result: Auto merged mysql-test/suite/rpl/r/rpl_extraCol_myisam.result: Auto merged mysql-test/suite/rpl/r/rpl_flushlog_loop.result: Auto merged mysql-test/suite/rpl/r/rpl_incident.result: Auto merged mysql-test/suite/rpl/r/rpl_innodb.result: Auto merged mysql-test/suite/rpl/r/rpl_known_bugs_detection.result: Auto merged mysql-test/suite/rpl/r/rpl_loaddata.result: Auto merged mysql-test/suite/rpl/r/rpl_log_pos.result: Auto merged mysql-test/suite/rpl/r/rpl_rbr_to_sbr.result: Auto merged mysql-test/suite/rpl/r/rpl_redirect.result: Auto merged mysql-test/suite/rpl/r/rpl_replicate_do.result: Auto merged mysql-test/suite/rpl/r/rpl_rotate_logs.result: Auto merged mysql-test/suite/rpl/r/rpl_row_basic_11bugs.result: Auto merged mysql-test/suite/rpl/r/rpl_row_inexist_tbl.result: Auto merged mysql-test/suite/rpl/r/rpl_row_log.result: Auto merged mysql-test/suite/rpl/r/rpl_row_log_innodb.result: Auto merged mysql-test/suite/rpl/r/rpl_row_max_relay_size.result: Auto merged mysql-test/suite/rpl/r/rpl_row_reset_slave.result: Auto merged mysql-test/suite/rpl/r/rpl_row_tabledefs_2myisam.result: Auto merged mysql-test/suite/rpl/r/rpl_row_tabledefs_3innodb.result: Auto merged mysql-test/suite/rpl/r/rpl_row_until.result: Auto merged mysql-test/suite/rpl/r/rpl_server_id1.result: Auto merged mysql-test/suite/rpl/r/rpl_server_id2.result: Auto merged mysql-test/suite/rpl/r/rpl_skip_error.result: Auto merged mysql-test/suite/rpl/r/rpl_slave_status.result: Auto merged mysql-test/suite/rpl/r/rpl_ssl.result: Auto merged mysql-test/suite/rpl/r/rpl_ssl1.result: Auto merged mysql-test/suite/rpl/r/rpl_stm_log.result: Auto merged mysql-test/suite/rpl/r/rpl_stm_max_relay_size.result: Auto merged mysql-test/suite/rpl/r/rpl_stm_reset_slave.result: Auto merged mysql-test/suite/rpl/r/rpl_stm_until.result: Auto merged mysql-test/suite/rpl/r/rpl_udf.result: Auto merged mysql-test/suite/rpl/t/rpl_000015.test: Auto merged mysql-test/suite/rpl/t/rpl_change_master.test: Auto merged mysql-test/suite/rpl/t/rpl_commit_after_flush.test: Auto merged mysql-test/suite/rpl/t/rpl_delete_no_where.test: Auto merged mysql-test/suite/rpl/t/rpl_empty_master_crash.test: Auto merged mysql-test/suite/rpl/t/rpl_flushlog_loop.test: Auto merged mysql-test/suite/rpl/t/rpl_innodb.test: Auto merged mysql-test/suite/rpl/t/rpl_insert_ignore.test: Auto merged mysql-test/suite/rpl/t/rpl_log_pos.test: Auto merged mysql-test/suite/rpl/t/rpl_multi_update2.test: Auto merged mysql-test/suite/rpl/t/rpl_multi_update3.test: Auto merged mysql-test/suite/rpl/t/rpl_rbr_to_sbr.test: Auto merged mysql-test/suite/rpl/t/rpl_redirect.test: Auto merged mysql-test/suite/rpl/t/rpl_relayrotate.test: Auto merged mysql-test/suite/rpl/t/rpl_replicate_do.test: Auto merged mysql-test/suite/rpl/t/rpl_rotate_logs.test: Auto merged mysql-test/suite/rpl/t/rpl_row_001.test: Auto merged mysql-test/suite/rpl/t/rpl_row_UUID.test: Auto merged mysql-test/suite/rpl/t/rpl_row_basic_11bugs.test: Auto merged mysql-test/suite/rpl/t/rpl_row_basic_2myisam.test: Auto merged mysql-test/suite/rpl/t/rpl_row_basic_3innodb.test: Auto merged mysql-test/suite/rpl/t/rpl_row_blob_innodb.test: Auto merged mysql-test/suite/rpl/t/rpl_row_blob_myisam.test: Auto merged mysql-test/suite/rpl/t/rpl_row_charset.test: Auto merged mysql-test/suite/rpl/t/rpl_row_func003.test: Auto merged mysql-test/suite/rpl/t/rpl_row_inexist_tbl.test: Auto merged mysql-test/suite/rpl/t/rpl_row_log.test: Auto merged mysql-test/suite/rpl/t/rpl_row_log_innodb.test: Auto merged mysql-test/suite/rpl/t/rpl_row_sp003.test: Auto merged mysql-test/suite/rpl/t/rpl_row_sp006_InnoDB.test: Auto merged mysql-test/suite/rpl/t/rpl_row_until.test: Auto merged mysql-test/suite/rpl/t/rpl_server_id1.test: Auto merged mysql-test/suite/rpl/t/rpl_server_id2.test: Auto merged mysql-test/suite/rpl/t/rpl_skip_error.test: Auto merged mysql-test/suite/rpl/t/rpl_slave_status.test: Auto merged mysql-test/suite/rpl/t/rpl_ssl.test: Auto merged mysql-test/suite/rpl/t/rpl_ssl1.test: Auto merged mysql-test/suite/rpl/t/rpl_stm_log.test: Auto merged mysql-test/suite/rpl/t/rpl_stm_until.test: Auto merged mysql-test/suite/rpl_ndb/r/rpl_ndb_basic.result: Auto merged mysql-test/suite/rpl_ndb/r/rpl_ndb_circular.result: Auto merged mysql-test/suite/rpl_ndb/r/rpl_ndb_dd_basic.result: Auto merged mysql-test/suite/rpl_ndb/r/rpl_ndb_extraCol.result: Auto merged mysql-test/suite/rpl_ndb/r/rpl_ndb_idempotent.result: Auto merged mysql-test/suite/rpl_ndb/r/rpl_ndb_log.result: Auto merged mysql-test/suite/rpl_ndb/r/rpl_ndb_stm_innodb.result: Auto merged mysql-test/suite/rpl_ndb/r/rpl_ndb_sync.result: Auto merged mysql-test/suite/rpl_ndb/r/rpl_truncate_7ndb.result: Auto merged mysql-test/suite/rpl_ndb/t/rpl_ndb_2innodb.test: Auto merged mysql-test/suite/rpl_ndb/t/rpl_ndb_2myisam.test: Auto merged mysql-test/suite/rpl_ndb/t/rpl_ndb_UUID.test: Auto merged mysql-test/suite/rpl_ndb/t/rpl_ndb_auto_inc.test: Auto merged mysql-test/suite/rpl_ndb/t/rpl_ndb_bank.test: Auto merged mysql-test/suite/rpl_ndb/t/rpl_ndb_basic.test: Auto merged mysql-test/suite/rpl_ndb/t/rpl_ndb_blob.test: Auto merged mysql-test/suite/rpl_ndb/t/rpl_ndb_blob2.test: Auto merged mysql-test/suite/rpl_ndb/t/rpl_ndb_charset.test: Auto merged mysql-test/suite/rpl_ndb/t/rpl_ndb_circular.test: Auto merged mysql-test/suite/rpl_ndb/t/rpl_ndb_circular_simplex.test: Auto merged mysql-test/suite/rpl_ndb/t/rpl_ndb_commit_afterflush.test: Auto merged mysql-test/suite/rpl_ndb/t/rpl_ndb_dd_advance.test: Auto merged mysql-test/suite/rpl_ndb/t/rpl_ndb_dd_basic.test: Auto merged mysql-test/suite/rpl_ndb/t/rpl_ndb_dd_partitions.test: Auto merged mysql-test/suite/rpl_ndb/t/rpl_ndb_ddl.test: Auto merged mysql-test/suite/rpl_ndb/t/rpl_ndb_delete_nowhere.test: Auto merged mysql-test/suite/rpl_ndb/t/rpl_ndb_do_db.test: Auto merged mysql-test/suite/rpl_ndb/t/rpl_ndb_do_table.test: Auto merged mysql-test/suite/rpl_ndb/t/rpl_ndb_extraCol.test: Auto merged mysql-test/suite/rpl_ndb/t/rpl_ndb_func003.test: Auto merged mysql-test/suite/rpl_ndb/t/rpl_ndb_idempotent.test: Auto merged mysql-test/suite/rpl_ndb/t/rpl_ndb_innodb2ndb.test: Auto merged mysql-test/suite/rpl_ndb/t/rpl_ndb_innodb_trans.test: Auto merged mysql-test/suite/rpl_ndb/t/rpl_ndb_insert_ignore.test: Auto merged mysql-test/suite/rpl_ndb/t/rpl_ndb_load.test: Auto merged mysql-test/suite/rpl_ndb/t/rpl_ndb_log.test: Auto merged mysql-test/suite/rpl_ndb/t/rpl_ndb_multi.test: Auto merged mysql-test/suite/rpl_ndb/t/rpl_ndb_multi_update2.test: Auto merged mysql-test/suite/rpl_ndb/t/rpl_ndb_multi_update3.test: Auto merged mysql-test/suite/rpl_ndb/t/rpl_ndb_myisam2ndb.test: Auto merged mysql-test/suite/rpl_ndb/t/rpl_ndb_relayrotate.test: Auto merged mysql-test/suite/rpl_ndb/t/rpl_ndb_rep_ignore.test: Auto merged mysql-test/suite/rpl_ndb/t/rpl_ndb_row_001.test: Auto merged mysql-test/suite/rpl_ndb/t/rpl_ndb_sp003.test: Auto merged mysql-test/suite/rpl_ndb/t/rpl_ndb_sp006.test: Auto merged mysql-test/suite/rpl_ndb/t/rpl_ndb_stm_innodb.test: Auto merged mysql-test/suite/rpl_ndb/t/rpl_ndb_sync.test: Auto merged mysql-test/suite/rpl_ndb/t/rpl_ndb_trig004.test: Auto merged mysql-test/suite/rpl_ndb/t/rpl_ndbapi_multi.test: Auto merged mysql-test/suite/rpl_ndb/t/rpl_row_basic_7ndb.test: Auto merged mysql-test/suite/rpl_ndb/t/rpl_truncate_7ndb.test: Auto merged BitKeeper/deleted/.del-binlog_row_blackhole.test: Auto merged BitKeeper/deleted/.del-binlog_row_blackhole.result: Auto merged BitKeeper/deleted/.del-ndb_binlog_basic2.result: Auto merged BitKeeper/deleted/.del-ndb_binlog_basic2.test: Auto merged mysql-test/t/disabled.def: Merge
Diffstat (limited to 'mysql-test/suite/rpl/t')
-rw-r--r--mysql-test/suite/rpl/t/disabled.def15
-rw-r--r--mysql-test/suite/rpl/t/rpl000010-slave.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl000010.test19
-rw-r--r--mysql-test/suite/rpl/t/rpl000011.test17
-rw-r--r--mysql-test/suite/rpl/t/rpl000013.test53
-rw-r--r--mysql-test/suite/rpl/t/rpl000017-slave.opt1
-rwxr-xr-xmysql-test/suite/rpl/t/rpl000017-slave.sh12
-rw-r--r--mysql-test/suite/rpl/t/rpl000017.test22
-rw-r--r--mysql-test/suite/rpl/t/rpl000018-master.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl000018-slave.opt1
-rwxr-xr-xmysql-test/suite/rpl/t/rpl_000015-slave.sh1
-rw-r--r--mysql-test/suite/rpl/t/rpl_000015.slave-mi1
-rw-r--r--mysql-test/suite/rpl/t/rpl_000015.test40
-rw-r--r--mysql-test/suite/rpl/t/rpl_EE_err.test7
-rw-r--r--mysql-test/suite/rpl/t/rpl_LD_INFILE.test38
-rw-r--r--mysql-test/suite/rpl/t/rpl_alter.test24
-rw-r--r--mysql-test/suite/rpl/t/rpl_alter_db.test10
-rw-r--r--mysql-test/suite/rpl/t/rpl_auto_increment-master.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_auto_increment-slave.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_auto_increment.test12
-rw-r--r--mysql-test/suite/rpl/t/rpl_auto_increment_11932.test63
-rw-r--r--mysql-test/suite/rpl/t/rpl_bit.test94
-rw-r--r--mysql-test/suite/rpl/t/rpl_bit_npk.test116
-rw-r--r--mysql-test/suite/rpl/t/rpl_change_master.test37
-rw-r--r--mysql-test/suite/rpl/t/rpl_charset_sjis.test25
-rw-r--r--mysql-test/suite/rpl/t/rpl_commit_after_flush.test12
-rw-r--r--mysql-test/suite/rpl/t/rpl_create_database-master.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_create_database-slave.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_create_database.test72
-rw-r--r--mysql-test/suite/rpl/t/rpl_critical_errors.test66
-rw-r--r--mysql-test/suite/rpl/t/rpl_ddl.test32
-rw-r--r--mysql-test/suite/rpl/t/rpl_deadlock_innodb-slave.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_deadlock_innodb.test11
-rw-r--r--mysql-test/suite/rpl/t/rpl_delete_no_where.test7
-rw-r--r--mysql-test/suite/rpl/t/rpl_do_grant.test114
-rw-r--r--mysql-test/suite/rpl/t/rpl_drop.test16
-rw-r--r--mysql-test/suite/rpl/t/rpl_drop_db.test61
-rw-r--r--mysql-test/suite/rpl/t/rpl_drop_temp-slave.opt2
-rw-r--r--mysql-test/suite/rpl/t/rpl_drop_temp.test27
-rw-r--r--mysql-test/suite/rpl/t/rpl_dual_pos_advance-master.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_dual_pos_advance.test114
-rw-r--r--mysql-test/suite/rpl/t/rpl_empty_master_crash-master.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_empty_master_crash.test14
-rw-r--r--mysql-test/suite/rpl/t/rpl_err_ignoredtable-slave.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_err_ignoredtable.test66
-rw-r--r--mysql-test/suite/rpl/t/rpl_events.test47
-rw-r--r--mysql-test/suite/rpl/t/rpl_extraCol_innodb-master.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_extraCol_innodb-slave.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_extraCol_innodb.test13
-rw-r--r--mysql-test/suite/rpl/t/rpl_extraCol_myisam.test12
-rw-r--r--mysql-test/suite/rpl/t/rpl_failed_optimize-master.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_failed_optimize.test11
-rw-r--r--mysql-test/suite/rpl/t/rpl_flushlog_loop-master.opt1
-rwxr-xr-xmysql-test/suite/rpl/t/rpl_flushlog_loop-master.sh5
-rw-r--r--mysql-test/suite/rpl/t/rpl_flushlog_loop-slave.opt1
-rwxr-xr-xmysql-test/suite/rpl/t/rpl_flushlog_loop-slave.sh4
-rw-r--r--mysql-test/suite/rpl/t/rpl_flushlog_loop.test49
-rw-r--r--mysql-test/suite/rpl/t/rpl_foreign_key_innodb-slave.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_foreign_key_innodb.test11
-rw-r--r--mysql-test/suite/rpl/t/rpl_free_items-slave.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_free_items.test22
-rw-r--r--mysql-test/suite/rpl/t/rpl_get_lock.test43
-rw-r--r--mysql-test/suite/rpl/t/rpl_ignore_grant-slave.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_ignore_grant.test59
-rw-r--r--mysql-test/suite/rpl/t/rpl_ignore_revoke-slave.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_ignore_revoke.test51
-rw-r--r--mysql-test/suite/rpl/t/rpl_ignore_table-slave.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_ignore_table.test164
-rw-r--r--mysql-test/suite/rpl/t/rpl_ignore_table_update-slave.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_ignore_table_update.test38
-rw-r--r--mysql-test/suite/rpl/t/rpl_incident-master.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_incident.test42
-rw-r--r--mysql-test/suite/rpl/t/rpl_init_slave-slave.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_init_slave.test34
-rw-r--r--mysql-test/suite/rpl/t/rpl_innodb.test115
-rw-r--r--mysql-test/suite/rpl/t/rpl_insert.test44
-rw-r--r--mysql-test/suite/rpl/t/rpl_insert_id-slave.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_insert_id.test11
-rw-r--r--mysql-test/suite/rpl/t/rpl_insert_id_pk-slave.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_insert_id_pk.test11
-rw-r--r--mysql-test/suite/rpl/t/rpl_insert_ignore-slave.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_insert_ignore.test9
-rw-r--r--mysql-test/suite/rpl/t/rpl_insert_select.test19
-rw-r--r--mysql-test/suite/rpl/t/rpl_known_bugs_detection-master.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_known_bugs_detection.test93
-rw-r--r--mysql-test/suite/rpl/t/rpl_load_from_master-slave.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_load_from_master.test180
-rw-r--r--mysql-test/suite/rpl/t/rpl_load_table_from_master.test98
-rw-r--r--mysql-test/suite/rpl/t/rpl_loaddata.test7
-rw-r--r--mysql-test/suite/rpl/t/rpl_loaddata_charset.test33
-rw-r--r--mysql-test/suite/rpl/t/rpl_loaddata_m-master.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_loaddata_m.test52
-rw-r--r--mysql-test/suite/rpl/t/rpl_loaddata_s-slave.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_loaddata_s.test28
-rw-r--r--mysql-test/suite/rpl/t/rpl_loaddata_simple.test14
-rw-r--r--mysql-test/suite/rpl/t/rpl_loaddatalocal.test65
-rw-r--r--mysql-test/suite/rpl/t/rpl_loadfile.test52
-rw-r--r--mysql-test/suite/rpl/t/rpl_locale.test24
-rw-r--r--mysql-test/suite/rpl/t/rpl_log_pos.test50
-rw-r--r--mysql-test/suite/rpl/t/rpl_many_optimize.test22
-rw-r--r--mysql-test/suite/rpl/t/rpl_master_pos_wait.test18
-rwxr-xr-xmysql-test/suite/rpl/t/rpl_misc_functions-slave.sh1
-rw-r--r--mysql-test/suite/rpl/t/rpl_misc_functions.test103
-rw-r--r--mysql-test/suite/rpl/t/rpl_mixed_ddl_dml.test46
-rw-r--r--mysql-test/suite/rpl/t/rpl_multi_delete-slave.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_multi_delete.test26
-rw-r--r--mysql-test/suite/rpl/t/rpl_multi_delete2-slave.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_multi_delete2.test68
-rw-r--r--mysql-test/suite/rpl/t/rpl_multi_engine-slave.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_multi_engine.test108
-rw-r--r--mysql-test/suite/rpl/t/rpl_multi_update.test7
-rw-r--r--mysql-test/suite/rpl/t/rpl_multi_update2-slave.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_multi_update2.test10
-rw-r--r--mysql-test/suite/rpl/t/rpl_multi_update3.test10
-rw-r--r--mysql-test/suite/rpl/t/rpl_multi_update4-slave.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_multi_update4.test45
-rw-r--r--mysql-test/suite/rpl/t/rpl_optimize.test54
-rw-r--r--mysql-test/suite/rpl/t/rpl_packet-master.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_packet-slave.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_packet.test80
-rw-r--r--mysql-test/suite/rpl/t/rpl_ps.test51
-rw-r--r--mysql-test/suite/rpl/t/rpl_rbr_to_sbr.test47
-rw-r--r--mysql-test/suite/rpl/t/rpl_read_only-slave.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_read_only.test113
-rw-r--r--mysql-test/suite/rpl/t/rpl_redirect.test45
-rw-r--r--mysql-test/suite/rpl/t/rpl_relay_space_innodb-master.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_relay_space_innodb-slave.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_relay_space_innodb.test22
-rw-r--r--mysql-test/suite/rpl/t/rpl_relay_space_myisam.test21
-rw-r--r--mysql-test/suite/rpl/t/rpl_relayrotate-slave.opt3
-rw-r--r--mysql-test/suite/rpl/t/rpl_relayrotate.test11
-rw-r--r--mysql-test/suite/rpl/t/rpl_relayspace-slave.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_relayspace.test34
-rw-r--r--mysql-test/suite/rpl/t/rpl_replicate_do-slave.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_replicate_do.test92
-rw-r--r--mysql-test/suite/rpl/t/rpl_replicate_ignore_db-slave.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_replicate_ignore_db.test30
-rw-r--r--mysql-test/suite/rpl/t/rpl_rewrt_db-slave.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_rewrt_db.test84
-rw-r--r--mysql-test/suite/rpl/t/rpl_rotate_logs-master.opt1
-rwxr-xr-xmysql-test/suite/rpl/t/rpl_rotate_logs-slave.sh2
-rw-r--r--mysql-test/suite/rpl/t/rpl_rotate_logs.slave-mi1
-rw-r--r--mysql-test/suite/rpl/t/rpl_rotate_logs.test169
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_001.test9
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_4_bytes-master.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_4_bytes.test33
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_NOW.test74
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_USER.test60
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_UUID.test9
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_basic_11bugs-master.opt2
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_basic_11bugs-slave.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_basic_11bugs.test225
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_basic_2myisam.test6
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_basic_3innodb-slave.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_basic_3innodb.test8
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_basic_8partition.test210
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_blob_innodb-slave.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_blob_innodb.test14
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_blob_myisam.test13
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_charset.test9
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_create_table-slave.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_create_table.test236
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_delayed_ins.test7
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_drop.test48
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_err_daisychain-master.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_err_daisychain-slave.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_flsh_tbls.test17
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_func001.test57
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_func002.test104
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_func003-slave.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_func003.test13
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_inexist_tbl-slave.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_inexist_tbl.test33
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_insert_delayed.test14
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_log-master.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_log-slave.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_log.test17
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_log_innodb-master.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_log_innodb-slave.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_log_innodb.test14
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_max_relay_size.test11
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_mysqlbinlog-master.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_mysqlbinlog.test348
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_mystery22.test45
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_reset_slave.test5
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_sp001.test146
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_sp002_innodb-master.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_sp002_innodb-slave.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_sp002_innodb.test11
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_sp003-master.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_sp003-slave.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_sp003.test13
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_sp005.test110
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_sp006_InnoDB-slave.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_sp006_InnoDB.test13
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_sp007_innodb-slave.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_sp007_innodb.test11
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_sp008.test57
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_sp009.test105
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_sp010.test80
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_sp011.test111
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_sp012.test75
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_stop_middle.test44
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_stop_middle_update-master.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_stop_middle_update-slave.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_stop_middle_update.test31
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_tabledefs_2myisam.test8
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_tabledefs_3innodb-slave.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_tabledefs_3innodb.test9
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_trig001.test100
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_trig002.test80
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_trig003.test152
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_trig004.test18
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_until.test76
-rw-r--r--mysql-test/suite/rpl/t/rpl_row_view01.test89
-rw-r--r--mysql-test/suite/rpl/t/rpl_server_id1.test26
-rw-r--r--mysql-test/suite/rpl/t/rpl_server_id2-slave.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_server_id2.test26
-rw-r--r--mysql-test/suite/rpl/t/rpl_session_var.test42
-rw-r--r--mysql-test/suite/rpl/t/rpl_set_charset.test35
-rw-r--r--mysql-test/suite/rpl/t/rpl_sf.test70
-rw-r--r--mysql-test/suite/rpl/t/rpl_skip_error-slave.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_skip_error.test51
-rw-r--r--mysql-test/suite/rpl/t/rpl_slave_status.test58
-rw-r--r--mysql-test/suite/rpl/t/rpl_sp-master.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_sp-slave.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_sp.test585
-rw-r--r--mysql-test/suite/rpl/t/rpl_sp004.test97
-rw-r--r--mysql-test/suite/rpl/t/rpl_sp_effects-master.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_sp_effects-slave.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_sp_effects.test211
-rw-r--r--mysql-test/suite/rpl/t/rpl_sporadic_master-master.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_sporadic_master.test29
-rw-r--r--mysql-test/suite/rpl/t/rpl_ssl.test71
-rw-r--r--mysql-test/suite/rpl/t/rpl_ssl1.test97
-rw-r--r--mysql-test/suite/rpl/t/rpl_start_stop_slave.test36
-rw-r--r--mysql-test/suite/rpl/t/rpl_stm_000001-slave.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_stm_000001.test2
-rw-r--r--mysql-test/suite/rpl/t/rpl_stm_EE_err2.test8
-rw-r--r--mysql-test/suite/rpl/t/rpl_stm_charset.test2
-rw-r--r--mysql-test/suite/rpl/t/rpl_stm_flsh_tbls.test8
-rw-r--r--mysql-test/suite/rpl/t/rpl_stm_insert_delayed.test20
-rw-r--r--mysql-test/suite/rpl/t/rpl_stm_log-master.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_stm_log-slave.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_stm_log.test9
-rw-r--r--mysql-test/suite/rpl/t/rpl_stm_max_relay_size.test11
-rw-r--r--mysql-test/suite/rpl/t/rpl_stm_multi_query.test12
-rw-r--r--mysql-test/suite/rpl/t/rpl_stm_mystery22.test66
-rw-r--r--mysql-test/suite/rpl/t/rpl_stm_no_op.test93
-rw-r--r--mysql-test/suite/rpl/t/rpl_stm_reset_slave.test6
-rw-r--r--mysql-test/suite/rpl/t/rpl_stm_until.test77
-rw-r--r--mysql-test/suite/rpl/t/rpl_switch_stm_row_mixed.test568
-rw-r--r--mysql-test/suite/rpl/t/rpl_temp_table.test59
-rw-r--r--mysql-test/suite/rpl/t/rpl_temporary.test215
-rw-r--r--mysql-test/suite/rpl/t/rpl_timezone-master.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_timezone-slave.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_timezone.test142
-rw-r--r--mysql-test/suite/rpl/t/rpl_trigger.test477
-rw-r--r--mysql-test/suite/rpl/t/rpl_trunc_temp.test35
-rw-r--r--mysql-test/suite/rpl/t/rpl_truncate_2myisam.test4
-rw-r--r--mysql-test/suite/rpl/t/rpl_truncate_3innodb.test6
-rw-r--r--mysql-test/suite/rpl/t/rpl_truncate_7ndb_2-master.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_truncate_7ndb_2.test6
-rw-r--r--mysql-test/suite/rpl/t/rpl_udf-master.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_udf-slave.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_udf.test22
-rw-r--r--mysql-test/suite/rpl/t/rpl_user_variables.test362
-rw-r--r--mysql-test/suite/rpl/t/rpl_variables-master.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_variables.test20
-rw-r--r--mysql-test/suite/rpl/t/rpl_view-slave.opt1
-rw-r--r--mysql-test/suite/rpl/t/rpl_view.test167
271 files changed, 10951 insertions, 0 deletions
diff --git a/mysql-test/suite/rpl/t/disabled.def b/mysql-test/suite/rpl/t/disabled.def
new file mode 100644
index 00000000000..180a700acaf
--- /dev/null
+++ b/mysql-test/suite/rpl/t/disabled.def
@@ -0,0 +1,15 @@
+##############################################################################
+#
+# List the test cases that are to be disabled temporarily.
+#
+# Separate the test case name and the comment with ':'.
+#
+# <testcasename> : BUG#<xxxx> <date disabled> <disabler> <comment>
+#
+# Do not use any TAB characters for whitespace.
+#
+##############################################################################
+
+rpl_ddl : BUG#26418 2007-03-01 mleich Slave out of sync after CREATE/DROP TEMPORARY TABLE + ROLLBACK on master
+rpl_innodb_mixed_ddl : Bug #29363 rpl.rpl_innodb_mixed_* test failures
+rpl_innodb_mixed_dml : Bug #29363 rpl.rpl_innodb_mixed_* test failures
diff --git a/mysql-test/suite/rpl/t/rpl000010-slave.opt b/mysql-test/suite/rpl/t/rpl000010-slave.opt
new file mode 100644
index 00000000000..0dbfb311e33
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl000010-slave.opt
@@ -0,0 +1 @@
+--disconnect-slave-event-count=2
diff --git a/mysql-test/suite/rpl/t/rpl000010.test b/mysql-test/suite/rpl/t/rpl000010.test
new file mode 100644
index 00000000000..261b9148774
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl000010.test
@@ -0,0 +1,19 @@
+# This tests the offset off by 22 mystery bug
+# Must run slave with --disconnect-slave-event-count=1 --master-connect-retry=1
+
+source include/master-slave.inc;
+
+create table t1 (n int not null auto_increment primary key);
+insert into t1 values(NULL);
+insert into t1 values(2);
+save_master_pos;
+connection slave;
+sync_with_master;
+select n from t1;
+connection master;
+drop table t1;
+save_master_pos;
+connection slave;
+sync_with_master;
+
+# End of 4.1 tests
diff --git a/mysql-test/suite/rpl/t/rpl000011.test b/mysql-test/suite/rpl/t/rpl000011.test
new file mode 100644
index 00000000000..32f6227f7c5
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl000011.test
@@ -0,0 +1,17 @@
+source include/master-slave.inc;
+
+create table t1 (n int);
+insert into t1 values(1);
+sync_slave_with_master;
+stop slave;
+start slave;
+connection master;
+insert into t1 values(2);
+#let slave catch up
+sync_slave_with_master;
+select * from t1;
+connection master;
+drop table t1;
+sync_slave_with_master;
+
+# End of 4.1 tests
diff --git a/mysql-test/suite/rpl/t/rpl000013.test b/mysql-test/suite/rpl/t/rpl000013.test
new file mode 100644
index 00000000000..69a102e84ce
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl000013.test
@@ -0,0 +1,53 @@
+# This test is to verify that DROP TEMPORARY TABLE
+# is automatically binlogged and sent to slave
+# when a temp table is dropped by disconnection
+# of a master's conection.
+# So it does not apply to row-based, where we neither need
+# nor do this automatic binlogging. And if we run this test
+# in row-based, it hangs waiting for an offset which is never
+# reached (the "sync_with_master 1"), logically.
+
+--source include/have_binlog_format_mixed_or_statement.inc
+source include/master-slave.inc;
+save_master_pos;
+connection slave;
+sync_with_master;
+connection master;
+
+create table t2(n int);
+create temporary table t1 (n int);
+insert into t1 values(1),(2),(3);
+insert into t2 select * from t1;
+connection master1;
+create temporary table t1 (n int);
+insert into t1 values (4),(5);
+insert into t2 select * from t1 as t10;
+save_master_pos;
+disconnect master;
+connection slave;
+#add 1 to catch drop table
+sync_with_master 1;
+connection master1;
+insert into t2 values(6);
+save_master_pos;
+disconnect master1;
+connection slave;
+# same trick to go one more event
+sync_with_master 1;
+select * from t2;
+show status like 'Slave_open_temp_tables';
+#
+# Clean up
+#
+connect (master2,localhost,root,,);
+connection master2;
+
+# We will get a warning for t1 as this is a temporary table that doesn't
+# exist in this connection.
+
+drop table if exists t1,t2;
+save_master_pos;
+connection slave;
+sync_with_master;
+
+# End of 4.1 tests
diff --git a/mysql-test/suite/rpl/t/rpl000017-slave.opt b/mysql-test/suite/rpl/t/rpl000017-slave.opt
new file mode 100644
index 00000000000..58a964c90d0
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl000017-slave.opt
@@ -0,0 +1 @@
+--skip-slave-start
diff --git a/mysql-test/suite/rpl/t/rpl000017-slave.sh b/mysql-test/suite/rpl/t/rpl000017-slave.sh
new file mode 100755
index 00000000000..17188aba0db
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl000017-slave.sh
@@ -0,0 +1,12 @@
+rm -f $MYSQLTEST_VARDIR/log/*relay*
+rm -f $MYSQLTEST_VARDIR/slave-data/relay-log.info
+cat > $MYSQLTEST_VARDIR/slave-data/master.info <<EOF
+master-bin.000001
+4
+127.0.0.1
+replicate
+aaaaaaaaaaaaaaab
+$MASTER_MYPORT
+1
+0
+EOF
diff --git a/mysql-test/suite/rpl/t/rpl000017.test b/mysql-test/suite/rpl/t/rpl000017.test
new file mode 100644
index 00000000000..2ba321cd8c3
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl000017.test
@@ -0,0 +1,22 @@
+source include/master-slave.inc;
+connection slave;
+stop slave;
+connection master;
+grant replication slave on *.* to replicate@localhost identified by 'aaaaaaaaaaaaaaab';
+grant replication slave on *.* to replicate@127.0.0.1 identified by 'aaaaaaaaaaaaaaab';
+connection slave;
+start slave;
+connection master;
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+create table t1(n int);
+insert into t1 values(24);
+sync_slave_with_master;
+select * from t1;
+connection master;
+drop table t1;
+delete from mysql.user where user="replicate";
+sync_slave_with_master;
+
+# End of 4.1 tests
diff --git a/mysql-test/suite/rpl/t/rpl000018-master.opt b/mysql-test/suite/rpl/t/rpl000018-master.opt
new file mode 100644
index 00000000000..ad2c6a647b5
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl000018-master.opt
@@ -0,0 +1 @@
+-O max_binlog_size=4096
diff --git a/mysql-test/suite/rpl/t/rpl000018-slave.opt b/mysql-test/suite/rpl/t/rpl000018-slave.opt
new file mode 100644
index 00000000000..e854f0d0bb2
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl000018-slave.opt
@@ -0,0 +1 @@
+--skip-slave-start --abort-slave-event-count=1
diff --git a/mysql-test/suite/rpl/t/rpl_000015-slave.sh b/mysql-test/suite/rpl/t/rpl_000015-slave.sh
new file mode 100755
index 00000000000..7deeca3d2d6
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_000015-slave.sh
@@ -0,0 +1 @@
+rm -f $MYSQLTEST_VARDIR/slave-data/master.info
diff --git a/mysql-test/suite/rpl/t/rpl_000015.slave-mi b/mysql-test/suite/rpl/t/rpl_000015.slave-mi
new file mode 100644
index 00000000000..28bc753dd56
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_000015.slave-mi
@@ -0,0 +1 @@
+--server-id=22 --master-connect-retry=7
diff --git a/mysql-test/suite/rpl/t/rpl_000015.test b/mysql-test/suite/rpl/t/rpl_000015.test
new file mode 100644
index 00000000000..80db596244b
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_000015.test
@@ -0,0 +1,40 @@
+-- source include/have_log_bin.inc
+#####################
+# Change Author: JBM
+# Change Date: 2006-01-17
+# Change: added order by in select
+#####################
+
+connect (master,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK);
+connect (slave,localhost,root,,test,$SLAVE_MYPORT,$SLAVE_MYSOCK);
+connection master;
+reset master;
+show master status;
+save_master_pos;
+connection slave;
+reset slave;
+source include/show_slave_status.inc;
+
+change master to master_host='127.0.0.1';
+# The following needs to be cleaned up when change master is fixed
+source include/show_slave_status.inc;
+--replace_result $MASTER_MYPORT MASTER_PORT
+eval change master to master_host='127.0.0.1',master_user='root',
+ master_password='',master_port=$MASTER_MYPORT;
+source include/show_slave_status.inc;
+start slave;
+sync_with_master;
+source include/show_slave_status.inc;
+connection master;
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+create table t1 (n int, PRIMARY KEY(n));
+insert into t1 values (10),(45),(90);
+sync_slave_with_master;
+connection slave;
+SELECT * FROM t1 ORDER BY n;
+connection master;
+SELECT * FROM t1 ORDER BY n;
+drop table t1;
+sync_slave_with_master;
diff --git a/mysql-test/suite/rpl/t/rpl_EE_err.test b/mysql-test/suite/rpl/t/rpl_EE_err.test
new file mode 100644
index 00000000000..6d064ae3197
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_EE_err.test
@@ -0,0 +1,7 @@
+########################################################
+# By JBM 2006-02-14 Wrapped to share test code between #
+# engines. Added to skip test when NDB is default #
+########################################################
+-- source include/not_ndb_default.inc
+let $engine_type=myisam;
+-- source extra/rpl_tests/rpl_EE_err.test
diff --git a/mysql-test/suite/rpl/t/rpl_LD_INFILE.test b/mysql-test/suite/rpl/t/rpl_LD_INFILE.test
new file mode 100644
index 00000000000..bace5d4c1f5
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_LD_INFILE.test
@@ -0,0 +1,38 @@
+#############################################################################
+# Original Author: JBM #
+# Original Date: Aug/18/2005 #
+#############################################################################
+# TEST: To test the LOAD DATA INFILE in rbr #
+#############################################################################
+
+# Includes
+-- source include/master-slave.inc
+
+# Begin clean up test section
+--disable_warnings
+connection master;
+DROP TABLE IF EXISTS test.t1;
+--enable_warnings
+
+# Section 1 test
+CREATE TABLE test.t1 (a VARCHAR(255), PRIMARY KEY(a));
+LOAD DATA INFILE '../std_data_ln/words2.dat' INTO TABLE test.t1;
+DELETE FROM test.t1 WHERE a = 'abashed';
+DELETE FROM test.t1;
+LOAD DATA INFILE '../std_data_ln/words2.dat' INTO TABLE test.t1;
+
+
+SELECT * FROM test.t1 ORDER BY a DESC;
+save_master_pos;
+sync_slave_with_master;
+connection slave;
+SELECT * FROM test.t1 ORDER BY a DESC;
+
+# Cleanup
+#show binlog events;
+connection master;
+DROP TABLE test.t1;
+sync_slave_with_master;
+
+# End of 5.0 test case
+
diff --git a/mysql-test/suite/rpl/t/rpl_alter.test b/mysql-test/suite/rpl/t/rpl_alter.test
new file mode 100644
index 00000000000..576376a0264
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_alter.test
@@ -0,0 +1,24 @@
+source include/master-slave.inc;
+--disable_warnings
+drop database if exists mysqltest;
+--enable_warnings
+create database mysqltest;
+
+create table mysqltest.t1 ( n int);
+alter table mysqltest.t1 add m int;
+insert into mysqltest.t1 values (1,2);
+create table mysqltest.t2 (n int);
+insert into mysqltest.t2 values (45);
+rename table mysqltest.t2 to mysqltest.t3, mysqltest.t1 to mysqltest.t2;
+save_master_pos;
+connection slave;
+sync_with_master;
+select * from mysqltest.t2;
+select * from mysqltest.t3;
+connection master;
+drop database mysqltest;
+save_master_pos;
+connection slave;
+sync_with_master;
+
+# End of 4.1 tests
diff --git a/mysql-test/suite/rpl/t/rpl_alter_db.test b/mysql-test/suite/rpl/t/rpl_alter_db.test
new file mode 100644
index 00000000000..5ac8a2f4018
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_alter_db.test
@@ -0,0 +1,10 @@
+source include/master-slave.inc;
+connection master;
+use mysql; # to be different from initial `test' db of mysqltest client
+alter database collate latin1_bin;
+save_master_pos;
+
+connection slave;
+sync_with_master;
+
+
diff --git a/mysql-test/suite/rpl/t/rpl_auto_increment-master.opt b/mysql-test/suite/rpl/t/rpl_auto_increment-master.opt
new file mode 100644
index 00000000000..a8a6af19da9
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_auto_increment-master.opt
@@ -0,0 +1 @@
+--auto-increment-increment=10 --auto-increment-offset=2
diff --git a/mysql-test/suite/rpl/t/rpl_auto_increment-slave.opt b/mysql-test/suite/rpl/t/rpl_auto_increment-slave.opt
new file mode 100644
index 00000000000..48457b17309
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_auto_increment-slave.opt
@@ -0,0 +1 @@
+--loose-innodb
diff --git a/mysql-test/suite/rpl/t/rpl_auto_increment.test b/mysql-test/suite/rpl/t/rpl_auto_increment.test
new file mode 100644
index 00000000000..19770ffbdc0
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_auto_increment.test
@@ -0,0 +1,12 @@
+#####################################
+# Wrapper for rpl_auto_increment.test#
+#####################################
+########################################################
+# By JBM 2005-02-15 Wrapped to allow reuse of test code#
+# Added to skip if ndb is default #
+########################################################
+-- source include/not_ndb_default.inc
+-- source include/have_innodb.inc
+let $engine_type=innodb;
+let $engine_type2=myisam;
+-- source extra/rpl_tests/rpl_auto_increment.test
diff --git a/mysql-test/suite/rpl/t/rpl_auto_increment_11932.test b/mysql-test/suite/rpl/t/rpl_auto_increment_11932.test
new file mode 100644
index 00000000000..d4b7872fb2b
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_auto_increment_11932.test
@@ -0,0 +1,63 @@
+#
+# Test of auto_increment
+# BUG#11932
+#
+# Bug reported that master and slave get out of sync after TRUNCATE
+# TABLE.
+#
+# Test supplied by Are Casilla
+
+source include/master-slave.inc;
+--disable_warnings
+connection master;
+drop database if exists test1;
+--enable_warnings
+create database test1;
+use test1;
+
+CREATE TABLE `t1` (
+ `id` int(10) unsigned NOT NULL auto_increment,
+ `fname` varchar(100) default NULL,
+ PRIMARY KEY (`id`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
+
+INSERT INTO `t1` VALUES (1, 'blablabla');
+
+CREATE TABLE `t2` (
+ `id` int(10) NOT NULL auto_increment,
+ `comment` varchar(255) NOT NULL default '',
+ PRIMARY KEY (`id`)
+) ENGINE=MyISAM AUTO_INCREMENT=3 ;
+
+INSERT INTO `t2` VALUES (1, 'testtest 1');
+INSERT INTO `t2` VALUES (2, 'test 2');
+
+DELIMITER $;
+CREATE PROCEDURE simpleproc3 ()
+ NOT DETERMINISTIC
+ BEGIN
+ INSERT INTO t1 (fname) (SELECT t2.comment FROM t2 WHERE t2.id = '1');
+ INSERT INTO t1 (fname) VALUES('test');
+ END
+ $
+DELIMITER ;$
+
+CALL simpleproc3();
+
+select * from t2;
+
+TRUNCATE TABLE `t1`;
+CALL simpleproc3();
+
+select * from t1;
+
+save_master_pos;
+connection slave;
+sync_with_master;
+
+use test1;
+select * from t1;
+
+drop database test1;
+connection master;
+drop database test1;
diff --git a/mysql-test/suite/rpl/t/rpl_bit.test b/mysql-test/suite/rpl/t/rpl_bit.test
new file mode 100644
index 00000000000..07b0778296c
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_bit.test
@@ -0,0 +1,94 @@
+#############################################################################
+# Original Author: JBM #
+# Original Date: Sept/15/2005 #
+#############################################################################
+# Test: To test the replication of the bit field #
+#############################################################################
+# Change Author: JBM
+# Change Date: 2006-01-16
+# Change: Added Order by for NDB
+##########
+
+-- source include/master-slave.inc
+
+
+# Begin clean up test section
+connection master;
+--disable_warnings
+DROP TABLE IF EXISTS test.t1;
+--enable_warnings
+# End of cleanup
+
+# Begin test section 1
+
+CREATE TABLE test.t1 (
+ dummyKey INTEGER NOT NULL,
+ f01 TINYINT,
+ f10 TINYINT,
+ f12 TINYINT,
+ f15 TINYINT,
+ f16 TINYINT,
+ f7 TINYINT,
+ f9 TINYINT,
+ f29 TINYINT,
+ f0 TINYINT,
+ fA1 TINYINT,
+ C32 TINYINT,
+ A42 TINYINT,
+ CA3 TINYINT,
+ A044 TINYINT,
+ f001 TINYINT,
+ A3002 TINYINT,
+ fC003 TINYINT,
+ CA300 TINYINT,
+ A305 TINYINT,
+ CA321 TINYINT,
+ r001 TINYINT,
+ bit1 BIT(6),
+ bit2 BIT(6),
+ bit3 BIT(6),
+ State1 TINYINT,
+ State2 TINYINT,
+ State3 TINYINT,
+ State4 TINYINT,
+ SubState TINYINT,
+ gState TINYINT,
+ oSupp TINYINT,
+ tSupp TINYINT,
+ sSuppD TINYINT,
+ mSuppf TINYINT,
+ GSuppDf TINYINT,
+ VNotSupp TINYINT,
+ x034 TINYINT,
+PRIMARY KEY USING HASH (dummyKey) );
+
+LOCK TABLES test.t1 WRITE;
+INSERT INTO test.t1 VALUES (6,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b'111111',b'111110',b'110101',4,5,5,5,5,5,5,5,5,5,3,2,1);
+INSERT INTO test.t1 VALUES (1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b'111111',b'000000',b'100100',4,5,5,5,5,5,5,5,5,5,3,2,1);
+INSERT INTO test.t1 VALUES (2,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b'000000',b'101010',b'010101',4,5,5,5,5,5,5,5,5,5,3,2,1);
+INSERT INTO test.t1 VALUES (3,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b'101010',b'111111',b'000000',4,5,5,5,5,5,5,5,5,5,3,2,1);
+INSERT INTO test.t1 VALUES (4,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,4,5,5,5,5,5,5,5,5,5,3,2,1);
+INSERT INTO test.t1 VALUES (5,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,4,5,5,5,5,5,5,5,5,5,3,2,1);
+INSERT INTO test.t1 VALUES (7,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,4,5,5,5,5,5,5,5,5,5,3,2,1);
+INSERT INTO test.t1 VALUES (8,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,4,5,5,5,5,5,5,5,5,5,3,2,1);
+UNLOCK TABLES;
+
+
+SELECT oSupp, sSuppD, GSuppDf, VNotSupp, x034 FROM test.t1;
+SELECT hex(bit1) FROM test.t1 ORDER BY bit1;
+SELECT hex(bit2) from test.t1 ORDER BY bit2;
+SELECT hex(bit3) from test.t1 ORDER BY bit3;
+save_master_pos;
+
+connection slave;
+sync_with_master;
+SELECT oSupp, sSuppD, GSuppDf, VNotSupp, x034 FROM test.t1;
+SELECT hex(bit1) FROM test.t1 ORDER BY bit1;
+SELECT hex(bit2) from test.t1 ORDER BY bit2;
+SELECT hex(bit3) from test.t1 ORDER BY bit3;
+
+connection master;
+DROP TABLE IF EXISTS test.t1;
+sync_slave_with_master;
+
+# End of 5.0 test case
diff --git a/mysql-test/suite/rpl/t/rpl_bit_npk.test b/mysql-test/suite/rpl/t/rpl_bit_npk.test
new file mode 100644
index 00000000000..12b587919f9
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_bit_npk.test
@@ -0,0 +1,116 @@
+#############################################################################
+# Original Author: JBM #
+# Original Date: Sept/15/2005 #
+#############################################################################
+# Test: To test the replication of the bit field #
+#############################################################################
+
+-- source include/master-slave.inc
+
+
+# Begin clean up test section
+connection master;
+--disable_warnings
+DROP TABLE IF EXISTS test.t1;
+--enable_warnings
+# End of cleanup
+
+# Begin test section 1
+
+CREATE TABLE test.t1 (
+ dummyKey INTEGER NOT NULL,
+ f01 TINYINT,
+ f10 TINYINT,
+ f12 TINYINT,
+ f15 TINYINT,
+ f16 TINYINT,
+ f7 TINYINT,
+ f9 TINYINT,
+ f29 TINYINT,
+ f0 TINYINT,
+ fA1 TINYINT,
+ C32 TINYINT,
+ A42 TINYINT,
+ CA3 TINYINT,
+ A044 TINYINT,
+ f001 TINYINT,
+ A3002 TINYINT,
+ fC003 TINYINT,
+ CA300 TINYINT,
+ A305 TINYINT,
+ CA321 TINYINT,
+ r001 TINYINT,
+ bit1 BIT(6),
+ bit2 BIT(6),
+ bit3 BIT(6),
+ State1 TINYINT,
+ State2 TINYINT,
+ State3 TINYINT,
+ State4 TINYINT,
+ SubState TINYINT,
+ gState TINYINT,
+ oSupp TINYINT,
+ tSupp TINYINT,
+ sSuppD TINYINT,
+ mSuppf TINYINT,
+ GSuppDf TINYINT,
+ VNotSupp TINYINT,
+ x034 TINYINT);
+
+LOCK TABLES test.t1 WRITE;
+INSERT INTO test.t1 VALUES (6,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b'111111',b'111110',b'110101',4,5,5,5,5,5,5,5,5,5,3,NULL,1);
+INSERT INTO test.t1 VALUES (1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b'111111',b'000000',b'100100',4,5,5,5,5,5,5,5,5,5,3,2,1);
+INSERT INTO test.t1 VALUES (2,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b'000000',b'101010',b'010101',4,5,5,5,5,5,5,5,5,5,3,2,1);
+INSERT INTO test.t1 VALUES (3,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b'101010',b'111111',b'000000',4,5,5,5,5,5,5,5,5,5,3,2,1);
+INSERT INTO test.t1 VALUES (4,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b'0',1,1,4,5,5,5,5,5,5,5,5,5,3,2,1);
+INSERT INTO test.t1 VALUES (5,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,4,5,5,5,5,5,5,5,5,5,3,2,1);
+INSERT INTO test.t1 VALUES (7,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,4,5,5,5,5,5,5,5,5,5,3,2,1);
+INSERT INTO test.t1 VALUES (8,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,4,5,5,5,5,5,5,5,5,5,3,2,1);
+UNLOCK TABLES;
+
+UPDATE test.t1 set x034 = 50 where bit3 = b'000000';
+UPDATE test.t1 set VNotSupp = 33 where bit1 = b'0';
+SELECT oSupp, sSuppD, GSuppDf, VNotSupp, x034
+ FROM test.t1
+ ORDER BY oSupp, sSuppD, GSuppDf, VNotSupp, x034;
+SELECT hex(bit1) from test.t1 ORDER BY bit1;
+SELECT hex(bit2) from test.t1 ORDER BY bit2;
+SELECT hex(bit3) from test.t1 ORDER BY bit3;
+save_master_pos;
+
+connection slave;
+sync_with_master;
+SELECT oSupp, sSuppD, GSuppDf, VNotSupp, x034
+ FROM test.t1
+ ORDER BY oSupp, sSuppD, GSuppDf, VNotSupp, x034;
+SELECT hex(bit1) from test.t1 ORDER BY bit1;
+SELECT hex(bit2) from test.t1 ORDER BY bit2;
+SELECT hex(bit3) from test.t1 ORDER BY bit3;
+
+connection master;
+CREATE TABLE test.t2 (a INT, b BIT(1));
+INSERT INTO test.t2 VALUES (1, b'0');
+INSERT INTO test.t2 VALUES (1, b'1');
+UPDATE test.t2 SET a = 2 WHERE b = b'1';
+
+CREATE TABLE test.t3 (a INT, b INT);
+INSERT INTO test.t3 VALUES (1, NULL);
+INSERT INTO test.t3 VALUES (1, 0);
+UPDATE test.t3 SET a = 2 WHERE b = 0;
+
+SELECT a, hex(b) FROM test.t2 ORDER BY a,b;
+SELECT * FROM test.t3 ORDER BY a,b;
+save_master_pos;
+
+connection slave;
+sync_with_master;
+SELECT a, hex(b) FROM test.t2 ORDER BY a,b;
+SELECT * FROM test.t3 ORDER BY a,b;
+
+connection master;
+DROP TABLE IF EXISTS test.t1;
+DROP TABLE IF EXISTS test.t2;
+DROP TABLE IF EXISTS test.t3;
+sync_slave_with_master;
+
+# End of 5.0 test case
diff --git a/mysql-test/suite/rpl/t/rpl_change_master.test b/mysql-test/suite/rpl/t/rpl_change_master.test
new file mode 100644
index 00000000000..7256fed656f
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_change_master.test
@@ -0,0 +1,37 @@
+# Verify that after CHANGE MASTER, replication (I/O thread and SQL
+# thread) restart from where SQL thread left, not from where
+# I/O thread left (some old bug fixed in 4.0.17)
+
+source include/master-slave.inc;
+
+connection master;
+# Make SQL slave thread advance a bit
+create table t1(n int);
+sync_slave_with_master;
+select * from t1;
+# Now stop it and make I/O slave thread be ahead
+stop slave sql_thread;
+connection master;
+insert into t1 values(1);
+insert into t1 values(2);
+save_master_pos;
+connection slave;
+--real_sleep 3 # wait for I/O thread to have read updates
+stop slave;
+--replace_result $MASTER_MYPORT MASTER_PORT
+--replace_column 1 # 7 # 8 # 9 # 16 # 23 # 33 # 35 # 36 #
+query_vertical SHOW SLAVE STATUS;
+change master to master_user='root';
+--replace_result $MASTER_MYPORT MASTER_PORT
+--replace_column 1 # 7 # 8 # 9 # 16 # 23 # 33 # 35 # 36 #
+query_vertical SHOW SLAVE STATUS;
+start slave;
+sync_with_master;
+select * from t1;
+connection master;
+drop table t1;
+save_master_pos;
+connection slave;
+sync_with_master;
+
+# End of 4.1 tests
diff --git a/mysql-test/suite/rpl/t/rpl_charset_sjis.test b/mysql-test/suite/rpl/t/rpl_charset_sjis.test
new file mode 100644
index 00000000000..2469b0db8a2
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_charset_sjis.test
@@ -0,0 +1,25 @@
+source include/have_sjis.inc;
+source include/master-slave.inc;
+
+--disable_warnings
+drop table if exists t1;
+drop procedure if exists p1;
+--enable_warnings
+create table t1 (a varchar(255) character set sjis);
+create procedure p1 (in a varchar(255) character set sjis) insert into t1 values (a);
+
+SET NAMES binary;
+CALL p1 ('–\\');
+select "--- on master ---";
+select hex(a) from t1 ;
+sync_slave_with_master;
+connection slave;
+select "--- on slave ---";
+select hex(a) from t1;
+connection master;
+drop table t1;
+drop procedure p1;
+sync_slave_with_master;
+connection master;
+
+# End of 5.0 tests
diff --git a/mysql-test/suite/rpl/t/rpl_commit_after_flush.test b/mysql-test/suite/rpl/t/rpl_commit_after_flush.test
new file mode 100644
index 00000000000..47df391d6be
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_commit_after_flush.test
@@ -0,0 +1,12 @@
+#####################################
+# Wrapper for rpl_commit_after_flush#
+#####################################
+########################################################
+# By JBM 2005-02-15 Wrapped to allow reuse of test code#
+# Added to skip if ndb is default #
+########################################################
+-- source include/not_ndb_default.inc
+-- source include/have_innodb.inc
+-- source include/master-slave.inc
+let $engine_type=innodb;
+-- source extra/rpl_tests/rpl_commit_after_flush.test
diff --git a/mysql-test/suite/rpl/t/rpl_create_database-master.opt b/mysql-test/suite/rpl/t/rpl_create_database-master.opt
new file mode 100644
index 00000000000..85660a17140
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_create_database-master.opt
@@ -0,0 +1 @@
+--binlog-do-db=mysqltest_sisyfos --binlog-do-db=mysqltest_prometheus
diff --git a/mysql-test/suite/rpl/t/rpl_create_database-slave.opt b/mysql-test/suite/rpl/t/rpl_create_database-slave.opt
new file mode 100644
index 00000000000..96d630c9229
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_create_database-slave.opt
@@ -0,0 +1 @@
+--replicate-do-db=mysqltest_sisyfos --replicate-do-db=mysqltest_prometheus
diff --git a/mysql-test/suite/rpl/t/rpl_create_database.test b/mysql-test/suite/rpl/t/rpl_create_database.test
new file mode 100644
index 00000000000..70cff8daca2
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_create_database.test
@@ -0,0 +1,72 @@
+#
+# Tests for replication of statements that manipulate databases.
+#
+# For this test file, we have a number of databases. All databases
+# with "greek" names will be replicated on the slave, while other names
+# (e.g., american) will not be replicated.
+#
+
+source include/master-slave.inc;
+
+# Bug#6391 (binlog-do-db rules ignored)
+# In this case, 'mysqltest_bob' should not be replicated to the slave.
+--disable_warnings
+DROP DATABASE IF EXISTS mysqltest_prometheus;
+DROP DATABASE IF EXISTS mysqltest_sisyfos;
+DROP DATABASE IF EXISTS mysqltest_bob;
+sync_slave_with_master;
+# This database is not replicated
+DROP DATABASE IF EXISTS mysqltest_bob;
+--enable_warnings
+
+connection master;
+CREATE DATABASE mysqltest_prometheus;
+CREATE DATABASE mysqltest_sisyfos;
+CREATE DATABASE mysqltest_bob;
+
+USE mysqltest_sisyfos;
+# These should be replicated
+CREATE TABLE t1 (b int);
+INSERT INTO t1 VALUES(1);
+
+USE mysqltest_bob;
+# These should *not* be replicated
+CREATE TABLE t2 (b int);
+INSERT INTO t2 VALUES(2);
+
+# Current database is now 'mysqltest_bob'
+# The following should be replicated
+ALTER DATABASE mysqltest_sisyfos CHARACTER SET latin1;
+
+USE mysqltest_sisyfos;
+# The following should *not* be replicated
+ALTER DATABASE mysqltest_bob CHARACTER SET latin1;
+
+SHOW DATABASES;
+sync_slave_with_master;
+SHOW DATABASES;
+
+connection master;
+DROP DATABASE IF EXISTS mysqltest_sisyfos;
+USE mysqltest_prometheus;
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1);
+CREATE DATABASE mysqltest_sisyfos;
+USE mysqltest_sisyfos;
+CREATE TABLE t2 (a INT);
+let $VERSION=`select version()`;
+SHOW DATABASES;
+sync_slave_with_master;
+SHOW DATABASES;
+USE mysqltest_prometheus;
+SHOW TABLES;
+USE mysqltest_sisyfos;
+SHOW TABLES;
+
+connection master;
+DROP DATABASE IF EXISTS mysqltest_prometheus;
+DROP DATABASE IF EXISTS mysqltest_sisyfos;
+DROP DATABASE IF EXISTS mysqltest_bob;
+sync_slave_with_master;
+
+# End of 4.1 tests
diff --git a/mysql-test/suite/rpl/t/rpl_critical_errors.test b/mysql-test/suite/rpl/t/rpl_critical_errors.test
new file mode 100644
index 00000000000..abf827c8d1f
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_critical_errors.test
@@ -0,0 +1,66 @@
+# Test for BUG#26551
+#
+
+# This test is unfortunately very fragile and very dependent on the
+# load of the computer. The test is therefore disabled normally. It is
+# entered here to demonstrate how to check that the bug is actually
+# solved.
+
+--echo Turn on parsing to run this test
+
+disable_parsing;
+
+source include/master-slave.inc;
+
+connection master;
+CREATE TABLE t1 (data LONGBLOB) ENGINE=MYISAM;
+CREATE TABLE t2 (data LONGBLOB) ENGINE=MYISAM;
+
+INSERT INTO t1 (data) VALUES (repeat('a',1024*1024));
+INSERT INTO t1 SELECT * FROM t1;
+INSERT INTO t1 SELECT * FROM t1;
+INSERT INTO t1 SELECT * FROM t1;
+INSERT INTO t1 SELECT * FROM t1;
+INSERT INTO t1 SELECT * FROM t1;
+INSERT INTO t1 SELECT * FROM t1;
+INSERT INTO t1 SELECT * FROM t1;
+INSERT INTO t1 SELECT * FROM t1;
+sync_slave_with_master;
+
+connection master;
+send INSERT INTO t2 SELECT * FROM t1;
+
+connection master1;
+
+# This sleep is picked so that the query above has started to insert
+# some rows into t2. If it hasn't the slave will not stop below.
+sleep 4;
+
+# SHOW PROCESSLIST;
+
+# Code for the 5.1 server to get the thread id of the thread executing
+# the query above.
+#
+#SET @id = 0;
+#SELECT id INTO @id
+# FROM information_schema.processlist
+# WHERE info LIKE 'INSERT INTO t2%';
+
+# This is the connection that is executing the INSERT INTO t2...
+KILL QUERY 2;
+
+connection slave;
+
+# Here the slave will only stop if the query above actually started
+# inserting some rows into t2. Otherwise, it will hang forever.
+--source include/wait_for_slave_to_stop.inc
+
+# The following should be 0
+SELECT COUNT(*) FROM t2;
+
+# ... and there the error code should be 1317 (ER_QUERY_INTERRUPTED)
+--replace_result $MASTER_MYPORT MASTER_PORT
+--replace_column 1 # 7 # 8 # 9 # 20 # 22 # 23 # 33 #
+query_vertical SHOW SLAVE STATUS;
+
+enable_parsing;
diff --git a/mysql-test/suite/rpl/t/rpl_ddl.test b/mysql-test/suite/rpl/t/rpl_ddl.test
new file mode 100644
index 00000000000..80df16a7a00
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_ddl.test
@@ -0,0 +1,32 @@
+######################## rpl_ddl.test ########################
+# #
+# DDL statements (sometimes with implicit COMMIT) executed #
+# by the master and it's propagation into the slave #
+# #
+##############################################################
+
+#
+# NOTE, PLEASE BE CAREFUL, WHEN MODIFYING THE TESTS !!
+#
+# 1. !All! objects to be dropped, renamed, altered ... must be created
+# in AUTOCOMMIT= 1 mode before AUTOCOMMIT is set to 0 and the test
+# sequences start.
+#
+# 2. Never use a test object, which was direct or indirect affected by a
+# preceeding test sequence again.
+# Except table d1.t1 where ONLY DML is allowed.
+#
+# If one preceeding test sequence hits a (sometimes not good visible,
+# because the sql error code of the statement might be 0) bug
+# and these rules are ignored, a following test sequence might earn ugly
+# effects like failing 'sync_slave_with_master', crashes of the slave or
+# abort of the test case etc..
+#
+--source include/not_ndb_default.inc
+--source include/master-slave.inc
+--source include/have_innodb.inc
+let $engine_type= InnoDB;
+let $temp_engine_type= MEMORY;
+let $show_binlog = 0;
+let $manipulate = 0;
+-- source extra/rpl_tests/rpl_ddl.test
diff --git a/mysql-test/suite/rpl/t/rpl_deadlock_innodb-slave.opt b/mysql-test/suite/rpl/t/rpl_deadlock_innodb-slave.opt
new file mode 100644
index 00000000000..c52c239a1a1
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_deadlock_innodb-slave.opt
@@ -0,0 +1 @@
+--innodb --innodb_lock_wait_timeout=4 --slave-transaction-retries=2 --max-relay-log-size=4096
diff --git a/mysql-test/suite/rpl/t/rpl_deadlock_innodb.test b/mysql-test/suite/rpl/t/rpl_deadlock_innodb.test
new file mode 100644
index 00000000000..ee907f81b22
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_deadlock_innodb.test
@@ -0,0 +1,11 @@
+################################
+# Wrapper for rpl_deadlock.test#
+################################
+########################################################
+# By JBM 2005-02-15 Wrapped to allow reuse of test code#
+# Added to skip if ndb is default #
+########################################################
+-- source include/not_ndb_default.inc
+-- source include/have_innodb.inc
+let $engine_type=innodb;
+-- source extra/rpl_tests/rpl_deadlock.test
diff --git a/mysql-test/suite/rpl/t/rpl_delete_no_where.test b/mysql-test/suite/rpl/t/rpl_delete_no_where.test
new file mode 100644
index 00000000000..64a293b4058
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_delete_no_where.test
@@ -0,0 +1,7 @@
+###################################################
+# By JBM 2006-02-14 added to skip test when NDB #
+##################################################
+-- source include/not_ndb_default.inc
+-- source include/master-slave.inc
+let $engine_type=myisam;
+-- source extra/rpl_tests/rpl_delete_no_where.test
diff --git a/mysql-test/suite/rpl/t/rpl_do_grant.test b/mysql-test/suite/rpl/t/rpl_do_grant.test
new file mode 100644
index 00000000000..5615900c2dd
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_do_grant.test
@@ -0,0 +1,114 @@
+# Works in statement-based and row-based binlogging.
+# Test that GRANT and other user management commands are replicated to the slave
+
+-- source include/master-slave.inc
+
+# do not be influenced by other tests.
+connection master;
+delete from mysql.user where user=_binary'rpl_do_grant';
+delete from mysql.db where user=_binary'rpl_do_grant';
+flush privileges;
+save_master_pos;
+connection slave;
+sync_with_master;
+# if these DELETE did nothing on the master, we need to do them manually on the
+# slave.
+delete from mysql.user where user=_binary'rpl_ignore_grant';
+delete from mysql.db where user=_binary'rpl_ignore_grant';
+flush privileges;
+
+# test replication of GRANT
+connection master;
+grant select on *.* to rpl_do_grant@localhost;
+grant drop on test.* to rpl_do_grant@localhost;
+save_master_pos;
+connection slave;
+sync_with_master;
+show grants for rpl_do_grant@localhost;
+
+# test replication of SET PASSWORD
+connection master;
+set password for rpl_do_grant@localhost=password("does it work?");
+save_master_pos;
+connection slave;
+sync_with_master;
+select password<>_binary'' from mysql.user where user=_binary'rpl_do_grant';
+
+#
+# Bug#24158 SET PASSWORD in binary log fails under ANSI_QUOTES
+#
+connection master;
+update mysql.user set password='' where user='rpl_do_grant';
+flush privileges;
+select password<>'' from mysql.user where user='rpl_do_grant';
+set sql_mode='ANSI_QUOTES';
+set password for rpl_do_grant@localhost=password('does it work?');
+set sql_mode='';
+save_master_pos;
+connection slave;
+sync_with_master;
+select password<>'' from mysql.user where user='rpl_do_grant';
+
+
+# clear what we have done, to not influence other tests.
+connection master;
+delete from mysql.user where user=_binary'rpl_do_grant';
+delete from mysql.db where user=_binary'rpl_do_grant';
+flush privileges;
+sync_slave_with_master;
+# The mysql database is not replicated, so we have to do the deletes
+# manually on the slave as well.
+delete from mysql.user where user=_binary'rpl_do_grant';
+delete from mysql.db where user=_binary'rpl_do_grant';
+flush privileges;
+
+# End of 4.1 tests
+
+connection master;
+--error 1141
+show grants for rpl_do_grant@localhost;
+connection slave;
+--error 1141
+show grants for rpl_do_grant@localhost;
+
+connection master;
+create user rpl_do_grant@localhost;
+show grants for rpl_do_grant@localhost;
+--error 1141
+show grants for rpl_do_grant2@localhost;
+sync_slave_with_master;
+show grants for rpl_do_grant@localhost;
+--error 1141
+show grants for rpl_do_grant2@localhost;
+
+connection master;
+rename user rpl_do_grant@localhost to rpl_do_grant2@localhost;
+show grants for rpl_do_grant2@localhost;
+sync_slave_with_master;
+show grants for rpl_do_grant2@localhost;
+
+connection master;
+grant DELETE,INSERT on mysqltest1.* to rpl_do_grant2@localhost;
+show grants for rpl_do_grant2@localhost;
+sync_slave_with_master;
+show grants for rpl_do_grant2@localhost;
+
+connection master;
+revoke DELETE on mysqltest1.* from rpl_do_grant2@localhost;
+show grants for rpl_do_grant2@localhost;
+sync_slave_with_master;
+show grants for rpl_do_grant2@localhost;
+
+connection master;
+revoke all privileges, grant option from rpl_do_grant2@localhost;
+show grants for rpl_do_grant2@localhost;
+sync_slave_with_master;
+show grants for rpl_do_grant2@localhost;
+
+connection master;
+drop user rpl_do_grant2@localhost;
+--error 1141
+show grants for rpl_do_grant2@localhost;
+sync_slave_with_master;
+--error 1141
+show grants for rpl_do_grant2@localhost;
diff --git a/mysql-test/suite/rpl/t/rpl_drop.test b/mysql-test/suite/rpl/t/rpl_drop.test
new file mode 100644
index 00000000000..b38007a755f
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_drop.test
@@ -0,0 +1,16 @@
+# Testcase for BUG#4552 (DROP on two tables, one of which does not
+# exist, must be binlogged with a non-zero error code)
+source include/master-slave.inc;
+--disable_warnings
+drop table if exists t1, t2;
+--enable_warnings
+create table t1 (a int);
+--error 1051
+drop table t1, t2;
+save_master_pos;
+connection slave;
+sync_with_master;
+
+# End of 4.1 tests
+
+
diff --git a/mysql-test/suite/rpl/t/rpl_drop_db.test b/mysql-test/suite/rpl/t/rpl_drop_db.test
new file mode 100644
index 00000000000..7f4a7843c4a
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_drop_db.test
@@ -0,0 +1,61 @@
+# test case for BUG#4680 -- if there are extra files in the db directory
+# dropping the db on the master causes replication problems
+
+-- source include/master-slave.inc
+connection master;
+
+--disable_warnings
+drop database if exists mysqltest1;
+--enable_warnings
+create database mysqltest1;
+create table mysqltest1.t1 (n int);
+insert into mysqltest1.t1 values (1);
+select * from mysqltest1.t1 into outfile 'mysqltest1/f1.txt';
+create table mysqltest1.t2 (n int);
+create table mysqltest1.t3 (n int);
+--replace_result \\ /
+--error 1010
+drop database mysqltest1;
+use mysqltest1;
+show tables;
+
+# test the branch of the code that deals with the query buffer overflow
+
+--disable_query_log
+let $1=50;
+while ($1)
+{
+ eval create table mysqltest1.mysqltest_long_table_name$1 (n int);
+ dec $1;
+}
+--enable_query_log
+
+--replace_result \\ /
+--error 1010
+drop database mysqltest1;
+use mysqltest1;
+show tables;
+use test;
+create table t1 (n int);
+insert into t1 values (1234);
+sync_slave_with_master;
+
+connection slave;
+use mysqltest1;
+show tables;
+use test;
+select * from t1;
+
+#cleanup
+connection slave;
+stop slave;
+drop database mysqltest1;
+
+connection master;
+# Remove the "extra" file created above
+--remove_file $MYSQLTEST_VARDIR/master-data/mysqltest1/f1.txt
+drop database mysqltest1;
+
+use test;
+drop table t1;
+
diff --git a/mysql-test/suite/rpl/t/rpl_drop_temp-slave.opt b/mysql-test/suite/rpl/t/rpl_drop_temp-slave.opt
new file mode 100644
index 00000000000..2f9244c65ff
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_drop_temp-slave.opt
@@ -0,0 +1,2 @@
+--replicate-ignore-table=mysqltest.t2
+
diff --git a/mysql-test/suite/rpl/t/rpl_drop_temp.test b/mysql-test/suite/rpl/t/rpl_drop_temp.test
new file mode 100644
index 00000000000..305c78d3f06
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_drop_temp.test
@@ -0,0 +1,27 @@
+##############################################
+# Change Author: JBM
+# Change Date: 2006-02-07
+# Change: Added ENGINE=MyISAM
+# Purpose: According to TU in 16552 This is how
+# to work around NDB's issue with temp tables
+##############################################
+source include/master-slave.inc;
+--disable_warnings
+create database if not exists mysqltest;
+--enable_warnings
+
+create temporary table mysqltest.t1 (n int)ENGINE=MyISAM;
+create temporary table mysqltest.t2 (n int)ENGINE=MyISAM;
+sync_slave_with_master;
+connection master;
+disconnect master;
+connection slave;
+--real_sleep 3 # time for DROP to be written
+show status like 'Slave_open_temp_tables';
+
+# Cleanup
+connection default;
+drop database mysqltest;
+sync_slave_with_master;
+
+# End of 4.1 tests
diff --git a/mysql-test/suite/rpl/t/rpl_dual_pos_advance-master.opt b/mysql-test/suite/rpl/t/rpl_dual_pos_advance-master.opt
new file mode 100644
index 00000000000..cef79bc8585
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_dual_pos_advance-master.opt
@@ -0,0 +1 @@
+--force-restart
diff --git a/mysql-test/suite/rpl/t/rpl_dual_pos_advance.test b/mysql-test/suite/rpl/t/rpl_dual_pos_advance.test
new file mode 100644
index 00000000000..27c920a3186
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_dual_pos_advance.test
@@ -0,0 +1,114 @@
+# This test checks that in a dual-head setup
+# A->B->A, where A has --log-slave-updates (why would it?
+# assume that there is a C as slave of A),
+# then the Exec_master_log_pos of SHOW SLAVE STATUS does
+# not stay too low on B(BUG#13023 due to events ignored because
+# of their server id).
+# It also will test BUG#13861.
+
+source include/master-slave.inc;
+
+
+# set up "dual head"
+
+connection slave;
+reset master;
+
+connection master;
+--replace_result $SLAVE_MYPORT SLAVE_PORT
+eval change master to master_host="127.0.0.1",master_port=$SLAVE_MYPORT,master_user="root";
+
+start slave;
+
+# now we test it
+
+connection slave;
+
+create table t1 (n int);
+
+save_master_pos;
+connection master;
+sync_with_master;
+
+# Now test BUG#13861. This will be enabled when Guilhem fixes this
+# bug.
+
+# stop slave
+
+# create table t2 (n int); # create one ignored event
+
+# save_master_pos;
+# connection slave;
+# sync_with_master;
+
+# connection slave;
+
+# show tables;
+
+# save_master_pos;
+
+# create table t3 (n int);
+
+# connection master;
+
+# bug is that START SLAVE UNTIL may stop too late, we test that by
+# asking it to stop before creation of t3.
+
+# start slave until master_log_file="slave-bin.000001",master_log_pos=195;
+
+# wait until it's started (the position below is the start of "CREATE
+# TABLE t2") (otherwise wait_for_slave_to_stop may return at once)
+
+# select master_pos_wait("slave-bin.000001",137);
+
+# --source include/wait_for_slave_to_stop.inc
+
+# then BUG#13861 causes t3 to show up below (because stopped too
+# late).
+
+# show tables;
+
+# start slave;
+
+# BUG#13023 is that Exec_master_log_pos may stay too low "forever":
+
+connection master;
+
+create table t4 (n int); # create 3 ignored events
+create table t5 (n int);
+create table t6 (n int);
+
+save_master_pos;
+connection slave;
+sync_with_master;
+
+connection slave;
+
+save_master_pos;
+
+connection master;
+
+# then BUG#13023 caused hang below ("master" looks behind, while it's
+# not in terms of updates done).
+
+sync_with_master;
+
+show tables;
+
+# cleanup
+
+stop slave;
+reset slave;
+drop table t1,t4,t5,t6; # add t2 and t3 later
+
+save_master_pos;
+connection slave;
+sync_with_master;
+
+# End of 4.1 tests
+
+# Cleanup
+# The A->B->A replication causes the master to start writing relay logs
+# in var/run, remove them
+remove_file $MYSQLTEST_VARDIR/run/master-relay-bin.000001;
+remove_file $MYSQLTEST_VARDIR/run/master-relay-bin.index;
diff --git a/mysql-test/suite/rpl/t/rpl_empty_master_crash-master.opt b/mysql-test/suite/rpl/t/rpl_empty_master_crash-master.opt
new file mode 100644
index 00000000000..cef79bc8585
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_empty_master_crash-master.opt
@@ -0,0 +1 @@
+--force-restart
diff --git a/mysql-test/suite/rpl/t/rpl_empty_master_crash.test b/mysql-test/suite/rpl/t/rpl_empty_master_crash.test
new file mode 100644
index 00000000000..f8e7870ae3c
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_empty_master_crash.test
@@ -0,0 +1,14 @@
+source include/master-slave.inc;
+
+source include/show_slave_status.inc;
+
+#
+# Load table should not succeed on the master as this is not a slave
+#
+--error 1218
+load table t1 from master;
+connection slave;
+--error 1188
+load table t1 from master;
+
+# End of 4.1 tests
diff --git a/mysql-test/suite/rpl/t/rpl_err_ignoredtable-slave.opt b/mysql-test/suite/rpl/t/rpl_err_ignoredtable-slave.opt
new file mode 100644
index 00000000000..cb49119bfcb
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_err_ignoredtable-slave.opt
@@ -0,0 +1 @@
+--replicate-ignore-table=test.t1 --replicate-ignore-table=test.t2 --replicate-ignore-table=test.t3
diff --git a/mysql-test/suite/rpl/t/rpl_err_ignoredtable.test b/mysql-test/suite/rpl/t/rpl_err_ignoredtable.test
new file mode 100644
index 00000000000..4e06a6a7096
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_err_ignoredtable.test
@@ -0,0 +1,66 @@
+# Test for
+# Bug #797: If a query is ignored on slave (replicate-ignore-table) the slave
+# still checks that it has the same error as on the master.
+##########################################################################
+# 2006-02-07 JBM Added error code 1022 for NDB Engine + ORDER BY
+##########################################################################
+
+-- source include/master-slave.inc
+
+connection master;
+create table t1 (a int primary key);
+create table t4 (a int primary key);
+# generate an error that goes to the binlog
+--error 1022, ER_DUP_ENTRY
+insert into t1 values (1),(1);
+insert into t4 values (1),(2);
+save_master_pos;
+connection slave;
+# as the t1 table is ignored on the slave, the slave should be able to sync
+sync_with_master;
+# check that the table has been ignored, because otherwise the test is nonsense
+show tables like 't1';
+show tables like 't4';
+SELECT * FROM test.t4 ORDER BY a;
+connection master;
+drop table t1;
+save_master_pos;
+connection slave;
+sync_with_master;
+
+# Now test that even critical errors (connection killed)
+# are ignored if rules allow it.
+# The "kill" idea was copied from rpl000001.test.
+
+connection master1;
+select get_lock('crash_lock%20C', 10);
+
+connection master;
+create table t2 (a int primary key);
+insert into t2 values(1);
+create table t3 (id int);
+insert into t3 values(connection_id());
+send update t2 set a = a + 1 + get_lock('crash_lock%20C', 10);
+
+connection master1;
+real_sleep 2;
+select (@id := id) - id from t3;
+kill @id;
+drop table t2,t3;
+insert into t4 values (3),(4);
+connection master;
+--error 0,1053,2013
+reap;
+connection master1;
+save_master_pos;
+connection slave;
+sync_with_master;
+SELECT * FROM test.t4 ORDER BY a;
+
+connection master1;
+DROP TABLE test.t4;
+save_master_pos;
+connection slave;
+sync_with_master;
+# End of 4.1 tests
+# Adding comment for force manual merge 5.0 -> wl1012. delete me if needed
diff --git a/mysql-test/suite/rpl/t/rpl_events.test b/mysql-test/suite/rpl/t/rpl_events.test
new file mode 100644
index 00000000000..62ffead7dcb
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_events.test
@@ -0,0 +1,47 @@
+##################################################################
+# Author: Giuseppe #
+# Date: 2006-12-20 #
+# Purpose: To test that event effects are replicated #
+# in both row based and statement based format #
+##################################################################
+
+set global event_scheduler=1;
+
+--source include/not_embedded.inc
+--source include/master-slave.inc
+
+let $engine_type= MyISAM;
+
+set binlog_format=row;
+
+# Embedded server doesn't support binlogging
+--source include/rpl_events.inc
+
+set binlog_format=statement;
+
+# Embedded server doesn't support binlogging
+--source include/rpl_events.inc
+
+#
+# Bug #28953 Using events in a replication let the slave crash.
+#
+
+connection master;
+
+DELIMITER |;
+CREATE EVENT event1 ON SCHEDULE EVERY 1 YEAR
+DO BEGIN
+ select * from t1;
+END;|
+DELIMITER ;|
+
+ALTER EVENT event1 RENAME TO event2;
+
+sync_slave_with_master;
+
+connection master;
+
+DROP EVENT event2;
+
+sync_slave_with_master;
+
diff --git a/mysql-test/suite/rpl/t/rpl_extraCol_innodb-master.opt b/mysql-test/suite/rpl/t/rpl_extraCol_innodb-master.opt
new file mode 100644
index 00000000000..627becdbfb5
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_extraCol_innodb-master.opt
@@ -0,0 +1 @@
+--innodb
diff --git a/mysql-test/suite/rpl/t/rpl_extraCol_innodb-slave.opt b/mysql-test/suite/rpl/t/rpl_extraCol_innodb-slave.opt
new file mode 100644
index 00000000000..627becdbfb5
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_extraCol_innodb-slave.opt
@@ -0,0 +1 @@
+--innodb
diff --git a/mysql-test/suite/rpl/t/rpl_extraCol_innodb.test b/mysql-test/suite/rpl/t/rpl_extraCol_innodb.test
new file mode 100644
index 00000000000..e9685baf01b
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_extraCol_innodb.test
@@ -0,0 +1,13 @@
+###########################################
+# Author: Jeb
+# Date: 2006-09-08
+# Purpose: Wapper for rpl_extraSlave_Col.test
+# Using innodb
+###########################################
+-- source include/have_binlog_format_row.inc
+-- source include/have_innodb.inc
+-- source include/master-slave.inc
+let $engine_type = 'InnoDB';
+-- source extra/rpl_tests/rpl_extraSlave_Col.test
+
+
diff --git a/mysql-test/suite/rpl/t/rpl_extraCol_myisam.test b/mysql-test/suite/rpl/t/rpl_extraCol_myisam.test
new file mode 100644
index 00000000000..d56df394ccf
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_extraCol_myisam.test
@@ -0,0 +1,12 @@
+###########################################
+# Author: Jeb
+# Date: 2006-09-07
+# Purpose: Wapper for rpl_extraSlave_Col.test
+# Using MyISAM
+###########################################
+-- source include/have_binlog_format_row.inc
+-- source include/master-slave.inc
+let $engine_type = 'MyISAM';
+-- source extra/rpl_tests/rpl_extraSlave_Col.test
+
+
diff --git a/mysql-test/suite/rpl/t/rpl_failed_optimize-master.opt b/mysql-test/suite/rpl/t/rpl_failed_optimize-master.opt
new file mode 100644
index 00000000000..3f82baff598
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_failed_optimize-master.opt
@@ -0,0 +1 @@
+--loose-innodb-lock-wait-timeout=1
diff --git a/mysql-test/suite/rpl/t/rpl_failed_optimize.test b/mysql-test/suite/rpl/t/rpl_failed_optimize.test
new file mode 100644
index 00000000000..81e8342b5c0
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_failed_optimize.test
@@ -0,0 +1,11 @@
+#######################################
+# Wrapper for rpl_failed_optimize.test#
+#######################################
+########################################################
+# By JBM 2005-02-15 Wrapped to allow reuse of test code#
+# Added to skip if ndb is default #
+########################################################
+-- source include/not_ndb_default.inc
+-- source include/have_innodb.inc
+let $engine_type=InnoDB;
+-- source extra/rpl_tests/rpl_failed_optimize.test
diff --git a/mysql-test/suite/rpl/t/rpl_flushlog_loop-master.opt b/mysql-test/suite/rpl/t/rpl_flushlog_loop-master.opt
new file mode 100644
index 00000000000..a4d1d403dc9
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_flushlog_loop-master.opt
@@ -0,0 +1 @@
+-O max_binlog_size=1M --relay-log=$MYSQLTEST_VARDIR/master-data/relay-log
diff --git a/mysql-test/suite/rpl/t/rpl_flushlog_loop-master.sh b/mysql-test/suite/rpl/t/rpl_flushlog_loop-master.sh
new file mode 100755
index 00000000000..a321dd690cd
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_flushlog_loop-master.sh
@@ -0,0 +1,5 @@
+rm -f $MYSQLTEST_VARDIR/slave-data/*-bin.*
+rm -f $MYSQLTEST_VARDIR/slave-data/master.info
+rm -f $MYSQLTEST_VARDIR/slave-data/*.index
+
+
diff --git a/mysql-test/suite/rpl/t/rpl_flushlog_loop-slave.opt b/mysql-test/suite/rpl/t/rpl_flushlog_loop-slave.opt
new file mode 100644
index 00000000000..95839c831c9
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_flushlog_loop-slave.opt
@@ -0,0 +1 @@
+-O max_binlog_size=1M --relay-log=$MYSQLTEST_VARDIR/slave-data/relay-log
diff --git a/mysql-test/suite/rpl/t/rpl_flushlog_loop-slave.sh b/mysql-test/suite/rpl/t/rpl_flushlog_loop-slave.sh
new file mode 100755
index 00000000000..e46ea6d400b
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_flushlog_loop-slave.sh
@@ -0,0 +1,4 @@
+rm -f $MYSQLTEST_VARDIR/master-data/master.info
+rm -f $MYSQLTEST_VARDIR/master-data/*-bin.*
+rm -f $MYSQLTEST_VARDIR/master-data/*.index
+
diff --git a/mysql-test/suite/rpl/t/rpl_flushlog_loop.test b/mysql-test/suite/rpl/t/rpl_flushlog_loop.test
new file mode 100644
index 00000000000..7d92ba9c2f4
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_flushlog_loop.test
@@ -0,0 +1,49 @@
+# Testing if "flush logs" command bouncing resulting in logs created in a loop
+# in case of bi-directional replication
+-- source include/master-slave.inc
+
+#
+# Start replication master -> slave
+#
+# We have to sync with master, to ensure slave had time to start properly
+# before we stop it. If not, we get errors about UNIX_TIMESTAMP() in the log.
+sync_slave_with_master;
+connection slave;
+--disable_warnings
+stop slave;
+--enable_warnings
+--replace_result $MASTER_MYPORT MASTER_PORT
+eval change master to master_host='127.0.0.1',master_user='root',
+ master_password='',master_port=$MASTER_MYPORT;
+start slave;
+
+#
+# Start replication slave -> master
+#
+connection master;
+--disable_warnings
+stop slave;
+--enable_warnings
+--replace_result $SLAVE_MYPORT SLAVE_PORT
+eval change master to master_host='127.0.0.1',master_user='root',
+ master_password='',master_port=$SLAVE_MYPORT;
+start slave;
+
+#
+# Wait for start of slave IO and SQL threads
+#
+let $result_pattern= '%127.0.0.1%root%slave-bin.000001%slave-bin.000001%Yes%Yes%0%0%None%';
+--source include/wait_slave_status.inc
+
+#
+# Flush logs of slave
+#
+flush logs;
+sleep 5;
+
+#
+# Show status of slave
+#
+--replace_result $SLAVE_MYPORT SLAVE_PORT
+--replace_column 1 # 8 # 9 # 16 # 23 # 33 # 34 # 35 #
+--query_vertical SHOW SLAVE STATUS
diff --git a/mysql-test/suite/rpl/t/rpl_foreign_key_innodb-slave.opt b/mysql-test/suite/rpl/t/rpl_foreign_key_innodb-slave.opt
new file mode 100644
index 00000000000..627becdbfb5
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_foreign_key_innodb-slave.opt
@@ -0,0 +1 @@
+--innodb
diff --git a/mysql-test/suite/rpl/t/rpl_foreign_key_innodb.test b/mysql-test/suite/rpl/t/rpl_foreign_key_innodb.test
new file mode 100644
index 00000000000..d085bff2012
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_foreign_key_innodb.test
@@ -0,0 +1,11 @@
+###################################
+# Wrapper for rpl_foreign_key.test#
+###################################
+# Change Author: JBM
+# Change Date: 2006-01-17
+# Change: FK not supported, skip test when NDB is forced
+####################################
+-- source include/not_ndb_default.inc
+-- source include/have_innodb.inc
+let $engine_type=INNODB;
+-- source extra/rpl_tests/rpl_foreign_key.test
diff --git a/mysql-test/suite/rpl/t/rpl_free_items-slave.opt b/mysql-test/suite/rpl/t/rpl_free_items-slave.opt
new file mode 100644
index 00000000000..b828d03fafb
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_free_items-slave.opt
@@ -0,0 +1 @@
+--replicate-wild-ignore-table=test.%
diff --git a/mysql-test/suite/rpl/t/rpl_free_items.test b/mysql-test/suite/rpl/t/rpl_free_items.test
new file mode 100644
index 00000000000..043e84160b8
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_free_items.test
@@ -0,0 +1,22 @@
+source include/master-slave.inc;
+create table t1 (a int);
+create table t2 (a int);
+disable_query_log;
+SET @query="INSERT INTO t2 SELECT * FROM t1 WHERE a REGEXP \"0\"";
+let $1 = 2000;
+while ($1)
+{
+ eval SET @query=concat(@query, " OR a REGEXP '$1'");
+ dec $1;
+}
+let $1=`select @query`;
+eval $1;
+enable_query_log;
+# I have seen the slave crash either now or at shutdown
+sync_slave_with_master;
+connection master;
+drop table t1;
+drop table t2;
+sync_slave_with_master;
+
+# End of 4.1 tests
diff --git a/mysql-test/suite/rpl/t/rpl_get_lock.test b/mysql-test/suite/rpl/t/rpl_get_lock.test
new file mode 100644
index 00000000000..945bd98c993
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_get_lock.test
@@ -0,0 +1,43 @@
+source include/master-slave.inc;
+
+create table t1(n int);
+insert into t1 values(get_lock("lock",2));
+dirty_close master;
+connection master1;
+select get_lock("lock",2);
+
+select release_lock("lock");
+#ignore
+disable_query_log;
+let $1=2000;
+while ($1)
+{
+ do get_lock("lock",2);
+ do release_lock("lock");
+ dec $1;
+}
+enable_query_log;
+save_master_pos;
+connection slave;
+sync_with_master;
+select get_lock("lock",3);
+select * from t1;
+# There is no point in testing REPLICATIION of the IS_*_LOCK
+# functions; slave does not run with the same concurrency context as
+# master (generally in slave we can't know that on master this lock
+# was already held by another connection and so that the the
+# get_lock() we're replicating timed out on master hence returned 0,
+# or that the is_free_lock() we're playing returned 0 etc.
+# But here all we do is test these functions outside of replication.
+select is_free_lock("lock"), is_used_lock("lock") = connection_id();
+explain extended select is_free_lock("lock"), is_used_lock("lock");
+# Check lock functions
+select is_free_lock("lock2");
+select is_free_lock(NULL);
+connection master1;
+drop table t1;
+save_master_pos;
+connection slave;
+sync_with_master;
+
+# End of 4.1 tests
diff --git a/mysql-test/suite/rpl/t/rpl_ignore_grant-slave.opt b/mysql-test/suite/rpl/t/rpl_ignore_grant-slave.opt
new file mode 100644
index 00000000000..e931bfbd37e
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_ignore_grant-slave.opt
@@ -0,0 +1 @@
+--replicate-wild-ignore-table=mysql.%
diff --git a/mysql-test/suite/rpl/t/rpl_ignore_grant.test b/mysql-test/suite/rpl/t/rpl_ignore_grant.test
new file mode 100644
index 00000000000..2e6e2ce9a31
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_ignore_grant.test
@@ -0,0 +1,59 @@
+# Test that GRANT is not replicated to the slave
+# when --replicate-wild-ignore-table=mysql.%
+# In BUG#980, this test would _randomly_ fail.
+
+source include/master-slave.inc;
+
+# do not be influenced by other tests.
+connection master;
+delete from mysql.user where user=_binary'rpl_ignore_grant';
+delete from mysql.db where user=_binary'rpl_ignore_grant';
+flush privileges;
+save_master_pos;
+connection slave;
+sync_with_master;
+# as these DELETE were not replicated, we need to do them manually on the
+# slave.
+delete from mysql.user where user=_binary'rpl_ignore_grant';
+delete from mysql.db where user=_binary'rpl_ignore_grant';
+flush privileges;
+
+# test non-replication of GRANT
+connection master;
+grant select on *.* to rpl_ignore_grant@localhost;
+grant drop on test.* to rpl_ignore_grant@localhost;
+show grants for rpl_ignore_grant@localhost;
+save_master_pos;
+connection slave;
+sync_with_master;
+--error 1141 #("no such grant for user")
+show grants for rpl_ignore_grant@localhost;
+# check it another way
+select count(*) from mysql.user where user=_binary'rpl_ignore_grant';
+select count(*) from mysql.db where user=_binary'rpl_ignore_grant';
+
+# test non-replication of SET PASSWORD
+# first force creation of the user on slave (because as the user does not exist
+# on slave, the SET PASSWORD may be replicated but silently do nothing; this is
+# not what we want; we want it to be not-replicated).
+grant select on *.* to rpl_ignore_grant@localhost;
+connection master;
+set password for rpl_ignore_grant@localhost=password("does it work?");
+save_master_pos;
+connection slave;
+sync_with_master;
+select password<>_binary'' from mysql.user where user=_binary'rpl_ignore_grant';
+
+# clear what we have done, to not influence other tests.
+connection master;
+delete from mysql.user where user=_binary'rpl_ignore_grant';
+delete from mysql.db where user=_binary'rpl_ignore_grant';
+flush privileges;
+save_master_pos;
+connection slave;
+sync_with_master;
+delete from mysql.user where user=_binary'rpl_ignore_grant';
+delete from mysql.db where user=_binary'rpl_ignore_grant';
+flush privileges;
+
+# End of 4.1 tests
diff --git a/mysql-test/suite/rpl/t/rpl_ignore_revoke-slave.opt b/mysql-test/suite/rpl/t/rpl_ignore_revoke-slave.opt
new file mode 100644
index 00000000000..e931bfbd37e
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_ignore_revoke-slave.opt
@@ -0,0 +1 @@
+--replicate-wild-ignore-table=mysql.%
diff --git a/mysql-test/suite/rpl/t/rpl_ignore_revoke.test b/mysql-test/suite/rpl/t/rpl_ignore_revoke.test
new file mode 100644
index 00000000000..00171605a92
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_ignore_revoke.test
@@ -0,0 +1,51 @@
+# test verifies that REVOKE must not be replicated when
+# slave server starts with --replicate-wild-ignore-table=mysql.%
+# the option is set in rpl_ignore_revoke-slave.opt
+# The first part of BUG#9483 for GRANT is checked by
+# existed specific rpl_ignore_grant test case (BUG#980)
+
+
+source include/master-slave.inc;
+
+### CLEAN-UP: create an account and manually duplicate it on the slave
+
+connection master;
+grant select on *.* to 'user_foo'@'%' identified by 'user_foopass';
+revoke select on *.* from 'user_foo'@'%';
+select select_priv from mysql.user where user='user_foo' /* master:must be N */;
+
+sync_slave_with_master;
+#connection slave;
+grant select on *.* to 'user_foo'@'%' identified by 'user_foopass';
+revoke select on *.* from 'user_foo'@'%';
+select select_priv from mysql.user where user='user_foo' /* slave:must be N */;
+
+
+### TEST
+
+#connection slave;
+grant select on *.* to 'user_foo'@'%' identified by 'user_foopass';
+select select_priv from mysql.user where user='user_foo' /* slave:must be Y */;
+
+connection master;
+revoke select on *.* from 'user_foo';
+select select_priv from mysql.user where user='user_foo' /* master:must be N */;
+
+sync_slave_with_master;
+#connection slave;
+select select_priv from mysql.user where user='user_foo' /* slave:must get Y */;
+
+### CLEAN-UP
+
+connection slave;
+--disable_abort_on_error
+revoke select on *.* FROM 'user_foo';
+--enable_abort_on_error
+
+connection master;
+delete from mysql.user where user="user_foo";
+sync_slave_with_master;
+
+# Since changes to mysql.* are ignored, the revoke need to
+# be done on slave as well
+delete from mysql.user where user="user_foo";
diff --git a/mysql-test/suite/rpl/t/rpl_ignore_table-slave.opt b/mysql-test/suite/rpl/t/rpl_ignore_table-slave.opt
new file mode 100644
index 00000000000..3aabbb2e0f5
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_ignore_table-slave.opt
@@ -0,0 +1 @@
+--replicate-ignore-table=test.t1 --replicate-ignore-table=test.t2 --replicate-ignore-table=test.t3 --replicate-wild-ignore-table=%.tmptbl%
diff --git a/mysql-test/suite/rpl/t/rpl_ignore_table.test b/mysql-test/suite/rpl/t/rpl_ignore_table.test
new file mode 100644
index 00000000000..fd4ae64165a
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_ignore_table.test
@@ -0,0 +1,164 @@
+source include/master-slave.inc;
+
+#
+# BUG#16487
+#
+# Requirement:
+# Multi-updates on ignored tables should not fail even if the slave does
+# not have the ignored tables.
+#
+# Note table t1, t2, and t3 are ignored in the option file to this test.
+#
+
+--echo **** Test case for BUG#16487 ****
+--echo **** Master ****
+connection master;
+CREATE TABLE test.t4 (a int);
+CREATE TABLE test.t1 (a int);
+
+# Expect: The row must *not* by updated on slave, since t1 is ignored
+UPDATE test.t4 NATURAL JOIN test.t1 SET t1.a=5;
+
+--echo **** Slave ****
+sync_slave_with_master;
+SELECT * FROM t4;
+
+# Cleanup
+connection master;
+DROP TABLE t1;
+DROP TABLE t4;
+
+sync_slave_with_master;
+
+
+#
+# Bug#25482 GRANT statements are not replicated if
+# you use "replicate-ignore-table"
+#
+
+--echo **** Test case for BUG#25482 ****
+--echo **** Adding GRANTS on master ****
+
+connection master;
+create table test.t1(a int);
+create table test.t4(a int);
+
+# Simple user that should not replicate
+GRANT SELECT ON test.t1 TO mysqltest1@localhost;
+
+# Partial replicate
+GRANT INSERT ON test.t4 TO mysqltest2@localhost;
+GRANT select, update, insert, references on t1
+ to mysqltest2@localhost;
+
+# Partial replicate 2
+GRANT SELECT ON test.* TO mysqltest3@localhost;
+GRANT INSERT ON test.t4 TO mysqltest3@localhost;
+GRANT select(a), update(a), insert(a), references(a) on t4
+ to mysqltest3@localhost;
+
+# Create another database and table
+create database mysqltest2;
+create table mysqltest2.t2 (id int);
+# Create a grant that should replicate
+GRANT SELECT ON mysqltest2.t2 TO mysqltest4@localhost IDENTIFIED BY 'pass';
+
+# Create a grant manually
+insert into mysql.user (user, host) values ("mysqltest5", "somehost");
+
+# Partial replicate 3 with *.*
+GRANT SELECT ON *.* TO mysqltest6@localhost;
+GRANT INSERT ON *.* TO mysqltest6@localhost;
+GRANT INSERT ON test.* TO mysqltest6@localhost;
+GRANT INSERT ON test.t1 TO mysqltest6@localhost;
+
+show grants for mysqltest1@localhost;
+show grants for mysqltest2@localhost;
+show grants for mysqltest3@localhost;
+show grants for mysqltest4@localhost;
+show grants for mysqltest6@localhost;
+
+flush privileges;
+show grants for mysqltest5@somehost;
+
+
+sync_slave_with_master;
+
+--echo **** Checking grants on slave ****
+
+# Check that grants are replicated to slave
+show grants for mysqltest2@localhost;
+show grants for mysqltest3@localhost;
+show grants for mysqltest4@localhost;
+show grants for mysqltest5@somehost;
+show grants for mysqltest6@localhost;
+
+# mysqltest1 should not be on slave
+--error 1141
+show grants for mysqltest1@localhost;
+
+--echo **** Revoking grants on master ****
+connection master;
+REVOKE SELECT ON test.t1 FROM mysqltest1@localhost;
+REVOKE SELECT ON mysqltest2.t2 FROM mysqltest4@localhost;
+REVOKE select(a) on t4
+ from mysqltest3@localhost;
+
+show grants for mysqltest1@localhost;
+show grants for mysqltest3@localhost;
+show grants for mysqltest4@localhost;
+
+sync_slave_with_master;
+
+--echo **** Checking grants on slave ****
+
+# mysqltest1 should not be on slave
+--error 1141
+show grants for mysqltest1@localhost;
+show grants for mysqltest3@localhost;
+show grants for mysqltest4@localhost;
+
+# Cleanup
+connection master;
+drop table t1, t4, mysqltest2.t2;
+drop database mysqltest2;
+delete from mysql.user where user like "mysqltest%";
+delete from mysql.db where user like "mysqltest%";
+#
+# BUG 27606 causes failure to replicate this statement
+# move it to slave instead
+#delete from mysql.tables_priv where user like "mysqltest%";
+delete from mysql.columns_priv where user like "mysqltest%";
+sync_slave_with_master;
+
+#BUG27606
+delete from mysql.tables_priv where user like "mysqltest%";
+
+connection master;
+
+#BUG27606
+delete from mysql.tables_priv where user like "mysqltest%";
+
+#
+# bug#22877 replication character sets get out of sync
+# using replicate-wild-ignore-table
+#
+connection master;
+--disable_warnings
+DROP TABLE IF EXISTS t5;
+--enable_warnings
+CREATE TABLE t5 (
+ word varchar(50) collate utf8_unicode_ci NOT NULL default ''
+) DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+SET @@session.character_set_client=33,@@session.collation_connection=192;
+CREATE TEMPORARY TABLE tmptbl504451f4258$1 (id INT NOT NULL) ENGINE=MEMORY;
+INSERT INTO t5 (word) VALUES ('TEST’');
+SELECT HEX(word) FROM t5;
+sync_slave_with_master;
+connection slave;
+SELECT HEX(word) FROM t5;
+--error 1146
+SELECT * FROM tmptbl504451f4258$1;
+connection master;
+DROP TABLE t5;
+sync_slave_with_master;
diff --git a/mysql-test/suite/rpl/t/rpl_ignore_table_update-slave.opt b/mysql-test/suite/rpl/t/rpl_ignore_table_update-slave.opt
new file mode 100644
index 00000000000..177f89e0910
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_ignore_table_update-slave.opt
@@ -0,0 +1 @@
+--replicate-ignore-table=test.mysqltest_foo
diff --git a/mysql-test/suite/rpl/t/rpl_ignore_table_update.test b/mysql-test/suite/rpl/t/rpl_ignore_table_update.test
new file mode 100644
index 00000000000..fe030f90411
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_ignore_table_update.test
@@ -0,0 +1,38 @@
+# This one assumes we are ignoring updates on table mysqltest_foo, but doing
+# the ones on all other tables
+
+source include/master-slave.inc;
+connection slave;
+
+#
+# For this test we must be in the test database
+#
+use test;
+
+--disable_warnings
+drop table if exists mysqltest_foo;
+drop table if exists mysqltest_bar;
+--enable_warnings
+
+create table mysqltest_foo (n int);
+insert into mysqltest_foo values(4);
+connection master;
+use test;
+create table mysqltest_foo (n int);
+insert into mysqltest_foo values(5);
+create table mysqltest_bar (m int);
+insert into mysqltest_bar values(15);
+create table t1 (k int);
+insert into t1 values(55);
+save_master_pos;
+connection slave;
+sync_with_master;
+select mysqltest_foo.n,mysqltest_bar.m,t1.k from mysqltest_foo,mysqltest_bar,t1;
+connection master;
+drop table mysqltest_foo,mysqltest_bar,t1;
+save_master_pos;
+connection slave;
+sync_with_master;
+drop table mysqltest_foo,mysqltest_bar,t1;
+
+# End of 4.1 tests
diff --git a/mysql-test/suite/rpl/t/rpl_incident-master.opt b/mysql-test/suite/rpl/t/rpl_incident-master.opt
new file mode 100644
index 00000000000..912801debc4
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_incident-master.opt
@@ -0,0 +1 @@
+--loose-debug=+d,incident_database_resync_on_replace
diff --git a/mysql-test/suite/rpl/t/rpl_incident.test b/mysql-test/suite/rpl/t/rpl_incident.test
new file mode 100644
index 00000000000..507cd0e0798
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_incident.test
@@ -0,0 +1,42 @@
+--source include/master-slave.inc
+--source include/have_debug.inc
+
+--echo **** On Master ****
+CREATE TABLE t1 (a INT);
+
+INSERT INTO t1 VALUES (1),(2),(3);
+SELECT * FROM t1;
+
+# This will generate an incident log event and store it in the binary
+# log before the replace statement.
+REPLACE INTO t1 VALUES (4);
+--save_master_pos
+SELECT * FROM t1;
+
+connection slave;
+--wait_for_slave_to_stop
+
+# The 4 should not be inserted into the table, since the incident log
+# event should have stop the slave.
+--echo **** On Slave ****
+SELECT * FROM t1;
+
+--replace_result $MASTER_MYPORT MASTER_PORT
+--replace_column 1 # 6 # 7 # 8 # 9 # 22 # 23 # 33 #
+--query_vertical SHOW SLAVE STATUS
+
+SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
+START SLAVE;
+--sync_with_master
+
+# Now, we should have inserted the row into the table and the slave
+# should be running. We should also have rotated to a new binary log.
+
+SELECT * FROM t1;
+--replace_result $MASTER_MYPORT MASTER_PORT
+--replace_column 1 # 6 # 7 # 8 # 9 # 22 # 23 # 33 #
+--query_vertical SHOW SLAVE STATUS
+
+connection master;
+DROP TABLE t1;
+--sync_slave_with_master
diff --git a/mysql-test/suite/rpl/t/rpl_init_slave-slave.opt b/mysql-test/suite/rpl/t/rpl_init_slave-slave.opt
new file mode 100644
index 00000000000..337e8a60d97
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_init_slave-slave.opt
@@ -0,0 +1 @@
+--init-slave="set global max_connections=500"
diff --git a/mysql-test/suite/rpl/t/rpl_init_slave.test b/mysql-test/suite/rpl/t/rpl_init_slave.test
new file mode 100644
index 00000000000..139b4902e12
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_init_slave.test
@@ -0,0 +1,34 @@
+source include/master-slave.inc;
+
+#
+# Test of init_slave variable
+#
+
+save_master_pos;
+connection slave;
+sleep 1;
+show variables like 'init_slave';
+show variables like 'max_connections';
+sync_with_master;
+reset master;
+connection master;
+show variables like 'init_slave';
+show variables like 'max_connections';
+save_master_pos;
+connection slave;
+sync_with_master;
+# Save variable value
+set @my_global_init_connect= @@global.init_connect;
+set global init_connect="set @c=1";
+show variables like 'init_connect';
+connection master;
+save_master_pos;
+connection slave;
+sync_with_master;
+stop slave;
+
+# Restore changed global variable
+set global init_connect= @my_global_init_connect;
+set global max_connections= default;
+
+# End of 4.1 tests
diff --git a/mysql-test/suite/rpl/t/rpl_innodb.test b/mysql-test/suite/rpl/t/rpl_innodb.test
new file mode 100644
index 00000000000..30d40e19614
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_innodb.test
@@ -0,0 +1,115 @@
+# File for specialities regarding replication from or to InnoDB
+# tables.
+
+source include/master-slave.inc;
+source include/have_innodb.inc;
+
+#
+# Bug#11401: Load data infile 'REPLACE INTO' fails on slave.
+#
+connection master;
+CREATE TABLE t4 (
+ id INT(5) unsigned NOT NULL auto_increment,
+ name varchar(15) NOT NULL default '',
+ number varchar(35) NOT NULL default 'default',
+ PRIMARY KEY (id),
+ UNIQUE KEY unique_rec (name,number)
+) ENGINE=InnoDB;
+
+--disable_warnings
+LOAD DATA
+ INFILE '../std_data_ln/loaddata_pair.dat'
+ REPLACE INTO TABLE t4
+ (name,number);
+--enable_warnings
+SELECT * FROM t4;
+
+sync_slave_with_master;
+SELECT * FROM t4;
+
+connection master;
+--disable_warnings
+LOAD DATA
+ INFILE '../std_data_ln/loaddata_pair.dat'
+ REPLACE INTO TABLE t4
+ (name,number);
+--enable_warnings
+SELECT * FROM t4;
+
+sync_slave_with_master;
+SELECT * FROM t4;
+
+connection master;
+--disable_query_log
+DROP TABLE t4;
+--enable_query_log
+sync_slave_with_master;
+connection master;
+
+# End of 4.1 tests
+
+#
+# Bug #26418: Slave out of sync after CREATE/DROP TEMPORARY TABLE + ROLLBACK
+# on master
+#
+#Note Matthias: to be merged to rpl_ddl.test
+
+--source include/not_ndb_default.inc
+
+FLUSH LOGS;
+sync_slave_with_master;
+FLUSH LOGS;
+connection master;
+let $engine_type= "InnoDB";
+
+--disable_warnings
+DROP DATABASE IF EXISTS mysqltest1;
+--enable_warnings
+
+CREATE DATABASE mysqltest1;
+CREATE TEMPORARY TABLE mysqltest1.tmp (f1 BIGINT);
+eval CREATE TABLE mysqltest1.t1 (f1 BIGINT) ENGINE=$engine_type;
+SET AUTOCOMMIT = 0;
+
+sync_slave_with_master;
+--echo -------- switch to slave --------
+connection slave;
+SHOW CREATE TABLE mysqltest1.t1;
+
+--echo -------- switch to master --------
+connection master;
+INSERT INTO mysqltest1.t1 SET f1= 1;
+DROP TEMPORARY TABLE mysqltest1.tmp;
+ROLLBACK;
+--error ER_NO_SUCH_TABLE
+SHOW CREATE TABLE mysqltest1.tmp;
+# Must return no rows here
+SELECT COUNT(*) FROM mysqltest1.t1;
+
+INSERT INTO mysqltest1.t1 SET f1= 2;
+CREATE TEMPORARY TABLE mysqltest1.tmp2(a INT);
+ROLLBACK;
+SHOW CREATE TABLE mysqltest1.tmp2;
+# Must return no rows here
+SELECT COUNT(*) FROM mysqltest1.t1;
+
+sync_slave_with_master;
+--echo -------- switch to slave --------
+connection slave;
+--error ER_NO_SUCH_TABLE
+SHOW CREATE TABLE mysqltest1.tmp;
+--error ER_NO_SUCH_TABLE
+SHOW CREATE TABLE mysqltest1.tmp2;
+# has two rows here : as the default is MyISAM and
+# it can't be rolled back by the master's ROLLBACK.
+SELECT COUNT(*) FROM mysqltest1.t1;
+FLUSH LOGS;
+
+--echo -------- switch to master --------
+connection master;
+FLUSH LOGS;
+
+DROP DATABASE mysqltest1;
+-- source include/master-slave-end.inc
+
+--echo End of 5.1 tests
diff --git a/mysql-test/suite/rpl/t/rpl_insert.test b/mysql-test/suite/rpl/t/rpl_insert.test
new file mode 100644
index 00000000000..0d471a0e0a9
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_insert.test
@@ -0,0 +1,44 @@
+--echo #
+--echo # Bug#20821: INSERT DELAYED fails to write some rows to binlog
+--echo #
+
+--source include/master-slave.inc
+--source include/not_embedded.inc
+--source include/not_windows.inc
+
+--disable_warnings
+CREATE SCHEMA IF NOT EXISTS mysqlslap;
+USE mysqlslap;
+--enable_warnings
+
+CREATE TABLE t1 (id INT, name VARCHAR(64));
+
+let $query = "INSERT DELAYED INTO t1 VALUES (1, 'Dr. No'), (2, 'From Russia With Love'), (3, 'Goldfinger'), (4, 'Thunderball'), (5, 'You Only Live Twice')";
+--exec $MYSQL_SLAP --silent --concurrency=5 --iterations=200 --query=$query --delimiter=";"
+
+# Wait until all the 5000 inserts has been inserted into the table
+--disable_query_log
+let $counter= 300; # Max 30 seconds wait
+while (`select count(*)!=5000 from mysqlslap.t1`)
+{
+ sleep 0.1;
+ dec $counter;
+ if (!$counter)
+ {
+ Number of records in t1 didnt reach 5000;
+ }
+}
+--enable_query_log
+
+SELECT COUNT(*) FROM mysqlslap.t1;
+sync_slave_with_master;
+SELECT COUNT(*) FROM mysqlslap.t1;
+
+--echo #
+--echo # Cleanup
+--echo #
+
+connection master;
+USE test;
+DROP SCHEMA mysqlslap;
+sync_slave_with_master;
diff --git a/mysql-test/suite/rpl/t/rpl_insert_id-slave.opt b/mysql-test/suite/rpl/t/rpl_insert_id-slave.opt
new file mode 100644
index 00000000000..48457b17309
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_insert_id-slave.opt
@@ -0,0 +1 @@
+--loose-innodb
diff --git a/mysql-test/suite/rpl/t/rpl_insert_id.test b/mysql-test/suite/rpl/t/rpl_insert_id.test
new file mode 100644
index 00000000000..bfd66431d3c
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_insert_id.test
@@ -0,0 +1,11 @@
+#################################
+# Wrapper for rpl_insert_id.test#
+#################################
+########################################################
+# By JBM 2005-02-15 Wrapped to allow reuse of test code#
+# Added to skip if ndb is default #
+########################################################
+-- source include/not_ndb_default.inc
+-- source include/have_innodb.inc
+let $engine_type=innodb;
+-- source extra/rpl_tests/rpl_insert_id.test
diff --git a/mysql-test/suite/rpl/t/rpl_insert_id_pk-slave.opt b/mysql-test/suite/rpl/t/rpl_insert_id_pk-slave.opt
new file mode 100644
index 00000000000..48457b17309
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_insert_id_pk-slave.opt
@@ -0,0 +1 @@
+--loose-innodb
diff --git a/mysql-test/suite/rpl/t/rpl_insert_id_pk.test b/mysql-test/suite/rpl/t/rpl_insert_id_pk.test
new file mode 100644
index 00000000000..01f30b78ac5
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_insert_id_pk.test
@@ -0,0 +1,11 @@
+#################################
+# Wrapper for rpl_insert_id.test#
+#################################
+########################################################
+# By JBM 2005-02-15 Wrapped to allow reuse of test code#
+# Added to skip if ndb is default #
+########################################################
+-- source include/not_ndb_default.inc
+-- source include/have_innodb.inc
+let $engine_type=innodb;
+-- source extra/rpl_tests/rpl_insert_id_pk.test
diff --git a/mysql-test/suite/rpl/t/rpl_insert_ignore-slave.opt b/mysql-test/suite/rpl/t/rpl_insert_ignore-slave.opt
new file mode 100644
index 00000000000..48457b17309
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_insert_ignore-slave.opt
@@ -0,0 +1 @@
+--loose-innodb
diff --git a/mysql-test/suite/rpl/t/rpl_insert_ignore.test b/mysql-test/suite/rpl/t/rpl_insert_ignore.test
new file mode 100644
index 00000000000..2709430f85d
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_insert_ignore.test
@@ -0,0 +1,9 @@
+#####################################
+# Wrapper for rpl_insert_ignore.test#
+#####################################
+-- source include/not_ndb_default.inc
+-- source include/have_innodb.inc
+-- source include/master-slave.inc
+let $engine_type=innodb;
+let $engine_type2=myisam;
+-- source extra/rpl_tests/rpl_insert_ignore.test
diff --git a/mysql-test/suite/rpl/t/rpl_insert_select.test b/mysql-test/suite/rpl/t/rpl_insert_select.test
new file mode 100644
index 00000000000..677be526982
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_insert_select.test
@@ -0,0 +1,19 @@
+# Testcase for BUG#10456 - INSERT INTO ... SELECT violating a primary key
+# breaks replication
+
+-- source include/master-slave.inc
+connection master;
+
+create table t1 (n int not null primary key);
+insert into t1 values (1);
+create table t2 (n int);
+insert into t2 values (1);
+insert ignore into t1 select * from t2;
+insert into t1 values (2);
+sync_slave_with_master;
+connection slave;
+select * from t1;
+
+connection master;
+drop table t1,t2;
+sync_slave_with_master;
diff --git a/mysql-test/suite/rpl/t/rpl_known_bugs_detection-master.opt b/mysql-test/suite/rpl/t/rpl_known_bugs_detection-master.opt
new file mode 100644
index 00000000000..d4ba386a1a0
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_known_bugs_detection-master.opt
@@ -0,0 +1 @@
+--loose-debug=d,pretend_version_50034_in_binlog
diff --git a/mysql-test/suite/rpl/t/rpl_known_bugs_detection.test b/mysql-test/suite/rpl/t/rpl_known_bugs_detection.test
new file mode 100644
index 00000000000..b300603f454
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_known_bugs_detection.test
@@ -0,0 +1,93 @@
+# Test to see if slave can detect certain known bugs present
+# on the master, and appropriately decides to stop
+# (assuming the bug is fixed in the slave, slave cannot of course
+# imitate the bug, so it has to stop).
+
+source include/have_debug.inc;
+source include/master-slave.inc;
+
+# Currently only statement-based-specific bugs are here
+-- source include/have_binlog_format_mixed_or_statement.inc
+
+#
+# This is to test that slave properly detects if
+# master may suffer from:
+# BUG#24432 "INSERT... ON DUPLICATE KEY UPDATE skips auto_increment values"
+# (i.e. on master, INSERT ON DUPLICATE KEY UPDATE is used and manipulates
+# an auto_increment column, and is binlogged statement-based).
+#
+
+# testcase with INSERT VALUES
+CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY AUTO_INCREMENT, b INT,
+UNIQUE(b));
+sync_slave_with_master;
+connection master;
+INSERT INTO t1(b) VALUES(1),(1),(2) ON DUPLICATE KEY UPDATE t1.b=10;
+SELECT * FROM t1;
+connection slave;
+--source include/wait_for_slave_sql_to_stop.inc
+# show the error message
+--replace_column 1 # 4 # 7 # 8 # 9 # 23 # 33 #
+--query_vertical show slave status;
+# show that it was not replicated
+SELECT * FROM t1;
+
+# restart replication for the next testcase
+stop slave;
+reset slave;
+connection master;
+reset master;
+drop table t1;
+connection slave;
+start slave;
+
+# testcase with INSERT SELECT
+connection master;
+CREATE TABLE t1 (
+ id bigint(20) unsigned NOT NULL auto_increment,
+ field_1 int(10) unsigned NOT NULL,
+ field_2 varchar(255) NOT NULL,
+ field_3 varchar(255) NOT NULL,
+ PRIMARY KEY (id),
+ UNIQUE KEY field_1 (field_1, field_2)
+);
+CREATE TABLE t2 (
+ field_a int(10) unsigned NOT NULL,
+ field_b varchar(255) NOT NULL,
+ field_c varchar(255) NOT NULL
+);
+INSERT INTO t2 (field_a, field_b, field_c) VALUES (1, 'a', '1a');
+INSERT INTO t2 (field_a, field_b, field_c) VALUES (2, 'b', '2b');
+INSERT INTO t2 (field_a, field_b, field_c) VALUES (3, 'c', '3c');
+INSERT INTO t2 (field_a, field_b, field_c) VALUES (4, 'd', '4d');
+INSERT INTO t2 (field_a, field_b, field_c) VALUES (5, 'e', '5e');
+sync_slave_with_master;
+connection master;
+# Updating table t1 based on values from table t2
+INSERT INTO t1 (field_1, field_2, field_3)
+SELECT t2.field_a, t2.field_b, t2.field_c
+FROM t2
+ON DUPLICATE KEY UPDATE
+t1.field_3 = t2.field_c;
+# Inserting new record into t2
+INSERT INTO t2 (field_a, field_b, field_c) VALUES (6, 'f', '6f');
+# Updating t1 again
+INSERT INTO t1 (field_1, field_2, field_3)
+SELECT t2.field_a, t2.field_b, t2.field_c
+FROM t2
+ON DUPLICATE KEY UPDATE
+t1.field_3 = t2.field_c;
+SELECT * FROM t1;
+connection slave;
+--source include/wait_for_slave_sql_to_stop.inc
+# show the error message
+--replace_column 1 # 4 # 7 # 8 # 9 # 23 # 33 #
+--query_vertical show slave status;
+# show that it was not replicated
+SELECT * FROM t1;
+connection master;
+drop table t1, t2;
+connection slave;
+drop table t1, t2;
+
+# End of 5.0 tests
diff --git a/mysql-test/suite/rpl/t/rpl_load_from_master-slave.opt b/mysql-test/suite/rpl/t/rpl_load_from_master-slave.opt
new file mode 100644
index 00000000000..c015c02ba78
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_load_from_master-slave.opt
@@ -0,0 +1 @@
+--replicate-wild-do-table=mysqltest.%
diff --git a/mysql-test/suite/rpl/t/rpl_load_from_master.test b/mysql-test/suite/rpl/t/rpl_load_from_master.test
new file mode 100644
index 00000000000..9bab7d5696e
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_load_from_master.test
@@ -0,0 +1,180 @@
+# This one assumes we are ignoring updates on tables in database mysqltest2,
+# but doing the ones in database mysqltest
+#################################################################
+# Change Author: JBM
+# Change Date: 2006-02-02
+# Change: Added ENGINE=MyISAM
+# Reason: LOAD from master is only supported by MyISAM
+#################################################################
+
+source include/master-slave.inc;
+--disable_warnings
+drop database if exists mysqltest;
+drop database if exists mysqltest2;
+drop database if exists mysqltest3;
+connection slave;
+drop database if exists mysqltest;
+drop database if exists mysqltest2;
+drop database if exists mysqltest3;
+connection master;
+create database mysqltest2;
+create database mysqltest;
+--enable_warnings
+
+save_master_pos;
+connection slave;
+sync_with_master;
+create database mysqltest2;
+create table mysqltest2.foo (n int)ENGINE=MyISAM;
+insert into mysqltest2.foo values(4);
+connection master;
+create table mysqltest2.foo (n int)ENGINE=MyISAM;
+insert into mysqltest2.foo values(5);
+create table mysqltest.bar (m int)ENGINE=MyISAM;
+insert into mysqltest.bar values(15);
+save_master_pos;
+connection slave;
+sync_with_master;
+select mysqltest2.foo.n,mysqltest.bar.m from mysqltest2.foo,mysqltest.bar;
+connection master;
+drop database mysqltest;
+drop database if exists mysqltest2;
+save_master_pos;
+connection slave;
+sync_with_master;
+--error 1008
+drop database mysqltest;
+drop database mysqltest2;
+
+# Now let's test load data from master
+
+# First create some databases and tables on the master
+
+connection master;
+set sql_log_bin = 0;
+create database mysqltest2;
+create database mysqltest;
+show databases;
+create table mysqltest2.t1(n int, s char(20))ENGINE=MyISAM;
+create table mysqltest2.t2(n int, s text)ENGINE=MyISAM;
+insert into mysqltest2.t1 values (1, 'one'), (2, 'two'), (3, 'three');
+insert into mysqltest2.t2 values (11, 'eleven'), (12, 'twelve'), (13, 'thirteen');
+
+create table mysqltest.t1(n int, s char(20))ENGINE=MyISAM;
+create table mysqltest.t2(n int, s text)ENGINE=MyISAM;
+insert into mysqltest.t1 values (1, 'one test'), (2, 'two test'), (3, 'three test');
+insert into mysqltest.t2 values (11, 'eleven test'), (12, 'twelve test'),
+ (13, 'thirteen test');
+set sql_log_bin = 1;
+save_master_pos;
+connection slave;
+sync_with_master;
+
+# This should show that the slave is empty at this point
+show databases;
+# Create mysqltest2 and mysqltest3 on slave; we expect that LOAD DATA FROM
+# MASTER will neither touch database mysqltest nor mysqltest3
+create database mysqltest2;
+create table mysqltest2.t1(n int, s char(20))ENGINE=MyISAM;
+insert into mysqltest2.t1 values (1, 'original foo.t1');
+create table mysqltest2.t3(n int, s char(20))ENGINE=MyISAM;
+insert into mysqltest2.t3 values (1, 'original foo.t3');
+create database mysqltest3;
+create table mysqltest3.t1(n int, s char(20))ENGINE=MyISAM;
+insert into mysqltest3.t1 values (1, 'original foo2.t1');
+
+# Create mysqltest, and mysqltest.t1, to check that it gets replaced,
+# and mysqltest.t3 to check that it is not touched (there is no
+# mysqltest.t3 on master)
+create database mysqltest;
+create table mysqltest.t1(n int, s char(20))ENGINE=MyISAM;
+insert into mysqltest.t1 values (1, 'original bar.t1');
+create table mysqltest.t3(n int, s char(20))ENGINE=MyISAM;
+insert into mysqltest.t3 values (1, 'original bar.t3');
+
+load data from master;
+
+# Now let's check if we have the right tables and the right data in them
+show databases;
+use mysqltest2;
+
+# LOAD DATA FROM MASTER uses only replicate_*_db rules to decide which
+# databases have to be copied. So it thinks "mysqltest" has to be
+# copied. Before 4.0.16 it would first drop "mysqltest", then create
+# "mysqltest". This "drop" is a bug; in that case t3 would disappear. So
+# here the effect of this bug (BUG#1248) would be to leave an empty
+# "mysqltest" on the slave.
+
+show tables; # should be t1 & t3
+select * from t1; # should be slave's original
+use mysqltest3;
+show tables; # should be t1
+select * from t1; # should be slave's original
+use mysqltest;
+show tables; # should contain master's copied t1&t2, slave's original t3
+select * from mysqltest.t1;
+select * from mysqltest.t2;
+select * from mysqltest.t3;
+
+# Now let's see if replication works
+connection master;
+insert into mysqltest.t1 values (4, 'four test');
+save_master_pos;
+connection slave;
+sync_with_master;
+select * from mysqltest.t1;
+
+# Check that LOAD DATA FROM MASTER is able to create master.info
+# if needed (if RESET SLAVE was used before), before writing to it (BUG#2922).
+
+stop slave;
+reset slave;
+load data from master;
+start slave;
+# see if replication coordinates were restored fine
+connection master;
+insert into mysqltest.t1 values (5, 'five bar');
+save_master_pos;
+connection slave;
+sync_with_master;
+select * from mysqltest.t1;
+
+# Check that LOAD DATA FROM MASTER reports the error if it can't drop a
+# table to be overwritten.
+# DISABLED FOR NOW AS chmod IS NOT PORTABLE ON NON-UNIX
+# insert into mysqltest.t1 values(10, 'should be there');
+# flush tables;
+# system chmod 500 $MYSQLTEST_VARDIR/slave-data/mysqltest/;
+# --error 6
+# load data from master; # should fail (errno 13)
+# system chmod 700 $MYSQLTEST_VARDIR/slave-data/mysqltest/;
+# select * from mysqltest.t1; # should contain the row (10, ...)
+
+
+# Check that LOAD TABLE FROM MASTER fails if the table exists on slave
+--error 1050
+load table mysqltest.t1 from master;
+drop table mysqltest.t1;
+load table mysqltest.t1 from master;
+
+# Check what happens when requestion not existing table
+#
+--error 1188
+load table bar.t1 from master;
+
+# as LOAD DATA FROM MASTER failed it did not restart slave threads
+# DISABLED FOR NOW
+# start slave;
+
+# Now time for cleanup
+connection master;
+drop database mysqltest;
+drop database mysqltest2;
+save_master_pos;
+connection slave;
+sync_with_master;
+# These have to be dropped on slave because they are not replicated
+drop database mysqltest2;
+drop database mysqltest3;
+
+# End of 4.1 tests
diff --git a/mysql-test/suite/rpl/t/rpl_load_table_from_master.test b/mysql-test/suite/rpl/t/rpl_load_table_from_master.test
new file mode 100644
index 00000000000..b9cec3858a9
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_load_table_from_master.test
@@ -0,0 +1,98 @@
+###########################################################
+# Change Author: JBM
+# Change Date: 2006-2-2
+# Change: Added ENGINE=$engine_type for first create table
+# Reason: Only MyISAM supports load from master no need to
+# run test case for other engines, in addition test will
+# fail if other engines are set as default engine
+###########################################################
+# Change Author: JBM
+# Change Date: 2006-2-3
+# Change: removed ENGINE=$engine_type for first create table
+# and renamed test file to rpl_load_table_from_master.test.
+# In addition added test requirements.
+# Reason: Request from review.
+############################################################
+# REQUIREMENT TEST 1:
+# LOAD TABLE FROM MASTER must work with a forced timestamp.
+############################################################
+#
+# Test forced timestamp
+#
+-- source include/master-slave.inc
+
+-- echo "******************** Test Requirment 1 *************"
+
+# Don't log table creating to the slave as we want to test LOAD TABLE
+SET SQL_LOG_BIN=0,timestamp=200006;
+eval CREATE TABLE t1(t TIMESTAMP NOT NULL,a CHAR(1))ENGINE=MyISAM;
+INSERT INTO t1 ( a) VALUE ('F');
+select unix_timestamp(t) from t1;
+connection slave;
+load table t1 from master;
+select unix_timestamp(t) from t1;
+
+# Delete the created table on master and slave
+connection master;
+set SQL_LOG_BIN=1,timestamp=default;
+drop table t1;
+save_master_pos;
+connection slave;
+sync_with_master;
+connection master;
+
+#
+# Test copying table with checksum
+#
+
+# Don't log table creating to the slave as we want to test LOAD TABLE
+set SQL_LOG_BIN=0;
+
+#######################################################
+# REQUIREMENTi TEST 2:
+#LOAD TABLE FROM MASTER must work with table checksum
+#######################################################
+-- echo "******************** Test Requirment 2 *************"
+
+eval CREATE TABLE t1 (a INT NOT NULL) ENGINE=MyISAM MAX_ROWS=4000 CHECKSUM=1;
+INSERT INTO t1 VALUES (1);
+save_master_pos;
+connection slave;
+sync_with_master;
+load table t1 from master;
+check table t1;
+drop table t1;
+connection master;
+drop table t1;
+save_master_pos;
+connection slave;
+sync_with_master;
+
+connection master;
+set SQL_LOG_BIN=0;
+create table t1 (word char(20) not null, index(word))ENGINE=MyISAM;
+load data infile '../std_data_ln/words.dat' into table t1;
+create table t2 (word char(20) not null)ENGINE=MyISAM;
+load data infile '../std_data_ln/words.dat' into table t2;
+create table t3 (word char(20) not null primary key)ENGINE=MyISAM;
+connection slave;
+load table t1 from master;
+load table t2 from master;
+load table t3 from master;
+check table t1;
+select count(*) from t2;
+select count(*) from t3;
+connection master;
+set SQL_LOG_BIN=1;
+drop table if exists t1,t2,t3;
+save_master_pos;
+connection slave;
+sync_with_master;
+create table t1(n int);
+drop table t1;
+
+
+
+
+
+# End of 4.1 tests
diff --git a/mysql-test/suite/rpl/t/rpl_loaddata.test b/mysql-test/suite/rpl/t/rpl_loaddata.test
new file mode 100644
index 00000000000..6f9ee4ef80a
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_loaddata.test
@@ -0,0 +1,7 @@
+########################################################
+# By JBM 2005-02-15 Wrapped to allow reuse of test code#
+# Added to skip if ndb is default #
+########################################################
+-- source include/not_ndb_default.inc
+let $engine_type=MyISAM;
+-- source extra/rpl_tests/rpl_loaddata.test
diff --git a/mysql-test/suite/rpl/t/rpl_loaddata_charset.test b/mysql-test/suite/rpl/t/rpl_loaddata_charset.test
new file mode 100644
index 00000000000..7f2389cb9f6
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_loaddata_charset.test
@@ -0,0 +1,33 @@
+#
+# Check LOAD DATA + character sets + replication
+#
+source include/master-slave.inc;
+
+#
+# Bug#15126 character_set_database is not replicated
+# (LOAD DATA INFILE need it)
+#
+connection master;
+create table t1 (a varchar(10) character set utf8);
+load data infile '../std_data_ln/loaddata6.dat' into table t1;
+set @@character_set_database=koi8r;
+load data infile '../std_data_ln/loaddata6.dat' into table t1;
+set @@character_set_database=DEFAULT;
+load data infile '../std_data_ln/loaddata6.dat' into table t1;
+load data infile '../std_data_ln/loaddata6.dat' into table t1;
+load data infile '../std_data_ln/loaddata6.dat' into table t1;
+set @@character_set_database=koi8r;
+load data infile '../std_data_ln/loaddata6.dat' into table t1;
+set @@character_set_database=DEFAULT;
+load data infile '../std_data_ln/loaddata6.dat' into table t1 character set koi8r;
+
+select hex(a) from t1;
+
+save_master_pos;
+connection slave;
+sync_with_master;
+
+select hex(a) from t1;
+connection master;
+drop table t1;
+sync_slave_with_master;
diff --git a/mysql-test/suite/rpl/t/rpl_loaddata_m-master.opt b/mysql-test/suite/rpl/t/rpl_loaddata_m-master.opt
new file mode 100644
index 00000000000..9d4a8f0b95e
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_loaddata_m-master.opt
@@ -0,0 +1 @@
+--binlog_ignore_db=test
diff --git a/mysql-test/suite/rpl/t/rpl_loaddata_m.test b/mysql-test/suite/rpl/t/rpl_loaddata_m.test
new file mode 100644
index 00000000000..537d4c163ef
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_loaddata_m.test
@@ -0,0 +1,52 @@
+# See if the master logs LOAD DATA INFILE correctly when binlog_*_db rules
+# exist.
+# This is for BUG#1100 (LOAD DATA INFILE was half-logged).
+######################################################
+# Change Author: JBM
+# Change Date: 2005-12-22
+# Change: Test rewritten to remove show binlog events
+# and to test the option better + Cleanup
+######################################################
+-- source include/master-slave.inc
+
+--disable_warnings
+drop database if exists mysqltest;
+--enable_warnings
+
+connection master;
+# 'test' database should be ignored by the slave
+USE test;
+CREATE TABLE t1(a INT, b INT, UNIQUE(b));
+LOAD DATA INFILE '../std_data_ln/rpl_loaddata.dat' INTO TABLE test.t1;
+SELECT COUNT(*) FROM test.t1;
+
+# 'mysqltest' database should NOT be ignored by the slave
+CREATE DATABASE mysqltest;
+USE mysqltest;
+CREATE TABLE t1(a INT, b INT, UNIQUE(b));
+LOAD DATA INFILE '../std_data_ln/rpl_loaddata.dat' INTO TABLE mysqltest.t1;
+SELECT COUNT(*) FROM mysqltest.t1;
+
+# Now lets check the slave to see what we have :-)
+save_master_pos;
+connection slave;
+sync_with_master;
+
+SHOW DATABASES;
+
+USE test;
+SHOW TABLES;
+
+USE mysqltest;
+SHOW TABLES;
+SELECT COUNT(*) FROM mysqltest.t1;
+
+#show binlog events;
+
+# Cleanup
+connection master;
+DROP DATABASE mysqltest;
+DROP TABLE test.t1;
+sync_slave_with_master;
+
+# End of test
diff --git a/mysql-test/suite/rpl/t/rpl_loaddata_s-slave.opt b/mysql-test/suite/rpl/t/rpl_loaddata_s-slave.opt
new file mode 100644
index 00000000000..9d4a8f0b95e
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_loaddata_s-slave.opt
@@ -0,0 +1 @@
+--binlog_ignore_db=test
diff --git a/mysql-test/suite/rpl/t/rpl_loaddata_s.test b/mysql-test/suite/rpl/t/rpl_loaddata_s.test
new file mode 100644
index 00000000000..f397d741310
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_loaddata_s.test
@@ -0,0 +1,28 @@
+# See if the slave logs (in its own binlog, with --log-slave-updates) a
+# replicated LOAD DATA INFILE correctly when it has binlog_*_db rules.
+# This is for BUG#1100 (LOAD DATA INFILE was half-logged).
+
+-- source include/have_binlog_format_mixed_or_statement.inc
+-- source include/master-slave.inc
+
+connection slave;
+# Not sure why we connect to slave and then try to reset master, but I will leave it [JBM]
+reset master;
+
+connection master;
+# 'test' is the current database
+create table test.t1(a int, b int, unique(b));
+load data infile '../std_data_ln/rpl_loaddata.dat' into table test.t1;
+
+# Test logging on slave;
+
+save_master_pos;
+connection slave;
+sync_with_master;
+select count(*) from test.t1; # check that LOAD was replicated
+source include/show_binlog_events.inc;
+
+# Cleanup
+connection master;
+drop table test.t1;
+sync_slave_with_master;
diff --git a/mysql-test/suite/rpl/t/rpl_loaddata_simple.test b/mysql-test/suite/rpl/t/rpl_loaddata_simple.test
new file mode 100644
index 00000000000..9e908cac677
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_loaddata_simple.test
@@ -0,0 +1,14 @@
+--source include/master-slave.inc
+
+CREATE TABLE t1 (word CHAR(20) NOT NULL);
+LOAD DATA INFILE '../std_data_ln/words.dat' INTO TABLE t1;
+SELECT * FROM t1 ORDER BY word;
+sync_slave_with_master;
+
+# Check
+SELECT * FROM t1 ORDER BY word;
+
+# Cleanup
+connection master;
+drop table t1;
+sync_slave_with_master;
diff --git a/mysql-test/suite/rpl/t/rpl_loaddatalocal.test b/mysql-test/suite/rpl/t/rpl_loaddatalocal.test
new file mode 100644
index 00000000000..b10603e7195
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_loaddatalocal.test
@@ -0,0 +1,65 @@
+# See if "LOAD DATA LOCAL INFILE" is well replicated
+# (LOAD DATA LOCAL INFILE is not written to the binlog
+# the same way as LOAD DATA INFILE : Append_blocks are smaller).
+# In MySQL 4.0 <4.0.12 there were 2 bugs with LOAD DATA LOCAL INFILE :
+# - the loaded file was not written entirely to the master's binlog,
+# only the first 4KB, 8KB or 16KB usually.
+# - the loaded file's first line was not written entirely to the
+# master's binlog (1st char was absent)
+source include/master-slave.inc;
+
+create table t1(a int);
+let $1=10000;
+disable_query_log;
+set SQL_LOG_BIN=0;
+while ($1)
+{
+ insert into t1 values(1);
+ dec $1;
+}
+set SQL_LOG_BIN=1;
+enable_query_log;
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+eval select * into outfile '$MYSQLTEST_VARDIR/master-data/rpl_loaddatalocal.select_outfile' from t1;
+#This will generate a 20KB file, now test LOAD DATA LOCAL
+truncate table t1;
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+eval load data local infile '$MYSQLTEST_VARDIR/master-data/rpl_loaddatalocal.select_outfile' into table t1;
+--remove_file $MYSQLTEST_VARDIR/master-data/rpl_loaddatalocal.select_outfile
+save_master_pos;
+connection slave;
+sync_with_master;
+select a,count(*) from t1 group by a;
+connection master;
+drop table t1;
+save_master_pos;
+connection slave;
+sync_with_master;
+
+# End of 4.1 tests
+
+#
+# Now let us test how well we replicate LOAD DATA LOCAL in situation when
+# we met duplicates in tables to which we are adding rows.
+# (It supposed that LOAD DATA LOCAL ignores such errors)
+#
+connection master;
+create table t1(a int);
+insert into t1 values (1), (2), (2), (3);
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+eval select * into outfile '$MYSQLTEST_VARDIR/master-data/rpl_loaddatalocal.select_outfile' from t1;
+drop table t1;
+create table t1(a int primary key);
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+eval load data local infile '$MYSQLTEST_VARDIR/master-data/rpl_loaddatalocal.select_outfile' into table t1;
+--remove_file $MYSQLTEST_VARDIR/master-data/rpl_loaddatalocal.select_outfile
+SELECT * FROM t1 ORDER BY a;
+save_master_pos;
+connection slave;
+sync_with_master;
+SELECT * FROM t1 ORDER BY a;
+connection master;
+drop table t1;
+save_master_pos;
+connection slave;
+sync_with_master;
diff --git a/mysql-test/suite/rpl/t/rpl_loadfile.test b/mysql-test/suite/rpl/t/rpl_loadfile.test
new file mode 100644
index 00000000000..a671bab15bb
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_loadfile.test
@@ -0,0 +1,52 @@
+#############################################################################
+# Original Author: JBM #
+# Original Date: Aug/18/2005 #
+#############################################################################
+# TEST: To test the LOAD_FILE() in rbr #
+#############################################################################
+# Change Author: JBM
+# Change Date: 2006-01-16
+# Change: Added Order by for NDB
+##########
+
+# Includes
+-- source include/master-slave.inc
+
+
+# Begin clean up test section
+--disable_warnings
+connection master;
+DROP PROCEDURE IF EXISTS test.p1;
+DROP TABLE IF EXISTS test.t1;
+--enable_warnings
+
+# Section 1 test
+
+CREATE TABLE test.t1 (a INT, blob_column LONGBLOB, PRIMARY KEY(a));
+INSERT INTO test.t1 VALUES(1,'test');
+UPDATE test.t1 SET blob_column=LOAD_FILE('../std_data_ln/words2.dat') WHERE a=1;
+delimiter |;
+create procedure test.p1()
+begin
+ INSERT INTO test.t1 VALUES(2,'test');
+ UPDATE test.t1 SET blob_column=LOAD_FILE('../std_data_ln/words2.dat') WHERE a=2;
+end|
+delimiter ;|
+
+CALL test.p1();
+SELECT * FROM test.t1 ORDER BY blob_column;
+save_master_pos;
+# Need to allow some time when NDB engine is used for
+# the injector thread to have time to populate binlog
+sleep 10;
+sync_slave_with_master;
+connection slave;
+SELECT * FROM test.t1 ORDER BY blob_column;
+
+# Cleanup
+connection master;
+DROP PROCEDURE IF EXISTS test.p1;
+DROP TABLE test.t1;
+sync_slave_with_master;
+
+# End of 5.0 test case
diff --git a/mysql-test/suite/rpl/t/rpl_locale.test b/mysql-test/suite/rpl/t/rpl_locale.test
new file mode 100644
index 00000000000..2f2d637e1b4
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_locale.test
@@ -0,0 +1,24 @@
+# Replication of locale variables
+
+source include/master-slave.inc;
+
+#
+# Bug#22645 LC_TIME_NAMES: Statement not replicated
+#
+connection master;
+create table t1 (s1 char(10));
+set lc_time_names= 'de_DE';
+insert into t1 values (date_format('2001-01-01','%W'));
+set lc_time_names= 'en_US';
+insert into t1 values (date_format('2001-01-01','%W'));
+select * from t1;
+sync_slave_with_master;
+connection slave;
+select * from t1;
+connection master;
+drop table t1;
+sync_slave_with_master;
+
+# End of 4.1 tests
+
+
diff --git a/mysql-test/suite/rpl/t/rpl_log_pos.test b/mysql-test/suite/rpl/t/rpl_log_pos.test
new file mode 100644
index 00000000000..e5ad6f39ed2
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_log_pos.test
@@ -0,0 +1,50 @@
+##########
+# Change Author: JBM
+# Change Date: 2006-01-16
+# Change: Added Order by for NDB
+##########
+
+#
+# Testing of setting slave to wrong log position with master_log_pos
+#
+
+# Passes with rbr no problem, removed statement include [jbm]
+
+source include/master-slave.inc;
+--replace_column 3 <Binlog_Ignore_DB>
+show master status;
+sync_slave_with_master;
+stop slave;
+--source include/wait_for_slave_to_stop.inc
+
+change master to master_log_pos=75;
+source include/show_slave_status.inc;
+start slave;
+let $slave_param= Slave_SQL_Running;
+let $slave_param_value= Yes;
+--source include/wait_for_slave_param.inc
+let $slave_param= Slave_IO_Running;
+let $slave_param_value= No;
+--source include/wait_for_slave_param.inc
+stop slave;
+--source include/wait_for_slave_to_stop.inc
+
+source include/show_slave_status.inc;
+connection master;
+--replace_column 3 <Binlog_Ignore_DB>
+show master status;
+create table if not exists t1 (n int);
+drop table if exists t1;
+create table t1 (n int);
+insert into t1 values (1),(2),(3);
+save_master_pos;
+connection slave;
+change master to master_log_pos=106;
+start slave;
+sync_with_master;
+select * from t1 ORDER BY n;
+connection master;
+drop table t1;
+sync_slave_with_master;
+
+--echo End of 5.0 tests
diff --git a/mysql-test/suite/rpl/t/rpl_many_optimize.test b/mysql-test/suite/rpl/t/rpl_many_optimize.test
new file mode 100644
index 00000000000..91fab0b27a8
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_many_optimize.test
@@ -0,0 +1,22 @@
+# Test for BUG#7658 "optimize crashes slave thread (1 in 1000)]"
+
+source include/master-slave.inc;
+
+create table t1 (a int not null auto_increment primary key, b int, key(b));
+INSERT INTO t1 (a) VALUES (1),(2);
+# Now many OPTIMIZE to test if we crash (BUG#7658)
+let $1=300;
+disable_query_log;
+disable_result_log;
+while ($1)
+{
+ eval OPTIMIZE TABLE t1;
+ dec $1;
+}
+enable_result_log;
+enable_query_log;
+drop table t1;
+# Bug was that slave segfaulted after ~ a hundred of OPTIMIZE (or ANALYZE)
+sync_slave_with_master;
+
+# End of 4.1 tests
diff --git a/mysql-test/suite/rpl/t/rpl_master_pos_wait.test b/mysql-test/suite/rpl/t/rpl_master_pos_wait.test
new file mode 100644
index 00000000000..893c8746efc
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_master_pos_wait.test
@@ -0,0 +1,18 @@
+# See if master_pos_wait(,,timeout)
+# Terminates with "timeout expired" (-1)
+source include/master-slave.inc;
+save_master_pos;
+connection slave;
+sync_with_master;
+# Ask for a master log that has certainly not been reached yet
+# timeout= 2 seconds
+select master_pos_wait('master-bin.999999',0,2);
+explain extended select master_pos_wait('master-bin.999999',0,2);
+# Testcase for bug 651 (master_pos_wait() hangs if slave idle and STOP SLAVE).
+send select master_pos_wait('master-bin.999999',0);
+connection slave1;
+stop slave sql_thread;
+connection slave;
+reap;
+
+# End of 4.1 tests
diff --git a/mysql-test/suite/rpl/t/rpl_misc_functions-slave.sh b/mysql-test/suite/rpl/t/rpl_misc_functions-slave.sh
new file mode 100755
index 00000000000..8ce79797822
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_misc_functions-slave.sh
@@ -0,0 +1 @@
+rm -f $MYSQLTEST_VARDIR/master-data/test/rpl_misc_functions.outfile
diff --git a/mysql-test/suite/rpl/t/rpl_misc_functions.test b/mysql-test/suite/rpl/t/rpl_misc_functions.test
new file mode 100644
index 00000000000..db9b557baad
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_misc_functions.test
@@ -0,0 +1,103 @@
+#
+# Test of replicating some difficult functions
+#
+source include/master-slave.inc;
+
+create table t1(id int, i int, r1 int, r2 int, p varchar(100));
+insert into t1 values(1, connection_id(), 0, 0, "");
+# don't put rand and password in the same query, to see if they replicate
+# independently
+# Pure rand test
+insert into t1 values(2, 0, rand()*1000, rand()*1000, "");
+# change the rand suite on the master (we do this because otherwise password()
+# benefits from the fact that the above rand() is well replicated :
+# it picks the same sequence element, which hides a possible bug in password() replication.
+set sql_log_bin=0;
+insert into t1 values(6, 0, rand(), rand(), "");
+delete from t1 where id=6;
+set sql_log_bin=1;
+# Pure password test
+insert into t1 values(3, 0, 0, 0, password('does_this_work?'));
+# "altogether now"
+insert into t1 values(4, connection_id(), rand()*1000, rand()*1000, password('does_this_still_work?'));
+select * into outfile 'rpl_misc_functions.outfile' from t1;
+sync_slave_with_master;
+create table t2 like t1;
+# read the values from the master table
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+eval load data local infile '$MYSQLTEST_VARDIR/master-data/test/rpl_misc_functions.outfile' into table t2;
+# compare them with the replica; the SELECT below should return no row
+select * from t1, t2 where (t1.id=t2.id) and not(t1.i=t2.i and t1.r1=t2.r1 and t1.r2=t2.r2 and t1.p=t2.p);
+
+connection master;
+drop table t1;
+
+# End of 4.1 tests
+
+#
+# BUG#25543 test calling rand() multiple times on the master in
+# a stored procedure.
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (col_a double default NULL);
+
+DELIMITER |;
+
+# Use a SP that calls rand() multiple times
+CREATE PROCEDURE test_replication_sp1()
+BEGIN
+ INSERT INTO t1 VALUES (rand()), (rand());
+ INSERT INTO t1 VALUES (rand());
+END|
+
+# Use a SP that calls another SP to call rand() multiple times
+CREATE PROCEDURE test_replication_sp2()
+BEGIN
+ CALL test_replication_sp1();
+ CALL test_replication_sp1();
+END|
+
+# Use a SF that calls rand() multiple times
+CREATE FUNCTION test_replication_sf() RETURNS DOUBLE DETERMINISTIC
+BEGIN
+ RETURN (rand() + rand());
+END|
+
+DELIMITER ;|
+
+# Exercise the functions and procedures then compare the results on
+# the master to those on the slave.
+CALL test_replication_sp1();
+CALL test_replication_sp2();
+INSERT INTO t1 VALUES (test_replication_sf());
+INSERT INTO t1 VALUES (test_replication_sf());
+INSERT INTO t1 VALUES (test_replication_sf());
+
+# Record the results of the query on the master
+--exec $MYSQL --port=$MASTER_MYPORT test -e "SELECT * FROM test.t1" > $MYSQLTEST_VARDIR/tmp/rpl_rand_master.sql
+
+--sync_slave_with_master
+
+# Record the results of the query on the slave
+--exec $MYSQL --port=$SLAVE_MYPORT test -e "SELECT * FROM test.t1" > $MYSQLTEST_VARDIR/tmp/rpl_rand_slave.sql
+
+# Compare the results from the master to the slave.
+--exec diff $MYSQLTEST_VARDIR/tmp/rpl_rand_master.sql $MYSQLTEST_VARDIR/tmp/rpl_rand_slave.sql
+
+# Cleanup
+connection master;
+--disable_warnings
+DROP PROCEDURE IF EXISTS test_replication_sp1;
+DROP PROCEDURE IF EXISTS test_replication_sp2;
+DROP FUNCTION IF EXISTS test_replication_sf;
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+--sync_slave_with_master
+
+# If all is good, when can cleanup our dump files.
+--remove_file $MYSQLTEST_VARDIR/tmp/rpl_rand_master.sql
+--remove_file $MYSQLTEST_VARDIR/tmp/rpl_rand_slave.sql
diff --git a/mysql-test/suite/rpl/t/rpl_mixed_ddl_dml.test b/mysql-test/suite/rpl/t/rpl_mixed_ddl_dml.test
new file mode 100644
index 00000000000..6a1f81abed3
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_mixed_ddl_dml.test
@@ -0,0 +1,46 @@
+# Mixed DDL-DML (CREATE ... SELECT ...) statements can only be
+# replicated properly in statement-based replication.
+# Currently statement based due to bug 12345
+--source include/have_binlog_format_mixed_or_statement.inc
+
+source include/master-slave.inc;
+
+# Test replication of auto_increment
+
+create table t1 (n int auto_increment primary key);
+set insert_id = 2000;
+insert into t1 values (NULL),(NULL),(NULL);
+sync_slave_with_master;
+select * from t1;
+connection master;
+--replace_result $SLAVE_MYPORT 9999
+show slave hosts;
+drop table t1;
+sync_slave_with_master;
+stop slave;
+connection master;
+
+# Test replication of timestamp
+
+create table t2(id int auto_increment primary key, created datetime);
+set timestamp=12345;
+insert into t2 set created=now();
+select * from t2;
+
+# Test replication of CREATE .. LIKE (Bug #2557)
+
+create table t3 like t2;
+create temporary table t4 like t2;
+create table t5 select * from t4;
+save_master_pos;
+connection slave;
+start slave;
+sync_with_master;
+select * from t2;
+show create table t3;
+show create table t5;
+connection master;
+drop table t2,t3,t5;
+sync_slave_with_master;
+
+# End of 4.1 tests
diff --git a/mysql-test/suite/rpl/t/rpl_multi_delete-slave.opt b/mysql-test/suite/rpl/t/rpl_multi_delete-slave.opt
new file mode 100644
index 00000000000..c98fe0b0a46
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_multi_delete-slave.opt
@@ -0,0 +1 @@
+--replicate-wild-do-table=test.%
diff --git a/mysql-test/suite/rpl/t/rpl_multi_delete.test b/mysql-test/suite/rpl/t/rpl_multi_delete.test
new file mode 100644
index 00000000000..a251cbf8833
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_multi_delete.test
@@ -0,0 +1,26 @@
+source include/master-slave.inc;
+create table t1 (a int primary key);
+create table t2 (a int);
+
+insert into t1 values (1);
+insert into t2 values (1);
+
+
+delete t1.* from t1, t2 where t1.a = t2.a;
+
+save_master_pos;
+select * from t1;
+select * from t2;
+
+connection slave;
+sync_with_master;
+select * from t1;
+select * from t2;
+
+connection master;
+drop table t1,t2;
+save_master_pos;
+connection slave;
+sync_with_master;
+
+# End of 4.1 tests
diff --git a/mysql-test/suite/rpl/t/rpl_multi_delete2-slave.opt b/mysql-test/suite/rpl/t/rpl_multi_delete2-slave.opt
new file mode 100644
index 00000000000..0febb2891b1
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_multi_delete2-slave.opt
@@ -0,0 +1 @@
+"--replicate-rewrite-db=mysqltest_from->mysqltest_to" --replicate-do-table=mysqltest_to.a
diff --git a/mysql-test/suite/rpl/t/rpl_multi_delete2.test b/mysql-test/suite/rpl/t/rpl_multi_delete2.test
new file mode 100644
index 00000000000..81379d4056b
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_multi_delete2.test
@@ -0,0 +1,68 @@
+#multi delete replication bugs
+
+
+source include/master-slave.inc;
+
+#BUG#11139 - improper wild-table and table rules
+#checking for multi deletes with an alias
+
+connection master;
+set sql_log_bin=0;
+create database mysqltest_from;
+set sql_log_bin=1;
+
+connection slave;
+create database mysqltest_to;
+
+
+connection master;
+use mysqltest_from;
+--disable_warnings
+drop table if exists a;
+--enable_warnings
+CREATE TABLE a (i INT);
+INSERT INTO a VALUES(1);
+DELETE alias FROM a alias WHERE alias.i=1;
+SELECT * FROM a;
+insert into a values(2),(3);
+delete a alias FROM a alias where alias.i=2;
+select * from a;
+save_master_pos;
+connection slave;
+
+use mysqltest_to;
+sync_with_master;
+select * from a;
+
+# BUG#3461
+connection master;
+create table t1 (a int primary key);
+create table t2 (a int);
+
+insert into t1 values (1);
+insert into t2 values (1);
+
+delete t1.* from t1, t2 where t1.a = t2.a;
+
+save_master_pos;
+select * from t1;
+select * from t2;
+
+connection slave;
+# BUG#3461 would cause sync to fail
+sync_with_master;
+error 1146;
+select * from t1;
+error 1146;
+select * from t2;
+
+# cleanup
+connection master;
+set sql_log_bin=0;
+drop database mysqltest_from;
+set sql_log_bin=1;
+connection slave;
+drop database mysqltest_to;
+
+# End of 4.1 tests
+
diff --git a/mysql-test/suite/rpl/t/rpl_multi_engine-slave.opt b/mysql-test/suite/rpl/t/rpl_multi_engine-slave.opt
new file mode 100644
index 00000000000..48457b17309
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_multi_engine-slave.opt
@@ -0,0 +1 @@
+--loose-innodb
diff --git a/mysql-test/suite/rpl/t/rpl_multi_engine.test b/mysql-test/suite/rpl/t/rpl_multi_engine.test
new file mode 100644
index 00000000000..10780c765f7
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_multi_engine.test
@@ -0,0 +1,108 @@
+# See if replication between MyISAM, MEMORY and InnoDB works.
+
+#This test case is not written for NDB, result files do not
+#match when NDB is the default engine
+-- source include/not_ndb_default.inc
+
+-- source include/master-slave.inc
+
+connection slave;
+-- source include/have_innodb.inc
+
+connection master;
+-- source include/have_innodb.inc
+--disable_warnings
+create database if not exists mysqltest1;
+use mysqltest1;
+drop table if exists t1;
+
+CREATE TABLE t1 (id MEDIUMINT NOT NULL, b1 BIT(8), vc
+VARCHAR(255), bc CHAR(255), d DECIMAL(10,4) DEFAULT 0, f FLOAT DEFAULT
+0, total BIGINT UNSIGNED, y YEAR, t TIMESTAMP,PRIMARY KEY(id));
+
+sync_slave_with_master;
+use mysqltest1;
+
+# MyISAM to MyISAM then InnoDB then MEMORY
+
+connection master;
+alter table t1 engine=myisam;
+show create table t1;
+sync_slave_with_master;
+
+connection slave;
+alter table t1 engine=myisam;
+show create table t1;
+
+--source include/rpl_multi_engine.inc
+
+connection slave;
+alter table t1 engine=innodb;
+show create table t1;
+
+--source include/rpl_multi_engine.inc
+
+connection slave;
+alter table t1 engine=memory;
+show create table t1;
+
+--source include/rpl_multi_engine.inc
+
+# MEMORY to ...
+
+connection master;
+alter table t1 engine=memory;
+show create table t1;
+sync_slave_with_master;
+
+connection slave;
+alter table t1 engine=myisam;
+show create table t1;
+
+--source include/rpl_multi_engine.inc
+
+connection slave;
+alter table t1 engine=innodb;
+show create table t1;
+
+--source include/rpl_multi_engine.inc
+
+connection slave;
+alter table t1 engine=memory;
+show create table t1;
+
+--source include/rpl_multi_engine.inc
+
+# InnoDB to ...
+
+connection master;
+alter table t1 engine=innodb;
+show create table t1;
+sync_slave_with_master;
+
+connection slave;
+alter table t1 engine=myisam;
+show create table t1;
+
+--source include/rpl_multi_engine.inc
+
+connection slave;
+alter table t1 engine=innodb;
+show create table t1;
+
+--source include/rpl_multi_engine.inc
+
+connection slave;
+alter table t1 engine=memory;
+show create table t1;
+
+--source include/rpl_multi_engine.inc
+
+# cleanup
+connection master;
+DROP TABLE t1;
+# Need to drop mysqltest1 as well so other test will pass.
+DROP DATABASE mysqltest1;
+sync_slave_with_master;
+
+# End of 5.1 test case
diff --git a/mysql-test/suite/rpl/t/rpl_multi_update.test b/mysql-test/suite/rpl/t/rpl_multi_update.test
new file mode 100644
index 00000000000..a6111455d16
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_multi_update.test
@@ -0,0 +1,7 @@
+########################################################
+# By JBM 2005-02-15 Wrapped to allow reuse of test code#
+# Added to skip if ndb is default #
+########################################################
+-- source include/not_ndb_default.inc
+let $engine_type=MyISAM;
+-- source extra/rpl_tests/rpl_multi_update.test
diff --git a/mysql-test/suite/rpl/t/rpl_multi_update2-slave.opt b/mysql-test/suite/rpl/t/rpl_multi_update2-slave.opt
new file mode 100644
index 00000000000..17d4171af0e
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_multi_update2-slave.opt
@@ -0,0 +1 @@
+--replicate-ignore-table=nothing.sensible
diff --git a/mysql-test/suite/rpl/t/rpl_multi_update2.test b/mysql-test/suite/rpl/t/rpl_multi_update2.test
new file mode 100644
index 00000000000..812a486ad69
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_multi_update2.test
@@ -0,0 +1,10 @@
+#######################################################
+# Wrapper for rpl_multi_update2.test to allow multi #
+# Engines to reuse test code. By JBM 2006-02-15 #
+# Added comments section and to skip when ndb is #
+# Default engine. #
+#######################################################
+--source include/not_ndb_default.inc
+--source include/master-slave.inc
+let $engine_type=MyISAM;
+--source extra/rpl_tests/rpl_multi_update2.test
diff --git a/mysql-test/suite/rpl/t/rpl_multi_update3.test b/mysql-test/suite/rpl/t/rpl_multi_update3.test
new file mode 100644
index 00000000000..5da91c26b04
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_multi_update3.test
@@ -0,0 +1,10 @@
+#######################################################
+# Wrapper for rpl_multi_update3.test to allow multi #
+# Engines to reuse test code. By JBM 2006-02-15 #
+# Added comments section and to skip when ndb is #
+# Default engine. #
+#######################################################
+--source include/not_ndb_default.inc
+--source include/master-slave.inc
+let $engine_type=MyISAM;
+-- source extra/rpl_tests/rpl_multi_update3.test
diff --git a/mysql-test/suite/rpl/t/rpl_multi_update4-slave.opt b/mysql-test/suite/rpl/t/rpl_multi_update4-slave.opt
new file mode 100644
index 00000000000..fea27db43ee
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_multi_update4-slave.opt
@@ -0,0 +1 @@
+--replicate-wild-do-table=d1.%
diff --git a/mysql-test/suite/rpl/t/rpl_multi_update4.test b/mysql-test/suite/rpl/t/rpl_multi_update4.test
new file mode 100644
index 00000000000..4991a385f6f
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_multi_update4.test
@@ -0,0 +1,45 @@
+# Let's verify that multi-update is not always skipped by slave if
+# some replicate-* rules exist.
+# (BUG#15699)
+
+source include/master-slave.inc;
+
+### Clean-up
+
+connection master;
+--disable_warnings
+drop database if exists d1;
+drop database if exists d2;
+
+connection slave;
+drop database if exists d2;
+--enable_warnings
+
+### Do on master
+
+connection master;
+create database d1; # accepted by slave
+create table d1.t0 (id int);
+create database d2; # ignored by slave
+use d2;
+create table t1 (id int);
+create table t2 (id int);
+insert into t1 values (1), (2), (3), (4), (5);
+insert into t2 select id + 3 from t1;
+# a problematic query which must be filter out by slave
+update t1 join t2 using (id) set t1.id = 0;
+insert into d1.t0 values (0); # replication works
+
+### Check on slave
+
+sync_slave_with_master;
+use d1;
+select * from t0 where id=0; # must find
+
+### Clean-up
+connection master;
+drop database d1;
+drop database d2;
+sync_slave_with_master;
+
+# End of test
diff --git a/mysql-test/suite/rpl/t/rpl_optimize.test b/mysql-test/suite/rpl/t/rpl_optimize.test
new file mode 100644
index 00000000000..80f0c052fc8
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_optimize.test
@@ -0,0 +1,54 @@
+# Test for BUG#1858 "OPTIMIZE TABLE done by a client
+# thread stops the slave SQL thread".
+# You can replace OPTIMIZE by REPAIR.
+#####################################
+# Change Author: JBM
+# Change Date: 2006-02-09
+# Change: NDB does not and will not support
+# OPTIMIZE for memory tables. If and when
+# it does support for Disk Data, a new
+# version of this test will be need.
+# Skipping this test if default engine = ndb
+#####################################
+-- source include/not_ndb_default.inc
+-- source include/master-slave.inc
+
+create table t1 (a int not null auto_increment primary key, b int, key(b));
+INSERT INTO t1 (a) VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
+INSERT INTO t1 (a) SELECT null FROM t1;
+INSERT INTO t1 (a) SELECT null FROM t1;
+INSERT INTO t1 (a) SELECT null FROM t1;
+INSERT INTO t1 (a) SELECT null FROM t1;
+INSERT INTO t1 (a) SELECT null FROM t1;
+INSERT INTO t1 (a) SELECT null FROM t1;
+INSERT INTO t1 (a) SELECT null FROM t1;
+INSERT INTO t1 (a) SELECT null FROM t1;
+INSERT INTO t1 (a) SELECT null FROM t1;
+INSERT INTO t1 (a) SELECT null FROM t1;
+INSERT INTO t1 (a) SELECT null FROM t1;
+INSERT INTO t1 (a) SELECT null FROM t1;
+INSERT INTO t1 (a) SELECT null FROM t1;
+save_master_pos;
+# a few updates to force OPTIMIZE to do something
+update t1 set b=(a/2*rand());
+delete from t1 order by b limit 10000;
+
+connection slave;
+sync_with_master;
+optimize table t1;
+connection master;
+save_master_pos;
+connection slave;
+# Bug was that when the INSERT terminated on slave,
+# the slave SQL thread got killed by OPTIMIZE.
+sync_with_master; # won't work if slave SQL thread stopped
+
+connection master; # cleanup
+drop table t1;
+connection slave;
+sync_with_master;
+
+# If the machine is so fast that slave syncs before OPTIMIZE
+# starts, this test wil demonstrate nothing but will pass.
+
+# End of 4.1 tests
diff --git a/mysql-test/suite/rpl/t/rpl_packet-master.opt b/mysql-test/suite/rpl/t/rpl_packet-master.opt
new file mode 100644
index 00000000000..42d4f94c999
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_packet-master.opt
@@ -0,0 +1 @@
+-O max_allowed_packet=1024 -O net_buffer_length=1024
diff --git a/mysql-test/suite/rpl/t/rpl_packet-slave.opt b/mysql-test/suite/rpl/t/rpl_packet-slave.opt
new file mode 100644
index 00000000000..42d4f94c999
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_packet-slave.opt
@@ -0,0 +1 @@
+-O max_allowed_packet=1024 -O net_buffer_length=1024
diff --git a/mysql-test/suite/rpl/t/rpl_packet.test b/mysql-test/suite/rpl/t/rpl_packet.test
new file mode 100644
index 00000000000..26fe36d8c40
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_packet.test
@@ -0,0 +1,80 @@
+#
+# Check replication protocol packet size handling
+# Bug#19402 SQL close to the size of the max_allowed_packet fails on slave
+#
+
+# max-out size db name
+source include/master-slave.inc;
+
+let $db= DB_NAME_OF_MAX_LENGTH_AKA_NAME_LEN_64_BYTES_____________________;
+disable_warnings;
+eval drop database if exists $db;
+enable_warnings;
+eval create database $db;
+
+connection master;
+select @@net_buffer_length, @@max_allowed_packet;
+disconnect master;
+
+# alas, can't use eval here; if db name changed apply the change here
+connect (master,localhost,root,,DB_NAME_OF_MAX_LENGTH_AKA_NAME_LEN_64_BYTES_____________________);
+
+connection master;
+create table `t1` (`f1` LONGTEXT) ENGINE=MyISAM;
+
+INSERT INTO `t1`(`f1`) VALUES ('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1023');
+save_master_pos;
+
+connection slave;
+sync_with_master;
+eval select count(*) from `$db`.`t1` /* must be 1 */;
+
+SHOW STATUS LIKE 'Slave_running';
+select * from information_schema.session_status where variable_name= 'SLAVE_RUNNING';
+connection master;
+eval drop database $db;
+save_master_pos;
+
+connection slave;
+sync_with_master;
+
+#
+# Bug #23755: Replicated event larger that max_allowed_packet infinitely re-transmits
+#
+# Check that a situation when the size of event on the master is greater than
+# max_allowed_packet on the slave does not lead to infinite re-transmits.
+
+connection master;
+
+# Change the max packet size on master
+
+SET @@global.max_allowed_packet=4096;
+SET @@global.net_buffer_length=4096;
+
+# Restart slave for new setting to take effect
+connection slave;
+STOP SLAVE;
+START SLAVE;
+
+# Reconnect to master for new setting to take effect
+disconnect master;
+connect (master, localhost, root);
+connection master;
+
+CREATE TABLe `t1` (`f1` LONGTEXT) ENGINE=MyISAM;
+
+INSERT INTO `t1`(`f1`) VALUES ('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa2048');
+
+# The slave I/O thread must stop after trying to read the above event
+connection slave;
+sleep 2;
+SHOW STATUS LIKE 'Slave_running';
+
+# cleanup
+#connection master;
+#drop table t1;
+#connection slave;
+#drop table t1;
+
+
+# End of tests
diff --git a/mysql-test/suite/rpl/t/rpl_ps.test b/mysql-test/suite/rpl/t/rpl_ps.test
new file mode 100644
index 00000000000..b8792722192
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_ps.test
@@ -0,0 +1,51 @@
+#
+# Test of replicating user variables
+#
+###########################################################
+# 2006-02-08 By JBM added order by for use w/ NDB engine
+###########################################################
+source include/master-slave.inc;
+
+#save_master_pos;
+#connection slave;
+#sync_with_master;
+#reset master;
+#connection master;
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+create table t1(n char(30));
+
+prepare stmt1 from 'insert into t1 values (?)';
+set @var1= "from-master-1";
+execute stmt1 using @var1;
+set @var1= "from-master-2-'',";
+execute stmt1 using @var1;
+SELECT * FROM t1 ORDER BY n;
+
+set @var2= 'insert into t1 values (concat("from-var-", ?))';
+prepare stmt2 from @var2;
+set @var1='from-master-3';
+execute stmt2 using @var1;
+
+save_master_pos;
+connection slave;
+sync_with_master;
+SELECT * FROM t1 ORDER BY n;
+
+connection master;
+
+drop table t1;
+
+save_master_pos;
+connection slave;
+sync_with_master;
+stop slave;
+
+# End of 4.1 tests
+
+reset master;
+reset slave;
+disconnect master;
diff --git a/mysql-test/suite/rpl/t/rpl_rbr_to_sbr.test b/mysql-test/suite/rpl/t/rpl_rbr_to_sbr.test
new file mode 100644
index 00000000000..72ae6a99c44
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_rbr_to_sbr.test
@@ -0,0 +1,47 @@
+-- source include/have_binlog_format_mixed_or_statement.inc
+-- source include/not_ndb_default.inc
+-- source include/master-slave.inc
+
+# Test that the slave temporarily switches to ROW when seeing binrow
+# events when it is in STATEMENT or MIXED mode
+
+SET BINLOG_FORMAT=MIXED;
+SET GLOBAL BINLOG_FORMAT=MIXED;
+SELECT @@GLOBAL.BINLOG_FORMAT, @@SESSION.BINLOG_FORMAT;
+
+--echo **** On Master ****
+CREATE TABLE t1 (a INT, b LONG);
+INSERT INTO t1 VALUES (1,1), (2,2);
+INSERT INTO t1 VALUES (3,UUID()), (4,UUID());
+let $VERSION=`select version()`;
+--replace_result $VERSION VERSION
+--replace_column 2 # 5 #
+--replace_regex /table_id: [0-9]+/table_id: #/
+SHOW BINLOG EVENTS;
+sync_slave_with_master;
+--echo **** On Slave ****
+--replace_result $MASTER_MYPORT MASTER_PORT
+--replace_column 1 # 8 # 9 # 23 # 33 # 34 # 35 #
+--query_vertical SHOW SLAVE STATUS
+--replace_result $VERSION VERSION
+--replace_column 2 # 5 #
+--replace_regex /table_id: [0-9]+/table_id: #/
+SHOW BINLOG EVENTS;
+
+--exec $MYSQL_DUMP --compact --order-by-primary --skip-extended-insert --no-create-info test > $MYSQLTEST_VARDIR/tmp/rpl_rbr_to_sbr_master.sql
+--exec $MYSQL_DUMP_SLAVE --compact --order-by-primary --skip-extended-insert --no-create-info test > $MYSQLTEST_VARDIR/tmp/rpl_rbr_to_sbr_slave.sql
+
+connection master;
+DROP TABLE IF EXISTS t1;
+
+# Let's compare. Note: If they match test will pass, if they do not match
+# the test will show that the diff statement failed and not reject file
+# will be created. You will need to go to the mysql-test dir and diff
+# the files your self to see what is not matching
+
+diff_files $MYSQLTEST_VARDIR/tmp/rpl_rbr_to_sbr_master.sql $MYSQLTEST_VARDIR/tmp/rpl_rbr_to_sbr_slave.sql;
+
+# If all is good, we can remove the files
+
+--remove_file $MYSQLTEST_VARDIR/tmp/rpl_rbr_to_sbr_master.sql
+--remove_file $MYSQLTEST_VARDIR/tmp/rpl_rbr_to_sbr_slave.sql
diff --git a/mysql-test/suite/rpl/t/rpl_read_only-slave.opt b/mysql-test/suite/rpl/t/rpl_read_only-slave.opt
new file mode 100644
index 00000000000..48457b17309
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_read_only-slave.opt
@@ -0,0 +1 @@
+--loose-innodb
diff --git a/mysql-test/suite/rpl/t/rpl_read_only.test b/mysql-test/suite/rpl/t/rpl_read_only.test
new file mode 100644
index 00000000000..62864b62a28
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_read_only.test
@@ -0,0 +1,113 @@
+# Test case for BUG #11733
+-- source include/master-slave.inc
+-- source include/have_innodb.inc
+
+# Create a test and replicate it to slave
+connection master;
+create user test;
+sync_slave_with_master;
+
+# Setting the master readonly :
+# - the variable @@readonly is not replicated on the slave
+
+connect (master2,127.0.0.1,test,,test,$MASTER_MYPORT,);
+connect (slave2,127.0.0.1,test,,test,$SLAVE_MYPORT,);
+
+connection master1;
+
+create table t1(a int) engine=InnoDB;
+create table t2(a int) engine=MyISAM;
+insert into t1 values(1001);
+insert into t2 values(2001);
+
+connection master;
+set global read_only=1;
+
+connection master1;
+select @@read_only;
+select * from t1;
+select * from t2;
+
+sync_slave_with_master;
+select @@read_only;
+select * from t1;
+select * from t2;
+
+# - replication of transactions
+connection master;
+set global read_only=0;
+
+connection master1;
+BEGIN;
+insert into t1 values(1002);
+insert into t2 values(2002);
+
+connection master2;
+BEGIN;
+insert into t1 values(1003);
+insert into t2 values(2003);
+
+connection master;
+set global read_only=1;
+
+connection master1;
+## works even with read_only=1, because master1 is root
+COMMIT;
+
+connection master2;
+--error ER_OPTION_PREVENTS_STATEMENT
+COMMIT;
+
+connection master;
+set global read_only=0;
+
+connection master1;
+insert into t1 values(1004);
+insert into t2 values(2004);
+
+select * from t1;
+select * from t2;
+
+sync_slave_with_master;
+select * from t1;
+select * from t2;
+
+# Setting the slave readonly : replication will pass
+#
+connection slave1;
+set global read_only=1;
+
+connection slave;
+select @@read_only;
+# Make sure the replicated table is also transactional
+show create table t1;
+# Make sure the replicated table is not transactional
+show create table t2;
+
+connection master;
+insert into t1 values(1005);
+insert into t2 values(2005);
+select * from t1;
+select * from t2;
+
+sync_slave_with_master;
+connection slave;
+select * from t1;
+select * from t2;
+
+# Non root user can not write on the slave
+connection slave2;
+--error ER_OPTION_PREVENTS_STATEMENT
+insert into t1 values(1006);
+--error ER_OPTION_PREVENTS_STATEMENT
+insert into t2 values(2006);
+
+## Cleanup
+connection master;
+drop user test;
+drop table t1;
+drop table t2;
+sync_slave_with_master;
+set global read_only=0;
+
+
diff --git a/mysql-test/suite/rpl/t/rpl_redirect.test b/mysql-test/suite/rpl/t/rpl_redirect.test
new file mode 100644
index 00000000000..1c6f31a030e
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_redirect.test
@@ -0,0 +1,45 @@
+#
+# Test of automatic redirection of queries to master/slave.
+#
+
+source include/master-slave.inc;
+# We disable this for now as PS doesn't handle redirection
+--disable_ps_protocol
+
+#first, make sure the slave has had enough time to register
+save_master_pos;
+connection slave;
+sync_with_master;
+
+#discover slaves
+connection master;
+source include/show_slave_status.inc;
+--replace_result $SLAVE_MYPORT SLAVE_PORT
+SHOW SLAVE HOSTS;
+rpl_probe;
+
+#turn on master/slave query direction auto-magic
+enable_rpl_parse;
+create table t1 ( n int);
+insert into t1 values (1),(2),(3),(4);
+disable_rpl_parse;
+save_master_pos;
+connection slave;
+sync_with_master;
+insert into t1 values(5);
+connection master;
+enable_rpl_parse;
+# The first of the queries will be sent to the slave, the second to the master.
+SELECT * FROM t1 ORDER BY n;
+SELECT * FROM t1 ORDER BY n;
+disable_rpl_parse;
+SELECT * FROM t1 ORDER BY n;
+connection slave;
+SELECT * FROM t1 ORDER BY n;
+
+# Cleanup
+connection master;
+drop table t1;
+sync_slave_with_master;
+
+# End of 4.1 tests
diff --git a/mysql-test/suite/rpl/t/rpl_relay_space_innodb-master.opt b/mysql-test/suite/rpl/t/rpl_relay_space_innodb-master.opt
new file mode 100644
index 00000000000..627becdbfb5
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_relay_space_innodb-master.opt
@@ -0,0 +1 @@
+--innodb
diff --git a/mysql-test/suite/rpl/t/rpl_relay_space_innodb-slave.opt b/mysql-test/suite/rpl/t/rpl_relay_space_innodb-slave.opt
new file mode 100644
index 00000000000..627becdbfb5
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_relay_space_innodb-slave.opt
@@ -0,0 +1 @@
+--innodb
diff --git a/mysql-test/suite/rpl/t/rpl_relay_space_innodb.test b/mysql-test/suite/rpl/t/rpl_relay_space_innodb.test
new file mode 100644
index 00000000000..156d53ef856
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_relay_space_innodb.test
@@ -0,0 +1,22 @@
+###################################
+# Wrapper rpl_sv_relay_space.test #
+# This test has to be wrapped as #
+# It tests ndb, innodb and MyISAM.#
+# By Wrapping we are saving some #
+# space and making the test more #
+# Maintainable by only having one #
+# test file and reusing the code #
+# In Addition, INNODB has to have #
+# Option files during this test #
+# to force innodb on the slave #
+# else the test will fail #
+###################################
+#Change Author: JBM #
+#Change Date: 2006-02-03 #
+#Change: Added Comments #
+###################################
+-- source include/not_ndb_default.inc
+-- source include/have_innodb.inc
+let $engine_type=InnoDB;
+-- source extra/rpl_tests/rpl_sv_relay_space.test
+
diff --git a/mysql-test/suite/rpl/t/rpl_relay_space_myisam.test b/mysql-test/suite/rpl/t/rpl_relay_space_myisam.test
new file mode 100644
index 00000000000..1d8563e7fd9
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_relay_space_myisam.test
@@ -0,0 +1,21 @@
+###################################
+# Wrapper rpl_sv_relay_space.test #
+# This test has to be wrapped as #
+# It tests ndb, innodb and MyISAM.#
+# By Wrapping we are saving some #
+# space and making the test more #
+# Maintainable by only having one #
+# test file and reusing the code #
+# In Addition, INNODB has to have #
+# Option files during this test #
+# to force innodb on the slave #
+# else the test will fail #
+###################################
+#Change Author: JBM #
+#Change Date: 2006-02-03 #
+#Change: Added Comments #
+###################################
+-- source include/not_ndb_default.inc
+let $engine_type=MyISAM;
+-- source extra/rpl_tests/rpl_sv_relay_space.test
+
diff --git a/mysql-test/suite/rpl/t/rpl_relayrotate-slave.opt b/mysql-test/suite/rpl/t/rpl_relayrotate-slave.opt
new file mode 100644
index 00000000000..cf4319f2b40
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_relayrotate-slave.opt
@@ -0,0 +1,3 @@
+-O max_relay_log_size=16384
+--loose-innodb
+--log-warnings
diff --git a/mysql-test/suite/rpl/t/rpl_relayrotate.test b/mysql-test/suite/rpl/t/rpl_relayrotate.test
new file mode 100644
index 00000000000..ec3e6be4bea
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_relayrotate.test
@@ -0,0 +1,11 @@
+#######################################################
+# Wrapper for rpl_relayrotate.test to allow multi #
+# Engines to reuse test code. By JBM 2006-02-15 #
+# Added comments section and to skip when ndb is #
+# Default engine. #
+#######################################################
+-- source include/not_ndb_default.inc
+-- source include/have_innodb.inc
+-- source include/master-slave.inc
+let $engine_type=innodb;
+-- source extra/rpl_tests/rpl_relayrotate.test
diff --git a/mysql-test/suite/rpl/t/rpl_relayspace-slave.opt b/mysql-test/suite/rpl/t/rpl_relayspace-slave.opt
new file mode 100644
index 00000000000..06d96aa3b9a
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_relayspace-slave.opt
@@ -0,0 +1 @@
+--relay_log_space_limit=10
diff --git a/mysql-test/suite/rpl/t/rpl_relayspace.test b/mysql-test/suite/rpl/t/rpl_relayspace.test
new file mode 100644
index 00000000000..70315c14f34
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_relayspace.test
@@ -0,0 +1,34 @@
+# The slave is started with relay_log_space_limit=10 bytes,
+# to force the deadlock after one event.
+
+source include/master-slave.inc;
+connection slave;
+stop slave;
+connection master;
+# This will generate a master's binlog > 10 bytes
+create table t1 (a int);
+drop table t1;
+create table t1 (a int);
+drop table t1;
+connection slave;
+reset slave;
+start slave io_thread;
+# Give the I/O thread time to block.
+sleep 2;
+# A bug caused the I/O thread to refuse stopping.
+stop slave io_thread;
+reset slave;
+start slave;
+# The I/O thread stops filling the relay log when
+# it's >10b. And the SQL thread cannot purge this relay log
+# as purge is done only when the SQL thread switches to another
+# relay log, which does not exist here.
+# So we should have a deadlock.
+# if it is not resolved automatically we'll detect
+# it with master_pos_wait that waits for farther than 1Ob;
+# it will timeout after 10 seconds;
+# also the slave will probably not cooperate to shutdown
+# (as 2 threads are locked)
+select master_pos_wait('master-bin.001',200,6)=-1;
+
+# End of 4.1 tests
diff --git a/mysql-test/suite/rpl/t/rpl_replicate_do-slave.opt b/mysql-test/suite/rpl/t/rpl_replicate_do-slave.opt
new file mode 100644
index 00000000000..da345474216
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_replicate_do-slave.opt
@@ -0,0 +1 @@
+--replicate-do-table=test.t1
diff --git a/mysql-test/suite/rpl/t/rpl_replicate_do.test b/mysql-test/suite/rpl/t/rpl_replicate_do.test
new file mode 100644
index 00000000000..90f00764691
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_replicate_do.test
@@ -0,0 +1,92 @@
+# This test assumes we are ignoring updates on table t2, but doing
+# updates on t1
+source include/master-slave.inc;
+--disable_warnings
+drop table if exists t11;
+connection slave;
+drop table if exists t11;
+--enable_warnings
+
+create table t2 (n int);
+insert into t2 values(4);
+connection master;
+create table t2 (s char(20));
+load data infile '../std_data_ln/words.dat' into table t2;
+insert into t2 values('five');
+create table t1 (m int);
+insert into t1 values(15),(16),(17);
+update t1 set m=20 where m=16;
+delete from t1 where m=17;
+create table t11 select * from t1;
+save_master_pos;
+connection slave;
+sync_with_master;
+select * from t1 ORDER BY m;
+select * from t2;
+--error 1146
+select * from t11;
+connection master;
+drop table if exists t1,t2,t11;
+save_master_pos;
+connection slave;
+sync_with_master;
+# show slave status, just to see of it prints replicate-do-table
+--replace_result $MASTER_MYPORT MASTER_PORT
+--replace_column 1 # 7 # 8 # 9 # 22 # 23 # 33 # 35 # 36 #
+query_vertical SHOW SLAVE STATUS;
+
+#
+# BUG#12542
+# TEST: "SET ONE_SHOT should always be executed on slave"
+#
+# We could use any timezone different than server default in this test
+#
+connection master;
+create table t1 (ts timestamp);
+set one_shot time_zone='met';
+insert into t1 values('2005-08-12 00:00:00');
+set one_shot time_zone='met';
+select * from t1;
+sync_slave_with_master;
+
+connection slave;
+set one_shot time_zone='met';
+select * from t1;
+
+connection master;
+drop table t1;
+sync_slave_with_master;
+
+# End of 4.1 tests
+
+#
+# Bug#24478 DROP TRIGGER is not caught by replicate-*-table filters
+#
+--echo *** master ***
+connection master;
+create table t1 (a int, b int);
+create trigger trg1 before insert on t1 for each row set new.b=2;
+create table t2 (a int, b int);
+create trigger trg2 before insert on t2 for each row set new.b=2;
+show tables;
+show triggers;
+sync_slave_with_master;
+--echo *** slave ***
+connection slave;
+show tables;
+show triggers;
+--echo *** master ***
+connection master;
+drop trigger trg1;
+drop trigger trg2;
+show triggers;
+sync_slave_with_master;
+--echo *** slave ***
+connection slave;
+show tables;
+show triggers;
+--echo *** master ***
+connection master;
+drop table t1;
+drop table t2;
+sync_slave_with_master;
diff --git a/mysql-test/suite/rpl/t/rpl_replicate_ignore_db-slave.opt b/mysql-test/suite/rpl/t/rpl_replicate_ignore_db-slave.opt
new file mode 100644
index 00000000000..6e3aed44f78
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_replicate_ignore_db-slave.opt
@@ -0,0 +1 @@
+--replicate_ignore_db=mysqltest1
diff --git a/mysql-test/suite/rpl/t/rpl_replicate_ignore_db.test b/mysql-test/suite/rpl/t/rpl_replicate_ignore_db.test
new file mode 100644
index 00000000000..bcfef919fad
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_replicate_ignore_db.test
@@ -0,0 +1,30 @@
+# see if --replicate-ignore-db works
+
+--source include/master-slave.inc
+
+--disable_warnings
+drop database if exists mysqltest1;
+drop database if exists mysqltest2;
+--enable_warnings
+create database mysqltest1;
+create database mysqltest2;
+
+use mysqltest1;
+create table t1 (a int);
+insert into t1 values(1);
+sync_slave_with_master;
+--error 1146
+select * from mysqltest1.t1;
+
+connection master;
+use mysqltest2;
+create table t1 (a int);
+insert into t1 values(1);
+sync_slave_with_master;
+select * from mysqltest2.t1;
+
+# cleanup
+connection master;
+drop database mysqltest1;
+drop database mysqltest2;
+sync_slave_with_master;
diff --git a/mysql-test/suite/rpl/t/rpl_rewrt_db-slave.opt b/mysql-test/suite/rpl/t/rpl_rewrt_db-slave.opt
new file mode 100644
index 00000000000..a462ad19ba0
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_rewrt_db-slave.opt
@@ -0,0 +1 @@
+"--replicate-rewrite-db=test->rewrite" "--replicate-rewrite-db=mysqltest1->test"
diff --git a/mysql-test/suite/rpl/t/rpl_rewrt_db.test b/mysql-test/suite/rpl/t/rpl_rewrt_db.test
new file mode 100644
index 00000000000..52f04e073dd
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_rewrt_db.test
@@ -0,0 +1,84 @@
+# TBF - difference in row level logging
+-- source include/have_binlog_format_mixed_or_statement.inc
+-- source include/master-slave.inc
+
+--disable_warnings
+drop database if exists mysqltest1;
+--enable_warnings
+create database mysqltest1;
+
+use mysqltest1;
+create table t1 (a int);
+insert into t1 values(9);
+select * from mysqltest1.t1;
+sync_slave_with_master;
+show databases like 'mysqltest1'; # should be empty
+select * from test.t1;
+# cleanup
+connection master;
+drop table t1;
+drop database mysqltest1;
+sync_slave_with_master;
+
+#
+# BUG#6353:
+# Option --replicate-rewrite-db should work together with LOAD DATA INFILE
+#
+
+connection slave;
+--disable_warnings
+drop database if exists rewrite;
+--enable_warnings
+create database rewrite;
+
+connection master;
+use test;
+create table t1 (a date, b date, c date not null, d date);
+load data infile '../std_data_ln/loaddata1.dat' into table t1 fields terminated by ',';
+load data infile '../std_data_ln/loaddata1.dat' into table t1 fields terminated by ',' IGNORE 2 LINES;
+sync_slave_with_master;
+
+connection slave;
+select * from rewrite.t1;
+
+connection master;
+truncate table t1;
+load data infile '../std_data_ln/loaddata1.dat' into table t1 fields terminated by ',' LINES STARTING BY ',' (b,c,d);
+sync_slave_with_master;
+
+connection slave;
+select * from rewrite.t1;
+
+connection master;
+drop table t1;
+create table t1 (a text, b text);
+load data infile '../std_data_ln/loaddata2.dat' into table t1 fields terminated by ',' enclosed by '''';
+sync_slave_with_master;
+
+connection slave;
+select concat('|',a,'|'), concat('|',b,'|') from rewrite.t1;
+
+connection master;
+drop table t1;
+create table t1 (a int, b char(10));
+load data infile '../std_data_ln/loaddata3.dat' into table t1 fields terminated by '' enclosed by '' ignore 1 lines;
+sync_slave_with_master;
+
+connection slave;
+select * from rewrite.t1;
+
+connection master;
+truncate table t1;
+load data infile '../std_data_ln/loaddata4.dat' into table t1 fields terminated by '' enclosed by '' lines terminated by '' ignore 1 lines;
+sync_slave_with_master;
+
+connection slave;
+# The empty line last comes from the end line field in the file
+select * from rewrite.t1;
+
+drop database rewrite;
+
+connection master;
+drop table t1;
+
+# End of 4.1 tests
diff --git a/mysql-test/suite/rpl/t/rpl_rotate_logs-master.opt b/mysql-test/suite/rpl/t/rpl_rotate_logs-master.opt
new file mode 100644
index 00000000000..ad2c6a647b5
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_rotate_logs-master.opt
@@ -0,0 +1 @@
+-O max_binlog_size=4096
diff --git a/mysql-test/suite/rpl/t/rpl_rotate_logs-slave.sh b/mysql-test/suite/rpl/t/rpl_rotate_logs-slave.sh
new file mode 100755
index 00000000000..81490a54b4b
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_rotate_logs-slave.sh
@@ -0,0 +1,2 @@
+rm -f $MYSQLTEST_VARDIR/slave-data/master.info
+rm -f $MYSQLTEST_VARDIR/slave-data/*relay*
diff --git a/mysql-test/suite/rpl/t/rpl_rotate_logs.slave-mi b/mysql-test/suite/rpl/t/rpl_rotate_logs.slave-mi
new file mode 100644
index 00000000000..80190bf6d29
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_rotate_logs.slave-mi
@@ -0,0 +1 @@
+--server-id=2
diff --git a/mysql-test/suite/rpl/t/rpl_rotate_logs.test b/mysql-test/suite/rpl/t/rpl_rotate_logs.test
new file mode 100644
index 00000000000..c04b9045daa
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_rotate_logs.test
@@ -0,0 +1,169 @@
+# This test uses chmod, can't be run with root permissions
+-- source include/not_as_root.inc
+
+-- source include/have_log_bin.inc
+
+#
+# Test is run with max_binlog_size=2048 to force automatic rotation of the
+# binary log
+# Tests done:
+# - Check that slaves reports correct failures if master.info has strange
+# modes/information
+# - Automatic binary log rotation
+# - Ensure that temporary tables works over flush logs and binary log
+# changes
+# - Test creating a duplicate key error and recover from it
+
+# Requires statement logging
+-- source include/have_binlog_format_mixed_or_statement.inc
+
+connect (master,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK);
+--disable_warnings
+drop table if exists t1, t2, t3, t4;
+--enable_warnings
+connect (slave,localhost,root,,test,$SLAVE_MYPORT,$SLAVE_MYSOCK);
+# Create empty file
+write_file $MYSQLTEST_VARDIR/slave-data/master.info;
+EOF
+chmod 0000 $MYSQLTEST_VARDIR/slave-data/master.info;
+connection slave;
+--disable_warnings
+drop table if exists t1, t2, t3, t4;
+--enable_warnings
+
+# START SLAVE will fail because it can't read the file (mode 000)
+# (system error 13)
+--replace_result $MYSQL_TEST_DIR TESTDIR
+--error 1105,1105,29
+start slave;
+chmod 0600 $MYSQLTEST_VARDIR/slave-data/master.info;
+# It will fail again because the file is empty so the slave cannot get valuable
+# info about how to connect to the master from it (failure in
+# init_strvar_from_file() in init_master_info()).
+--error 1201
+start slave;
+--replace_result $MASTER_MYPORT MASTER_PORT
+
+# CHANGE MASTER will fail because it first parses master.info before changing
+# it (so when master.info is bad, people have to use RESET SLAVE first).
+--error 1201
+eval change master to master_host='127.0.0.1',master_port=$MASTER_MYPORT, master_user='root';
+reset slave;
+--replace_result $MASTER_MYPORT MASTER_PORT
+eval change master to master_host='127.0.0.1',master_port=$MASTER_MYPORT, master_user='root';
+connection master;
+reset master;
+connection slave;
+start slave;
+connection master;
+
+#
+# Test FLUSH LOGS
+#
+create temporary table temp_table (a char(80) not null);
+insert into temp_table values ("testing temporary tables");
+create table t1 (s text);
+insert into t1 values('Could not break slave'),('Tried hard');
+sync_slave_with_master;
+source include/show_slave_status.inc;
+select * from t1;
+connection master;
+flush logs;
+create table t2(m int not null auto_increment primary key);
+insert into t2 values (34),(67),(123);
+flush logs;
+show binary logs;
+create table t3 select * from temp_table;
+
+sync_slave_with_master;
+
+select * from t3;
+connection master;
+drop table temp_table, t3;
+
+#
+# Now lets make some duplicate key mess and see if we can recover from it
+#
+
+# First insert a value on the slave
+connection slave;
+insert into t2 values(1234);
+
+#same value on the master
+connection master;
+set insert_id=1234;
+insert into t2 values(NULL);
+connection slave;
+--source include/wait_for_slave_sql_to_stop.inc
+
+#restart slave skipping one event
+set global sql_slave_skip_counter=1;
+start slave;
+
+connection master;
+
+#let slave catch up
+sync_slave_with_master;
+connection master;
+purge master logs to 'master-bin.000002';
+show master logs;
+# we just tests if synonyms are accepted
+purge binary logs to 'master-bin.000002';
+show binary logs;
+
+# Calculate time to use in "purge master logs before" by taking
+# last modification time of t2 and adding 1 second
+# This is donw in order to handle the case where file system
+# time differs from mysqld's time
+--disable_result_log
+select @time_for_purge:=DATE_ADD(UPDATE_TIME, INTERVAL 1 SECOND)
+ from information_schema.tables
+ where TABLE_SCHEMA="test" and TABLE_NAME="t2";
+--enable_result_log
+
+purge master logs before (@time_for_purge);
+show binary logs;
+insert into t2 values (65);
+sync_slave_with_master;
+source include/show_slave_status.inc;
+select * from t2;
+
+#
+# Test forcing the replication log to rotate
+#
+
+connection master;
+create temporary table temp_table (a char(80) not null);
+insert into temp_table values ("testing temporary tables part 2");
+let $1=100;
+
+create table t3 (n int);
+disable_query_log;
+while ($1)
+{
+#eval means expand $ expressions
+ eval insert into t3 values($1 + 4);
+ dec $1;
+}
+enable_query_log;
+select count(*) from t3 where n >= 4;
+create table t4 select * from temp_table;
+show binary logs;
+show master status;
+save_master_pos;
+connection slave;
+sync_with_master;
+select * from t4;
+
+source include/show_slave_status.inc;
+# because of concurrent insert, the table may not be up to date
+# if we do not lock
+lock tables t3 read;
+select count(*) from t3 where n >= 4;
+unlock tables;
+#clean up
+connection master;
+drop table if exists t1,t2,t3,t4;
+sync_slave_with_master;
+
+# End of 4.1 tests
diff --git a/mysql-test/suite/rpl/t/rpl_row_001.test b/mysql-test/suite/rpl/t/rpl_row_001.test
new file mode 100644
index 00000000000..99eaebcdcaf
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_row_001.test
@@ -0,0 +1,9 @@
+########################################################
+# By JBM 2005-02-15 Wrapped to allow reuse of test code#
+# Added to skip if ndb is default #
+########################################################
+-- source include/not_ndb_default.inc
+-- source include/have_binlog_format_row.inc
+-- source include/master-slave.inc
+let $engine_type=MYISAM;
+-- source extra/rpl_tests/rpl_row_001.test
diff --git a/mysql-test/suite/rpl/t/rpl_row_4_bytes-master.opt b/mysql-test/suite/rpl/t/rpl_row_4_bytes-master.opt
new file mode 100644
index 00000000000..0e1929507f7
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_row_4_bytes-master.opt
@@ -0,0 +1 @@
+--loose-debug=d,"old_row_based_repl_4_byte_map_id_master"
diff --git a/mysql-test/suite/rpl/t/rpl_row_4_bytes.test b/mysql-test/suite/rpl/t/rpl_row_4_bytes.test
new file mode 100644
index 00000000000..73ef6dd2345
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_row_4_bytes.test
@@ -0,0 +1,33 @@
+# This test is to make sure that slaves can read a binlog containining
+# table map ids stored in 4 bytes, even though we now store them in 6
+# bytes. This is for backward-compatibility.
+# If the slave does not detect that the master stores the table map id
+# in 4 bytes, slave will read 6 bytes, and so will read the 2 bytes of
+# flags at the place where there actually is data, so the test should
+# fail.
+
+-- source include/have_binlog_format_row.inc
+-- source include/have_debug.inc
+-- source include/master-slave.inc
+
+connection master;
+--disable_warnings
+drop database if exists mysqltest1;
+create database mysqltest1;
+--enable_warnings
+use mysqltest1;
+CREATE TABLE t1 (a char(3));
+CREATE TABLE t2 (a char(3));
+insert into t1 values("ANN");
+insert into t1 values("GUI");
+insert into t2 values("LIL");
+insert into t2 values("ABE");
+insert into t2 values("ANG");
+sync_slave_with_master;
+use mysqltest1;
+select * from t1 order by a;
+select * from t2 order by a;
+
+connection master;
+DROP DATABASE mysqltest1;
+sync_slave_with_master;
diff --git a/mysql-test/suite/rpl/t/rpl_row_NOW.test b/mysql-test/suite/rpl/t/rpl_row_NOW.test
new file mode 100644
index 00000000000..c28b714277e
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_row_NOW.test
@@ -0,0 +1,74 @@
+#############################################################################
+# Original Author: JBM #
+# Original Date: Aug/18/2005 #
+# Updated 08/30/2005 Added dumps and diff #
+#############################################################################
+#TEST: Taken and modfied from http://bugs.mysql.com/bug.php?id=12480 #
+#############################################################################
+
+# Includes
+-- source include/have_binlog_format_row.inc
+-- source include/master-slave.inc
+
+
+# Begin clean up test section
+connection master;
+--disable_warnings
+create database if not exists mysqltest1;
+DROP TABLE IF EXISTS mysqltest1.t1;
+--enable_warnings
+
+
+# Begin test section 1
+CREATE TABLE mysqltest1.t1 (n MEDIUMINT NOT NULL AUTO_INCREMENT,
+ a TIMESTAMP DEFAULT '2005-05-05 01:01:01',
+ b TIMESTAMP DEFAULT '2005-05-05 01:01:01',
+ PRIMARY KEY(n));
+delimiter |;
+CREATE FUNCTION mysqltest1.f1() RETURNS TIMESTAMP
+BEGIN
+ DECLARE v1 INT DEFAULT 300;
+ WHILE v1 > 0 DO
+ SET v1 = v1 - 1;
+ END WHILE;
+ RETURN NOW();
+END|
+delimiter ;|
+
+INSERT INTO mysqltest1.t1 VALUES(NULL,NOW(),mysqltest1.f1());
+
+delimiter |;
+CREATE TRIGGER mysqltest1.trig1 BEFORE INSERT ON mysqltest1.t1
+FOR EACH ROW BEGIN
+ SET new.b = mysqltest1.f1();
+END|
+delimiter ;|
+
+INSERT INTO mysqltest1.t1 SET n = NULL, a = now();
+
+sync_slave_with_master;
+
+connection master;
+
+--exec $MYSQL_DUMP --compact --order-by-primary --skip-extended-insert --no-create-info mysqltest1 > $MYSQLTEST_VARDIR/tmp/NOW_master.sql
+--exec $MYSQL_DUMP_SLAVE --compact --order-by-primary --skip-extended-insert --no-create-info mysqltest1 > $MYSQLTEST_VARDIR/tmp/NOW_slave.sql
+
+# lets cleanup
+DROP TABLE IF EXISTS mysqltest1.t1;
+DROP FUNCTION mysqltest1.f1;
+DROP DATABASE mysqltest1;
+
+# Lets compare. Note: If they match test will pass, if they do not match
+# the test will show that the diff statement failed and not reject file
+# will be created. You will need to go to the mysql-test dir and diff
+# the files your self to see what is not matching :-) The failed dump
+# files will be located in $MYSQLTEST_VARDIR/tmp
+
+diff_files $MYSQLTEST_VARDIR/tmp/NOW_master.sql $MYSQLTEST_VARDIR/tmp/NOW_slave.sql;
+
+# If all is good, when can cleanup our dump files.
+--remove_file $MYSQLTEST_VARDIR/tmp/NOW_master.sql
+--remove_file $MYSQLTEST_VARDIR/tmp/NOW_slave.sql
+
+sync_slave_with_master;
+# End of 5.1 test case
diff --git a/mysql-test/suite/rpl/t/rpl_row_USER.test b/mysql-test/suite/rpl/t/rpl_row_USER.test
new file mode 100644
index 00000000000..7b13ebc50ee
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_row_USER.test
@@ -0,0 +1,60 @@
+#############################################################################
+# Original Author: JBM #
+# Original Date: Aug/18/2005 #
+#############################################################################
+# TEST: To test the USER() and CURRENT_USER() in rbr #
+#############################################################################
+# Change Author: JBM
+# Change Date: 2006-01-16
+# Change: Added Order by for NDB
+##########
+
+# Includes
+-- source include/have_binlog_format_row.inc
+-- source include/master-slave.inc
+
+# Begin clean up test section
+connection master;
+--disable_warnings
+DROP DATABASE IF EXISTS mysqltest1;
+CREATE DATABASE mysqltest1;
+--enable_warnings
+
+# Section 1 test
+CREATE USER tester IDENTIFIED BY 'test';
+GRANT ALL ON mysqltest1.* TO 'tester'@'%' IDENTIFIED BY 'test';
+GRANT ALL ON mysqltest1.* TO ''@'localhost%';
+FLUSH PRIVILEGES;
+connect (m_1,localhost,tester,,mysqltest1);
+
+connection m_1;
+CREATE TABLE mysqltest1.t1 (a INT, users VARCHAR(255), PRIMARY KEY(a));
+INSERT INTO mysqltest1.t1 VALUES(1,USER());
+INSERT INTO mysqltest1.t1 VALUES(2,CURRENT_USER());
+delimiter |;
+create procedure mysqltest1.p1()
+begin
+ INSERT INTO mysqltest1.t1 VALUES(3,USER());
+ INSERT INTO mysqltest1.t1 VALUES(4,CURRENT_USER());
+end|
+delimiter ;|
+
+CALL mysqltest1.p1();
+connection master;
+SELECT * FROM mysqltest1.t1 ORDER BY a;
+sync_slave_with_master;
+SELECT * FROM mysqltest1.t1 ORDER BY a;
+
+connection master;
+# Lets cleanup
+#show binlog events;
+
+DROP DATABASE mysqltest1;
+REVOKE ALL ON mysqltest1.* FROM 'tester'@'%';
+REVOKE ALL ON mysqltest1.* FROM ''@'localhost%';
+DROP USER tester@'%';
+DROP USER ''@'localhost%';
+
+sync_slave_with_master;
+
+# End of 5.0 test case
diff --git a/mysql-test/suite/rpl/t/rpl_row_UUID.test b/mysql-test/suite/rpl/t/rpl_row_UUID.test
new file mode 100644
index 00000000000..b0ef96463d0
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_row_UUID.test
@@ -0,0 +1,9 @@
+########################################################
+# By JBM 2005-02-15 Wrapped to allow reuse of test code#
+# Added to skip if ndb is default #
+########################################################
+-- source include/not_ndb_default.inc
+-- source include/have_binlog_format_row.inc
+-- source include/master-slave.inc
+let $engine_type=myisam;
+--source extra/rpl_tests/rpl_row_UUID.test
diff --git a/mysql-test/suite/rpl/t/rpl_row_basic_11bugs-master.opt b/mysql-test/suite/rpl/t/rpl_row_basic_11bugs-master.opt
new file mode 100644
index 00000000000..ed7656c1f99
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_row_basic_11bugs-master.opt
@@ -0,0 +1,2 @@
+--binlog_ignore_db=test_ignore --loose-innodb
+
diff --git a/mysql-test/suite/rpl/t/rpl_row_basic_11bugs-slave.opt b/mysql-test/suite/rpl/t/rpl_row_basic_11bugs-slave.opt
new file mode 100644
index 00000000000..48457b17309
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_row_basic_11bugs-slave.opt
@@ -0,0 +1 @@
+--loose-innodb
diff --git a/mysql-test/suite/rpl/t/rpl_row_basic_11bugs.test b/mysql-test/suite/rpl/t/rpl_row_basic_11bugs.test
new file mode 100644
index 00000000000..fb43664f121
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_row_basic_11bugs.test
@@ -0,0 +1,225 @@
+--source include/have_binlog_format_row.inc
+
+let $SERVER_VERSION=`select version()`;
+
+#This test case is not written for NDB, the result files
+#will not match when NDB is the default engine
+-- source include/not_ndb_default.inc
+
+--source include/master-slave.inc
+
+# Bug#15942 (RBR ignores --binlog_ignore_db and tries to map to table
+# on slave for writes)
+
+CREATE DATABASE test_ignore; # --binlog_ignore_db=mysqltest_ignore
+
+--echo **** On Master ****
+SHOW DATABASES;
+USE test;
+CREATE TABLE t1 (a INT, b INT);
+SHOW TABLES;
+INSERT INTO t1 VALUES (1,1), (2,2);
+USE test_ignore;
+CREATE TABLE t2 (a INT, b INT);
+SHOW TABLES;
+INSERT INTO t2 VALUES (3,3), (4,4);
+source include/show_binlog_events.inc;
+sync_slave_with_master;
+--echo **** On Slave ****
+SHOW DATABASES;
+USE test;
+SHOW TABLES;
+--error 1049
+USE test_ignore;
+
+connection master;
+DROP DATABASE test_ignore;
+sync_slave_with_master;
+
+# Bug#19995: Extreneous table maps generated for statements that does
+# not generate rows
+--disable_query_log
+--source include/master-slave-reset.inc
+--enable_query_log
+
+connection master;
+CREATE TABLE t1 (a INT);
+DELETE FROM t1;
+INSERT INTO t1 VALUES (1),(2);
+DELETE FROM t1 WHERE a = 0;
+UPDATE t1 SET a=99 WHERE a = 0;
+--replace_result $SERVER_VERSION SERVER_VERSION
+--replace_regex /table_id: [0-9]+/table_id: #/
+SHOW BINLOG EVENTS;
+
+DROP TABLE t1;
+
+# BUG#17620: Replicate (Row Based) Fails when Query Cache enabled on
+# slave
+--echo ================ Test for BUG#17620 ================
+--disable_query_log
+--source include/master-slave-reset.inc
+--enable_query_log
+
+--echo **** On Slave ****
+connection slave;
+SET GLOBAL QUERY_CACHE_SIZE=0;
+
+--echo **** On Master ****
+connection master;
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1),(2),(3);
+
+--echo **** On Slave ****
+sync_slave_with_master;
+SET GLOBAL QUERY_CACHE_SIZE=16*1024*1024;
+
+--echo **** On Master ****
+connection master;
+INSERT INTO t1 VALUES (4),(5),(6);
+
+--echo **** On Slave ****
+sync_slave_with_master;
+SELECT * FROM t1;
+
+--echo **** On Master ****
+connection master;
+INSERT INTO t1 VALUES (7),(8),(9);
+
+--echo **** On Slave ****
+sync_slave_with_master;
+SELECT * FROM t1;
+
+SET GLOBAL QUERY_CACHE_SIZE=0;
+
+# Bug#22550: Replication of BIT columns failing
+--echo ================ Test for BUG#22550 ================
+--disable_query_log
+--source include/master-slave-reset.inc
+--enable_query_log
+
+connection master;
+CREATE TABLE t1 (a BIT(1), b INT) ENGINE=MYISAM;
+sync_slave_with_master;
+
+connection master;
+INSERT INTO t1 VALUES(1,2);
+SELECT HEX(a),b FROM t1;
+sync_slave_with_master;
+SELECT HEX(a),b FROM t1;
+
+connection master;
+UPDATE t1 SET a=0 WHERE b=2;
+SELECT HEX(a),b FROM t1;
+sync_slave_with_master;
+SELECT HEX(a),b FROM t1;
+
+connection master;
+DROP TABLE IF EXISTS t1;
+sync_slave_with_master;
+
+# BUG#22583: RBR between MyISAM and non-MyISAM tables containing a BIT
+# field does not work
+
+--echo ================ Test for BUG#22583 ================
+--disable_query_log
+--source include/master-slave-reset.inc
+--enable_query_log
+
+# disabling warnings temporarily for ENGINE=INNODB to work without InnoDB
+--disable_warnings
+--echo **** On Master ****
+connection master;
+CREATE TABLE t1_myisam (k INT, a BIT(1), b BIT(9)) ENGINE=MYISAM;
+CREATE TABLE t1_innodb (k INT, a BIT(1), b BIT(9)) ENGINE=INNODB;
+CREATE TABLE t2_myisam (k INT, a BIT(1) NOT NULL, b BIT(4) NOT NULL) ENGINE=MYISAM;
+CREATE TABLE t2_innodb (k INT, a BIT(1) NOT NULL, b BIT(4) NOT NULL) ENGINE=INNODB;
+--echo **** On Slave ****
+sync_slave_with_master;
+ALTER TABLE t1_myisam ENGINE=INNODB;
+ALTER TABLE t1_innodb ENGINE=MYISAM;
+ALTER TABLE t2_myisam ENGINE=INNODB;
+ALTER TABLE t2_innodb ENGINE=MYISAM;
+--enable_warnings
+
+--echo **** On Master ****
+connection master;
+INSERT INTO t1_myisam VALUES(1, b'0', 257);
+INSERT INTO t1_myisam VALUES(2, b'1', 256);
+INSERT INTO t1_innodb VALUES(1, b'0', 257);
+INSERT INTO t1_innodb VALUES(2, b'1', 256);
+SELECT k, HEX(a),HEX(b) FROM t1_myisam;
+SELECT k, HEX(a),HEX(b) FROM t1_innodb;
+INSERT INTO t2_myisam VALUES(1, b'0', 9);
+INSERT INTO t2_myisam VALUES(2, b'1', 8);
+INSERT INTO t2_innodb VALUES(1, b'0', 9);
+INSERT INTO t2_innodb VALUES(2, b'1', 8);
+SELECT k, HEX(a),HEX(b) FROM t2_myisam;
+SELECT k, HEX(a),HEX(b) FROM t2_innodb;
+--echo **** On Slave ****
+sync_slave_with_master;
+SELECT k, HEX(a),HEX(b) FROM t1_myisam;
+SELECT k, HEX(a),HEX(b) FROM t1_innodb;
+SELECT k, HEX(a),HEX(b) FROM t2_myisam;
+SELECT k, HEX(a),HEX(b) FROM t2_innodb;
+
+--echo **** On Master ****
+connection master;
+UPDATE t1_myisam SET a=0 WHERE k=2;
+SELECT k, HEX(a),HEX(b) FROM t1_myisam;
+UPDATE t1_innodb SET a=0 WHERE k=2;
+SELECT k, HEX(a),HEX(b) FROM t1_innodb;
+UPDATE t2_myisam SET a=0 WHERE k=2;
+SELECT k, HEX(a),HEX(b) FROM t2_myisam;
+UPDATE t2_innodb SET a=0 WHERE k=2;
+SELECT k, HEX(a),HEX(b) FROM t2_innodb;
+--echo **** On Slave ****
+sync_slave_with_master;
+SELECT k, HEX(a),HEX(b) FROM t1_myisam;
+SELECT k, HEX(a),HEX(b) FROM t1_innodb;
+SELECT k, HEX(a),HEX(b) FROM t2_myisam;
+SELECT k, HEX(a),HEX(b) FROM t2_innodb;
+
+--echo **** On Master ****
+connection master;
+DROP TABLE IF EXISTS t1_myisam, t1_innodb, t2_myisam, t2_innodb;
+sync_slave_with_master;
+
+#
+# Bug#27716 multi-update did partially and has not binlogged
+#
+
+connection master;
+
+--disable_warnings
+drop table if exists t1, t2;
+--enable_warnings
+CREATE TABLE `t1` (
+ `a` int(11) NOT NULL auto_increment,
+ `b` int(11) default NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 ;
+
+CREATE TABLE `t2` (
+ `a` int(11) NOT NULL auto_increment,
+ `b` int(11) default NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 ;
+
+# testing multi_update::send_error() effective update
+insert into t1 values (1,1),(2,2);
+insert into t2 values (1,1),(4,4);
+
+connection master;
+error ER_DUP_ENTRY;
+UPDATE t2,t1 SET t2.a=t1.a+2;
+select * from t2 /* must be (3,1), (4,4) */;
+sync_slave_with_master;
+
+connection slave;
+select * from t2 /* must be (3,1), (4,4) */;
+
+connection master;
+drop table t1,t2;
+
+sync_slave_with_master;
diff --git a/mysql-test/suite/rpl/t/rpl_row_basic_2myisam.test b/mysql-test/suite/rpl/t/rpl_row_basic_2myisam.test
new file mode 100644
index 00000000000..c5648fa1d77
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_row_basic_2myisam.test
@@ -0,0 +1,6 @@
+-- source include/have_binlog_format_row.inc
+-- source include/master-slave.inc
+
+let $type= 'MYISAM' ;
+let $extra_index= ;
+-- source extra/rpl_tests/rpl_row_basic.test
diff --git a/mysql-test/suite/rpl/t/rpl_row_basic_3innodb-slave.opt b/mysql-test/suite/rpl/t/rpl_row_basic_3innodb-slave.opt
new file mode 100644
index 00000000000..627becdbfb5
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_row_basic_3innodb-slave.opt
@@ -0,0 +1 @@
+--innodb
diff --git a/mysql-test/suite/rpl/t/rpl_row_basic_3innodb.test b/mysql-test/suite/rpl/t/rpl_row_basic_3innodb.test
new file mode 100644
index 00000000000..3786a697e3f
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_row_basic_3innodb.test
@@ -0,0 +1,8 @@
+-- source include/have_innodb.inc
+-- source include/have_binlog_format_row.inc
+-- source include/master-slave.inc
+
+let $type= 'INNODB' ;
+let $extra_index= ;
+-- source extra/rpl_tests/rpl_row_basic.test
+
diff --git a/mysql-test/suite/rpl/t/rpl_row_basic_8partition.test b/mysql-test/suite/rpl/t/rpl_row_basic_8partition.test
new file mode 100644
index 00000000000..687b3bc785d
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_row_basic_8partition.test
@@ -0,0 +1,210 @@
+############################################################
+# Author: MATZ #
+# Date: 2006-03-22 #
+# Purpose: See if replication of partition tables work #
+# Most of this test is copied from the rpl_xxx2yyy tests, #
+# but here we just test some simple basic replication of #
+# partition tables with same engine (MyISAM) in both ends. #
+############################################################
+
+--source include/have_binlog_format_row.inc
+--source include/have_partition.inc
+--source include/not_ndb_default.inc
+--source include/master-slave.inc
+connection master;
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+
+let $maybe_ro_var = @@BINLOG_FORMAT;
+let $val4var = ROW;
+--source include/safe_set_to_maybe_ro_var.inc
+
+--echo **** Partition RANGE testing ****
+
+# Create table that is partitioned by range on year i.e. year(t) and
+# replicate basice operations such at insert, update delete between 2
+# different storage engines Alter table and ensure table is handled
+# Correctly on the slave
+# Note that the storage engine should not be explicit: the default
+# storage engine is used on master and slave.
+
+CREATE TABLE t1 (id MEDIUMINT NOT NULL, b1 BIT(8), vc VARCHAR(255),
+ bc CHAR(255), d DECIMAL(10,4) DEFAULT 0,
+ f FLOAT DEFAULT 0, total BIGINT UNSIGNED,
+ y YEAR, t DATE)
+ PARTITION BY RANGE (YEAR(t))
+ (PARTITION p0 VALUES LESS THAN (1901),
+ PARTITION p1 VALUES LESS THAN (1946),
+ PARTITION p2 VALUES LESS THAN (1966),
+ PARTITION p3 VALUES LESS THAN (1986),
+ PARTITION p4 VALUES LESS THAN (2005),
+ PARTITION p5 VALUES LESS THAN MAXVALUE);
+
+--echo --- On master ---
+SHOW CREATE TABLE t1;
+
+--echo --- On slave --
+sync_slave_with_master;
+SHOW CREATE TABLE t1;
+
+--source include/rpl_multi_engine3.inc
+
+connection master;
+# Check that simple Alter statements are replicated correctly
+ALTER TABLE t1 MODIFY vc TEXT;
+
+--echo --- On master ---
+SHOW CREATE TABLE t1;
+
+--echo --- On slave ---
+sync_slave_with_master;
+SHOW CREATE TABLE t1;
+
+# Perform basic operation on master and ensure replicated correctly
+--source include/rpl_multi_engine3.inc
+
+connection master;
+DROP TABLE IF EXISTS t1;
+
+########################################################
+
+--echo **** Partition LIST testing ****
+
+# Create table that is partitioned by list on id i.e. (2,4). Pretend
+# that we missed one and alter to add. Then replicate basice
+# operations such at insert, update delete between 2 different storage
+# engines Alter table and ensure table is handled Correctly on the
+# slave.
+
+
+CREATE TABLE t1 (id MEDIUMINT NOT NULL, b1 BIT(8), vc VARCHAR(255),
+ bc CHAR(255), d DECIMAL(10,4) DEFAULT 0,
+ f FLOAT DEFAULT 0, total BIGINT UNSIGNED,
+ y YEAR, t DATE)
+ PARTITION BY LIST(id)
+ (PARTITION p0 VALUES IN (2, 4),
+ PARTITION p1 VALUES IN (42, 142),
+ PARTITION p2 VALUES IN (412));
+
+--echo --- On master ---
+SHOW CREATE TABLE t1;
+
+--echo --- On slave ---
+sync_slave_with_master;
+SHOW CREATE TABLE t1;
+
+# Perform basic operation on master and ensure replicated correctly
+--source include/rpl_multi_engine3.inc
+
+connection master;
+# Check that simple Alter statements are replicated correctly ---
+ALTER TABLE t1 MODIFY vc TEXT;
+
+--echo --- On master ---
+SHOW CREATE TABLE t1;
+
+--echo --- On slave ---
+sync_slave_with_master;
+SHOW CREATE TABLE t1;
+
+# Perform basic operation on master and ensure replicated correctly
+--source include/rpl_multi_engine3.inc
+
+connection master;
+DROP TABLE IF EXISTS t1;
+
+########################################################
+
+--echo **** Partition HASH testing ****
+
+# Create table that is partitioned by hash on year i.e. YEAR(t). Then
+# replicate basice operations such at insert, update delete between 2
+# different storage engines Alter table and ensure table is handled
+# Correctly on the slave
+
+CREATE TABLE t1 (id MEDIUMINT NOT NULL, b1 BIT(8), vc VARCHAR(255),
+ bc CHAR(255), d DECIMAL(10,4) DEFAULT 0,
+ f FLOAT DEFAULT 0, total BIGINT UNSIGNED,
+ y YEAR, t DATE)
+ PARTITION BY HASH( YEAR(t) )
+ PARTITIONS 4;
+
+--echo --- On master ---
+SHOW CREATE TABLE t1;
+
+--echo --- On slave ---
+sync_slave_with_master;
+SHOW CREATE TABLE t1;
+
+--source include/rpl_multi_engine3.inc
+
+# Check that simple Alter statements are replicated correctly
+ALTER TABLE t1 MODIFY vc TEXT;
+
+--echo --- On master ---
+SHOW CREATE TABLE t1;
+
+--echo --- On slave ---
+sync_slave_with_master;
+SHOW CREATE TABLE t1;
+
+--source include/rpl_multi_engine3.inc
+
+connection master;
+DROP TABLE IF EXISTS t1;
+
+########################################################
+
+# This part does not work
+--echo **** Partition by KEY ****
+
+# Create table that is partitioned by key on id with 4 parts. Then
+# replicate basice operations such at insert, update delete between 2
+# different storage engines Alter table and ensure table is handled
+# Correctly on the slave
+
+CREATE TABLE t1 (id MEDIUMINT NOT NULL, b1 BIT(8), vc VARCHAR(255),
+ bc CHAR(255), d DECIMAL(10,4) DEFAULT 0,
+ f FLOAT DEFAULT 0, total BIGINT UNSIGNED,
+ y YEAR, t DATE,PRIMARY KEY(id))
+ PARTITION BY KEY()
+ PARTITIONS 4;
+
+--echo --- On master ---
+SHOW CREATE TABLE t1;
+
+--echo --- On slave ---
+sync_slave_with_master;
+SHOW CREATE TABLE t1;
+
+--source include/rpl_multi_engine3.inc
+
+connection master;
+# Check that simple Alter statements are replicated correctly
+ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY(id, total);
+
+--echo --- On master ---
+SHOW CREATE TABLE t1;
+
+--echo --- On slave ---
+sync_slave_with_master;
+SHOW CREATE TABLE t1;
+
+--source include/rpl_multi_engine3.inc
+
+connection master;
+# Check that simple Alter statements are replicated correctly
+ALTER TABLE t1 MODIFY vc TEXT;
+
+--echo --- On master ---
+SHOW CREATE TABLE t1;
+
+--echo --- On slave ---
+sync_slave_with_master;
+SHOW CREATE TABLE t1;
+
+--source include/rpl_multi_engine3.inc
+
+DROP TABLE IF EXISTS t1;
+
+# End of 5.1 test case
diff --git a/mysql-test/suite/rpl/t/rpl_row_blob_innodb-slave.opt b/mysql-test/suite/rpl/t/rpl_row_blob_innodb-slave.opt
new file mode 100644
index 00000000000..627becdbfb5
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_row_blob_innodb-slave.opt
@@ -0,0 +1 @@
+--innodb
diff --git a/mysql-test/suite/rpl/t/rpl_row_blob_innodb.test b/mysql-test/suite/rpl/t/rpl_row_blob_innodb.test
new file mode 100644
index 00000000000..6aa6c2a31b9
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_row_blob_innodb.test
@@ -0,0 +1,14 @@
+#################################
+# Wrapper for rpl_row_blob.test#
+#################################
+########################################################
+# By JBM 2005-02-15 Wrapped to allow reuse of test code#
+# Added to skip if ndb is default #
+########################################################
+-- source include/not_ndb_default.inc
+-- source include/have_innodb.inc
+-- source include/have_binlog_format_row.inc
+-- source include/master-slave.inc
+let $engine_type=InnoDB;
+-- source extra/rpl_tests/rpl_row_blob.test
+
diff --git a/mysql-test/suite/rpl/t/rpl_row_blob_myisam.test b/mysql-test/suite/rpl/t/rpl_row_blob_myisam.test
new file mode 100644
index 00000000000..11f5336502a
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_row_blob_myisam.test
@@ -0,0 +1,13 @@
+#################################
+# Wrapper for rpl_row_blob.test#
+#################################
+########################################################
+# By JBM 2005-02-15 Wrapped to allow reuse of test code#
+# Added to skip if ndb is default #
+########################################################
+-- source include/not_ndb_default.inc
+-- source include/have_binlog_format_row.inc
+-- source include/master-slave.inc
+let $engine_type=myisam;
+-- source extra/rpl_tests/rpl_row_blob.test
+
diff --git a/mysql-test/suite/rpl/t/rpl_row_charset.test b/mysql-test/suite/rpl/t/rpl_row_charset.test
new file mode 100644
index 00000000000..c83ccc586ba
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_row_charset.test
@@ -0,0 +1,9 @@
+########################################################
+# By JBM 2005-02-15 Wrapped to allow reuse of test code#
+# Added to skip if ndb is default #
+########################################################
+-- source include/not_ndb_default.inc
+-- source include/have_binlog_format_row.inc
+-- source include/master-slave.inc
+let $engine_type=myisam;
+-- source extra/rpl_tests/rpl_row_charset.test
diff --git a/mysql-test/suite/rpl/t/rpl_row_create_table-slave.opt b/mysql-test/suite/rpl/t/rpl_row_create_table-slave.opt
new file mode 100644
index 00000000000..48457b17309
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_row_create_table-slave.opt
@@ -0,0 +1 @@
+--loose-innodb
diff --git a/mysql-test/suite/rpl/t/rpl_row_create_table.test b/mysql-test/suite/rpl/t/rpl_row_create_table.test
new file mode 100644
index 00000000000..be10d48b757
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_row_create_table.test
@@ -0,0 +1,236 @@
+# Testing table creations for row-based replication.
+
+--source include/have_binlog_format_row.inc
+--source include/master-slave.inc
+--source include/have_innodb.inc
+connection slave;
+--source include/have_innodb.inc
+connection master;
+
+# Bug#18326: Do not lock table for writing during prepare of statement
+# The use of the ps protocol causes extra table maps in the binlog, so
+# we disable the ps-protocol for this statement.
+--disable_ps_protocol
+
+--disable_query_log
+--disable_warnings
+DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7,t8,t9;
+--enable_warnings
+--enable_query_log
+
+# Set the default storage engine to different values on master and
+# slave. We need to stop the slave for the server variable to take
+# effect, since the variable is only read on start-up.
+sync_slave_with_master;
+--disable_query_log
+set @storage_engine = @@global.storage_engine;
+STOP SLAVE;
+SET GLOBAL storage_engine=memory;
+START SLAVE;
+--enable_query_log
+
+connection master;
+CREATE TABLE t1 (a INT, b INT);
+CREATE TABLE t2 (a INT, b INT) ENGINE=Merge;
+CREATE TABLE t3 (a INT, b INT) CHARSET=utf8;
+CREATE TABLE t4 (a INT, b INT) ENGINE=Merge CHARSET=utf8;
+--replace_column 1 # 4 #
+--replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/
+--query_vertical SHOW BINLOG EVENTS FROM 216
+--echo **** On Master ****
+--query_vertical SHOW CREATE TABLE t1
+--query_vertical SHOW CREATE TABLE t2
+--query_vertical SHOW CREATE TABLE t3
+sync_slave_with_master;
+--echo **** On Slave ****
+--query_vertical SHOW CREATE TABLE t1
+--query_vertical SHOW CREATE TABLE t2
+--query_vertical SHOW CREATE TABLE t3
+
+connection master;
+CREATE TABLE t5 (b INT, c INT) SELECT * FROM t3;
+
+CREATE TEMPORARY TABLE tt3 (a INT, b INT);
+INSERT INTO tt3 VALUES (1,2), (2,4), (3,6), (4,2), (5,10), (6,12);
+CREATE TABLE t6 (b INT, c INT) SELECT * FROM tt3;
+--echo **** On Master ****
+--query_vertical SHOW CREATE TABLE t5
+SELECT * FROM t5 ORDER BY a,b,c;
+--query_vertical SHOW CREATE TABLE t6
+SELECT * FROM t6 ORDER BY a,b,c;
+sync_slave_with_master;
+--echo **** On Slave ****
+--query_vertical SHOW CREATE TABLE t5
+SELECT * FROM t5 ORDER BY a,b,c;
+--query_vertical SHOW CREATE TABLE t6
+SELECT * FROM t6 ORDER BY a,b,c;
+
+connection master;
+# Test for erroneous constructions
+--error ER_DUP_ENTRY
+CREATE TABLE t7 (UNIQUE(b)) SELECT a,b FROM tt3;
+# Shouldn't be written to the binary log
+--replace_column 1 # 4 #
+--replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/
+SHOW BINLOG EVENTS FROM 1098;
+
+# Test that INSERT-SELECT works the same way as for SBR.
+CREATE TABLE t7 (a INT, b INT UNIQUE);
+--error ER_DUP_ENTRY
+INSERT INTO t7 SELECT a,b FROM tt3;
+SELECT * FROM t7 ORDER BY a,b;
+# Should be written to the binary log
+--replace_column 1 # 4 #
+--replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/
+SHOW BINLOG EVENTS FROM 1098;
+sync_slave_with_master;
+SELECT * FROM t7 ORDER BY a,b;
+
+connection master;
+CREATE TEMPORARY TABLE tt4 (a INT, b INT);
+INSERT INTO tt4 VALUES (4,8), (5,10), (6,12);
+BEGIN;
+INSERT INTO t7 SELECT a,b FROM tt4;
+ROLLBACK;
+--replace_column 1 # 4 #
+--replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/
+SHOW BINLOG EVENTS FROM 1294;
+SELECT * FROM t7 ORDER BY a,b;
+sync_slave_with_master;
+SELECT * FROM t7 ORDER BY a,b;
+
+connection master;
+CREATE TABLE t8 LIKE t4;
+CREATE TABLE t9 LIKE tt4;
+CREATE TEMPORARY TABLE tt5 LIKE t4;
+CREATE TEMPORARY TABLE tt6 LIKE tt4;
+CREATE TEMPORARY TABLE tt7 SELECT 1;
+--echo **** On Master ****
+--query_vertical SHOW CREATE TABLE t8
+--query_vertical SHOW CREATE TABLE t9
+--replace_column 1 # 4 #
+--replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/
+SHOW BINLOG EVENTS FROM 1390;
+sync_slave_with_master;
+--echo **** On Slave ****
+--query_vertical SHOW CREATE TABLE t8
+--query_vertical SHOW CREATE TABLE t9
+
+connection master;
+DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7,t8,t9;
+sync_slave_with_master;
+# Here we reset the value of the default storage engine
+STOP SLAVE;
+SET GLOBAL storage_engine=@storage_engine;
+START SLAVE;
+--enable_ps_protocol
+
+# BUG#22864 (Rollback following CREATE ... SELECT discards 'CREATE
+# table' from log):
+--echo ================ BUG#22864 ================
+connection slave;
+STOP SLAVE;
+RESET SLAVE;
+connection master;
+RESET MASTER;
+connection slave;
+START SLAVE;
+connection master;
+SET AUTOCOMMIT=0;
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1),(2),(3);
+
+CREATE TABLE t2 ENGINE=INNODB SELECT * FROM t1;
+ROLLBACK;
+
+CREATE TABLE t3 ENGINE=INNODB SELECT * FROM t1;
+INSERT INTO t3 VALUES (4),(5),(6);
+ROLLBACK;
+
+CREATE TABLE t4 ENGINE=INNODB SELECT * FROM t1;
+INSERT INTO t1 VALUES (4),(5),(6);
+ROLLBACK;
+
+SHOW TABLES;
+SELECT TABLE_NAME,ENGINE
+ FROM INFORMATION_SCHEMA.TABLES
+ WHERE TABLE_NAME LIKE 't_'
+ORDER BY TABLE_NAME;
+SELECT * FROM t1 ORDER BY a;
+SELECT * FROM t2 ORDER BY a;
+SELECT * FROM t3 ORDER BY a;
+SELECT * FROM t4 ORDER BY a;
+--replace_column 1 # 4 #
+--replace_regex /\/\* xid=.* \*\//\/* XID *\// /Server ver: .*, Binlog ver: .*/Server ver: #, Binlog ver: #/ /table_id: [0-9]+/table_id: #/
+SHOW BINLOG EVENTS;
+sync_slave_with_master;
+SHOW TABLES;
+SELECT TABLE_NAME,ENGINE
+ FROM INFORMATION_SCHEMA.TABLES
+ WHERE TABLE_NAME LIKE 't_'
+ORDER BY TABLE_NAME;
+SELECT * FROM t1 ORDER BY a;
+SELECT * FROM t2 ORDER BY a;
+SELECT * FROM t3 ORDER BY a;
+SELECT * FROM t4 ORDER BY a;
+
+connection master;
+DROP TABLE IF EXISTS t1,t2,t3,t4;
+SET AUTOCOMMIT=1;
+sync_slave_with_master;
+
+# Some tests with temporary tables
+connection slave;
+STOP SLAVE;
+RESET SLAVE;
+
+connection master;
+RESET MASTER;
+
+connection slave;
+START SLAVE;
+
+connection master;
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1),(2),(3);
+
+CREATE TABLE t2 (a INT) ENGINE=INNODB;
+
+BEGIN;
+INSERT INTO t2 SELECT a*a FROM t1;
+CREATE TEMPORARY TABLE tt1
+SELECT a+1 AS a
+ FROM t1
+ WHERE a MOD 2 = 1;
+INSERT INTO t2 SELECT a+2 FROM tt1;
+COMMIT;
+
+SELECT * FROM t2 ORDER BY a;
+--replace_column 1 # 4 #
+--replace_regex /\/\* xid=.* \*\//\/* XID *\// /Server ver: .*, Binlog ver: .*/Server ver: #, Binlog ver: #/ /table_id: [0-9]+/table_id: #/
+SHOW BINLOG EVENTS;
+sync_slave_with_master;
+SELECT * FROM t2 ORDER BY a;
+
+connection master;
+TRUNCATE TABLE t2;
+
+BEGIN;
+INSERT INTO t2 SELECT a*a FROM t1;
+CREATE TEMPORARY TABLE tt2
+SELECT a+1 AS a
+ FROM t1
+ WHERE a MOD 2 = 1;
+INSERT INTO t2 SELECT a+2 FROM tt2;
+ROLLBACK;
+
+SELECT * FROM t2 ORDER BY a;
+--replace_column 1 # 4 #
+--replace_regex /\/\* xid=.* \*\//\/* XID *\// /Server ver: .*, Binlog ver: .*/Server ver: #, Binlog ver: #/ /table_id: [0-9]+/table_id: #/
+SHOW BINLOG EVENTS FROM 631;
+sync_slave_with_master;
+SELECT * FROM t2 ORDER BY a;
+
+connection master;
+DROP TABLE t1,t2;
+sync_slave_with_master;
diff --git a/mysql-test/suite/rpl/t/rpl_row_delayed_ins.test b/mysql-test/suite/rpl/t/rpl_row_delayed_ins.test
new file mode 100644
index 00000000000..a0e74567349
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_row_delayed_ins.test
@@ -0,0 +1,7 @@
+########################################################
+# By JBM 2005-02-15 Wrapped to allow reuse of test code#
+# Added to skip if ndb is default #
+########################################################
+-- source include/not_ndb_default.inc
+let $engine_type=myisam;
+-- source extra/rpl_tests/rpl_row_delayed_ins.test
diff --git a/mysql-test/suite/rpl/t/rpl_row_drop.test b/mysql-test/suite/rpl/t/rpl_row_drop.test
new file mode 100644
index 00000000000..20c217a7c3a
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_row_drop.test
@@ -0,0 +1,48 @@
+-- source include/have_binlog_format_row.inc
+-- source include/master-slave.inc
+
+# Bug#12415: DROP of temporary table on master stops slave
+connection master;
+--echo **** On Master ****
+CREATE TABLE t1 (a int);
+CREATE TABLE t2 (a int);
+CREATE TEMPORARY TABLE t2 (a int, b int);
+SHOW TABLES;
+sync_slave_with_master;
+--echo **** On Slave ****
+SHOW TABLES;
+connection master;
+--echo **** On Master ****
+DROP TABLE t2; # Dropping the temporary table
+SHOW TABLES;
+sync_slave_with_master;
+--echo **** On Slave ****
+SHOW TABLES; # There should be two tables on the slave
+
+connection master;
+--echo **** On Master ****
+CREATE TEMPORARY TABLE t2 (a int, b int);
+SHOW TABLES;
+sync_slave_with_master;
+--echo **** On Slave ****
+SHOW TABLES;
+connection master;
+--echo **** On Master ****
+# Should drop the non-temporary table t1 and the temporary table t2
+DROP TABLE t1,t2;
+let $VERSION=`select version()`;
+--replace_result $VERSION VERSION
+--replace_regex /table_id: [0-9]+/table_id: #/
+SHOW BINLOG EVENTS;
+SHOW TABLES;
+sync_slave_with_master;
+--echo **** On Slave ****
+SHOW TABLES;
+
+--disable_query_log
+--disable_warnings
+connection master;
+DROP TABLE IF EXISTS t2;
+sync_slave_with_master;
+--enable_warnings
+--enable_query_log
diff --git a/mysql-test/suite/rpl/t/rpl_row_err_daisychain-master.opt b/mysql-test/suite/rpl/t/rpl_row_err_daisychain-master.opt
new file mode 100644
index 00000000000..83ed8522e72
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_row_err_daisychain-master.opt
@@ -0,0 +1 @@
+--binlog-format=row
diff --git a/mysql-test/suite/rpl/t/rpl_row_err_daisychain-slave.opt b/mysql-test/suite/rpl/t/rpl_row_err_daisychain-slave.opt
new file mode 100644
index 00000000000..4cb7a31da81
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_row_err_daisychain-slave.opt
@@ -0,0 +1 @@
+--binlog-format=statement --log-slave-updates
diff --git a/mysql-test/suite/rpl/t/rpl_row_flsh_tbls.test b/mysql-test/suite/rpl/t/rpl_row_flsh_tbls.test
new file mode 100644
index 00000000000..a2f9e31fc5d
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_row_flsh_tbls.test
@@ -0,0 +1,17 @@
+# depends on the binlog output
+-- source include/have_binlog_format_row.inc
+
+let $rename_event_pos= 619;
+
+# Bug#18326: Do not lock table for writing during prepare of statement
+# The use of the ps protocol causes extra table maps in the binlog, so
+# we disable the ps-protocol for this statement.
+
+# Merge tables are not supported in NDB
+-- source include/not_ndb_default.inc
+
+
+--disable_ps_protocol
+-- source extra/rpl_tests/rpl_flsh_tbls.test
+--enable_ps_protocol
+
diff --git a/mysql-test/suite/rpl/t/rpl_row_func001.test b/mysql-test/suite/rpl/t/rpl_row_func001.test
new file mode 100644
index 00000000000..53fb55118e6
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_row_func001.test
@@ -0,0 +1,57 @@
+#############################################################################
+# This test is being created to test out the non deterministic items with #
+# row based replication. #
+# Original Author: JBM #
+# Original Date: Aug/10/2005 #
+# Update: 08/29/2005 change name to initails #
+#############################################################################
+
+# Includes
+-- source include/have_binlog_format_row.inc
+-- source include/master-slave.inc
+
+
+# Begin clean up test section
+connection master;
+--disable_warnings
+--error 0,1305
+DROP FUNCTION test.f1;
+DROP TABLE IF EXISTS test.t1;
+
+
+--enable_warnings
+
+# Section 1 test from bug #12487 Uses stored function to insert rows to see what is replicated.
+
+create table test.t1 (a int, PRIMARY KEY(a));
+
+delimiter //;
+create function test.f1(i int) returns int
+begin
+insert into test.t1 values(i);
+return 0;
+end//
+delimiter ;//
+
+select test.f1(1);
+select test.f1(2);
+select * from test.t1;
+
+save_master_pos;
+sync_slave_with_master;
+connection slave;
+#show create table test.t1;
+select * from test.t1;
+
+connection master;
+
+#Used for debugging
+#show binlog events;
+
+# Cleanup
+
+DROP FUNCTION test.f1;
+DROP TABLE test.t1;
+sync_slave_with_master;
+
+# End of 5.0 test case
diff --git a/mysql-test/suite/rpl/t/rpl_row_func002.test b/mysql-test/suite/rpl/t/rpl_row_func002.test
new file mode 100644
index 00000000000..44a704bfbc5
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_row_func002.test
@@ -0,0 +1,104 @@
+#############################################################################
+# This test is being created to test out the non deterministic items with #
+# row based replication. #
+# Original Author: JBM #
+# Original Date: Aug/10/2005 #
+# Update: 08/29/2005 Turn on diff #
+#############################################################################
+# Note: Many lines are commented out in this test case. These were used for #
+# creating the test case and debugging and are being left for #
+# debugging, but they can not be used for the regular testing as the #
+# Time changes and is not deteministic, so instead we dump both the #
+# master and slave and diff the dumps. If the dumps differ then the #
+# test case will fail. To run during diff failuers, comment out the #
+# diff. #
+#############################################################################
+
+# Includes
+-- source include/have_binlog_format_row.inc
+-- source include/master-slave.inc
+
+
+# Begin clean up test section
+connection master;
+--disable_warnings
+--error 0,1305
+DROP FUNCTION test.f1;
+DROP TABLE IF EXISTS test.t1;
+DROP TABLE IF EXISTS test.t2;
+
+--enable_warnings
+
+# Section 1 test from Peter G. This test changes uses a stored function to update rows and return the timestamp. We change the value of the time stamp on the master to see what is replicated.
+
+CREATE TABLE test.t1 (a INT NOT NULL AUTO_INCREMENT, t TIMESTAMP, t2 TIMESTAMP, PRIMARY KEY(a));
+CREATE TABLE test.t2 (a INT NOT NULL AUTO_INCREMENT, t TIMESTAMP, t2 TIMESTAMP, PRIMARY KEY(a));
+
+delimiter //;
+create function test.f1() RETURNS TIMESTAMP
+BEGIN
+UPDATE test.t1 SET t = CURRENT_TIMESTAMP;
+RETURN CURRENT_TIMESTAMP;
+END//
+delimiter ;//
+
+INSERT INTO test.t2 VALUES (null,f1(),CURRENT_TIMESTAMP);
+#select * from test.t1;
+#save_master_pos;
+#sync_slave_with_master;
+#connection slave;
+#select * from test.t1;
+#connection master;
+
+
+SET TIMESTAMP=2;
+INSERT INTO test.t2 VALUES (null,f1(),CURRENT_TIMESTAMP);
+#select * from test.t1;
+#save_master_pos;
+#sync_slave_with_master;
+#connection slave;
+#select * from test.t1;
+#connection master;
+
+#sleep 3;
+SET TIMESTAMP=1;
+INSERT INTO test.t2 VALUES (null,f1(),CURRENT_TIMESTAMP);
+#select * from test.t1;
+#save_master_pos;
+#sync_slave_with_master;
+#connection slave;
+#select * from test.t1;
+#connection master;
+
+
+SET TIMESTAMP=333300000;
+INSERT INTO test.t2 VALUES (null,f1(),CURRENT_TIMESTAMP);
+
+# We need a sync to ensure that the slave has caught up before
+# dumping the database.
+sync_slave_with_master;
+
+connection master;
+#Used for debugging
+#show binlog events;
+
+# time to dump the databases and so we can see if they match
+
+--exec $MYSQL_DUMP --compact --order-by-primary --skip-extended-insert --no-create-info test > $MYSQLTEST_VARDIR/tmp/func002_master.sql
+--exec $MYSQL_DUMP_SLAVE --compact --order-by-primary --skip-extended-insert --no-create-info test > $MYSQLTEST_VARDIR/tmp/func002_slave.sql
+
+# Cleanup
+DROP FUNCTION test.f1;
+DROP TABLE test.t1;
+DROP TABLE test.t2;
+sync_slave_with_master;
+
+# the test will show that the diff statement failed and no reject file
+# will be created. You will need to go to the mysql-test dir and diff
+# the files your self to see what is not matching :-). The files are located
+# in mysql-test/var/tmp
+
+diff_files $MYSQLTEST_VARDIR/tmp/func002_master.sql $MYSQLTEST_VARDIR/tmp/func002_slave.sql;
+
+# End of 5.0 test case
+
diff --git a/mysql-test/suite/rpl/t/rpl_row_func003-slave.opt b/mysql-test/suite/rpl/t/rpl_row_func003-slave.opt
new file mode 100644
index 00000000000..48457b17309
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_row_func003-slave.opt
@@ -0,0 +1 @@
+--loose-innodb
diff --git a/mysql-test/suite/rpl/t/rpl_row_func003.test b/mysql-test/suite/rpl/t/rpl_row_func003.test
new file mode 100644
index 00000000000..30b24cf4174
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_row_func003.test
@@ -0,0 +1,13 @@
+###################################
+# Wrapper for rpl_row_func003.test#
+###################################
+########################################################
+# By JBM 2005-02-15 Wrapped to allow reuse of test code#
+# Added to skip if ndb is default #
+########################################################
+-- source include/not_ndb_default.inc
+-- source include/have_innodb.inc
+-- source include/have_binlog_format_row.inc
+-- source include/master-slave.inc
+let $engine_type=INNODB;
+-- source extra/rpl_tests/rpl_row_func003.test
diff --git a/mysql-test/suite/rpl/t/rpl_row_inexist_tbl-slave.opt b/mysql-test/suite/rpl/t/rpl_row_inexist_tbl-slave.opt
new file mode 100644
index 00000000000..abd717f8222
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_row_inexist_tbl-slave.opt
@@ -0,0 +1 @@
+--replicate-ignore-table=test.t2
diff --git a/mysql-test/suite/rpl/t/rpl_row_inexist_tbl.test b/mysql-test/suite/rpl/t/rpl_row_inexist_tbl.test
new file mode 100644
index 00000000000..25a8c0e744e
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_row_inexist_tbl.test
@@ -0,0 +1,33 @@
+# Test to see what slave says when master is updating a table it does
+# not have
+--source include/have_binlog_format_row.inc
+
+source include/master-slave.inc;
+
+connection master;
+create table t1 (a int not null primary key);
+insert into t1 values (1);
+create table t2 (a int);
+insert into t2 values (1);
+update t1, t2 set t1.a = 0 where t1.a = t2.a;
+
+sync_slave_with_master;
+# t2 should not have been replicated
+# t1 should have been properly updated
+show tables;
+select * from t1;
+drop table t1;
+
+connection master;
+insert into t1 values (1);
+
+connection slave;
+# slave should have stopped because can't find table t1
+--source include/wait_for_slave_sql_to_stop.inc
+# see if we have a good error message:
+--replace_column 7 #
+source include/show_slave_status.inc;
+
+# cleanup
+connection master;
+drop table t1, t2;
diff --git a/mysql-test/suite/rpl/t/rpl_row_insert_delayed.test b/mysql-test/suite/rpl/t/rpl_row_insert_delayed.test
new file mode 100644
index 00000000000..9aeb57c4fa2
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_row_insert_delayed.test
@@ -0,0 +1,14 @@
+--source include/have_binlog_format_row.inc
+--source include/master-slave.inc
+--source include/not_embedded.inc
+--source include/not_windows.inc
+
+connection master;
+set @old_global_binlog_format = @@global.binlog_format;
+
+let $binlog_format_statement=0;
+set @@global.binlog_format = row;
+--source extra/rpl_tests/rpl_insert_delayed.test
+
+connection master;
+set @@global.binlog_format = @old_global_binlog_format;
diff --git a/mysql-test/suite/rpl/t/rpl_row_log-master.opt b/mysql-test/suite/rpl/t/rpl_row_log-master.opt
new file mode 100644
index 00000000000..e0d075c3fbd
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_row_log-master.opt
@@ -0,0 +1 @@
+--skip-external-locking
diff --git a/mysql-test/suite/rpl/t/rpl_row_log-slave.opt b/mysql-test/suite/rpl/t/rpl_row_log-slave.opt
new file mode 100644
index 00000000000..8b137891791
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_row_log-slave.opt
@@ -0,0 +1 @@
+
diff --git a/mysql-test/suite/rpl/t/rpl_row_log.test b/mysql-test/suite/rpl/t/rpl_row_log.test
new file mode 100644
index 00000000000..197f83c85af
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_row_log.test
@@ -0,0 +1,17 @@
+###################################
+# Wrapper for rpl_row_log.test #
+# Added wrapper so that MyISAM & #
+# Innodb and NDB could all use the#
+# Same test. NDB produced a diff #
+# bin-log #
+###################################
+########################################################
+# By JBM 2005-02-15 Wrapped to allow reuse of test code#
+# Added to skip if ndb is default #
+########################################################
+-- source include/not_ndb_default.inc
+-- source include/have_binlog_format_row.inc
+-- source include/master-slave.inc
+let $engine_type=MyISAM;
+-- source extra/rpl_tests/rpl_log.test
+
diff --git a/mysql-test/suite/rpl/t/rpl_row_log_innodb-master.opt b/mysql-test/suite/rpl/t/rpl_row_log_innodb-master.opt
new file mode 100644
index 00000000000..e0d075c3fbd
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_row_log_innodb-master.opt
@@ -0,0 +1 @@
+--skip-external-locking
diff --git a/mysql-test/suite/rpl/t/rpl_row_log_innodb-slave.opt b/mysql-test/suite/rpl/t/rpl_row_log_innodb-slave.opt
new file mode 100644
index 00000000000..627becdbfb5
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_row_log_innodb-slave.opt
@@ -0,0 +1 @@
+--innodb
diff --git a/mysql-test/suite/rpl/t/rpl_row_log_innodb.test b/mysql-test/suite/rpl/t/rpl_row_log_innodb.test
new file mode 100644
index 00000000000..16e775287b3
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_row_log_innodb.test
@@ -0,0 +1,14 @@
+###################################
+# Wrapper for rpl_row_log.test #
+# Added wrapper so that MyISAM & #
+# Innodb and NDB could all use the#
+# Same test. NDB produced a diff #
+# bin-log #
+###################################
+-- source include/not_ndb_default.inc
+-- source include/have_binlog_format_row.inc
+-- source include/have_innodb.inc
+-- source include/master-slave.inc
+let $engine_type=InnoDB;
+-- source extra/rpl_tests/rpl_log.test
+
diff --git a/mysql-test/suite/rpl/t/rpl_row_max_relay_size.test b/mysql-test/suite/rpl/t/rpl_row_max_relay_size.test
new file mode 100644
index 00000000000..a0be59e44a7
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_row_max_relay_size.test
@@ -0,0 +1,11 @@
+# Test of options max_binlog_size and max_relay_log_size and
+# how they act (if max_relay_log_size == 0, use max_binlog_size
+# for relay logs too).
+# Test of manual relay log rotation with FLUSH LOGS.
+
+# Requires statement logging
+-- source include/not_ndb_default.inc
+SET SESSION BINLOG_FORMAT=ROW;
+SET GLOBAL BINLOG_FORMAT=ROW;
+-- source extra/rpl_tests/rpl_max_relay_size.test
+
diff --git a/mysql-test/suite/rpl/t/rpl_row_mysqlbinlog-master.opt b/mysql-test/suite/rpl/t/rpl_row_mysqlbinlog-master.opt
new file mode 100644
index 00000000000..07d12817f5f
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_row_mysqlbinlog-master.opt
@@ -0,0 +1 @@
+--max-binlog-size=1040384
diff --git a/mysql-test/suite/rpl/t/rpl_row_mysqlbinlog.test b/mysql-test/suite/rpl/t/rpl_row_mysqlbinlog.test
new file mode 100644
index 00000000000..dd46d64f684
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_row_mysqlbinlog.test
@@ -0,0 +1,348 @@
+##################################################################
+# Author: JBM #
+# Date: 2006-02-22 #
+# Purpose: To test changes to mysqlbinlog for row based bin logs #
+# We are using .opt file since we need small binlog size #
+##################################################################
+# Include Section
+# Make sure that we have row based bin log
+-- source include/have_binlog_format_row.inc
+# Embedded server doesn't support binlogging
+-- source include/not_embedded.inc
+-- source include/master-slave.inc
+# This test requires the cp932 charset compiled in
+-- source include/have_cp932.inc
+
+# Setup Section
+# we need this for getting fixed timestamps inside of this test
+
+--disable_query_log
+select "---Setup Section --" as "";
+--enable_query_log
+
+set timestamp=1000000000;
+
+--disable_warnings
+DROP TABLE IF EXISTS t1,t2,t3;
+--enable_warnings
+
+connection master;
+CREATE TABLE t1(word VARCHAR(20));
+CREATE TABLE t2(id INT AUTO_INCREMENT NOT NULL PRIMARY KEY);
+CREATE TABLE t3(c1 INT NOT NULL PRIMARY KEY, c2 LONGBLOB, c3 TIMESTAMP, c4 TEXT, c5 FLOAT);
+
+
+# Test Section
+# Lets start by putting some data into the tables.
+
+--disable_query_log
+INSERT INTO t1 VALUES ("abirvalg");
+LOAD DATA INFILE '../std_data_ln/words.dat' INTO TABLE t1;
+LOAD DATA INFILE '../std_data_ln/words.dat' INTO TABLE t1;
+LOAD DATA INFILE '../std_data_ln/words.dat' INTO TABLE t1;
+LOAD DATA INFILE '../std_data_ln/words.dat' INTO TABLE t1;
+LOAD DATA INFILE '../std_data_ln/words.dat' INTO TABLE t1;
+
+# d1 length 3000
+set @d1 = 'dd1';
+set @d1 = concat(@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1);
+set @d1 = concat(@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1);
+set @d1 = concat(@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1,@d1);
+
+let $count=500;
+while ($count)
+{
+ INSERT INTO t2 VALUES (NULL);
+ eval INSERT INTO t3 VALUES ($count,@d1,'20060222000000','Tested in Texas',$count*2.2);
+ dec $count;
+}
+--enable_query_log
+
+
+--disable_query_log
+select "---Test1 check table load --" as "";
+--enable_query_log
+
+# Lets Check the tables on the Master
+SELECT COUNT(*) from t1;
+SELECT COUNT(*) from t2;
+SELECT COUNT(*) from t3;
+SELECT * FROM t1 ORDER BY word LIMIT 5;
+SELECT * FROM t2 ORDER BY id LIMIT 5;
+SELECT c1, c3, c4, c5 FROM t3 ORDER BY c1 LIMIT 5;
+
+# Should have the same on the slave;
+
+sync_slave_with_master;
+SELECT COUNT(*) from t1;
+SELECT COUNT(*) from t2;
+SELECT COUNT(*) from t3;
+SELECT * FROM t1 ORDER BY word LIMIT 5;
+SELECT * FROM t2 ORDER BY id LIMIT 5;
+SELECT c1, c3, c4, c5 FROM t3 ORDER BY c1 LIMIT 5;
+
+# Okay time to get busy, back to master
+
+connection master;
+
+# simple query to show more in second binlog
+insert into t1 values ("Alas");
+flush logs;
+
+# delimiters are for easier debugging in future
+--disable_query_log
+select "--- Test 1 Dump binlog to file --" as "";
+--enable_query_log
+
+#
+# Prepare local temporary file to recreate what we have currently.
+
+--exec $MYSQL_BINLOG $MYSQLTEST_VARDIR/log/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/master.sql
+
+--exec $MYSQL_BINLOG $MYSQLTEST_VARDIR/log/master-bin.000002 >> $MYSQLTEST_VARDIR/tmp/master.sql
+
+# Now that we have our file, lets get rid of the current database.
+# Cleanup the master and the slave and try to recreate.
+--disable_query_log
+select "--- Test 1 delete tables, clean master and slave --" as "";
+--enable_query_log
+
+DROP TABLE t1;
+DROP TABLE t2;
+DROP TABLE t3;
+
+sync_slave_with_master;
+#we expect STOP SLAVE to produce a warning as the slave is stopped
+#(the server was started with skip-slave-start)
+--disable_warnings
+stop slave;
+--enable_warnings
+--require r/slave-stopped.result
+show status like 'Slave_running';
+connection master;
+reset master;
+connection slave;
+reset slave;
+start slave;
+--require r/slave-running.result
+show status like 'Slave_running';
+connection master;
+
+# We should be clean at this point, now we will run in the file from above.
+--disable_query_log
+select "--- Test 1 Load from Dump binlog file --" as "";
+--enable_query_log
+
+--exec $MYSQL -e "source $MYSQLTEST_VARDIR/tmp/master.sql"
+
+--disable_query_log
+select "--- Test 1 Check Load Results --" as "";
+--enable_query_log
+
+# Lets Check the tables on the Master
+SELECT COUNT(*) from t1;
+SELECT COUNT(*) from t2;
+SELECT COUNT(*) from t3;
+SELECT * FROM t1 ORDER BY word LIMIT 5;
+SELECT * FROM t2 ORDER BY id LIMIT 5;
+SELECT c1, c3, c4, c5 FROM t3 ORDER BY c1 LIMIT 5;
+
+# Should have the same on the slave;
+
+sync_slave_with_master;
+SELECT COUNT(*) from t1;
+SELECT COUNT(*) from t2;
+SELECT COUNT(*) from t3;
+SELECT * FROM t1 ORDER BY word LIMIT 5;
+SELECT * FROM t2 ORDER BY id LIMIT 5;
+SELECT c1, c3, c4, c5 FROM t3 ORDER BY c1 LIMIT 5;
+connection master;
+
+# We should be gold by the time, so I will get rid of our file.
+
+--exec rm $MYSQLTEST_VARDIR/tmp/master.sql
+
+
+# this test for position option
+# By setting this position to 413, we should only get the create of t3
+--disable_query_log
+select "--- Test 2 position test --" as "";
+--enable_query_log
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --position=416 $MYSQLTEST_VARDIR/log/master-bin.000001
+
+# These are tests for remote binlog.
+# They should return the same as previous test.
+
+--disable_query_log
+select "--- Test 3 First Remote test --" as "";
+--enable_query_log
+
+# This is broken now
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001
+
+# This part is disabled due to bug #17654
+
+--disable_query_log
+select "--- Test 4 Second Remote test --" as "";
+--enable_query_log
+--exec $MYSQL_BINLOG --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 > $MYSQLTEST_VARDIR/tmp/remote.sql
+
+--exec $MYSQL_BINLOG --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000002 >> $MYSQLTEST_VARDIR/tmp/remote.sql
+
+# Now that we have our file, lets get rid of the current database.
+# Cleanup the master and the slave and try to recreate.
+
+DROP TABLE t1;
+DROP TABLE t2;
+DROP TABLE t3;
+
+sync_slave_with_master;
+
+#we expect STOP SLAVE to produce a warning as the slave is stopped
+#(the server was started with skip-slave-start)
+
+--disable_warnings
+stop slave;
+--enable_warnings
+--require r/slave-stopped.result
+show status like 'Slave_running';
+connection master;
+reset master;
+connection slave;
+reset slave;
+start slave;
+--require r/slave-running.result
+show status like 'Slave_running';
+connection master;
+
+# We should be clean at this point, now we will run in the file from above.
+
+--exec $MYSQL -e "source $MYSQLTEST_VARDIR/tmp/remote.sql"
+
+# Lets Check the tables on the Master
+
+SELECT COUNT(*) from t1;
+SELECT COUNT(*) from t2;
+SELECT COUNT(*) from t3;
+SELECT * FROM t1 ORDER BY word LIMIT 5;
+SELECT * FROM t2 ORDER BY id LIMIT 5;
+SELECT c1, c3, c4, c5 FROM t3 ORDER BY c1 LIMIT 5;
+
+# Should have the same on the slave;
+
+sync_slave_with_master;
+SELECT COUNT(*) from t1;
+SELECT COUNT(*) from t2;
+SELECT COUNT(*) from t3;
+SELECT * FROM t1 ORDER BY word LIMIT 5;
+SELECT * FROM t2 ORDER BY id LIMIT 5;
+SELECT c1, c3, c4, c5 FROM t3 ORDER BY c1 LIMIT 5;
+connection master;
+
+# We should be gold by the time, so I will get rid of our file.
+
+--exec rm $MYSQLTEST_VARDIR/tmp/remote.sql
+################### End Bug 17654 ######################
+
+# LOAD DATA
+--disable_query_log
+select "--- Test 5 LOAD DATA --" as "";
+--enable_query_log
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000002
+
+# Bug#7853 (mysqlbinlog does not accept input from stdin)
+
+--disable_query_log
+select "--- Test 6 reading stdin --" as "";
+--enable_query_log
+--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
+--exec $MYSQL_BINLOG --short-form - < $MYSQLTEST_VARDIR/log/master-bin.000001
+
+--disable_query_log
+select "--- Test 7 reading stdin w/position --" as "";
+--enable_query_log
+--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
+--exec $MYSQL_BINLOG --short-form --position=416 - < $MYSQLTEST_VARDIR/log/master-bin.000001
+
+# Bug#16217 (mysql client did not know how not switch its internal charset)
+--disable_query_log
+select "--- Test 8 switch internal charset --" as "";
+--enable_query_log
+sync_slave_with_master;
+
+#we expect STOP SLAVE to produce a warning as the slave is stopped
+#(the server was started with skip-slave-start)
+
+--disable_warnings
+stop slave;
+--enable_warnings
+--require r/slave-stopped.result
+show status like 'Slave_running';
+connection master;
+reset master;
+connection slave;
+reset slave;
+start slave;
+--require r/slave-running.result
+show status like 'Slave_running';
+connection master;
+
+create table t4 (f text character set utf8);
+create table t5 (f text character set cp932);
+--exec $MYSQL --default-character-set=utf8 test -e "insert into t4 values(_utf8'ソ')"
+--exec $MYSQL --default-character-set=cp932 test -e "insert into t5 values(_cp932'ƒ\');"
+flush logs;
+rename table t4 to t04, t5 to t05;
+--exec $MYSQL_BINLOG $MYSQLTEST_VARDIR/log/master-bin.000001 | $MYSQL --default-character-set=utf8
+# original and recovered data must be equal
+select HEX(f) from t04;
+select HEX(f) from t4;
+select HEX(f) from t05;
+select HEX(f) from t5;
+
+# slave should have same
+sync_slave_with_master;
+select HEX(f) from t04;
+select HEX(f) from t4;
+select HEX(f) from t05;
+select HEX(f) from t5;
+
+--disable_query_log
+select "--- Test cleanup --" as "";
+--enable_query_log
+# clean up
+connection master;
+sync_slave_with_master;
+
+connection master;
+
+# BUG#17654 also test mysqlbinlog to ensure it can read the binlog from a remote server
+# and ensure that the results are the same as if read from a file (the same file).
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (a INT NOT NULL KEY, b INT);
+
+INSERT INTO t1 VALUES(1,1);
+
+SELECT * FROM t1;
+
+FLUSH LOGS;
+
+--exec $MYSQL_BINLOG --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 > $MYSQLTEST_VARDIR/tmp/remote.sql
+--exec $MYSQL_BINLOG $MYSQLTEST_VARDIR/log/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/local.sql
+
+--diff_files $MYSQLTEST_VARDIR/tmp/local.sql $MYSQLTEST_VARDIR/tmp/remote.sql
+
+--exec rm $MYSQLTEST_VARDIR/tmp/remote.sql
+
+--exec rm $MYSQLTEST_VARDIR/tmp/local.sql
+
+DROP TABLE IF EXISTS t1, t2, t3, t04, t05, t4, t5;
+
+# End of 4.1 tests
diff --git a/mysql-test/suite/rpl/t/rpl_row_mystery22.test b/mysql-test/suite/rpl/t/rpl_row_mystery22.test
new file mode 100644
index 00000000000..9933fec22fc
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_row_mystery22.test
@@ -0,0 +1,45 @@
+# Originally taken from rpl_mystery22.test,
+# but this row-based-replication test has a totally different spirit:
+# slave will not stop because of dup key,
+# instead we test if it does overwrite the dup key
+# as expected.
+-- source include/have_binlog_format_row.inc
+-- source include/master-slave.inc
+
+# first, cause a duplicate key problem on the slave
+create table t1(n int auto_increment primary key, s char(10));
+sync_slave_with_master;
+insert into t1 values (2,'old');
+connection master;
+insert into t1 values(NULL,'new');
+insert into t1 values(NULL,'new');
+save_master_pos;
+connection slave;
+sync_with_master;
+select * from t1 order by n;
+delete from t1 where n = 2;
+--disable_warnings
+start slave;
+--enable_warnings
+sync_with_master;
+stop slave;
+connection master;
+create table t2(n int);
+drop table t2;
+insert into t1 values(NULL,'new');
+# what happens when we delete a row which does not exist on slave?
+set sql_log_bin=0;
+insert into t1 values(NULL,'new');
+set sql_log_bin=1;
+delete from t1 where n=4;
+save_master_pos;
+connection slave;
+--disable_warnings
+start slave;
+--enable_warnings
+sync_with_master;
+select * from t1 order by n;
+#clean up
+connection master;
+drop table t1;
+sync_slave_with_master;
diff --git a/mysql-test/suite/rpl/t/rpl_row_reset_slave.test b/mysql-test/suite/rpl/t/rpl_row_reset_slave.test
new file mode 100644
index 00000000000..a970c161153
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_row_reset_slave.test
@@ -0,0 +1,5 @@
+# TBF - difference in row level logging
+# Temp tables are not replicated in rbr, but it is still good to hit rbr with everthing
+-- source include/have_binlog_format_row.inc
+-- source extra/rpl_tests/rpl_reset_slave.test
+
diff --git a/mysql-test/suite/rpl/t/rpl_row_sp001.test b/mysql-test/suite/rpl/t/rpl_row_sp001.test
new file mode 100644
index 00000000000..c12e73b6861
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_row_sp001.test
@@ -0,0 +1,146 @@
+#############################################################################
+# This test is being created to test out the non deterministic items with #
+# row based replication. #
+# Original Author: JBM #
+# Original Date: Aug/09/2005 #
+# Updated: Aug/29/2005
+#############################################################################
+# Test: Includes two stored procedure tests. First test uses SP to insert #
+# values from RAND() and NOW() into a table. #
+# The second test uses SP with CASE structure to decide what to text #
+# to update a given table with. #
+############################################################################
+
+# Includes
+-- source include/have_binlog_format_row.inc
+-- source include/master-slave.inc
+
+-- disable_query_log
+-- disable_result_log
+
+# Begin clean up test section
+connection master;
+--disable_warnings
+DROP PROCEDURE IF EXISTS test.p1;
+DROP PROCEDURE IF EXISTS test.p2;
+DROP TABLE IF EXISTS test.t1;
+DROP TABLE IF EXISTS test.t2;
+
+-- enable_query_log
+-- enable_result_log
+
+# Begin test section 1 for non deterministic SP
+let $message=<Begin test section 1 (non deterministic SP)>;
+--source include/show_msg.inc
+
+create table test.t1 (n MEDIUMINT NOT NULL AUTO_INCREMENT, f FLOAT, d DATETIME, PRIMARY KEY(n));
+
+delimiter //;
+create procedure test.p1()
+begin
+ INSERT INTO test.t1 (f,d) VALUES (RAND(),NOW());
+end//
+delimiter ;//
+
+# show binlog events;
+
+-- disable_query_log
+-- disable_result_log
+let $1=10;
+while ($1)
+{
+ call test.p1();
+ sleep 1;
+ dec $1;
+}
+-- enable_result_log
+-- enable_query_log
+
+## Used for debugging
+#show binlog events;
+#select * from test.t1;
+#sync_slave_with_master;
+#select * from test.t1;
+#connection master;
+
+let $message=<End test section 1 (non deterministic SP)>;
+--source include/show_msg.inc
+
+
+CREATE TABLE test.t2 (a INT NOT NULL AUTO_INCREMENT, t CHAR(4), PRIMARY KEY(a));
+
+delimiter //;
+CREATE PROCEDURE test.p2(n int)
+begin
+CASE n
+WHEN 1 THEN
+ UPDATE test.t2 set t ='Tex';
+WHEN 2 THEN
+ UPDATE test.t2 set t ='SQL';
+ELSE
+ UPDATE test.t2 set t ='NONE';
+END CASE;
+end//
+delimiter ;//
+
+INSERT INTO test.t2 VALUES(NULL,'NEW'),(NULL,'NEW'),(NULL,'NEW'),(NULL,'NEW');
+
+SELECT * FROM t2 ORDER BY a;
+save_master_pos;
+connection slave;
+sync_with_master;
+SELECT * FROM t2 ORDER BY a;
+
+connection master;
+call test.p2(1);
+SELECT * FROM t2 ORDER BY a;
+sync_slave_with_master;
+SELECT * FROM t2 ORDER BY a;
+
+
+connection master;
+call test.p2(2);
+SELECT * FROM t2 ORDER BY a;
+save_master_pos;
+connection slave;
+sync_with_master;
+SELECT * FROM t2 ORDER BY a;
+
+connection master;
+call test.p2(3);
+SELECT * FROM t2 ORDER BY a;
+save_master_pos;
+connection slave;
+sync_with_master;
+SELECT * FROM t2 ORDER BY a;
+
+##Used for debugging
+#show binlog events;
+
+# time to dump the databases and so we can see if they match
+
+--exec $MYSQL_DUMP --compact --order-by-primary --skip-extended-insert --no-create-info test > $MYSQLTEST_VARDIR/tmp/sp001_master.sql
+--exec $MYSQL_DUMP_SLAVE --compact --order-by-primary --skip-extended-insert --no-create-info test > $MYSQLTEST_VARDIR/tmp/sp001_slave.sql
+
+# First lets cleanup
+
+connection master;
+DROP PROCEDURE test.p1;
+DROP PROCEDURE test.p2;
+DROP TABLE test.t1;
+DROP TABLE test.t2;
+sync_slave_with_master;
+
+# Lets compare. Note: If they match test will pass, if they do not match
+# the test will show that the diff statement failed and not reject file
+# will be created. You will need to go to the mysql-test dir and diff
+# the files your self to see what is not matching :-) Failed dump files
+# will be located in $MYSQLTEST_VARDIR/tmp
+
+diff_files $MYSQLTEST_VARDIR/tmp/sp001_master.sql $MYSQLTEST_VARDIR/tmp/sp001_slave.sql;
+
+# If all is good, when can cleanup our dump files.
+--remove_file $MYSQLTEST_VARDIR/tmp/sp001_master.sql
+--remove_file $MYSQLTEST_VARDIR/tmp/sp001_slave.sql
+
+# End of 5.0 test case
diff --git a/mysql-test/suite/rpl/t/rpl_row_sp002_innodb-master.opt b/mysql-test/suite/rpl/t/rpl_row_sp002_innodb-master.opt
new file mode 100644
index 00000000000..627becdbfb5
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_row_sp002_innodb-master.opt
@@ -0,0 +1 @@
+--innodb
diff --git a/mysql-test/suite/rpl/t/rpl_row_sp002_innodb-slave.opt b/mysql-test/suite/rpl/t/rpl_row_sp002_innodb-slave.opt
new file mode 100644
index 00000000000..627becdbfb5
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_row_sp002_innodb-slave.opt
@@ -0,0 +1 @@
+--innodb
diff --git a/mysql-test/suite/rpl/t/rpl_row_sp002_innodb.test b/mysql-test/suite/rpl/t/rpl_row_sp002_innodb.test
new file mode 100644
index 00000000000..e272e34e715
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_row_sp002_innodb.test
@@ -0,0 +1,11 @@
+#################################
+# Wrapper for rpl_row_sp002.test#
+#################################
+########################################################
+# By JBM 2005-02-15 Wrapped to allow reuse of test code#
+# Added to skip if ndb is default #
+########################################################
+-- source include/not_ndb_default.inc
+-- source include/have_innodb.inc
+let $engine_type=INNODB;
+-- source extra/rpl_tests/rpl_row_sp002.test
diff --git a/mysql-test/suite/rpl/t/rpl_row_sp003-master.opt b/mysql-test/suite/rpl/t/rpl_row_sp003-master.opt
new file mode 100644
index 00000000000..48457b17309
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_row_sp003-master.opt
@@ -0,0 +1 @@
+--loose-innodb
diff --git a/mysql-test/suite/rpl/t/rpl_row_sp003-slave.opt b/mysql-test/suite/rpl/t/rpl_row_sp003-slave.opt
new file mode 100644
index 00000000000..48457b17309
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_row_sp003-slave.opt
@@ -0,0 +1 @@
+--loose-innodb
diff --git a/mysql-test/suite/rpl/t/rpl_row_sp003.test b/mysql-test/suite/rpl/t/rpl_row_sp003.test
new file mode 100644
index 00000000000..391ecd59b22
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_row_sp003.test
@@ -0,0 +1,13 @@
+#################################
+# Wrapper for rpl_row_sp003.test#
+#################################
+########################################################
+# By JBM 2005-02-15 Wrapped to allow reuse of test code#
+# Added to skip if ndb is default #
+########################################################
+-- source include/not_ndb_default.inc
+-- source include/have_innodb.inc
+-- source include/have_binlog_format_row.inc
+-- source include/master-slave.inc
+let $engine_type=INNODB;
+-- source extra/rpl_tests/rpl_row_sp003.test
diff --git a/mysql-test/suite/rpl/t/rpl_row_sp005.test b/mysql-test/suite/rpl/t/rpl_row_sp005.test
new file mode 100644
index 00000000000..054fa02f514
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_row_sp005.test
@@ -0,0 +1,110 @@
+#############################################################################
+# Original Author: JBM #
+# Original Date: Aug/15/2005 #
+# Updated: Aug/29/2005: Removed sleeps #
+#############################################################################
+# Test: Tests SPs with cursors, flow logic, and alter sp. In addition the #
+# tests SPs with insert and update operations. #
+#############################################################################
+# 2006-02-08 By JBM added ORDER BY for use with NDB engine
+#############################################################################
+
+# Includes
+-- source include/have_binlog_format_row.inc
+-- source include/master-slave.inc
+
+
+# Begin clean up test section
+connection master;
+--disable_warnings
+DROP PROCEDURE IF EXISTS test.p1;
+DROP PROCEDURE IF EXISTS test.p2;
+DROP TABLE IF EXISTS test.t2;
+DROP TABLE IF EXISTS test.t1;
+DROP TABLE IF EXISTS test.t3;
+--enable_warnings
+# End of cleanup
+
+# Begin test section 1
+CREATE TABLE IF NOT EXISTS test.t1(id INT, data CHAR(16),PRIMARY KEY(id));
+CREATE TABLE IF NOT EXISTS test.t2(id2 INT,PRIMARY KEY(id2));
+CREATE TABLE IF NOT EXISTS test.t3(id3 INT,PRIMARY KEY(id3), c CHAR(16));
+
+delimiter |;
+CREATE PROCEDURE test.p1()
+BEGIN
+DECLARE done INT DEFAULT 0;
+ DECLARE spa CHAR(16);
+ DECLARE spb,spc INT;
+ DECLARE cur1 CURSOR FOR SELECT id,data FROM test.t1 ORDER BY id;
+ DECLARE cur2 CURSOR FOR SELECT id2 FROM test.t2 ORDER BY id2;
+ DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done = 1;
+
+ OPEN cur1;
+ OPEN cur2;
+
+ REPEAT
+ FETCH cur1 INTO spb, spa;
+ FETCH cur2 INTO spc;
+ IF NOT done THEN
+ IF spb < spc THEN
+ INSERT INTO test.t3 VALUES (spb,spa);
+ ELSE
+ INSERT INTO test.t3 VALUES (spc,spa);
+ END IF;
+ END IF;
+ UNTIL done END REPEAT;
+
+ CLOSE cur1;
+ CLOSE cur2;
+END|
+CREATE PROCEDURE test.p2()
+BEGIN
+ INSERT INTO test.t1 VALUES (4,'MySQL'),(20,'ROCKS'),(11,'Texas'),(10,'kyle');
+ INSERT INTO test.t2 VALUES (4),(2),(1),(3);
+ UPDATE test.t1 SET id=id+4 WHERE id=4;
+END|
+delimiter ;|
+
+let $message=< ---- Master selects-- >;
+--source include/show_msg.inc
+CALL test.p2();
+SELECT * FROM test.t1 ORDER BY id;
+SELECT * FROM test.t2 ORDER BY id2;
+
+let $message=< ---- Slave selects-- >;
+--source include/show_msg.inc
+save_master_pos;
+connection slave;
+sync_with_master;
+SELECT * FROM test.t1 ORDER BY id;
+SELECT * FROM test.t2 ORDER BY id2;
+
+let $message=< ---- Master selects-- >;
+--source include/show_msg.inc
+connection master;
+CALL test.p1();
+sleep 6;
+SELECT * FROM test.t3 ORDER BY id3;
+
+let $message=< ---- Slave selects-- >;
+--source include/show_msg.inc
+connection slave;
+SELECT * FROM test.t3 ORDER BY id3;
+
+connection master;
+
+ALTER PROCEDURE test.p1 MODIFIES SQL DATA;
+#show binlog events;
+
+# Cleanup
+
+connection master;
+DROP PROCEDURE IF EXISTS test.p1;
+DROP PROCEDURE IF EXISTS test.p2;
+DROP TABLE IF EXISTS test.t1;
+DROP TABLE IF EXISTS test.t2;
+DROP TABLE IF EXISTS test.t3;
+sync_slave_with_master;
+
+# End of 5.0 test case
diff --git a/mysql-test/suite/rpl/t/rpl_row_sp006_InnoDB-slave.opt b/mysql-test/suite/rpl/t/rpl_row_sp006_InnoDB-slave.opt
new file mode 100644
index 00000000000..627becdbfb5
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_row_sp006_InnoDB-slave.opt
@@ -0,0 +1 @@
+--innodb
diff --git a/mysql-test/suite/rpl/t/rpl_row_sp006_InnoDB.test b/mysql-test/suite/rpl/t/rpl_row_sp006_InnoDB.test
new file mode 100644
index 00000000000..e5be4e6dc28
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_row_sp006_InnoDB.test
@@ -0,0 +1,13 @@
+#################################
+# Wrapper for rpl_row_sp006.test#
+#################################
+########################################################
+# By JBM 2005-02-15 Wrapped to allow reuse of test code#
+# Added to skip if ndb is default #
+########################################################
+-- source include/not_ndb_default.inc
+-- source include/have_innodb.inc
+-- source include/have_binlog_format_row.inc
+-- source include/master-slave.inc
+let $engine_type=InnoDB;
+-- source extra/rpl_tests/rpl_row_sp006.test
diff --git a/mysql-test/suite/rpl/t/rpl_row_sp007_innodb-slave.opt b/mysql-test/suite/rpl/t/rpl_row_sp007_innodb-slave.opt
new file mode 100644
index 00000000000..627becdbfb5
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_row_sp007_innodb-slave.opt
@@ -0,0 +1 @@
+--innodb
diff --git a/mysql-test/suite/rpl/t/rpl_row_sp007_innodb.test b/mysql-test/suite/rpl/t/rpl_row_sp007_innodb.test
new file mode 100644
index 00000000000..41af5a5f997
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_row_sp007_innodb.test
@@ -0,0 +1,11 @@
+#################################
+# Wrapper for rpl_row_sp007.test#
+#################################
+########################################################
+# By JBM 2005-02-15 Wrapped to allow reuse of test code#
+# Added to skip if ndb is default #
+########################################################
+-- source include/not_ndb_default.inc
+-- source include/have_innodb.inc
+let $engine_type=INNODB;
+-- source extra/rpl_tests/rpl_row_sp007.test
diff --git a/mysql-test/suite/rpl/t/rpl_row_sp008.test b/mysql-test/suite/rpl/t/rpl_row_sp008.test
new file mode 100644
index 00000000000..b1295820c99
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_row_sp008.test
@@ -0,0 +1,57 @@
+#############################################################################
+# Original Author: JBM #
+# Original Date: Aug/15/2005 #
+# Update: 08/29/2005 Remove sleep #
+#############################################################################
+# TEST: Use SQL_CALC_FOUND_ROWS and insert results into a table inside a sp #
+#############################################################################
+
+
+# Includes
+-- source include/have_binlog_format_row.inc
+-- source include/master-slave.inc
+
+# Begin clean up test section
+connection master;
+--disable_warnings
+DROP PROCEDURE IF EXISTS test.p1;
+DROP TABLE IF EXISTS test.t2;
+--enable_warnings
+# End of cleanup
+
+
+
+# Begin test section 1
+CREATE TABLE test.t1 (a INT,PRIMARY KEY(a));
+CREATE TABLE test.t2 (a INT,PRIMARY KEY(a));
+INSERT INTO test.t1 VALUES(1),(2);
+
+delimiter |;
+CREATE PROCEDURE test.p1()
+BEGIN
+ SELECT SQL_CALC_FOUND_ROWS * FROM test.t1 LIMIT 1;
+ INSERT INTO test.t2 VALUES(FOUND_ROWS());
+END|
+delimiter ;|
+
+let $message=< ---- Master selects-- >;
+--source include/show_msg.inc
+CALL test.p1();
+SELECT * FROM test.t2;
+
+let $message=< ---- Slave selects-- >;
+--source include/show_msg.inc
+save_master_pos;
+connection slave;
+sync_with_master;
+SELECT * FROM test.t2;
+
+# Cleanup
+
+connection master;
+DROP PROCEDURE IF EXISTS test.p1;
+DROP TABLE IF EXISTS test.t1;
+DROP TABLE IF EXISTS test.t2;
+sync_slave_with_master;
+
+# End of 5.0 test case
diff --git a/mysql-test/suite/rpl/t/rpl_row_sp009.test b/mysql-test/suite/rpl/t/rpl_row_sp009.test
new file mode 100644
index 00000000000..92d47c6f50f
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_row_sp009.test
@@ -0,0 +1,105 @@
+#############################################################################
+# Original Author: JBM #
+# Original Date: Aug/18/2005 #
+# Updated: 08/29/2005 removed sleeps and added master pos save and snyc #
+#############################################################################
+#TEST: Taken and modfied from http://bugs.mysql.com/bug.php?id=12168 #
+#############################################################################
+# 2006-02-08 By JBM : Added order by for ndb engine use
+#############################################################################
+
+# Includes
+-- source include/have_binlog_format_row.inc
+-- source include/master-slave.inc
+
+
+# Begin clean up test section
+connection master;
+--disable_warnings
+DROP PROCEDURE IF EXISTS test.p1;
+DROP TABLE IF EXISTS test.t1;
+DROP TABLE IF EXISTS test.t2;
+
+
+# Begin test section 1
+CREATE TABLE test.t1 (a INT, PRIMARY KEY(a));
+INSERT INTO test.t1 VALUES (1),(2),(3),(4);
+CREATE TABLE test.t2 (a INT, PRIMARY KEY(a));
+
+delimiter |;
+CREATE PROCEDURE test.p1 (arg1 CHAR(1))
+BEGIN
+ DECLARE b, c INT;
+ IF arg1 = 'a' THEN
+ BEGIN
+ DECLARE cur1 CURSOR FOR SELECT A FROM test.t1 WHERE a % 2;
+ DECLARE continue handler for not found set b = 1;
+ SET b = 0;
+ OPEN cur1;
+ c1_repeat: REPEAT
+ FETCH cur1 INTO c;
+ IF (b = 1) THEN
+ LEAVE c1_repeat;
+ END IF;
+
+ INSERT INTO test.t2 VALUES (c);
+ UNTIL b = 1
+ END REPEAT;
+ CLOSE cur1;
+ END;
+ END IF;
+ IF arg1 = 'b' THEN
+ BEGIN
+ DECLARE cur2 CURSOR FOR SELECT a FROM test.t1 WHERE NOT a % 2;
+ DECLARE continue handler for not found set b = 1;
+ SET b = 0;
+ OPEN cur2;
+ c2_repeat: REPEAT
+ FETCH cur2 INTO c;
+ IF (b = 1) THEN
+ LEAVE c2_repeat;
+ END IF;
+
+ INSERT INTO test.t2 VALUES (c);
+ UNTIL b = 1
+ END REPEAT;
+ CLOSE cur2;
+ END;
+ END IF;
+END|
+delimiter ;|
+
+CALL test.p1('a');
+SELECT * FROM test.t2 ORDER BY a;
+save_master_pos;
+connection slave;
+sync_with_master;
+SELECT * FROM test.t2 ORDER BY a;
+connection master;
+truncate test.t2;
+
+# this next call fails, but should not
+call test.p1('b');
+select * from test.t2 ORDER BY a;
+save_master_pos;
+connection slave;
+sync_with_master;
+SELECT * FROM test.t2 ORDER BY a;
+
+connection master;
+truncate test.t2;
+SELECT * FROM test.t2 ORDER BY a;
+save_master_pos;
+connection slave;
+sync_with_master;
+SELECT * FROM test.t2 ORDER BY a;
+
+# Cleanup
+connection master;
+#show binlog events;
+DROP PROCEDURE test.p1;
+DROP TABLE test.t1;
+DROP TABLE test.t2;
+sync_slave_with_master;
+
+# End of 5.0 test case
diff --git a/mysql-test/suite/rpl/t/rpl_row_sp010.test b/mysql-test/suite/rpl/t/rpl_row_sp010.test
new file mode 100644
index 00000000000..28b82217517
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_row_sp010.test
@@ -0,0 +1,80 @@
+#############################################################################
+# Original Author: JBM #
+# Original Date: Aug/18/2005 #
+# Update: 08/29/2005 remove sleep added master pos save and sync #
+#############################################################################
+#TEST: Taken and modfied from http://bugs.mysql.com/bug.php?id=11126 #
+#############################################################################
+
+# Includes
+-- source include/have_binlog_format_row.inc
+-- source include/master-slave.inc
+
+
+# Begin clean up test section
+connection master;
+--disable_warnings
+DROP PROCEDURE IF EXISTS test.p1;
+DROP PROCEDURE IF EXISTS test.p2;
+DROP PROCEDURE IF EXISTS test.p3;
+DROP PROCEDURE IF EXISTS test.p4;
+DROP TABLE IF EXISTS test.t1;
+DROP TABLE IF EXISTS test.t2;
+
+
+# Begin test section 1
+delimiter |;
+CREATE PROCEDURE test.p1()
+BEGIN
+ INSERT INTO test.t1 VALUES(2);
+END|
+CREATE PROCEDURE test.p2()
+BEGIN
+ DROP TEMPORARY TABLE IF EXISTS test.t1;
+ CREATE TEMPORARY TABLE test.t1 (a int, PRIMARY KEY(a));
+ INSERT INTO test.t1 VALUES(1);
+ CALL test.p1();
+END|
+delimiter ;|
+CALL test.p2();
+SELECT * FROM test.t1 ORDER BY a;
+
+save_master_pos;
+connection slave;
+sync_with_master;
+show tables;
+
+connection master;
+delimiter |;
+CREATE PROCEDURE test.p3()
+BEGIN
+ INSERT INTO test.t2 VALUES(7);
+END|
+CREATE PROCEDURE test.p4()
+BEGIN
+ DROP TABLE IF EXISTS test.t2;
+ CREATE TABLE test.t2 (a int, PRIMARY KEY(a));
+ INSERT INTO test.t2 VALUES(6);
+ CALL test.p3();
+END|
+delimiter ;|
+CALL test.p4();
+SELECT * FROM test.t2 ORDER BY a;
+
+save_master_pos;
+connection slave;
+sync_with_master;
+SELECT * FROM test.t2 ORDER BY a;
+
+# Cleanup
+connection master;
+#show binlog events;
+DROP PROCEDURE IF EXISTS test.p1;
+DROP PROCEDURE IF EXISTS test.p2;
+DROP PROCEDURE IF EXISTS test.p3;
+DROP PROCEDURE IF EXISTS test.p4;
+DROP TABLE IF EXISTS test.t1;
+DROP TABLE IF EXISTS test.t2;
+sync_slave_with_master;
+
+# End of 5.0 test case
diff --git a/mysql-test/suite/rpl/t/rpl_row_sp011.test b/mysql-test/suite/rpl/t/rpl_row_sp011.test
new file mode 100644
index 00000000000..25c2fc9ad26
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_row_sp011.test
@@ -0,0 +1,111 @@
+#############################################################################
+# Original Author: JBM #
+# Original Date: Aug/18/2005 #
+# Updated: 08/29/2005 turned on diff and commented out debug SQL statements#
+#############################################################################
+#TEST: SP to test alter table and nested SP calls #
+#############################################################################
+
+# Includes
+-- source include/have_binlog_format_row.inc
+-- source include/master-slave.inc
+
+
+# Begin clean up test section
+connection master;
+--disable_warnings
+DROP PROCEDURE IF EXISTS test.p1;
+DROP PROCEDURE IF EXISTS test.p2;
+DROP PROCEDURE IF EXISTS test.p3;
+DROP PROCEDURE IF EXISTS test.p4;
+DROP PROCEDURE IF EXISTS test.p5;
+DROP PROCEDURE IF EXISTS test.p6;
+DROP PROCEDURE IF EXISTS test.p7;
+DROP TABLE IF EXISTS test.t1;
+DROP TABLE IF EXISTS test.t2;
+
+
+# Begin test section 1
+CREATE TABLE test.t1 (a int, PRIMARY KEY(a));
+INSERT INTO test.t1 VALUES (1);
+
+delimiter |;
+CREATE PROCEDURE test.p1()
+BEGIN
+ ALTER TABLE test.t1 ADD COLUMN b CHAR(4) AFTER a;
+ UPDATE test.t1 SET b = 'rbr' WHERE a = 1;
+ CALL test.p2();
+END|
+CREATE PROCEDURE test.p2()
+BEGIN
+ ALTER TABLE test.t1 ADD COLUMN f FLOAT AFTER b;
+ UPDATE test.t1 SET f = RAND() WHERE a = 1;
+ CALL test.p3();
+END|
+CREATE PROCEDURE test.p3()
+BEGIN
+ ALTER TABLE test.t1 RENAME test.t2;
+ CALL test.p4();
+END|
+CREATE PROCEDURE test.p4()
+BEGIN
+ ALTER TABLE test.t2 ADD INDEX (f);
+ ALTER TABLE test.t2 CHANGE a a INT UNSIGNED NOT NULL AUTO_INCREMENT;
+ INSERT INTO test.t2 VALUES (NULL,'TEST',RAND());
+ CALL test.p5();
+END|
+CREATE PROCEDURE test.p5()
+BEGIN
+ ALTER TABLE test.t2 ORDER BY f;
+ INSERT INTO test.t2 VALUES (NULL,'STM',RAND());
+ CALL test.p6();
+END|
+CREATE PROCEDURE test.p6()
+BEGIN
+ ALTER TABLE test.t2 ADD COLUMN b2 CHAR(4) FIRST;
+ ALTER TABLE test.t2 ADD COLUMN to_drop BIT(8) AFTER b2;
+ INSERT INTO test.t2 VALUES ('new',1,NULL,'STM',RAND());
+ CALL test.p7();
+END|
+CREATE PROCEDURE test.p7()
+BEGIN
+ ALTER TABLE test.t2 DROP COLUMN to_drop;
+ INSERT INTO test.t2 VALUES ('gone',NULL,'STM',RAND());
+END|
+delimiter ;|
+CALL test.p1();
+
+#SELECT * FROM test.t2;
+sync_slave_with_master;
+#SELECT * FROM test.t2;
+
+--exec $MYSQL_DUMP --compact --order-by-primary --skip-extended-insert --no-create-info test > $MYSQLTEST_VARDIR/tmp/sp011_master.sql
+--exec $MYSQL_DUMP_SLAVE --compact --order-by-primary --skip-extended-insert --no-create-info test > $MYSQLTEST_VARDIR/tmp/sp011_slave.sql
+
+# Cleanup
+connection master;
+#show binlog events;
+DROP PROCEDURE IF EXISTS test.p1;
+DROP PROCEDURE IF EXISTS test.p2;
+DROP PROCEDURE IF EXISTS test.p3;
+DROP PROCEDURE IF EXISTS test.p4;
+DROP PROCEDURE IF EXISTS test.p5;
+DROP PROCEDURE IF EXISTS test.p6;
+DROP PROCEDURE IF EXISTS test.p7;
+DROP TABLE IF EXISTS test.t1;
+DROP TABLE IF EXISTS test.t2;
+sync_slave_with_master;
+
+# Lets compare. Note: If they match test will pass, if they do not match
+# the test will show that the diff statement failed and not reject file
+# will be created. You will need to go to the mysql-test dir and diff
+# the files your self to see what is not matching :-) Failed test
+# Will leave dump files in $MYSQLTEST_VARDIR/tmp
+
+diff_files $MYSQLTEST_VARDIR/tmp/sp011_master.sql $MYSQLTEST_VARDIR/tmp/sp011_slave.sql;
+
+# If all is good, when can cleanup our dump files.
+--remove_file $MYSQLTEST_VARDIR/tmp/sp011_master.sql
+--remove_file $MYSQLTEST_VARDIR/tmp/sp011_slave.sql
+
+# End of 5.0 test case
diff --git a/mysql-test/suite/rpl/t/rpl_row_sp012.test b/mysql-test/suite/rpl/t/rpl_row_sp012.test
new file mode 100644
index 00000000000..3a8d295121c
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_row_sp012.test
@@ -0,0 +1,75 @@
+#############################################################################
+# Original Author: JBM #
+# Original Date: Aug/22/2005 #
+# Update: 08/29/2005 Added save pos and sync #
+#############################################################################
+#TEST: SP to test security and current_user and user #
+#############################################################################
+
+
+# Includes
+-- source include/have_binlog_format_row.inc
+-- source include/not_embedded.inc
+-- source include/master-slave.inc
+
+
+# Begin clean up test section
+connection master;
+--disable_warnings
+DROP PROCEDURE IF EXISTS test.p1;
+DROP PROCEDURE IF EXISTS test.p2;
+DROP PROCEDURE IF EXISTS test.p3;
+
+
+# Begin test section 1
+# Create user user1 with no particular access rights
+grant usage on *.* to user1@localhost;
+flush privileges;
+
+SELECT CURRENT_USER();
+SELECT USER();
+CREATE PROCEDURE test.p1 () SQL SECURITY INVOKER SELECT CURRENT_USER(), USER();
+CREATE PROCEDURE test.p2 () SQL SECURITY DEFINER CALL test.p1();
+CREATE PROCEDURE test.p3 () SQL SECURITY INVOKER CALL test.p1();
+GRANT EXECUTE ON PROCEDURE p1 TO user1@localhost;
+GRANT EXECUTE ON PROCEDURE p2 TO user1@localhost;
+GRANT EXECUTE ON PROCEDURE p3 TO user1@localhost;
+
+# Need to wait for the rights to be applied at the slave
+sync_slave_with_master;
+
+let $message=<******** Master user1 p3 & p2 calls *******>;
+--source include/show_msg.inc
+connect (muser1,localhost,user1,,);
+connection muser1;
+SELECT CURRENT_USER();
+SELECT USER();
+CALL test.p3();
+CALL test.p2();
+
+let $message=<******** Slave user1 p3 & p2 calls *******>;
+--source include/show_msg.inc
+connect (suser1,127.0.0.1,user1,,test,$SLAVE_MYPORT,);
+
+connection master;
+save_master_pos;
+connection suser1;
+sync_with_master;
+
+SELECT CURRENT_USER();
+SELECT USER();
+CALL test.p3();
+CALL test.p2();
+
+# Cleanup
+connection master;
+DROP PROCEDURE IF EXISTS test.p1;
+DROP PROCEDURE IF EXISTS test.p3;
+DROP PROCEDURE IF EXISTS test.p2;
+DROP TABLE IF EXISTS test.t1;
+DROP TABLE IF EXISTS test.t2;
+DROP USER user1@localhost;
+sync_slave_with_master;
+
+# End of 5.0 test case
+
diff --git a/mysql-test/suite/rpl/t/rpl_row_stop_middle.test b/mysql-test/suite/rpl/t/rpl_row_stop_middle.test
new file mode 100644
index 00000000000..da363736100
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_row_stop_middle.test
@@ -0,0 +1,44 @@
+# Test for BUG#11729: see if, when STOP SLAVE occurs while the slave
+# SQL thread has processed a Table_map_log_event but has not processed
+# the last Rows_log_event associated to it, the slave thread does not
+# forget to close its tables.
+
+# Can be run with statement-based but no interest (and long test)
+--source include/have_binlog_format_row.inc
+--source include/master-slave.inc
+
+connection master;
+create table t1 (a int not null auto_increment primary key, b int, key(b));
+sync_slave_with_master;
+stop slave;
+connection master;
+INSERT INTO t1 (a) VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
+INSERT INTO t1 (a) SELECT null FROM t1;
+INSERT INTO t1 (a) SELECT null FROM t1;
+INSERT INTO t1 (a) SELECT null FROM t1;
+INSERT INTO t1 (a) SELECT null FROM t1;
+INSERT INTO t1 (a) SELECT null FROM t1;
+INSERT INTO t1 (a) SELECT null FROM t1;
+INSERT INTO t1 (a) SELECT null FROM t1;
+INSERT INTO t1 (a) SELECT null FROM t1;
+INSERT INTO t1 (a) SELECT null FROM t1;
+INSERT INTO t1 (a) SELECT null FROM t1;
+INSERT INTO t1 (a) SELECT null FROM t1;
+INSERT INTO t1 (a) SELECT null FROM t1;
+INSERT INTO t1 (a) SELECT null FROM t1;
+
+connection slave;
+start slave;
+
+# hope one second is not enough for slave to reach the last
+# Rows_log_event, so that test actually tests something.
+
+real_sleep 1;
+stop slave;
+
+# see if slave hangs on DROP TABLE
+
+drop table t1;
+
+connection master; # cleanup
+drop table t1;
diff --git a/mysql-test/suite/rpl/t/rpl_row_stop_middle_update-master.opt b/mysql-test/suite/rpl/t/rpl_row_stop_middle_update-master.opt
new file mode 100644
index 00000000000..b7db8f97bdd
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_row_stop_middle_update-master.opt
@@ -0,0 +1 @@
+--loose-binlog-row-event-max-size=256
diff --git a/mysql-test/suite/rpl/t/rpl_row_stop_middle_update-slave.opt b/mysql-test/suite/rpl/t/rpl_row_stop_middle_update-slave.opt
new file mode 100644
index 00000000000..ea49a27adf4
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_row_stop_middle_update-slave.opt
@@ -0,0 +1 @@
+--loose-debug=d,STOP_SLAVE_after_first_Rows_event
diff --git a/mysql-test/suite/rpl/t/rpl_row_stop_middle_update.test b/mysql-test/suite/rpl/t/rpl_row_stop_middle_update.test
new file mode 100644
index 00000000000..29b3008e822
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_row_stop_middle_update.test
@@ -0,0 +1,31 @@
+-- source include/have_binlog_format_row.inc
+-- source include/have_debug.inc
+-- source include/master-slave.inc
+
+# master is asked to create small Rows events: if only one event is
+# created, stopping slave at the end of that one will show no bug, we
+# need at least two (and stop after first); in this test we use three.
+
+connection master;
+create table t1 (words varchar(20)) engine=myisam;
+
+load data infile '../std_data_ln/words.dat' into table t1 (words);
+select count(*) from t1;
+save_master_pos;
+
+connection slave;
+
+# slave will automatically tell itself to stop thanks to the .opt
+# file; it will initiate the stop request after the first
+# Rows_log_event (out of 3) but should wait until the last one is
+# executed before stopping.
+
+wait_for_slave_to_stop;
+
+# check that we inserted all rows (waited until the last Rows event)
+select count(*) from t1;
+
+connection master;
+drop table t1;
+connection slave; # slave SQL thread is stopped
+drop table t1;
diff --git a/mysql-test/suite/rpl/t/rpl_row_tabledefs_2myisam.test b/mysql-test/suite/rpl/t/rpl_row_tabledefs_2myisam.test
new file mode 100644
index 00000000000..ab4914e15fa
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_row_tabledefs_2myisam.test
@@ -0,0 +1,8 @@
+
+-- source include/have_binlog_format_row.inc
+-- source include/master-slave.inc
+
+let $engine_type = 'MyISAM';
+-- source extra/rpl_tests/rpl_row_tabledefs.test
+
+
diff --git a/mysql-test/suite/rpl/t/rpl_row_tabledefs_3innodb-slave.opt b/mysql-test/suite/rpl/t/rpl_row_tabledefs_3innodb-slave.opt
new file mode 100644
index 00000000000..627becdbfb5
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_row_tabledefs_3innodb-slave.opt
@@ -0,0 +1 @@
+--innodb
diff --git a/mysql-test/suite/rpl/t/rpl_row_tabledefs_3innodb.test b/mysql-test/suite/rpl/t/rpl_row_tabledefs_3innodb.test
new file mode 100644
index 00000000000..7824fbfb663
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_row_tabledefs_3innodb.test
@@ -0,0 +1,9 @@
+
+-- source include/have_binlog_format_row.inc
+-- source include/have_innodb.inc
+-- source include/master-slave.inc
+
+let $engine_type = 'InnoDB';
+-- source extra/rpl_tests/rpl_row_tabledefs.test
+
+
diff --git a/mysql-test/suite/rpl/t/rpl_row_trig001.test b/mysql-test/suite/rpl/t/rpl_row_trig001.test
new file mode 100644
index 00000000000..7b1fca2d6a1
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_row_trig001.test
@@ -0,0 +1,100 @@
+#############################################################################
+# Original Author: JBM #
+# Original Date: Aug/09/2005 #
+#############################################################################
+# TEST: Use after insert and before inset triggers and stored procdures to #
+# Update and insert data #
+#############################################################################
+
+# Includes
+-- source include/have_binlog_format_row.inc
+-- source include/master-slave.inc
+
+-- disable_query_log
+-- disable_result_log
+
+# Begin clean up test section
+connection master;
+--disable_warnings
+DROP PROCEDURE IF EXISTS test.p2;
+DROP PROCEDURE IF EXISTS test.p3;
+--error 0,1360
+DROP TRIGGER test.t2_ai;
+--error 0,1360
+DROP TRIGGER test.t3_bi_t2;
+--error 0,1360
+DROP TABLE IF EXISTS test.t1;
+DROP TABLE IF EXISTS test.t2;
+DROP TABLE IF EXISTS test.t3;
+
+
+# test section 1, lets add a trigger to the mix. Taken from bug #12280
+let $message=<Begin test section 1 (Tiggers & SP)>;
+--source include/show_msg.inc
+
+CREATE TABLE test.t1 (n MEDIUMINT NOT NULL, d DATETIME, PRIMARY KEY(n));
+CREATE TABLE test.t2 (n MEDIUMINT NOT NULL AUTO_INCREMENT, f FLOAT, d DATETIME, PRIMARY KEY(n));
+CREATE TABLE test.t3 (n MEDIUMINT NOT NULL AUTO_INCREMENT, d DATETIME, PRIMARY KEY(n));
+
+INSERT INTO test.t1 VALUES (1,NOW());
+
+delimiter //;
+CREATE TRIGGER test.t2_ai AFTER INSERT ON test.t2 FOR EACH ROW UPDATE test.t1 SET d=NOW() where n = 1;//
+CREATE PROCEDURE test.p3()
+BEGIN
+ INSERT INTO test.t3 (d) VALUES (NOW());
+END//
+CREATE TRIGGER test.t3_bi_t2 BEFORE INSERT ON test.t2 FOR EACH ROW CALL test.p3()//
+CREATE PROCEDURE test.p2()
+BEGIN
+ INSERT INTO test.t2 (f,d) VALUES (RAND(),NOW());
+END//
+delimiter ;//
+
+-- disable_query_log
+-- disable_result_log
+let $1=10;
+while ($1)
+{
+ CALL test.p2();
+ sleep 1;
+ dec $1;
+}
+-- enable_result_log
+-- enable_query_log
+
+#show binlog events;
+#select * from test.t2;
+#select * from test.t3;
+#connection slave;
+#select * from test.t2;
+#select * from test.t3;
+
+let $message=<End test section 2 (Tiggers & SP)>;
+--source include/show_msg.inc
+
+# time to dump the databases and so we can see if they match
+
+--exec $MYSQL_DUMP --compact --order-by-primary --skip-extended-insert --no-create-info test > $MYSQLTEST_VARDIR/tmp/trig001_master.sql
+--exec $MYSQL_DUMP_SLAVE --compact --order-by-primary --skip-extended-insert --no-create-info test > $MYSQLTEST_VARDIR/tmp/trig001_slave.sql
+
+# Cleanup
+connection master;
+DROP PROCEDURE test.p2;
+DROP PROCEDURE test.p3;
+DROP TRIGGER test.t2_ai;
+DROP TRIGGER test.t3_bi_t2;
+DROP TABLE test.t1;
+DROP TABLE test.t2;
+DROP TABLE test.t3;
+sync_slave_with_master;
+
+# Lets compare. Note: If they match test will pass, if they do not match
+# the test will show that the diff statement failed and not reject file
+# will be created. You will need to go to the mysql-test dir and diff
+# the files your self to see what is not matching :-) Failed tests
+# will leave dump files in $MYSQLTEST_VARDIR/tmp
+
+diff_files $MYSQLTEST_VARDIR/tmp/trig001_master.sql $MYSQLTEST_VARDIR/tmp/trig001_slave.sql;
+
+# End of 5.0 test case
diff --git a/mysql-test/suite/rpl/t/rpl_row_trig002.test b/mysql-test/suite/rpl/t/rpl_row_trig002.test
new file mode 100644
index 00000000000..7ca8a68f060
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_row_trig002.test
@@ -0,0 +1,80 @@
+#############################################################################
+# Original Author: JBM #
+# Original Date: Aug/14/2005 #
+# Updated: 08/29/2005 added save master pos and sync with master #
+#############################################################################
+# TEST: Taken and modified from BUG#12048 After Insert updates replication #
+#############################################################################
+
+# Includes
+-- source include/have_binlog_format_row.inc
+-- source include/master-slave.inc
+
+#-- disable_query_log
+#-- disable_result_log
+
+# Begin clean up test section
+connection master;
+--disable_warnings
+--error 0,1360
+DROP TRIGGER test.t2_ai;
+DROP TABLE IF EXISTS test.t1;
+DROP TABLE IF EXISTS test.t2;
+DROP TABLE IF EXISTS test.t3;
+--enable_warnings
+
+# test section 1, Taken from bug #12408
+
+CREATE TABLE test.t2 (value CHAR(30),domain_id INT, mailaccount_id INT, program CHAR(30),keey CHAR(30),PRIMARY KEY(domain_id));
+
+CREATE TABLE test.t3 (value CHAR(30),domain_id INT, mailaccount_id INT, program CHAR(30),keey CHAR(30),PRIMARY KEY(domain_id));
+
+CREATE TABLE test.t1 (id INT,domain CHAR(30),PRIMARY KEY(id));
+
+delimiter |;
+CREATE TRIGGER test.t2_ai AFTER INSERT ON test.t2 FOR EACH ROW UPDATE test.t3 ms, test.t1 d SET ms.value='No' WHERE ms.domain_id = (SELECT max(id) FROM test.t1 WHERE domain='example.com') AND ms.mailaccount_id IS NULL AND ms.program='spamfilter' AND ms.keey='scan_incoming'|
+delimiter ;|
+
+INSERT INTO test.t1 VALUES (1, 'example.com'),(2, 'mysql.com'),(3, 'earthmotherwear.com'), (4, 'yahoo.com'),(5, 'example.com');
+
+SELECT * FROM test.t1 ORDER BY id;
+#show binlog events;
+save_master_pos;
+connection slave;
+sync_with_master;
+SELECT * FROM test.t1 ORDER BY id;
+connection master;
+
+INSERT INTO test.t3 VALUES ('Yes', 5, NULL, 'spamfilter','scan_incoming');
+INSERT INTO test.t3 VALUES ('Yes', 1, NULL, 'spamfilter','scan_incoming');
+INSERT INTO test.t2 VALUES ('Yes', 1, NULL, 'spamfilter','scan_incoming');
+
+select * from test.t2;
+select * from test.t3;
+save_master_pos;
+connection slave;
+sync_with_master;
+select * from test.t2;
+select * from test.t3;
+connection master;
+
+DELETE FROM test.t1 WHERE id = 1;
+
+SELECT * FROM test.t1 ORDER BY id;
+connection master;
+SELECT * FROM test.t1 ORDER BY id;
+save_master_pos;
+connection slave;
+sync_with_master;
+SELECT * FROM test.t1 ORDER BY id;
+
+# Cleanup
+connection master;
+#show binlog events;
+DROP TRIGGER test.t2_ai;
+DROP TABLE test.t1;
+DROP TABLE test.t2;
+DROP TABLE test.t3;
+sync_slave_with_master;
+
+# End of 5.0 test case
diff --git a/mysql-test/suite/rpl/t/rpl_row_trig003.test b/mysql-test/suite/rpl/t/rpl_row_trig003.test
new file mode 100644
index 00000000000..4a1bbc5ca89
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_row_trig003.test
@@ -0,0 +1,152 @@
+#############################################################################
+# Original Author: JBM #
+# Original Date: Aug/16/2005 #
+# Updated: 8/29/2005 Remove sleep calls add dump and diff #
+#############################################################################
+# TEST: This test includes all trigger types. BEFORE/AFTER INSERT, UPDATE & #
+# DELETE. In addition, includes cursor, bit, varchar, flow control, #
+# looping, ROUND(), NOW(), YEAR(), TIMESTAMP #
+#############################################################################
+
+# Includes
+-- source include/have_binlog_format_row.inc
+-- source include/master-slave.inc
+
+#-- disable_query_log
+#-- disable_result_log
+
+# Begin clean up test section
+connection master;
+--disable_warnings
+--error 0,1360
+DROP TRIGGER test.t1_bi;
+--error 0,1360
+DROP TRIGGER test.t2_ai;
+--error 0,1360
+DROP TRIGGER test.t1_bu;
+--error 0,1360
+DROP TRIGGER test.t2_au;
+--error 0,1360
+DROP TRIGGER test.t1_bd;
+--error 0,1360
+DROP TRIGGER test.t2_ad;
+DROP TABLE IF EXISTS test.t1;
+DROP TABLE IF EXISTS test.t2;
+DROP TABLE IF EXISTS test.t3;
+--enable_warnings
+
+# test section 1
+
+CREATE TABLE test.t1 (id MEDIUMINT NOT NULL AUTO_INCREMENT, b1 BIT(8), vc VARCHAR(255), bc CHAR(255), d DECIMAL(10,4) DEFAULT 0, f FLOAT DEFAULT 0, total BIGINT UNSIGNED, y YEAR, t TIMESTAMP,PRIMARY KEY(id));
+CREATE TABLE test.t2 (id MEDIUMINT NOT NULL AUTO_INCREMENT, b1 BIT(8), vc VARCHAR(255), bc CHAR(255), d DECIMAL(10,4) DEFAULT 0, f FLOAT DEFAULT 0, total BIGINT UNSIGNED, y YEAR, t TIMESTAMP,PRIMARY KEY(id));
+CREATE TABLE test.t3 (id MEDIUMINT NOT NULL AUTO_INCREMENT, b1 BIT(8), vc VARCHAR(255), bc CHAR(255), d DECIMAL(10,4) DEFAULT 0, f FLOAT DEFAULT 0, total BIGINT UNSIGNED, y YEAR, t TIMESTAMP,PRIMARY KEY(id));
+
+# Note Most of these cause the slave to core or do not produce desired results. Currently commenting out the ones not working until they are fixed.
+
+delimiter |;
+CREATE TRIGGER test.t1_bi BEFORE INSERT ON test.t1 FOR EACH ROW UPDATE test.t3 SET b1=1 and y=YEAR(NOW())|
+CREATE TRIGGER test.t2_ai AFTER INSERT ON test.t2 FOR EACH ROW BEGIN
+ INSERT INTO test.t3 VALUES(NULL,0,'MySQL Replication team rocks!', 'Dark beer in prague is #1',12345.34,12.51,0,1965,NOW());
+ UPDATE test.t3 SET f = ROUND(f);
+END|
+CREATE TRIGGER test.t1_bu BEFORE UPDATE on test.t1 FOR EACH ROW BEGIN
+ UPDATE test.t3 SET y = '2000';
+ INSERT INTO test.t3 VALUES(NULL,1,'Testing MySQL databases before update ', 'Insert should work',621.43, 0105.21,0,1974,NOW());
+END|
+CREATE TRIGGER test.t2_au AFTER UPDATE on test.t2 FOR EACH ROW BEGIN
+ DECLARE done INT DEFAULT 0;
+ DECLARE a DECIMAL(10,4);
+ DECLARE b FLOAT;
+ DECLARE num MEDIUMINT;
+ DECLARE cur1 CURSOR FOR SELECT t2.id, t2.d, t2.f FROM test.t2;
+ DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done = 1;
+
+ OPEN cur1;
+
+ REPEAT
+ FETCH cur1 INTO num, a, b;
+ IF NOT done THEN
+ UPDATE test.t3 SET total =(a*b) WHERE ID = num;
+ END IF;
+ UNTIL done END REPEAT;
+ CLOSE cur1;
+END|
+CREATE TRIGGER test.t1_bd BEFORE DELETE on test.t1 FOR EACH ROW BEGIN
+ DECLARE done INT DEFAULT 0;
+ DECLARE a BIT(8);
+ DECLARE b VARCHAR(255);
+ DECLARE c CHAR(255);
+ DECLARE d DECIMAL(10,4);
+ DECLARE e FLOAT;
+ DECLARE f BIGINT UNSIGNED;
+ DECLARE g YEAR;
+ DECLARE h TIMESTAMP;
+ DECLARE cur1 CURSOR FOR SELECT t1.b1, t1.vc, t1.bc, t1.d, t1.f, t1.total, t1.y, t1.t FROM test.t1;
+ DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done = 1;
+
+ OPEN cur1;
+
+ REPEAT
+ FETCH cur1 INTO a, b, c, d, e, f, g, h;
+ IF NOT done THEN
+ INSERT INTO test.t3 VALUES(NULL, a, b, c, d, e, f, g, h);
+ END IF;
+ UNTIL done END REPEAT;
+ CLOSE cur1;
+END|
+CREATE TRIGGER test.t2_ad AFTER DELETE ON test.t2 FOR EACH ROW
+ DELETE FROM test.t1|
+delimiter ;|
+
+INSERT INTO test.t1 VALUES(NULL,1,'Testing MySQL databases is a cool ', 'Must make it bug free for the customer',654321.4321,15.21,0,1965,NOW());
+INSERT INTO test.t2 VALUES(NULL,0,'Testing MySQL databases is a cool ', 'MySQL Customers ROCK!',654321.4321,1.24521,0,YEAR(NOW()),NOW());
+
+UPDATE test.t1 SET b1 = 0 WHERE b1 = 1;
+
+INSERT INTO test.t2 VALUES(NULL,1,'This is an after update test.', 'If this works, total will not be zero on the master or slave',1.4321,5.221,0,YEAR(NOW()),NOW());
+UPDATE test.t2 SET b1 = 0 WHERE b1 = 1;
+
+INSERT INTO test.t1 VALUES(NULL,1,'add some more test data test.', 'and hope for the best', 3.321,5.221,0,YEAR(NOW()),NOW());
+
+# To make sure BUG#14698 is gone, we sleep 2 seconds before calling trigger
+# (with the bug in, that caused differences in TIMESTAMP columns).
+# We just need to let the machine's clock advance, it's not
+# to do synchronization, so real_sleep is good.
+real_sleep 2;
+
+DELETE FROM test.t1 WHERE id = 1;
+
+DELETE FROM test.t2 WHERE id = 1;
+
+save_master_pos;
+connection slave;
+sync_with_master;
+connection master;
+
+# time to dump the databases and so we can see if they match
+
+--exec $MYSQL_DUMP --compact --order-by-primary --skip-extended-insert --no-create-info test > $MYSQLTEST_VARDIR/tmp/trg003_master.sql
+--exec $MYSQL_DUMP_SLAVE --compact --order-by-primary --skip-extended-insert --no-create-info test > $MYSQLTEST_VARDIR/tmp/trg003_slave.sql
+
+# cleanup
+--disable_warnings
+--error 0,1360
+DROP TRIGGER test.t1_bi;
+--error 0,1360
+DROP TRIGGER test.t2_ai;
+--error 0,1360
+DROP TRIGGER test.t1_bu;
+--error 0,1360
+DROP TRIGGER test.t2_au;
+--error 0,1360
+DROP TRIGGER test.t1_bd;
+--error 0,1360
+DROP TRIGGER test.t2_ad;
+DROP TABLE IF EXISTS test.t1;
+DROP TABLE IF EXISTS test.t2;
+DROP TABLE IF EXISTS test.t3;
+--enable_warnings
+
+diff_files $MYSQLTEST_VARDIR/tmp/trg003_master.sql $MYSQLTEST_VARDIR/tmp/trg003_slave.sql;
+
+# End of 5.0 test case
diff --git a/mysql-test/suite/rpl/t/rpl_row_trig004.test b/mysql-test/suite/rpl/t/rpl_row_trig004.test
new file mode 100644
index 00000000000..a918c602d56
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_row_trig004.test
@@ -0,0 +1,18 @@
+#############################################################################
+# Original Author: JBM #
+# Original Date: Oct/18/2005 #
+#############################################################################
+# TEST: Use before insert triggers and has the second insert fail #
+#############################################################################
+# Change by JBM 2006-02-14 added to skip when NDB default engine #
+# This test has been wrapped to allow multipal engines to use same code #
+#############################################################################
+
+# Includes
+-- source include/not_ndb_default.inc
+-- source include/have_binlog_format_row.inc
+-- source include/have_innodb.inc
+-- source include/master-slave.inc
+let $engine_type=INNODB;
+-- source extra/rpl_tests/rpl_trig004.test
+
diff --git a/mysql-test/suite/rpl/t/rpl_row_until.test b/mysql-test/suite/rpl/t/rpl_row_until.test
new file mode 100644
index 00000000000..9464e5cfadd
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_row_until.test
@@ -0,0 +1,76 @@
+-- source include/not_ndb_default.inc
+-- source include/have_binlog_format_row.inc
+-- source include/master-slave.inc
+
+# Test is dependent on binlog positions
+
+# prepare version for substitutions
+let $VERSION=`select version()`;
+
+# stop slave before he will start replication also sync with master
+# for avoiding undetermenistic behaviour
+save_master_pos;
+connection slave;
+sync_with_master;
+stop slave;
+
+connection master;
+# create some events on master
+create table t1(n int not null auto_increment primary key);
+insert into t1 values (1),(2),(3),(4);
+drop table t1;
+create table t2(n int not null auto_increment primary key);
+insert into t2 values (1),(2);
+insert into t2 values (3),(4);
+drop table t2;
+
+# try to replicate all queries until drop of t1
+connection slave;
+start slave until master_log_file='master-bin.000001', master_log_pos=311;
+--source include/wait_for_slave_sql_to_stop.inc
+# here table should be still not deleted
+select * from t1;
+source include/show_slave_status.inc;
+
+# this should fail right after start
+start slave until master_log_file='master-no-such-bin.000001', master_log_pos=291;
+--source include/wait_for_slave_sql_to_stop.inc
+# again this table should be still not deleted
+select * from t1;
+source include/show_slave_status.inc;
+
+# try replicate all up to and not including the second insert to t2;
+start slave until relay_log_file='slave-relay-bin.000004', relay_log_pos=728;
+--source include/wait_for_slave_sql_to_stop.inc
+select * from t2;
+source include/show_slave_status.inc;
+
+# clean up
+start slave;
+connection master;
+save_master_pos;
+connection slave;
+sync_with_master;
+stop slave;
+
+# this should stop immediately as we are already there
+start slave until master_log_file='master-bin.000001', master_log_pos=740;
+--source include/wait_for_slave_sql_to_stop.inc
+# here the sql slave thread should be stopped
+--replace_result bin.000005 bin.000004 bin.000006 bin.000004 bin.000007 bin.000004
+source include/show_slave_status.inc;
+
+#testing various error conditions
+--error 1277
+start slave until master_log_file='master-bin', master_log_pos=561;
+--error 1277
+start slave until master_log_file='master-bin.000001', master_log_pos=561, relay_log_pos=12;
+--error 1277
+start slave until master_log_file='master-bin.000001';
+--error 1277
+start slave until relay_log_file='slave-relay-bin.000002';
+--error 1277
+start slave until relay_log_file='slave-relay-bin.000002', master_log_pos=561;
+# Warning should be given for second command
+start slave sql_thread;
+start slave until master_log_file='master-bin.000001', master_log_pos=740;
diff --git a/mysql-test/suite/rpl/t/rpl_row_view01.test b/mysql-test/suite/rpl/t/rpl_row_view01.test
new file mode 100644
index 00000000000..634e3c30cc6
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_row_view01.test
@@ -0,0 +1,89 @@
+#############################################################################
+# Original Author: JBM #
+# Original Date: Aug/19/2005 #
+# Updated: 08/29/2005 Remove sleeps #
+#############################################################################
+#TEST: row based replication of views #
+#############################################################################
+# 2006-02-08 By JBM added order by and sleep for use with ndb engine
+#############################################################################
+# Includes
+-- source include/have_binlog_format_row.inc
+-- source include/master-slave.inc
+
+# Begin clean up test section
+connection master;
+--disable_warnings
+create database if not exists mysqltest1;
+DROP VIEW IF EXISTS mysqltest1.v1;
+DROP VIEW IF EXISTS mysqltest1.v2;
+DROP VIEW IF EXISTS mysqltest1.v3;
+DROP VIEW IF EXISTS mysqltest1.v4;
+DROP TABLE IF EXISTS mysqltest1.t3;
+DROP TABLE IF EXISTS mysqltest1.t1;
+DROP TABLE IF EXISTS mysqltest1.t2;
+DROP TABLE IF EXISTS mysqltest1.t4;
+
+# Begin test section 1
+CREATE TABLE mysqltest1.t1 (a INT, c CHAR(6),PRIMARY KEY(a));
+CREATE TABLE mysqltest1.t2 (a INT, c CHAR(6),PRIMARY KEY(a));
+CREATE TABLE mysqltest1.t3 (a INT, c CHAR(6), c2 CHAR(6), PRIMARY KEY(a));
+CREATE TABLE mysqltest1.t4 (a INT, qty INT, price INT,PRIMARY KEY(a));
+CREATE TABLE mysqltest1.t5 (qty INT, price INT, total INT, PRIMARY KEY(qty));
+INSERT INTO mysqltest1.t1 VALUES (1,'Thank'),(2,'it'),(3,'Friday');
+INSERT INTO mysqltest1.t2 VALUES (1,'GOD'),(2,'is'),(3,'TGIF');
+INSERT INTO mysqltest1.t4 VALUES(1, 3, 50),(2, 18, 3),(4, 4, 4);
+
+
+CREATE VIEW mysqltest1.v2 AS SELECT qty, price, qty*price AS value FROM mysqltest1.t4 ORDER BY qty;
+CREATE VIEW mysqltest1.v1 AS SELECT t1.a, t1.c, t2.c as c2 FROM mysqltest1.t1 as t1, mysqltest1.t2 AS t2 WHERE mysqltest1.t1.a = mysqltest1.t2.a ORDER BY a;
+CREATE VIEW mysqltest1.v3 AS SELECT * FROM mysqltest1.t1;
+CREATE VIEW mysqltest1.v4 AS SELECT * FROM mysqltest1.v3 WHERE a > 1 WITH LOCAL CHECK OPTION;
+
+
+SELECT * FROM mysqltest1.v2;
+SELECT * FROM mysqltest1.v1;
+# Had to add a sleep for use with NDB
+# engine. Injector thread would have not
+# populated biblog and data would not be on
+# the slave.
+sleep 10;
+sync_slave_with_master;
+SELECT * FROM mysqltest1.v2;
+SELECT * FROM mysqltest1.v1;
+connection master;
+
+INSERT INTO mysqltest1.t5 SELECT * FROM mysqltest1.v2;
+INSERT INTO mysqltest1.t3 SELECT * FROM mysqltest1.v1;
+
+SELECT * FROM mysqltest1.t5 ORDER BY qty;
+SELECT * FROM mysqltest1.t3 ORDER BY a;
+sync_slave_with_master;
+SELECT * FROM mysqltest1.t5 ORDER BY qty;
+SELECT * FROM mysqltest1.t3 ORDER BY a;
+connection master;
+
+INSERT INTO mysqltest1.v4 VALUES (4,'TEST');
+
+SELECT * FROM mysqltest1.t1 ORDER BY a;
+SELECT * FROM mysqltest1.v4 ORDER BY a;
+sync_slave_with_master;
+SELECT * FROM mysqltest1.t1 ORDER BY a;
+SELECT * FROM mysqltest1.v4 ORDER BY a;
+
+connection master;
+
+# lets cleanup
+DROP VIEW IF EXISTS mysqltest1.v1;
+DROP VIEW IF EXISTS mysqltest1.v2;
+DROP VIEW IF EXISTS mysqltest1.v3;
+DROP VIEW IF EXISTS mysqltest1.v4;
+DROP TABLE IF EXISTS mysqltest1.t3;
+DROP TABLE IF EXISTS mysqltest1.t1;
+DROP TABLE IF EXISTS mysqltest1.t2;
+DROP TABLE IF EXISTS mysqltest1.t4;
+DROP DATABASE mysqltest1;
+sync_slave_with_master;
+
+# End of 5.1 test case
+
diff --git a/mysql-test/suite/rpl/t/rpl_server_id1.test b/mysql-test/suite/rpl/t/rpl_server_id1.test
new file mode 100644
index 00000000000..2db1f6e364d
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_server_id1.test
@@ -0,0 +1,26 @@
+# This test checks that the slave I/O thread refuses to start if slave
+# and master have the same server id (because this is a useless setup,
+# and otherwise SHOW SLAVE STATUS shows progress but all queries are
+# ignored, which has caught our customers), unless
+# --replicate-same-server-id.
+
+source include/master-slave.inc;
+connection slave;
+create table t1 (n int);
+reset master;
+# replicate ourselves
+stop slave;
+--replace_result $SLAVE_MYPORT SLAVE_PORT
+eval change master to master_port=$SLAVE_MYPORT;
+--replace_result $SLAVE_MYPORT SLAVE_PORT
+--replace_column 16 # 18 # 35 # 36 #
+query_vertical show slave status;
+start slave;
+insert into t1 values (1);
+# can't MASTER_POS_WAIT(), it does not work in this weird setup
+# (when slave is its own master without --replicate-same-server-id)
+sleep 2; # enough time for the event to be replicated (it should not)
+show status like "slave_running";
+drop table t1;
+
+# End of 4.1 tests
diff --git a/mysql-test/suite/rpl/t/rpl_server_id2-slave.opt b/mysql-test/suite/rpl/t/rpl_server_id2-slave.opt
new file mode 100644
index 00000000000..302889525dd
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_server_id2-slave.opt
@@ -0,0 +1 @@
+--disable-log-slave-updates --replicate-same-server-id
diff --git a/mysql-test/suite/rpl/t/rpl_server_id2.test b/mysql-test/suite/rpl/t/rpl_server_id2.test
new file mode 100644
index 00000000000..7e67fb42b4f
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_server_id2.test
@@ -0,0 +1,26 @@
+# This test checks that a slave DOES execute queries originating
+# from itself, if running with --replicate-same-server-id.
+
+source include/master-slave.inc;
+connection slave;
+create table t1 (n int);
+reset master;
+# replicate ourselves
+stop slave;
+--replace_result $SLAVE_MYPORT SLAVE_PORT
+eval change master to master_port=$SLAVE_MYPORT;
+--replace_result $SLAVE_MYPORT SLAVE_PORT
+--replace_column 18 # 35 # 36 #
+query_vertical show slave status;
+start slave;
+insert into t1 values (1);
+save_master_pos;
+sync_with_master;
+select * from t1; # check that indeed 2 were inserted
+# We stop the slave before cleaning up otherwise we'll get
+# 'drop table t1' executed twice, so an error in the slave.err
+# (not critical).
+stop slave;
+drop table t1;
+
+# End of 4.1 tests
diff --git a/mysql-test/suite/rpl/t/rpl_session_var.test b/mysql-test/suite/rpl/t/rpl_session_var.test
new file mode 100644
index 00000000000..a6f4b496a23
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_session_var.test
@@ -0,0 +1,42 @@
+# Replication of session variables.
+# FOREIGN_KEY_CHECKS is tested in rpl_insert_id.test
+
+source include/master-slave.inc;
+drop table if exists t1;
+create table t1(a varchar(100),b int);
+set @@session.sql_mode=pipes_as_concat;
+insert into t1 values('My'||'SQL', 1);
+set @@session.sql_mode=default;
+insert into t1 values('1'||'2', 2);
+select * from t1 where b<3 order by a;
+save_master_pos;
+connection slave;
+sync_with_master;
+select * from t1 where b<3 order by a;
+connection master;
+# if the slave does the next sync_with_master fine, then it means it accepts the
+# two lines of ANSI syntax below, which is what we want to check.
+set @@session.sql_mode=ignore_space;
+insert into t1 values(password ('MySQL'), 3);
+set @@session.sql_mode=ansi_quotes;
+create table "t2" ("a" int);
+drop table t1, t2;
+set @@session.sql_mode=default;
+create table t1(a int auto_increment primary key);
+create table t2(b int, a int);
+set @@session.sql_auto_is_null=1;
+insert into t1 values(null);
+insert into t2 select 1,a from t1 where a is null;
+set @@session.sql_auto_is_null=0;
+insert into t1 values(null);
+insert into t2 select 2,a from t1 where a is null;
+select * from t2 order by b;
+save_master_pos;
+connection slave;
+sync_with_master;
+select * from t2 order by b;
+connection master;
+drop table t1,t2;
+save_master_pos;
+connection slave;
+sync_with_master;
diff --git a/mysql-test/suite/rpl/t/rpl_set_charset.test b/mysql-test/suite/rpl/t/rpl_set_charset.test
new file mode 100644
index 00000000000..c70eb2681f5
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_set_charset.test
@@ -0,0 +1,35 @@
+source include/master-slave.inc;
+--disable_warnings
+drop database if exists mysqltest1;
+# 4.1 bases its conversion on the db's charset,
+# while 4.0 uses the part of "SET CHARACTER SET" after "_".
+# So for 4.1 we add a clause to CREATE DATABASE.
+create database mysqltest1 /*!40100 character set latin2 */;
+use mysqltest1;
+drop table if exists t1;
+--enable_warnings
+create table t1 (a varchar(255) character set latin2, b varchar(4));
+SET CHARACTER SET cp1250_latin2;
+INSERT INTO t1 VALUES ('ŠŒŽ','80');
+INSERT INTO t1 VALUES ('šœžŸ','90');
+INSERT INTO t1 VALUES ('£¥ª¯','A0');
+INSERT INTO t1 VALUES ('³¹º¼¾¿','B0');
+INSERT INTO t1 VALUES ('ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏ','C0');
+INSERT INTO t1 VALUES ('ÐÑÒÓÔÕÖרÙÚÛÜÝÞß','D0');
+INSERT INTO t1 VALUES ('àáâãäåæçèéêëìíîï','E0');
+INSERT INTO t1 VALUES ('ðñòóôõö÷øùúûüýþÿ','F0');
+select "--- on master ---";
+select hex(a),b from t1 order by b;
+save_master_pos;
+connection slave;
+sync_with_master;
+use mysqltest1;
+select "--- on slave ---";
+select hex(a),b from t1 order by b;
+connection master;
+drop database mysqltest1;
+save_master_pos;
+connection slave;
+sync_with_master;
+
+# End of 4.1 tests
diff --git a/mysql-test/suite/rpl/t/rpl_sf.test b/mysql-test/suite/rpl/t/rpl_sf.test
new file mode 100644
index 00000000000..ecf91a723fa
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_sf.test
@@ -0,0 +1,70 @@
+-- source include/have_log_bin.inc
+
+# Bug#16456 RBR: rpl_sp.test expects query to fail, but passes in RBR
+
+# save status
+
+let $oblf=`select @@SESSION.BINLOG_FORMAT`;
+let $otfc=`select @@log_bin_trust_function_creators`;
+
+set global log_bin_trust_function_creators=0;
+
+
+
+# fail *on definition*
+
+set binlog_format=STATEMENT;
+
+delimiter |;
+--error ER_BINLOG_UNSAFE_ROUTINE
+create function fn16456()
+ returns int
+begin
+ return unix_timestamp();
+end|
+delimiter ;|
+
+
+
+# force in definition, so we can see whether we fail on call
+
+set global log_bin_trust_function_creators=1;
+
+delimiter |;
+create function fn16456()
+ returns int
+begin
+ return unix_timestamp();
+end|
+delimiter ;|
+
+set global log_bin_trust_function_creators=0;
+
+
+
+# allow funcall in RBR
+
+set binlog_format=ROW;
+
+--replace_column 1 timestamp
+select fn16456();
+
+
+
+# fail funcall in SBR
+
+set binlog_format=STATEMENT;
+
+--error ER_BINLOG_ROW_RBR_TO_SBR
+select fn16456();
+
+
+
+# restore status
+
+drop function fn16456;
+
+--disable_query_log
+eval set binlog_format=$oblf;
+eval set global log_bin_trust_function_creators=$otfc;
+--enable_query_log
diff --git a/mysql-test/suite/rpl/t/rpl_skip_error-slave.opt b/mysql-test/suite/rpl/t/rpl_skip_error-slave.opt
new file mode 100644
index 00000000000..982362d93a5
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_skip_error-slave.opt
@@ -0,0 +1 @@
+--slave-skip-error=1053,1582
diff --git a/mysql-test/suite/rpl/t/rpl_skip_error.test b/mysql-test/suite/rpl/t/rpl_skip_error.test
new file mode 100644
index 00000000000..b68b637b3b0
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_skip_error.test
@@ -0,0 +1,51 @@
+##########################################
+# 2006-02-07 By JBM: Added order by
+#########################################
+# Note that errors are ignored by opt file.
+source include/master-slave.inc;
+
+create table t1 (n int not null primary key);
+save_master_pos;
+connection slave;
+sync_with_master;
+insert into t1 values (1);
+connection master;
+# Here we expect (ignored) error, since 1 is already in slave table
+insert into t1 values (1);
+
+# These should work fine
+insert into t1 values (2),(3);
+
+save_master_pos;
+connection slave;
+sync_with_master;
+select * from t1 ORDER BY n;
+
+# Cleanup
+connection master;
+drop table t1;
+sync_slave_with_master;
+
+# End of 4.1 tests
+
+#
+# #28839 Errors in strict mode silently stop SQL thread if --slave-skip-errors exists
+#
+connection master;
+create table t1(a int primary key);
+insert into t1 values (1),(2);
+delete from t1 where @@server_id=1;
+set sql_mode=strict_trans_tables;
+select @@server_id;
+insert into t1 values (1),(2),(3);
+sync_slave_with_master;
+connection slave;
+select @@server_id;
+select * from t1;
+--replace_column 1 # 8 # 9 # 23 # 33 #
+--replace_result $MASTER_MYPORT MASTER_PORT
+show slave status;
+connection master;
+drop table t1;
+sync_with_master;
+# End of 5.0 tests
diff --git a/mysql-test/suite/rpl/t/rpl_slave_status.test b/mysql-test/suite/rpl/t/rpl_slave_status.test
new file mode 100644
index 00000000000..d07cf13dcf4
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_slave_status.test
@@ -0,0 +1,58 @@
+--source include/master-slave.inc
+
+############################################################################
+# Test case for BUG#10780
+#
+# REQUIREMENT
+# A slave without replication privileges should have Slave_IO_Running = No
+
+# 1. Create new replication user
+connection master;
+grant replication slave on *.* to rpl@127.0.0.1 identified by 'rpl';
+
+connection slave;
+stop slave;
+change master to master_user='rpl',master_password='rpl';
+start slave;
+
+# 2. Do replication as new user
+connection master;
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+create table t1 (n int);
+insert into t1 values (1);
+save_master_pos;
+connection slave;
+sync_with_master;
+select * from t1;
+
+# 3. Delete new replication user
+connection master;
+delete from mysql.user where user='rpl';
+flush privileges;
+connection slave;
+
+# 4. Restart slave without privileges
+# (slave.err will contain access denied error for this START SLAVE command)
+stop slave;
+start slave;
+
+# 5. Make sure Slave_IO_Running = No
+--replace_result $MASTER_MYPORT MASTER_MYPORT
+# Column 1 is replaced, since the output can be either
+# "Connecting to master" or "Waiting for master update"
+--replace_column 1 # 7 # 8 # 9 # 22 # 23 # 35 # 36 #
+--vertical_results
+show slave status;
+
+# Cleanup (Note that slave IO thread is not running)
+connection slave;
+drop table t1;
+delete from mysql.user where user='rpl';
+connection master;
+drop table t1;
+
+# end of test case for BUG#10780
+
+# end of 4.1 tests
diff --git a/mysql-test/suite/rpl/t/rpl_sp-master.opt b/mysql-test/suite/rpl/t/rpl_sp-master.opt
new file mode 100644
index 00000000000..709a224fd92
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_sp-master.opt
@@ -0,0 +1 @@
+--log_bin_trust_routine_creators=0
diff --git a/mysql-test/suite/rpl/t/rpl_sp-slave.opt b/mysql-test/suite/rpl/t/rpl_sp-slave.opt
new file mode 100644
index 00000000000..709a224fd92
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_sp-slave.opt
@@ -0,0 +1 @@
+--log_bin_trust_routine_creators=0
diff --git a/mysql-test/suite/rpl/t/rpl_sp.test b/mysql-test/suite/rpl/t/rpl_sp.test
new file mode 100644
index 00000000000..f363b64558a
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_sp.test
@@ -0,0 +1,585 @@
+# row-based and statement have expected binlog difference in result files
+
+# Test of replication of stored procedures (WL#2146 for MySQL 5.0)
+# Modified by WL#2971.
+
+# Note that in the .opt files we still use the old variable name
+# log-bin-trust-routine-creators so that this test checks that it's
+# still accepted (this test also checks that the new name is
+# accepted). The old name could be removed in 5.1 or 6.0.
+
+source include/have_binlog_format_mixed.inc;
+source include/master-slave.inc;
+
+# we need a db != test, where we don't have automatic grants
+--disable_warnings
+drop database if exists mysqltest1;
+--enable_warnings
+create database mysqltest1;
+use mysqltest1;
+create table t1 (a varchar(100));
+sync_slave_with_master;
+use mysqltest1;
+
+# ********************** PART 1 : STORED PROCEDURES ***************
+
+# Does the same proc as on master get inserted into mysql.proc ?
+# (same definer, same properties...)
+
+connection master;
+
+delimiter |;
+
+# Stored procedures don't have the limitations that functions have
+# regarding binlogging: it's ok to create a procedure as not
+# deterministic and updating data, while it's not ok to create such a
+# function. We test this.
+
+create procedure foo()
+begin
+ declare b int;
+ set b = 8;
+ insert into t1 values (b);
+ insert into t1 values (unix_timestamp());
+end|
+delimiter ;|
+
+# we replace columns having times
+# (even with fixed timestamp displayed time may changed based on TZ)
+--replace_result localhost.localdomain localhost 127.0.0.1 localhost
+--replace_column 13 # 14 #
+select * from mysql.proc where name='foo' and db='mysqltest1';
+sync_slave_with_master;
+# You will notice in the result that the definer does not match what
+# it is on master, it is a known bug on which Alik is working
+--replace_result localhost.localdomain localhost 127.0.0.1 localhost
+--replace_column 13 # 14 #
+select * from mysql.proc where name='foo' and db='mysqltest1';
+
+connection master;
+# see if timestamp used in SP on slave is same as on master
+set timestamp=1000000000;
+call foo();
+select * from t1;
+sync_slave_with_master;
+select * from t1;
+
+# Now a SP which is not updating tables
+
+connection master;
+delete from t1;
+create procedure foo2()
+ select * from mysqltest1.t1;
+call foo2();
+
+# check that this is allowed (it's not for functions):
+alter procedure foo2 contains sql;
+
+# SP with definer's right
+
+drop table t1;
+create table t1 (a int);
+create table t2 like t1;
+
+create procedure foo3()
+ deterministic
+ insert into t1 values (15);
+
+# let's create a non-privileged user
+grant CREATE ROUTINE, EXECUTE on mysqltest1.* to "zedjzlcsjhd"@127.0.0.1;
+grant SELECT on mysqltest1.t1 to "zedjzlcsjhd"@127.0.0.1;
+grant SELECT, INSERT on mysqltest1.t2 to "zedjzlcsjhd"@127.0.0.1;
+
+# ToDo: BUG#14931: There is a race between the last grant binlogging, and
+# the binlogging in the new connection made below, causing sporadic test
+# failures due to switched statement order in binlog. To fix this we do
+# SELECT 1 in the first connection before starting the second, ensuring
+# that binlogging is done in the expected order.
+# Please remove this SELECT 1 when BUG#14931 is fixed.
+SELECT 1;
+
+connect (con1,127.0.0.1,zedjzlcsjhd,,mysqltest1,$MASTER_MYPORT,);
+connection con1;
+
+# this routine will fail in the second INSERT because of privileges
+delimiter |;
+create procedure foo4()
+ deterministic
+ begin
+ insert into t2 values(3);
+ insert into t1 values (5);
+ end|
+
+delimiter ;|
+
+# I add ,0 so that it does not print the error in the test output,
+# because this error is hostname-dependent
+--error 1142,0
+call foo4(); # invoker has no INSERT grant on table t1 => failure
+
+connection master;
+call foo3(); # success (definer == root)
+show warnings;
+
+--error 1142,0
+call foo4(); # definer's rights => failure
+
+# we test replication of ALTER PROCEDURE
+alter procedure foo4 sql security invoker;
+call foo4(); # invoker's rights => success
+show warnings;
+
+# Note that half-failed procedure calls are ok with binlogging;
+# if we compare t2 on master and slave we see they are identical:
+
+select * from t1;
+select * from t2;
+sync_slave_with_master;
+select * from t1;
+select * from t2;
+
+# Let's check another failing-in-the-middle procedure
+connection master;
+delete from t2;
+alter table t2 add unique (a);
+
+drop procedure foo4;
+delimiter |;
+create procedure foo4()
+ deterministic
+ begin
+ insert into t2 values(20),(20);
+ end|
+
+delimiter ;|
+
+--error ER_DUP_ENTRY
+call foo4();
+show warnings;
+
+select * from t2;
+sync_slave_with_master;
+# check that this failed-in-the-middle replicated right:
+select * from t2;
+
+# Test of DROP PROCEDURE
+
+--replace_result localhost.localdomain localhost 127.0.0.1 localhost
+--replace_column 13 # 14 #
+select * from mysql.proc where name="foo4" and db='mysqltest1';
+connection master;
+drop procedure foo4;
+select * from mysql.proc where name="foo4" and db='mysqltest1';
+sync_slave_with_master;
+select * from mysql.proc where name="foo4" and db='mysqltest1';
+
+# ********************** PART 2 : FUNCTIONS ***************
+
+connection master;
+drop procedure foo;
+drop procedure foo2;
+drop procedure foo3;
+
+delimiter |;
+# check that needs "deterministic"
+--error 1418
+create function fn1(x int)
+ returns int
+begin
+ insert into t1 values (x);
+ return x+2;
+end|
+create function fn1(x int)
+ returns int
+ deterministic
+begin
+ insert into t1 values (x);
+ return x+2;
+end|
+
+delimiter ;|
+delete t1,t2 from t1,t2;
+select fn1(20);
+insert into t2 values(fn1(21));
+select * from t1;
+select * from t2;
+sync_slave_with_master;
+select * from t1;
+select * from t2;
+
+connection master;
+delimiter |;
+
+drop function fn1;
+
+create function fn1()
+ returns int
+ no sql
+begin
+ return unix_timestamp();
+end|
+
+delimiter ;|
+# check that needs "deterministic"
+--error 1418
+alter function fn1 contains sql;
+
+delete from t1;
+set timestamp=1000000000;
+insert into t1 values(fn1());
+
+connection con1;
+
+delimiter |;
+--error 1419 # only full-global-privs user can create a function
+create function fn2()
+ returns int
+ no sql
+begin
+ return unix_timestamp();
+end|
+delimiter ;|
+connection master;
+# test old variable name:
+set global log_bin_trust_routine_creators=1;
+# now use new name:
+set global log_bin_trust_function_creators=0;
+set global log_bin_trust_function_creators=1;
+# slave needs it too otherwise will not execute what master allowed:
+connection slave;
+set global log_bin_trust_function_creators=1;
+
+connection con1;
+
+delimiter |;
+create function fn2()
+ returns int
+ no sql
+begin
+ return unix_timestamp();
+end|
+delimiter ;|
+
+connection master;
+
+# Now a function which is supposed to not update tables
+# as it's "reads sql data", so should not give error even if
+# non-deterministic.
+
+delimiter |;
+create function fn3()
+ returns int
+ not deterministic
+ reads sql data
+begin
+ return 0;
+end|
+delimiter ;|
+
+select fn3();
+--replace_result localhost.localdomain localhost 127.0.0.1 localhost
+--replace_column 13 # 14 #
+select * from mysql.proc where db='mysqltest1';
+select * from t1;
+
+sync_slave_with_master;
+use mysqltest1;
+select * from t1;
+--replace_result localhost.localdomain localhost 127.0.0.1 localhost
+--replace_column 13 # 14 #
+select * from mysql.proc where db='mysqltest1';
+
+# Let's check a failing-in-the-middle function
+connection master;
+delete from t2;
+alter table t2 add unique (a);
+
+drop function fn1;
+
+delimiter |;
+create function fn1(x int)
+ returns int
+begin
+ insert into t2 values(x),(x);
+ return 10;
+end|
+
+delimiter ;|
+
+do fn1(100);
+
+--error ER_DUP_ENTRY
+select fn1(20);
+
+select * from t2;
+sync_slave_with_master;
+
+# check that this failed-in-the-middle replicated right:
+select * from t2;
+
+# ********************** PART 3 : TRIGGERS ***************
+
+connection con1;
+# now fails due to missing trigger grant (err 1142 i/o 1227) due to new
+# check in sql_trigger.cc (v1.44) by anozdrin on 2006/02/01 --azundris
+--error ER_TABLEACCESS_DENIED_ERROR
+create trigger trg before insert on t1 for each row set new.a= 10;
+
+connection master;
+delete from t1;
+# TODO: when triggers can contain an update, test that this update
+# does not go into binlog.
+# I'm not setting user vars in the trigger, because replication of user vars
+# would take care of propagating the user var's value to slave, so even if
+# the trigger was not executed on slave it would not be discovered.
+create trigger trg before insert on t1 for each row set new.a= 10;
+insert into t1 values (1);
+select * from t1;
+sync_slave_with_master;
+select * from t1;
+
+connection master;
+delete from t1;
+drop trigger trg;
+insert into t1 values (1);
+select * from t1;
+sync_slave_with_master;
+select * from t1;
+
+
+# ********************** PART 4 : RELATED FIXED BUGS ***************
+
+
+#
+# Test for bug #13969 "Routines which are replicated from master can't be
+# executed on slave".
+#
+connection master;
+create procedure foo()
+ not deterministic
+ reads sql data
+ select * from t1;
+sync_slave_with_master;
+# This should not fail
+call foo();
+connection master;
+drop procedure foo;
+sync_slave_with_master;
+
+
+# Clean up
+connection master;
+drop function fn1;
+drop database mysqltest1;
+drop user "zedjzlcsjhd"@127.0.0.1;
+use test;
+sync_slave_with_master;
+use test;
+
+#
+# Bug#14077 "Failure to replicate a stored function with a cursor":
+# verify that stored routines with cursors work on slave.
+#
+connection master;
+--disable_warnings
+drop function if exists f1;
+--enable_warnings
+delimiter |;
+create function f1() returns int reads sql data
+begin
+ declare var integer;
+ declare c cursor for select a from v1;
+ open c;
+ fetch c into var;
+ close c;
+ return var;
+end|
+delimiter ;|
+create view v1 as select 1 as a;
+create table t1 (a int);
+insert into t1 (a) values (f1());
+select * from t1;
+drop view v1;
+drop function f1;
+sync_slave_with_master;
+connection slave;
+select * from t1;
+
+#
+# Bug#16621 "INSERTs in Stored Procedures causes data corruption in the Binary
+# Log for 5.0.18"
+#
+
+# Prepare environment.
+
+connection master;
+
+--disable_warnings
+DROP PROCEDURE IF EXISTS p1;
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+# Test case.
+
+CREATE TABLE t1(col VARCHAR(10));
+
+CREATE PROCEDURE p1(arg VARCHAR(10))
+ INSERT INTO t1 VALUES(arg);
+
+CALL p1('test');
+
+SELECT * FROM t1;
+
+sync_slave_with_master;
+SELECT * FROM t1;
+
+# Cleanup
+connection master;
+DROP PROCEDURE p1;
+
+
+#
+# BUG#20438: CREATE statements for views, stored routines and triggers can be
+# not replicable.
+#
+
+--echo
+--echo ---> Test for BUG#20438
+
+# Prepare environment.
+
+--echo
+--echo ---> Preparing environment...
+--echo ---> connection: master
+--connection master
+
+--disable_warnings
+DROP PROCEDURE IF EXISTS p1;
+DROP FUNCTION IF EXISTS f1;
+--enable_warnings
+
+--echo
+--echo ---> Synchronizing slave with master...
+
+--save_master_pos
+--connection slave
+--sync_with_master
+
+--echo
+--echo ---> connection: master
+--connection master
+
+# Test.
+
+--echo
+--echo ---> Creating procedure...
+
+/*!50003 CREATE PROCEDURE p1() SET @a = 1 */;
+
+/*!50003 CREATE FUNCTION f1() RETURNS INT RETURN 0 */;
+
+--echo
+--echo ---> Checking on master...
+
+SHOW CREATE PROCEDURE p1;
+SHOW CREATE FUNCTION f1;
+
+--echo
+--echo ---> Synchronizing slave with master...
+
+--save_master_pos
+--connection slave
+--sync_with_master
+
+--echo ---> connection: master
+
+--echo
+--echo ---> Checking on slave...
+
+SHOW CREATE PROCEDURE p1;
+SHOW CREATE FUNCTION f1;
+
+# Cleanup.
+
+--echo
+--echo ---> connection: master
+--connection master
+
+--echo
+--echo ---> Cleaning up...
+
+DROP PROCEDURE p1;
+DROP FUNCTION f1;
+
+--save_master_pos
+--connection slave
+--sync_with_master
+--connection master
+
+
+# cleanup
+connection master;
+drop table t1;
+sync_slave_with_master;
+
+#
+# Bug22043: MySQL don't add "USE <DATABASE>" before "DROP PROCEDURE IF EXISTS"
+#
+
+connection master;
+--disable_warnings
+drop database if exists mysqltest;
+drop database if exists mysqltest2;
+--enable_warnings
+create database mysqltest;
+create database mysqltest2;
+use mysqltest2;
+create table t ( t integer );
+create procedure mysqltest.test() begin end;
+insert into t values ( 1 );
+--error ER_BAD_DB_ERROR
+create procedure `\\`.test() begin end;
+
+#
+# BUG#19725: Calls to stored function in other database are not
+# replicated correctly in some cases
+#
+
+connection master;
+delimiter |;
+create function f1 () returns int
+begin
+ insert into t values (1);
+ return 0;
+end|
+delimiter ;|
+sync_slave_with_master;
+# Let us test if we don't forget to binlog the function's database
+connection master;
+use mysqltest;
+set @a:= mysqltest2.f1();
+sync_slave_with_master;
+connection master;
+
+
+# Final inspection which verifies how all statements of this test file
+# were written to the binary log.
+--replace_column 2 # 5 #
+--replace_regex /table_id: [0-9]+/table_id: #/
+show binlog events in 'master-bin.000001' from 106;
+
+
+# Restore log_bin_trust_function_creators to its original value.
+# This is a cleanup for all parts above where we tested stored
+# functions and triggers.
+set global log_bin_trust_function_creators=0;
+connection master;
+set global log_bin_trust_function_creators=0;
+
+# Clean up
+drop database mysqltest;
+drop database mysqltest2;
+
+--echo End of 5.0 tests
+--echo End of 5.1 tests
+
diff --git a/mysql-test/suite/rpl/t/rpl_sp004.test b/mysql-test/suite/rpl/t/rpl_sp004.test
new file mode 100644
index 00000000000..967e7007c15
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_sp004.test
@@ -0,0 +1,97 @@
+#############################################################################
+# Original Author: JBM #
+# Original Date: Aug/14/2005 #
+#############################################################################
+# Test: This test contains two sp that create and drop tables, insert and #
+# updated data and uses the NOW() function. #
+#############################################################################
+
+
+# Includes
+-- source include/master-slave.inc
+
+
+# Begin clean up test section
+connection master;
+--disable_warnings
+DROP PROCEDURE IF EXISTS test.p1;
+DROP PROCEDURE IF EXISTS test.p2;
+DROP TABLE IF EXISTS test.t2;
+DROP TABLE IF EXISTS test.t1;
+DROP TABLE IF EXISTS test.t3;
+--enable_warnings
+# End of cleanup
+
+# Begin test section 1
+
+delimiter |;
+CREATE PROCEDURE test.p1()
+BEGIN
+ CREATE TABLE IF NOT EXISTS test.t1(a INT,PRIMARY KEY(a));
+ CREATE TABLE IF NOT EXISTS test.t2(a INT,PRIMARY KEY(a));
+ INSERT INTO test.t1 VALUES (4),(2),(1),(3);
+ UPDATE test.t1 SET a=a+4 WHERE a=4;
+ INSERT INTO test.t2 (a) SELECT t1.a FROM test.t1;
+ UPDATE test.t1 SET a=a+4 WHERE a=8;
+ CREATE TABLE IF NOT EXISTS test.t3(n MEDIUMINT NOT NULL AUTO_INCREMENT, f FLOAT, d DATETIME, PRIMARY KEY(n));
+END|
+CREATE PROCEDURE test.p2()
+BEGIN
+ DROP TABLE IF EXISTS test.t1;
+ DROP TABLE IF EXISTS test.t2;
+ INSERT INTO test.t3 VALUES(NULL,11111111.233333,NOW());
+END|
+delimiter ;|
+
+CALL test.p1();
+SELECT * FROM test.t1 ORDER BY a;
+SELECT * FROM test.t2 ORDER BY a;
+save_master_pos;
+connection slave;
+sync_with_master;
+SELECT * FROM test.t1 ORDER BY a;
+SELECT * FROM test.t2 ORDER BY a;
+
+connection master;
+CALL test.p2();
+USE test;
+SHOW TABLES;
+#SELECT * FROM test.t3;
+save_master_pos;
+connection slave;
+sync_with_master;
+USE test;
+SHOW TABLES;
+#SELECT * FROM test.t3;
+
+connection master;
+CALL test.p1();
+SELECT * FROM test.t1 ORDER BY a;
+SELECT * FROM test.t2 ORDER BY a;
+#SELECT * FROM test.t3;
+save_master_pos;
+connection slave;
+sync_with_master;
+SELECT * FROM test.t1 ORDER BY a;
+SELECT * FROM test.t2 ORDER BY a;
+#SELECT * FROM test.t3;
+
+--exec $MYSQL_DUMP --compact --order-by-primary --skip-extended-insert --no-create-info test > $MYSQLTEST_VARDIR/tmp/sp004_master.sql
+--exec $MYSQL_DUMP_SLAVE --compact --order-by-primary --skip-extended-insert --no-create-info test > $MYSQLTEST_VARDIR/tmp/sp004_slave.sql
+
+# Cleanup
+connection master;
+#show binlog events;
+DROP PROCEDURE IF EXISTS test.p1;
+DROP PROCEDURE IF EXISTS test.p2;
+DROP TABLE IF EXISTS test.t1;
+DROP TABLE IF EXISTS test.t2;
+DROP TABLE IF EXISTS test.t3;
+sync_slave_with_master;
+
+# If the test fails, you will need to diff the dumps to see why.
+
+diff_files $MYSQLTEST_VARDIR/tmp/sp004_master.sql $MYSQLTEST_VARDIR/tmp/sp004_slave.sql;
+
+
+# End of 5.0 test case
diff --git a/mysql-test/suite/rpl/t/rpl_sp_effects-master.opt b/mysql-test/suite/rpl/t/rpl_sp_effects-master.opt
new file mode 100644
index 00000000000..61dd7a6ad0e
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_sp_effects-master.opt
@@ -0,0 +1 @@
+--log_bin_trust_routine_creators=1
diff --git a/mysql-test/suite/rpl/t/rpl_sp_effects-slave.opt b/mysql-test/suite/rpl/t/rpl_sp_effects-slave.opt
new file mode 100644
index 00000000000..61dd7a6ad0e
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_sp_effects-slave.opt
@@ -0,0 +1 @@
+--log_bin_trust_routine_creators=1
diff --git a/mysql-test/suite/rpl/t/rpl_sp_effects.test b/mysql-test/suite/rpl/t/rpl_sp_effects.test
new file mode 100644
index 00000000000..027bfd69f36
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_sp_effects.test
@@ -0,0 +1,211 @@
+##########################################
+# Change Author: JBM
+# Change Date: 2006-05-02
+# Change: Added Order By for NDB testing
+##########################################
+
+# Test of replication of stored procedures (WL#2146 for MySQL 5.0)
+-- source include/master-slave.inc
+
+# ****************************************************************
+connection master;
+
+# cleanup
+--disable_warnings
+drop procedure if exists p1;
+drop procedure if exists p2;
+drop function if exists f1;
+drop table if exists t1,t2;
+drop view if exists v1;
+--enable_warnings
+create table t1 (a int);
+
+SET GLOBAL log_bin_trust_function_creators = 1;
+
+# 1. Test simple variables use.
+delimiter //;
+create procedure p1()
+begin
+ declare spv int default 0;
+ while spv < 5 do
+ insert into t1 values(spv+1);
+ set spv=spv+1;
+ end while;
+end//
+delimiter ;//
+
+call p1();
+
+sync_slave_with_master;
+connection slave;
+SELECT * FROM t1 ORDER BY a;
+connection master;
+SELECT * FROM t1 ORDER BY a;
+
+# 2. Test SP variable name
+delimiter //;
+create procedure p2()
+begin
+ declare a int default 4;
+ create table t2 as select a;
+end//
+delimiter ;//
+
+call p2();
+SELECT * FROM t2 ORDER BY a;
+sync_slave_with_master;
+connection slave;
+SELECT * FROM t2 ORDER BY a;
+
+connection master;
+drop procedure p1;
+drop procedure p2;
+drop table t2;
+
+# 3. Test FUNCTIONs in various places
+
+delimiter //;
+create function f1(x int) returns int
+begin
+ insert into t1 values(x);
+ return x+1;
+end//
+
+create procedure p1(a int, b int)
+begin
+ declare v int default f1(5);
+ if (f1(6)) then
+ select 'yes';
+ end if;
+ set v = f1(7);
+ while f1(8) < 1 do
+ select 'this cant be';
+ end while;
+
+end//
+delimiter ;//
+
+call p1(f1(1), f1(2));
+SELECT * FROM t1 ORDER BY a;
+
+create table t2(a int);
+insert into t2 values (10),(11);
+SELECT a,f1(a) FROM t2 ORDER BY a;
+
+# This shouldn't put separate 'call f1(3)' into binlog:
+insert into t2 select f1(3);
+SELECT 'master:',a FROM t1 ORDER BY a;
+
+sync_slave_with_master;
+connection slave;
+SELECT 'slave:',a FROM t1 ORDER BY a;
+
+connection master;
+drop procedure p1;
+delete from t1;
+delete from t2;
+
+# 4. VIEWs
+delete from t1;
+insert into t2 values(1),(2);
+create view v1 as select f1(a) as f from t2;
+select * from v1 order by f;
+SELECT 'master:',a FROM t1 ORDER BY a;
+
+sync_slave_with_master;
+connection slave;
+SELECT 'slave:',a FROM t1 ORDER BY a;
+
+connection master;
+drop view v1;
+delete from t1;
+
+# 5. Prepared statements.
+prepare s1 from 'select f1(?)';
+set @xx=123;
+execute s1 using @xx;
+SELECT 'master:',a FROM t1 ORDER BY a;
+
+sync_slave_with_master;
+connection slave;
+SELECT 'slave:',a FROM t1 ORDER BY a;
+
+connection master;
+delete from t1;
+
+# 5. Cursors.
+# t2 has (1),(2);
+delimiter //;
+create procedure p1(spv int)
+begin
+ declare c cursor for select f1(spv) from t2;
+ while (spv > 2) do
+ open c;
+ fetch c into spv;
+ close c;
+ set spv= spv - 10;
+ end while;
+end//
+delimiter ;//
+call p1(15);
+SELECT 'master:',a FROM t1 ORDER BY a;
+sync_slave_with_master;
+connection slave;
+SELECT 'slave:',a FROM t1 ORDER BY a;
+
+connection master;
+drop procedure p1;
+drop function f1;
+drop table t1,t2;
+
+# BUG#12637: User variables + SPs replication
+create table t1 (a int);
+delimiter //;
+create procedure p1()
+begin
+ insert into t1 values(@x);
+ set @x=@x+1;
+ insert into t1 values(@x);
+ if (f2()) then
+ insert into t1 values(1243);
+ end if;
+end//
+
+create function f2() returns int
+begin
+ insert into t1 values(@z);
+ set @z=@z+1;
+ insert into t1 values(@z);
+ return 0;
+end//
+
+create function f1() returns int
+begin
+ insert into t1 values(@y);
+ call p1();
+ return 0;
+end//
+
+delimiter ;//
+
+set @x=10;
+set @y=20;
+set @z=100;
+select f1();
+
+set @x=30;
+call p1();
+
+SELECT 'master', a FROM t1 ORDER BY a;
+sync_slave_with_master;
+connection slave;
+SELECT 'slave', a FROM t1 ORDER BY a;
+
+connection master;
+drop table t1;
+drop function f1;
+drop function f2;
+drop procedure p1;
+sync_slave_with_master;
+
+SET GLOBAL log_bin_trust_function_creators = 0;
diff --git a/mysql-test/suite/rpl/t/rpl_sporadic_master-master.opt b/mysql-test/suite/rpl/t/rpl_sporadic_master-master.opt
new file mode 100644
index 00000000000..6d5b66bed61
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_sporadic_master-master.opt
@@ -0,0 +1 @@
+--sporadic-binlog-dump-fail --max-binlog-dump-events=2
diff --git a/mysql-test/suite/rpl/t/rpl_sporadic_master.test b/mysql-test/suite/rpl/t/rpl_sporadic_master.test
new file mode 100644
index 00000000000..824f7abc9f5
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_sporadic_master.test
@@ -0,0 +1,29 @@
+#############################################################
+# 2006-02-07 By JBM added order by
+#############################################################
+# test to see if replication can continue when master sporadically fails on
+# COM_BINLOG_DUMP and additionally limits the number of events per dump
+
+source include/master-slave.inc;
+
+create table t2(n int);
+create table t1(n int not null auto_increment primary key);
+insert into t1 values (NULL),(NULL);
+truncate table t1;
+# We have to use 4 in the following to make this test work with all table types
+insert into t1 values (4),(NULL);
+sync_slave_with_master;
+stop slave;
+start slave;
+connection master;
+insert into t1 values (NULL),(NULL);
+flush logs;
+truncate table t1;
+insert into t1 values (10),(NULL),(NULL),(NULL),(NULL),(NULL);
+sync_slave_with_master;
+select * from t1 ORDER BY n;
+connection master;
+drop table t1,t2;
+sync_slave_with_master;
+
+# End of 4.1 tests
diff --git a/mysql-test/suite/rpl/t/rpl_ssl.test b/mysql-test/suite/rpl/t/rpl_ssl.test
new file mode 100644
index 00000000000..4bc07ee0622
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_ssl.test
@@ -0,0 +1,71 @@
+source include/have_ssl.inc;
+source include/master-slave.inc;
+
+# create a user for replication that requires ssl encryption
+connection master;
+grant replication slave on *.* to replssl@localhost require ssl;
+create table t1 (t int auto_increment, KEY(t));
+
+sync_slave_with_master;
+
+# Set slave to use SSL for connection to master
+stop slave;
+--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
+eval change master to
+ master_user='replssl',
+ master_password='',
+ master_ssl=1,
+ master_ssl_ca ='$MYSQL_TEST_DIR/std_data/cacert.pem',
+ master_ssl_cert='$MYSQL_TEST_DIR/std_data/client-cert.pem',
+ master_ssl_key='$MYSQL_TEST_DIR/std_data/client-key.pem';
+start slave;
+
+# Switch to master and insert one record, then sync it to slave
+connection master;
+insert into t1 values(1);
+sync_slave_with_master;
+
+# The record should now be on slave
+select * from t1;
+
+# The slave is synced and waiting/reading from master
+# SHOW SLAVE STATUS will show "Waiting for master to send event"
+--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR $MASTER_MYPORT MASTER_MYPORT
+--replace_column 1 # 7 # 8 # 9 # 22 # 23 # 33 # 35 # 36 #
+query_vertical show slave status;
+
+# Stop the slave, as reported in bug#21871 it would hang
+STOP SLAVE;
+
+select * from t1;
+
+# Do the same thing a number of times
+disable_query_log;
+let $i= 100;
+while ($i)
+{
+ start slave;
+ connection master;
+ insert into t1 values (NULL);
+ connection slave;
+ stop slave;
+ dec $i;
+}
+start slave;
+enable_query_log;
+connection master;
+# INSERT one more record to make sure
+# the sync has something to do
+insert into t1 values (NULL);
+sync_slave_with_master;
+--source include/wait_for_slave_to_start.inc
+--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR $MASTER_MYPORT MASTER_MYPORT
+--replace_column 1 # 7 # 8 # 9 # 22 # 23 # 33 # 35 # 36 #
+query_vertical show slave status;
+
+connection master;
+drop user replssl@localhost;
+drop table t1;
+sync_slave_with_master;
+
+--echo End of 5.0 tests
diff --git a/mysql-test/suite/rpl/t/rpl_ssl1.test b/mysql-test/suite/rpl/t/rpl_ssl1.test
new file mode 100644
index 00000000000..b660c3991dd
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_ssl1.test
@@ -0,0 +1,97 @@
+source include/have_ssl.inc;
+source include/master-slave.inc;
+
+# We don't test all types of ssl auth params here since it's a bit hard
+# until problems with OpenSSL 0.9.7 are unresolved
+
+# creating replication user for whom ssl auth is required
+# preparing playground
+connection master;
+grant replication slave on *.* to replssl@localhost require ssl;
+create table t1 (t int);
+save_master_pos;
+
+#syncing with master
+connection slave;
+sync_with_master;
+
+#trying to use this user without ssl
+stop slave;
+change master to master_user='replssl',master_password='';
+start slave;
+
+#showing that replication don't work
+connection master;
+insert into t1 values (1);
+#reasonable timeout for changes to propagate to slave
+sleep 3;
+connection slave;
+select * from t1;
+
+#showing that replication could work with ssl params
+stop slave;
+--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
+eval change master to master_ssl=1 , master_ssl_ca ='$MYSQL_TEST_DIR/std_data/cacert.pem', master_ssl_cert='$MYSQL_TEST_DIR/std_data/client-cert.pem', master_ssl_key='$MYSQL_TEST_DIR/std_data/client-key.pem';
+start slave;
+
+#avoiding unneeded sleeps
+connection master;
+save_master_pos;
+connection slave;
+sync_with_master;
+
+#checking that replication is ok
+select * from t1;
+
+#checking show slave status
+--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR $MASTER_MYPORT MASTER_MYPORT
+--replace_column 1 # 6 # 7 # 8 # 9 # 10 # 11 # 16 # 22 # 23 # 33 # 35 # 36 #
+query_vertical show slave status;
+
+#checking if replication works without ssl also performing clean up
+stop slave;
+change master to master_user='root',master_password='', master_ssl=0;
+start slave;
+connection master;
+drop user replssl@localhost;
+drop table t1;
+save_master_pos;
+connection slave;
+sync_with_master;
+--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR $MASTER_MYPORT MASTER_MYPORT
+--replace_column 1 # 6 # 7 # 8 # 9 # 10 # 11 # 16 # 22 # 23 # 33 # 35 # 36 #
+query_vertical show slave status;
+
+# End of 4.1 tests
+
+# Start replication with ssl_verify_server_cert turned on
+connection slave;
+stop slave;
+--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
+eval change master to
+ master_host="localhost",
+ master_ssl=1 ,
+ master_ssl_ca ='$MYSQL_TEST_DIR/std_data/cacert.pem',
+ master_ssl_cert='$MYSQL_TEST_DIR/std_data/client-cert.pem',
+ master_ssl_key='$MYSQL_TEST_DIR/std_data/client-key.pem',
+ master_ssl_verify_server_cert=1;
+start slave;
+
+connection master;
+create table t1 (t int);
+insert into t1 values (1);
+
+sync_slave_with_master;
+
+echo on slave;
+#checking that replication is ok
+select * from t1;
+
+#checking show slave status
+--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR $MASTER_MYPORT MASTER_MYPORT
+--replace_column 1 # 6 # 7 # 8 # 9 # 10 # 11 # 16 # 22 # 23 # 33 # 35 # 36 #
+query_vertical show slave status;
+
+connection master;
+drop table t1;
+sync_slave_with_master;
diff --git a/mysql-test/suite/rpl/t/rpl_start_stop_slave.test b/mysql-test/suite/rpl/t/rpl_start_stop_slave.test
new file mode 100644
index 00000000000..19988cf902a
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_start_stop_slave.test
@@ -0,0 +1,36 @@
+source include/master-slave.inc;
+
+#
+# Bug#6148 ()
+#
+connection slave;
+stop slave;
+
+# Let the master do lots of insertions
+connection master;
+create table t1(n int);
+let $1=5000;
+disable_query_log;
+while ($1)
+{
+ eval insert into t1 values($1);
+ dec $1;
+}
+enable_query_log;
+save_master_pos;
+
+connection slave;
+start slave;
+sleep 1;
+stop slave io_thread;
+start slave io_thread;
+sync_with_master;
+
+connection master;
+drop table t1;
+save_master_pos;
+
+connection slave;
+sync_with_master;
+
+# End of 4.1 tests
diff --git a/mysql-test/suite/rpl/t/rpl_stm_000001-slave.opt b/mysql-test/suite/rpl/t/rpl_stm_000001-slave.opt
new file mode 100644
index 00000000000..48457b17309
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_stm_000001-slave.opt
@@ -0,0 +1 @@
+--loose-innodb
diff --git a/mysql-test/suite/rpl/t/rpl_stm_000001.test b/mysql-test/suite/rpl/t/rpl_stm_000001.test
new file mode 100644
index 00000000000..aee067b2d4a
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_stm_000001.test
@@ -0,0 +1,2 @@
+let $engine_type=myisam;
+-- source extra/rpl_tests/rpl_stm_000001.test
diff --git a/mysql-test/suite/rpl/t/rpl_stm_EE_err2.test b/mysql-test/suite/rpl/t/rpl_stm_EE_err2.test
new file mode 100644
index 00000000000..face651b9a1
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_stm_EE_err2.test
@@ -0,0 +1,8 @@
+#############################
+# Author: JBM
+# Date: 2006-01-11
+# Purpose: Engine Wrapper for rpl_stm_EE_err2.test
+##############################
+-- source include/have_binlog_format_mixed_or_statement.inc
+let $engine_type=myisam;
+-- source extra/rpl_tests/rpl_stm_EE_err2.test
diff --git a/mysql-test/suite/rpl/t/rpl_stm_charset.test b/mysql-test/suite/rpl/t/rpl_stm_charset.test
new file mode 100644
index 00000000000..b103a47d78c
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_stm_charset.test
@@ -0,0 +1,2 @@
+let $engine_type=myisam;
+-- source extra/rpl_tests/rpl_stm_charset.test
diff --git a/mysql-test/suite/rpl/t/rpl_stm_flsh_tbls.test b/mysql-test/suite/rpl/t/rpl_stm_flsh_tbls.test
new file mode 100644
index 00000000000..a8a33d05e8b
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_stm_flsh_tbls.test
@@ -0,0 +1,8 @@
+# depends on the binlog output
+--source include/have_binlog_format_mixed_or_statement.inc
+
+let $rename_event_pos= 656;
+-- source extra/rpl_tests/rpl_flsh_tbls.test
+
+# End of 4.1 tests
+# Adding comment for force manual merge 5.0 -> wl1012. Delete me if needed.
diff --git a/mysql-test/suite/rpl/t/rpl_stm_insert_delayed.test b/mysql-test/suite/rpl/t/rpl_stm_insert_delayed.test
new file mode 100644
index 00000000000..d55e3a4da2c
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_stm_insert_delayed.test
@@ -0,0 +1,20 @@
+# we run first in statement-based then in mixed binlogging
+
+--source include/have_binlog_format_mixed_or_statement.inc
+--source include/master-slave.inc
+--source include/not_embedded.inc
+--source include/not_windows.inc
+
+connection master;
+set @old_global_binlog_format = @@global.binlog_format;
+
+let $binlog_format_statement=1;
+set @@global.binlog_format = statement;
+--source extra/rpl_tests/rpl_insert_delayed.test
+
+let $binlog_format_statement=0;
+set @@global.binlog_format = mixed;
+--source extra/rpl_tests/rpl_insert_delayed.test
+
+connection master;
+set @@global.binlog_format = @old_global_binlog_format;
diff --git a/mysql-test/suite/rpl/t/rpl_stm_log-master.opt b/mysql-test/suite/rpl/t/rpl_stm_log-master.opt
new file mode 100644
index 00000000000..cef79bc8585
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_stm_log-master.opt
@@ -0,0 +1 @@
+--force-restart
diff --git a/mysql-test/suite/rpl/t/rpl_stm_log-slave.opt b/mysql-test/suite/rpl/t/rpl_stm_log-slave.opt
new file mode 100644
index 00000000000..8b137891791
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_stm_log-slave.opt
@@ -0,0 +1 @@
+
diff --git a/mysql-test/suite/rpl/t/rpl_stm_log.test b/mysql-test/suite/rpl/t/rpl_stm_log.test
new file mode 100644
index 00000000000..2af9d7f85bc
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_stm_log.test
@@ -0,0 +1,9 @@
+# Requires statement logging
+-- source include/have_binlog_format_mixed_or_statement.inc
+-- source include/master-slave.inc
+let $engine_type=MyISAM;
+-- source extra/rpl_tests/rpl_log.test
+
+
+# End of 4.1 tests
+# Adding comment for force manual merge 5.0 -> wl1012: Delete me
diff --git a/mysql-test/suite/rpl/t/rpl_stm_max_relay_size.test b/mysql-test/suite/rpl/t/rpl_stm_max_relay_size.test
new file mode 100644
index 00000000000..950aa8b322a
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_stm_max_relay_size.test
@@ -0,0 +1,11 @@
+# Test of options max_binlog_size and max_relay_log_size and
+# how they act (if max_relay_log_size == 0, use max_binlog_size
+# for relay logs too).
+# Test of manual relay log rotation with FLUSH LOGS.
+
+# Requires statement logging
+-- source include/have_binlog_format_mixed_or_statement.inc
+-- source extra/rpl_tests/rpl_max_relay_size.test
+
+# End of 4.1 tests
+#
diff --git a/mysql-test/suite/rpl/t/rpl_stm_multi_query.test b/mysql-test/suite/rpl/t/rpl_stm_multi_query.test
new file mode 100644
index 00000000000..c39d1fad015
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_stm_multi_query.test
@@ -0,0 +1,12 @@
+# Test for BUG#8436: verify that a multi-query (i.e. one query
+# containing several queries (assuming client has
+# CLIENT_MULTI_STATEMENTS) will be binlogged ONE-query-per-event (not
+# one binlog event containing all queries)
+
+# Requires statement logging
+-- source include/have_binlog_format_mixed_or_statement.inc
+-- source extra/rpl_tests/rpl_multi_query.test
+
+
+# End of 4.1 tests
+#
diff --git a/mysql-test/suite/rpl/t/rpl_stm_mystery22.test b/mysql-test/suite/rpl/t/rpl_stm_mystery22.test
new file mode 100644
index 00000000000..017593fdfba
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_stm_mystery22.test
@@ -0,0 +1,66 @@
+################################
+# Change Author: JBM
+# Change Date: 2006-01-12
+# Change: Added back have stm binlog
+# and added requirments comments
+################################
+# test case to make slave thread get ahead by 22 bytes
+################################
+#REQUIREMENT: If there is a faked slave duplicate key insert
+#error and the slave is restarted, the replication should
+#proceed in a correct way.
+################################
+#REQUIREMENT: If there is a faked slave non-existing record
+#delete error and the slave is restarted, then the replication
+#should proceed in a correct way.
+#################################
+
+-- source include/have_binlog_format_mixed_or_statement.inc
+-- source include/master-slave.inc
+
+# first, cause a duplicate key problem on the slave
+create table t1(n int auto_increment primary key, s char(10));
+sync_slave_with_master;
+insert into t1 values (2,'old');
+connection master;
+insert into t1 values(NULL,'new');
+insert into t1 values(NULL,'new');
+save_master_pos;
+connection slave;
+# wait until the slave tries to run the query, fails and aborts slave thread
+wait_for_slave_to_stop;
+select * from t1 order by n;
+delete from t1 where n = 2;
+--disable_warnings
+start slave;
+--enable_warnings
+sync_with_master;
+#now the buggy slave would be confused on the offset but it can replicate
+#in order to make it break, we need to stop/start the slave one more time
+stop slave;
+connection master;
+# to be able to really confuse the slave, we need some non-auto-increment
+# events in the log
+create table t2(n int);
+drop table t2;
+insert into t1 values(NULL,'new');
+# what happens when we delete a row which does not exist on slave?
+set sql_log_bin=0;
+insert into t1 values(NULL,'new');
+set sql_log_bin=1;
+delete from t1 where n=4;
+save_master_pos;
+connection slave;
+--disable_warnings
+start slave;
+--enable_warnings
+#now the truth comes out - if the slave is buggy, it will never sync because
+#the slave thread is not able to read events
+sync_with_master;
+select * from t1 order by n;
+#clean up
+connection master;
+drop table t1;
+sync_slave_with_master;
+
+# End of 4.1 tests
diff --git a/mysql-test/suite/rpl/t/rpl_stm_no_op.test b/mysql-test/suite/rpl/t/rpl_stm_no_op.test
new file mode 100644
index 00000000000..66dc89bd712
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_stm_no_op.test
@@ -0,0 +1,93 @@
+# It's true only in statement-based replication that a statement which
+# updates no rows (UPDATE/DELETE) is binlogged; in row-based
+# replication, as we log modified rows, nothing is binlogged in this
+# case. So this test is meaningul only in statement-based (and if it was
+# enabled in row-based, it would fail as expected).
+
+-- source include/have_binlog_format_mixed_or_statement.inc
+
+source include/master-slave.inc;
+
+# see if DROP DATABASE is binlogged even if no effect
+connection slave;
+create database mysqltest;
+connection master;
+drop database if exists mysqltest;
+sync_slave_with_master;
+# can't read dir
+--replace_result "Errcode: 1" "Errcode: X" "Errcode: 2" "Errcode: X" \\ /
+--error 1049
+show tables from mysqltest;
+
+# see if DROP TABLE is binlogged even if no effect
+connection slave;
+create table t1 (a int);
+connection master;
+drop table if exists t1;
+sync_slave_with_master;
+# table does not exist
+--error 1146
+select * from t1;
+
+# see if single-table DELETE is binlogged even if no effect
+connection master;
+create table t1 (a int, b int);
+sync_slave_with_master;
+insert into t1 values(1,1);
+connection master;
+delete from t1;
+sync_slave_with_master;
+select * from t1;
+
+# see if single-table UPDATE is binlogged even if no effect
+insert into t1 values(1,1);
+connection master;
+insert into t1 values(2,1);
+update t1 set a=2;
+sync_slave_with_master;
+select * from t1;
+
+# End of 4.1 tests
+
+# see if multi-table UPDATE is binlogged even if no effect (BUG#13348)
+
+connection master;
+create table t2 (a int, b int);
+delete from t1;
+insert into t1 values(1,1);
+insert into t2 values(1,1);
+
+sync_slave_with_master;
+# force a difference to see if master's multi-UPDATE will correct it
+update t1 set a=2;
+
+connection master;
+UPDATE t1, t2 SET t1.a = t2.a;
+
+sync_slave_with_master;
+select * from t1;
+select * from t2;
+
+# See if multi-table DELETE is binlogged even if no effect
+
+connection master;
+delete from t1;
+delete from t2;
+
+sync_slave_with_master;
+# force a difference to see if master's multi-DELETE will correct it
+insert into t1 values(1,1);
+insert into t2 values(1,1);
+
+connection master;
+DELETE t1.*, t2.* from t1, t2;
+
+sync_slave_with_master;
+select * from t1;
+select * from t2;
+
+
+# cleanup
+connection master;
+drop table t1, t2;
+sync_slave_with_master;
diff --git a/mysql-test/suite/rpl/t/rpl_stm_reset_slave.test b/mysql-test/suite/rpl/t/rpl_stm_reset_slave.test
new file mode 100644
index 00000000000..6a99d4e1613
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_stm_reset_slave.test
@@ -0,0 +1,6 @@
+# TBF - difference in row level logging
+-- source include/have_binlog_format_mixed_or_statement.inc
+-- source extra/rpl_tests/rpl_reset_slave.test
+
+# End of 4.1 tests
+#
diff --git a/mysql-test/suite/rpl/t/rpl_stm_until.test b/mysql-test/suite/rpl/t/rpl_stm_until.test
new file mode 100644
index 00000000000..98e7e0e5eac
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_stm_until.test
@@ -0,0 +1,77 @@
+-- source include/have_binlog_format_mixed_or_statement.inc
+-- source include/master-slave.inc
+
+# Test is dependent on binlog positions
+
+# prepare version for substitutions
+let $VERSION=`select version()`;
+
+# stop slave before he will start replication also sync with master
+# for avoiding undetermenistic behaviour
+save_master_pos;
+connection slave;
+sync_with_master;
+stop slave;
+
+connection master;
+# create some events on master
+create table t1(n int not null auto_increment primary key);
+insert into t1 values (1),(2),(3),(4);
+drop table t1;
+create table t2(n int not null auto_increment primary key);
+insert into t2 values (1),(2);
+insert into t2 values (3),(4);
+drop table t2;
+
+# try to replicate all queries until drop of t1
+connection slave;
+start slave until master_log_file='master-bin.000001', master_log_pos=323;
+--source include/wait_for_slave_sql_to_stop.inc
+# here table should be still not deleted
+select * from t1;
+source include/show_slave_status.inc;
+
+# this should fail right after start
+start slave until master_log_file='master-no-such-bin.000001', master_log_pos=291;
+--source include/wait_for_slave_sql_to_stop.inc
+# again this table should be still not deleted
+select * from t1;
+source include/show_slave_status.inc;
+
+# try replicate all up to and not including the second insert to t2;
+start slave until relay_log_file='slave-relay-bin.000004', relay_log_pos=746;
+--source include/wait_for_slave_sql_to_stop.inc
+select * from t2;
+source include/show_slave_status.inc;
+
+# clean up
+start slave;
+connection master;
+save_master_pos;
+connection slave;
+sync_with_master;
+stop slave;
+
+# this should stop immediately as we are already there
+start slave until master_log_file='master-bin.000001', master_log_pos=776;
+--source include/wait_for_slave_sql_to_stop.inc
+# here the sql slave thread should be stopped
+--replace_result bin.000005 bin.000004 bin.000006 bin.000004 bin.000007 bin.000004
+source include/show_slave_status.inc;
+
+#testing various error conditions
+--error 1277
+start slave until master_log_file='master-bin', master_log_pos=561;
+--error 1277
+start slave until master_log_file='master-bin.000001', master_log_pos=561, relay_log_pos=12;
+--error 1277
+start slave until master_log_file='master-bin.000001';
+--error 1277
+start slave until relay_log_file='slave-relay-bin.000002';
+--error 1277
+start slave until relay_log_file='slave-relay-bin.000002', master_log_pos=561;
+# Warning should be given for second command
+start slave sql_thread;
+start slave until master_log_file='master-bin.000001', master_log_pos=776;
+
+# End of 4.1 tests
diff --git a/mysql-test/suite/rpl/t/rpl_switch_stm_row_mixed.test b/mysql-test/suite/rpl/t/rpl_switch_stm_row_mixed.test
new file mode 100644
index 00000000000..b0012827db8
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_switch_stm_row_mixed.test
@@ -0,0 +1,568 @@
+#
+# rpl_switch_stm_row_mixed tests covers
+#
+# - switching explicitly between STATEMENT, ROW, and MIXED binlog format
+# showing when it is possible and when not.
+# - switching from MIXED to RBR implicitly listing all use cases,
+# e.g a query invokes UUID(), thereafter to serve as the definition
+# of MIXED binlog format
+# - correctness of execution
+
+
+-- source include/not_ndb_default.inc
+-- source include/master-slave.inc
+
+connection master;
+--disable_warnings
+drop database if exists mysqltest1;
+create database mysqltest1;
+--enable_warnings
+use mysqltest1;
+
+# Save binlog format
+set @my_binlog_format= @@global.binlog_format;
+
+# play with switching
+set session binlog_format=mixed;
+show session variables like "binlog_format%";
+set session binlog_format=statement;
+show session variables like "binlog_format%";
+set session binlog_format=row;
+show session variables like "binlog_format%";
+
+set global binlog_format=DEFAULT;
+show global variables like "binlog_format%";
+set global binlog_format=MIXED;
+show global variables like "binlog_format%";
+set global binlog_format=STATEMENT;
+show global variables like "binlog_format%";
+set global binlog_format=ROW;
+show global variables like "binlog_format%";
+show session variables like "binlog_format%";
+select @@global.binlog_format, @@session.binlog_format;
+
+CREATE TABLE t1 (a varchar(100));
+
+prepare stmt1 from 'insert into t1 select concat(UUID(),?)';
+set @string="emergency_1_";
+insert into t1 values("work_2_");
+execute stmt1 using @string;
+deallocate prepare stmt1;
+
+prepare stmt1 from 'insert into t1 select ?';
+insert into t1 values(concat(UUID(),"work_3_"));
+execute stmt1 using @string;
+deallocate prepare stmt1;
+
+insert into t1 values(concat("for_4_",UUID()));
+insert into t1 select "yesterday_5_";
+
+# verify that temp tables prevent a switch to SBR
+create temporary table tmp(a char(100));
+insert into tmp values("see_6_");
+--error ER_TEMP_TABLE_PREVENTS_SWITCH_OUT_OF_RBR
+set binlog_format=statement;
+insert into t1 select * from tmp;
+drop temporary table tmp;
+
+# Now we go to SBR
+set binlog_format=statement;
+show global variables like "binlog_format%";
+show session variables like "binlog_format%";
+select @@global.binlog_format, @@session.binlog_format;
+set global binlog_format=statement;
+show global variables like "binlog_format%";
+show session variables like "binlog_format%";
+select @@global.binlog_format, @@session.binlog_format;
+
+prepare stmt1 from 'insert into t1 select ?';
+set @string="emergency_7_";
+insert into t1 values("work_8_");
+execute stmt1 using @string;
+deallocate prepare stmt1;
+
+prepare stmt1 from 'insert into t1 select ?';
+insert into t1 values("work_9_");
+execute stmt1 using @string;
+deallocate prepare stmt1;
+
+insert into t1 values("for_10_");
+insert into t1 select "yesterday_11_";
+
+# test statement (is not default after wl#3368)
+set binlog_format=statement;
+select @@global.binlog_format, @@session.binlog_format;
+set global binlog_format=statement;
+select @@global.binlog_format, @@session.binlog_format;
+
+prepare stmt1 from 'insert into t1 select ?';
+set @string="emergency_12_";
+insert into t1 values("work_13_");
+execute stmt1 using @string;
+deallocate prepare stmt1;
+
+prepare stmt1 from 'insert into t1 select ?';
+insert into t1 values("work_14_");
+execute stmt1 using @string;
+deallocate prepare stmt1;
+
+insert into t1 values("for_15_");
+insert into t1 select "yesterday_16_";
+
+# and now the mixed mode
+
+set global binlog_format=mixed;
+select @@global.binlog_format, @@session.binlog_format;
+set binlog_format=default;
+select @@global.binlog_format, @@session.binlog_format;
+
+prepare stmt1 from 'insert into t1 select concat(UUID(),?)';
+set @string="emergency_17_";
+insert into t1 values("work_18_");
+execute stmt1 using @string;
+deallocate prepare stmt1;
+
+prepare stmt1 from 'insert into t1 select ?';
+insert into t1 values(concat(UUID(),"work_19_"));
+execute stmt1 using @string;
+deallocate prepare stmt1;
+
+insert into t1 values(concat("for_20_",UUID()));
+insert into t1 select "yesterday_21_";
+
+prepare stmt1 from 'insert into t1 select ?';
+insert into t1 values(concat(UUID(),"work_22_"));
+execute stmt1 using @string;
+deallocate prepare stmt1;
+
+insert into t1 values(concat("for_23_",UUID()));
+insert into t1 select "yesterday_24_";
+
+# Test of CREATE TABLE SELECT
+
+create table t2 select rpad(UUID(),100,' ');
+create table t3 select 1 union select UUID();
+create table t4 select * from t1 where 3 in (select 1 union select 2 union select UUID() union select 3);
+create table t5 select * from t1 where 3 in (select 1 union select 2 union select curdate() union select 3);
+# what if UUID() is first:
+insert into t5 select UUID() from t1 where 3 in (select 1 union select 2 union select 3 union select * from t4);
+
+# inside a stored procedure
+
+delimiter |;
+create procedure foo()
+begin
+insert into t1 values("work_25_");
+insert into t1 values(concat("for_26_",UUID()));
+insert into t1 select "yesterday_27_";
+end|
+create procedure foo2()
+begin
+insert into t1 values(concat("emergency_28_",UUID()));
+insert into t1 values("work_29_");
+insert into t1 values(concat("for_30_",UUID()));
+set session binlog_format=row; # accepted for stored procs
+insert into t1 values("more work_31_");
+set session binlog_format=mixed;
+end|
+create function foo3() returns bigint unsigned
+begin
+ set session binlog_format=row; # rejected for stored funcs
+ insert into t1 values("alarm");
+ return 100;
+end|
+create procedure foo4(x varchar(100))
+begin
+insert into t1 values(concat("work_250_",x));
+insert into t1 select "yesterday_270_";
+end|
+delimiter ;|
+call foo();
+call foo2();
+call foo4("hello");
+call foo4(UUID());
+call foo4("world");
+
+# test that can't SET in a stored function
+--error ER_STORED_FUNCTION_PREVENTS_SWITCH_BINLOG_FORMAT
+select foo3();
+select * from t1 where a="alarm";
+
+# Tests of stored functions/triggers/views for BUG#20930 "Mixed
+# binlogging mode does not work with stored functions, triggers,
+# views"
+
+# Function which calls procedure
+drop function foo3;
+delimiter |;
+create function foo3() returns bigint unsigned
+begin
+ insert into t1 values("foo3_32_");
+ call foo();
+ return 100;
+end|
+delimiter ;|
+insert into t2 select foo3();
+
+prepare stmt1 from 'insert into t2 select foo3()';
+execute stmt1;
+execute stmt1;
+deallocate prepare stmt1;
+
+# Test if stored function calls stored function which calls procedure
+# which requires row-based.
+
+delimiter |;
+create function foo4() returns bigint unsigned
+begin
+ insert into t2 select foo3();
+ return 100;
+end|
+delimiter ;|
+select foo4();
+
+prepare stmt1 from 'select foo4()';
+execute stmt1;
+execute stmt1;
+deallocate prepare stmt1;
+
+# A simple stored function
+delimiter |;
+create function foo5() returns bigint unsigned
+begin
+ insert into t2 select UUID();
+ return 100;
+end|
+delimiter ;|
+select foo5();
+
+prepare stmt1 from 'select foo5()';
+execute stmt1;
+execute stmt1;
+deallocate prepare stmt1;
+
+# A simple stored function where UUID() is in the argument
+delimiter |;
+create function foo6(x varchar(100)) returns bigint unsigned
+begin
+ insert into t2 select x;
+ return 100;
+end|
+delimiter ;|
+select foo6("foo6_1_");
+select foo6(concat("foo6_2_",UUID()));
+
+prepare stmt1 from 'select foo6(concat("foo6_3_",UUID()))';
+execute stmt1;
+execute stmt1;
+deallocate prepare stmt1;
+
+
+# Test of views using UUID()
+
+create view v1 as select uuid();
+create table t11 (data varchar(255));
+insert into t11 select * from v1;
+# Test of querying INFORMATION_SCHEMA which parses the view's body,
+# to verify that it binlogs statement-based (is not polluted by
+# the parsing of the view's body).
+insert into t11 select TABLE_NAME from INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA='mysqltest1' and TABLE_NAME IN ('v1','t11');
+prepare stmt1 from "insert into t11 select TABLE_NAME from INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA='mysqltest1' and TABLE_NAME IN ('v1','t11')";
+execute stmt1;
+execute stmt1;
+deallocate prepare stmt1;
+
+# Test of triggers with UUID()
+delimiter |;
+create trigger t11_bi before insert on t11 for each row
+begin
+ set NEW.data = concat(NEW.data,UUID());
+end|
+delimiter ;|
+insert into t11 values("try_560_");
+
+# Test that INSERT DELAYED works in mixed mode (BUG#20649)
+insert delayed into t2 values("delay_1_");
+insert delayed into t2 values(concat("delay_2_",UUID()));
+insert delayed into t2 values("delay_6_");
+
+# Test for BUG#20633 (INSERT DELAYED RAND()/user_variable does not
+# replicate fine in statement-based ; we test that in mixed mode it
+# works).
+insert delayed into t2 values(rand());
+set @a=2.345;
+insert delayed into t2 values(@a);
+
+sleep 4; # time for the delayed inserts to reach disk
+
+# If you want to do manual testing of the mixed mode regarding UDFs (not
+# testable automatically as quite platform- and compiler-dependent),
+# you just need to set the variable below to 1, and to
+# "make udf_example.so" in sql/, and to copy sql/udf_example.so to
+# MYSQL_TEST_DIR/lib/mysql.
+let $you_want_to_test_UDF=0;
+if ($you_want_to_test_UDF)
+{
+ CREATE FUNCTION metaphon RETURNS STRING SONAME 'udf_example.so';
+ prepare stmt1 from 'insert into t1 select metaphon(?)';
+ set @string="emergency_133_";
+ insert into t1 values("work_134_");
+ execute stmt1 using @string;
+ deallocate prepare stmt1;
+ prepare stmt1 from 'insert into t1 select ?';
+ insert into t1 values(metaphon("work_135_"));
+ execute stmt1 using @string;
+ deallocate prepare stmt1;
+ insert into t1 values(metaphon("for_136_"));
+ insert into t1 select "yesterday_137_";
+ create table t6 select metaphon("for_138_");
+ create table t7 select 1 union select metaphon("for_139_");
+ create table t8 select * from t1 where 3 in (select 1 union select 2 union select metaphon("for_140_") union select 3);
+ create table t9 select * from t1 where 3 in (select 1 union select 2 union select curdate() union select 3);
+}
+
+create table t20 select * from t1; # save for comparing later
+create table t21 select * from t2;
+create table t22 select * from t3;
+drop table t1,t2,t3;
+
+# This tests the fix to
+# BUG#19630 stored function inserting into two auto_increment breaks statement-based binlog
+# We verify that under the mixed binlog mode, a stored function
+# modifying at least two tables having an auto_increment column,
+# is binlogged row-based. Indeed in statement-based binlogging,
+# only the auto_increment value generated for the first table
+# is recorded in the binlog, the value generated for the 2nd table
+# lacking.
+
+create table t1 (a int primary key auto_increment, b varchar(100));
+create table t2 (a int primary key auto_increment, b varchar(100));
+create table t3 (b varchar(100));
+delimiter |;
+create function f (x varchar(100)) returns int deterministic
+begin
+ insert into t1 values(null,x);
+ insert into t2 values(null,x);
+ return 1;
+end|
+delimiter ;|
+select f("try_41_");
+# Two operations which compensate each other except that their net
+# effect is that they advance the auto_increment counter of t2 on slave:
+sync_slave_with_master;
+use mysqltest1;
+insert into t2 values(2,null),(3,null),(4,null);
+delete from t2 where a>=2;
+
+connection master;
+# this is the call which didn't replicate well
+select f("try_42_");
+sync_slave_with_master;
+
+# now use prepared statement and test again, just to see that the RBB
+# mode isn't set at PREPARE but at EXECUTE.
+
+insert into t2 values(3,null),(4,null);
+delete from t2 where a>=3;
+
+connection master;
+prepare stmt1 from 'select f(?)';
+set @string="try_43_";
+insert into t1 values(null,"try_44_"); # should be SBB
+execute stmt1 using @string; # should be RBB
+deallocate prepare stmt1;
+sync_slave_with_master;
+
+# verify that if only one table has auto_inc, it does not trigger RBB
+# (we'll check in binlog further below)
+
+connection master;
+create table t12 select * from t1; # save for comparing later
+drop table t1;
+create table t1 (a int, b varchar(100), key(a));
+select f("try_45_");
+
+# restore table's key
+create table t13 select * from t1;
+drop table t1;
+create table t1 (a int primary key auto_increment, b varchar(100));
+
+# now test if it's two functions, each of them inserts in one table
+
+drop function f;
+# we need a unique key to have sorting of rows by mysqldump
+create table t14 (unique (a)) select * from t2;
+truncate table t2;
+delimiter |;
+create function f1 (x varchar(100)) returns int deterministic
+begin
+ insert into t1 values(null,x);
+ return 1;
+end|
+create function f2 (x varchar(100)) returns int deterministic
+begin
+ insert into t2 values(null,x);
+ return 1;
+end|
+delimiter ;|
+select f1("try_46_"),f2("try_47_");
+
+sync_slave_with_master;
+insert into t2 values(2,null),(3,null),(4,null);
+delete from t2 where a>=2;
+
+connection master;
+# Test with SELECT and INSERT
+select f1("try_48_"),f2("try_49_");
+insert into t3 values(concat("try_50_",f1("try_51_"),f2("try_52_")));
+sync_slave_with_master;
+
+# verify that if f2 does only read on an auto_inc table, this does not
+# switch to RBB
+connection master;
+drop function f2;
+delimiter |;
+create function f2 (x varchar(100)) returns int deterministic
+begin
+ declare y int;
+ insert into t1 values(null,x);
+ set y = (select count(*) from t2);
+ return y;
+end|
+delimiter ;|
+select f1("try_53_"),f2("try_54_");
+sync_slave_with_master;
+
+# And now, a normal statement with a trigger (no stored functions)
+
+connection master;
+drop function f2;
+delimiter |;
+create trigger t1_bi before insert on t1 for each row
+begin
+ insert into t2 values(null,"try_55_");
+end|
+delimiter ;|
+insert into t1 values(null,"try_56_");
+# and now remove one auto_increment and verify SBB
+alter table t1 modify a int, drop primary key;
+insert into t1 values(null,"try_57_");
+sync_slave_with_master;
+
+# Test for BUG#20499 "mixed mode with temporary table breaks binlog"
+# Slave used to have only 2 rows instead of 3.
+connection master;
+CREATE TEMPORARY TABLE t15 SELECT UUID();
+create table t16 like t15;
+INSERT INTO t16 SELECT * FROM t15;
+# we'll verify that this one is done RBB
+insert into t16 values("try_65_");
+drop table t15;
+# we'll verify that this one is done SBB
+insert into t16 values("try_66_");
+sync_slave_with_master;
+
+# and now compare:
+
+connection master;
+
+# first check that data on master is sensible
+select count(*) from t1;
+select count(*) from t2;
+select count(*) from t3;
+select count(*) from t4;
+select count(*) from t5;
+select count(*) from t11;
+select count(*) from t20;
+select count(*) from t21;
+select count(*) from t22;
+select count(*) from t12;
+select count(*) from t13;
+select count(*) from t14;
+select count(*) from t16;
+if ($you_want_to_test_UDF)
+{
+ select count(*) from t6;
+ select count(*) from t7;
+ select count(*) from t8;
+ select count(*) from t9;
+}
+
+sync_slave_with_master;
+
+#
+# Bug#20863 If binlog format is changed between update and unlock of
+# tables, wrong binlog
+#
+
+connection master;
+DROP TABLE IF EXISTS t11;
+SET SESSION BINLOG_FORMAT=STATEMENT;
+CREATE TABLE t11 (song VARCHAR(255));
+LOCK TABLES t11 WRITE;
+SET SESSION BINLOG_FORMAT=ROW;
+INSERT INTO t11 VALUES('Several Species of Small Furry Animals Gathered Together in a Cave and Grooving With a Pict');
+SET SESSION BINLOG_FORMAT=STATEMENT;
+INSERT INTO t11 VALUES('Careful With That Axe, Eugene');
+UNLOCK TABLES;
+
+--query_vertical SELECT * FROM t11
+sync_slave_with_master;
+USE mysqltest1;
+--query_vertical SELECT * FROM t11
+
+connection master;
+DROP TABLE IF EXISTS t12;
+SET SESSION BINLOG_FORMAT=MIXED;
+CREATE TABLE t12 (data LONG);
+LOCK TABLES t12 WRITE;
+INSERT INTO t12 VALUES(UUID());
+UNLOCK TABLES;
+
+source include/show_binlog_events.inc;
+sync_slave_with_master;
+
+# as we're using UUID we don't SELECT but use "diff" like in rpl_row_UUID
+--exec $MYSQL_DUMP --compact --order-by-primary --skip-extended-insert --no-create-info mysqltest1 > $MYSQLTEST_VARDIR/tmp/rpl_switch_stm_row_mixed_master.sql
+--exec $MYSQL_DUMP_SLAVE --compact --order-by-primary --skip-extended-insert --no-create-info mysqltest1 > $MYSQLTEST_VARDIR/tmp/rpl_switch_stm_row_mixed_slave.sql
+
+# Let's compare. Note: If they match test will pass, if they do not match
+# the test will show that the diff statement failed and not reject file
+# will be created. You will need to go to the mysql-test dir and diff
+# the files your self to see what is not matching
+
+diff_files $MYSQLTEST_VARDIR/tmp/rpl_switch_stm_row_mixed_master.sql $MYSQLTEST_VARDIR/tmp/rpl_switch_stm_row_mixed_slave.sql;
+
+connection master;
+source include/show_binlog_events.inc;
+
+# Now test that mysqlbinlog works fine on a binlog generated by the
+# mixed mode
+
+# BUG#11312 "DELIMITER is not written to the binary log that causes
+# syntax error" makes that mysqlbinlog will fail if we pass it the
+# text of queries; this forces us to use --base64-output here.
+
+# BUG#20929 "BINLOG command causes invalid free plus assertion
+# failure" makes mysqld segfault when receiving --base64-output
+
+# So I can't enable this piece of test
+# SIGH
+
+if ($enable_when_11312_or_20929_fixed)
+{
+--exec $MYSQL_BINLOG --base64-output $MYSQLTEST_VARDIR/log/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/mysqlbinlog_mixed.sql
+drop database mysqltest1;
+--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/mysqlbinlog_mixed.sql
+--exec $MYSQL_DUMP --compact --order-by-primary --skip-extended-insert --no-create-info mysqltest1 > $MYSQLTEST_VARDIR/tmp/rpl_switch_stm_row_mixed_master.sql
+# the old mysqldump output on slave is the same as what it was on
+# master before restoring on master.
+diff_files $MYSQLTEST_VARDIR/tmp/rpl_switch_stm_row_mixed_master.sql $MYSQLTEST_VARDIR/tmp/rpl_switch_stm_row_mixed_slave.sql;
+}
+
+drop database mysqltest1;
+sync_slave_with_master;
+
+connection master;
+# Restore binlog format setting
+set global binlog_format =@my_binlog_format;
diff --git a/mysql-test/suite/rpl/t/rpl_temp_table.test b/mysql-test/suite/rpl/t/rpl_temp_table.test
new file mode 100644
index 00000000000..9b73961aeea
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_temp_table.test
@@ -0,0 +1,59 @@
+# drop table t1 t2 t3 are included int master-slave.inc
+# meaningful only in statement-based:
+
+-- source include/have_binlog_format_mixed_or_statement.inc
+-- source include/master-slave.inc
+
+
+create table t2 (n int, PRIMARY KEY(n));
+create temporary table t1 (n int);
+create temporary table t3 (n int not null);
+
+insert into t1 values(1),(2),(3),(100),(25),(26),(200),(300);
+insert into t2 select * from t1;
+alter table t3 add primary key(n);
+
+flush logs;
+insert into t3 values (1010);
+insert into t2 select * from t3;
+
+drop table if exists t3;
+insert into t2 values (1012);
+
+connection master1;
+create temporary table t1 (n int);
+insert into t1 values (4),(5);
+insert into t2 select * from t1;
+
+save_master_pos;
+disconnect master;
+
+connection slave;
+#add 1 to the saved position, so we will catch drop table on disconnect
+#for sure
+sync_with_master 1;
+
+connection master1;
+insert into t2 values(61);
+
+save_master_pos;
+disconnect master1;
+
+connection slave;
+#same trick - make sure we catch drop of temporary table on disconnect
+sync_with_master 1;
+
+select * from t2;
+select count(*) from t2;
+select sum(n) from t2;
+show status like 'Slave_open_temp_tables';
+
+#
+# Clean up
+#
+connect (master2,localhost,root,,);
+connection master2;
+drop table if exists t1,t2;
+save_master_pos;
+connection slave;
+sync_with_master;
diff --git a/mysql-test/suite/rpl/t/rpl_temporary.test b/mysql-test/suite/rpl/t/rpl_temporary.test
new file mode 100644
index 00000000000..09b8b83f25f
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_temporary.test
@@ -0,0 +1,215 @@
+# Test need anonymous user when connection are made as "zedjzlcsjhd"
+source include/add_anonymous_users.inc;
+
+-- source include/master-slave.inc
+
+# Clean up old slave's binlogs.
+# The slave is started with --log-slave-updates
+# and this test does SHOW BINLOG EVENTS on the slave's
+# binlog. But previous tests can influence the current test's
+# binlog (e.g. a temporary table in the previous test has not
+# been explicitly deleted, or it has but the slave hasn't had
+# enough time to catch it before STOP SLAVE,
+# and at the beginning of the current
+# test the slave immediately writes DROP TEMPORARY TABLE this_old_table).
+# We wait for the slave to have written all he wants to the binlog
+# (otherwise RESET MASTER may come too early).
+save_master_pos;
+connection slave;
+sync_with_master;
+reset master;
+connection master;
+
+connect (con1,localhost,root,,);
+connect (con2,localhost,root,,);
+# We want to connect as an unprivileged user. But if we use user="" then this
+# will pick the Unix login, which will cause problems if you're running the test
+# as root.
+connect (con3,localhost,zedjzlcsjhd,,);
+
+# We are going to use SET PSEUDO_THREAD_ID in this test;
+# check that it requires the SUPER privilege.
+
+connection con3;
+SET @save_select_limit=@@session.sql_select_limit;
+--error 1227
+SET @@session.sql_select_limit=10, @@session.pseudo_thread_id=100;
+SELECT @@session.sql_select_limit = @save_select_limit; #shouldn't have changed
+# While we are here we also test that SQL_LOG_BIN can't be set
+--error 1227
+SET @@session.sql_select_limit=10, @@session.sql_log_bin=0;
+SELECT @@session.sql_select_limit = @save_select_limit; #shouldn't have changed
+# Now as root, to be sure it works
+connection con2;
+SET @@session.pseudo_thread_id=100;
+SET @@session.pseudo_thread_id=connection_id();
+SET @@session.sql_log_bin=0;
+SET @@session.sql_log_bin=1;
+
+connection con3;
+let $VERSION=`select version()`;
+
+--disable_warnings
+drop table if exists t1,t2;
+--enable_warnings
+
+create table t1(f int);
+create table t2(f int);
+insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
+
+connection con1;
+create temporary table t3(f int);
+insert into t3 select * from t1 where f<6;
+sleep 1;
+
+connection con2;
+create temporary table t3(f int);
+sleep 1;
+
+connection con1;
+insert into t2 select count(*) from t3;
+sleep 1;
+
+connection con2;
+insert into t3 select * from t1 where f>=4;
+sleep 1;
+
+connection con1;
+drop temporary table t3;
+sleep 1;
+
+connection con2;
+insert into t2 select count(*) from t3;
+drop temporary table t3;
+
+select * from t2 ORDER BY f;
+
+# Commented out 8/30/2005 to make compatable with both sbr and rbr
+#--replace_result $VERSION VERSION
+#--replace_column 2 # 5 #
+#show binlog events;
+
+drop table t1, t2;
+
+use test;
+SET TIMESTAMP=1040323920;
+create table t1(f int);
+SET TIMESTAMP=1040323931;
+create table t2(f int);
+SET TIMESTAMP=1040323938;
+insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
+
+SET TIMESTAMP=1040323945;
+SET @@session.pseudo_thread_id=1;
+create temporary table t3(f int);
+SET TIMESTAMP=1040323952;
+SET @@session.pseudo_thread_id=1;
+insert into t3 select * from t1 where f<6;
+SET TIMESTAMP=1040324145;
+SET @@session.pseudo_thread_id=2;
+create temporary table t3(f int);
+SET TIMESTAMP=1040324186;
+SET @@session.pseudo_thread_id=1;
+insert into t2 select count(*) from t3;
+SET TIMESTAMP=1040324200;
+SET @@session.pseudo_thread_id=2;
+insert into t3 select * from t1 where f>=4;
+SET TIMESTAMP=1040324211;
+SET @@session.pseudo_thread_id=1;
+drop temporary table t3;
+SET TIMESTAMP=1040324219;
+SET @@session.pseudo_thread_id=2;
+insert into t2 select count(*) from t3;
+SET TIMESTAMP=1040324224;
+SET @@session.pseudo_thread_id=2;
+drop temporary table t3;
+
+select * from t2 ORDER BY f;
+drop table t1,t2;
+
+# Create last a temporary table that is not dropped at end to ensure that we
+# don't get any memory leaks for this
+
+create temporary table t3 (f int);
+sync_with_master;
+
+# The server will now close done
+
+#
+# Bug#17284 erroneous temp table cleanup on slave
+#
+
+connection master;
+create temporary table t4 (f int);
+create table t5 (f int);
+sync_with_master;
+# find dumper's $id
+select id from information_schema.processlist where command='Binlog Dump' into @id;
+kill @id; # to stimulate reconnection by slave w/o timeout
+insert into t5 select * from t4;
+save_master_pos;
+
+connection slave;
+sync_with_master;
+select * from t5 /* must be 1 after reconnection */;
+
+connection master;
+drop temporary table t4;
+drop table t5;
+
+#
+# BUG#17263 incorrect generation DROP temp tables
+# Temporary tables of connection are dropped in batches
+# where a batch correspond to pseudo_thread_id
+# value was set up at the moment of temp table creation
+#
+connection con1;
+set @@session.pseudo_thread_id=100;
+create temporary table t101 (id int);
+create temporary table t102 (id int);
+set @@session.pseudo_thread_id=200;
+create temporary table t201 (id int);
+create temporary table `t``201` (id int);
+# emulate internal temp table not to come to binlog
+create temporary table `#sql_not_user_table202` (id int);
+set @@session.pseudo_thread_id=300;
+create temporary table t301 (id int);
+create temporary table t302 (id int);
+create temporary table `#sql_not_user_table303` (id int);
+disconnect con1;
+
+#now do something to show that slave is ok after DROP temp tables
+connection master;
+create table t1(f int);
+insert into t1 values (1);
+
+sync_slave_with_master;
+#connection slave;
+select * from t1 /* must be 1 */;
+
+connection master;
+drop table t1;
+
+#
+#14157: utf8 encoding in binlog without set character_set_client
+#
+--write_file $MYSQLTEST_VARDIR/tmp/bug14157.sql
+create table t1 (a int);
+set names latin1;
+create temporary table `äöüÄÖÜ` (a int);
+insert into `äöüÄÖÜ` values (1);
+insert into t1 select * from `äöüÄÖÜ`
+EOF
+--exec $MYSQL --character-sets-dir=../sql/share/charsets/ --default-character-set=latin1 test < $MYSQLTEST_VARDIR/tmp/bug14157.sql
+
+sync_slave_with_master;
+#connection slave;
+select * from t1;
+
+connection master;
+drop table t1;
+
+# Delete the anonymous users
+source include/delete_anonymous_users.inc;
+
+# End of 5.1 tests
diff --git a/mysql-test/suite/rpl/t/rpl_timezone-master.opt b/mysql-test/suite/rpl/t/rpl_timezone-master.opt
new file mode 100644
index 00000000000..8e43bfbbb7e
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_timezone-master.opt
@@ -0,0 +1 @@
+--default-time-zone=Europe/Moscow
diff --git a/mysql-test/suite/rpl/t/rpl_timezone-slave.opt b/mysql-test/suite/rpl/t/rpl_timezone-slave.opt
new file mode 100644
index 00000000000..191182c329c
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_timezone-slave.opt
@@ -0,0 +1 @@
+--default-time-zone=Japan
diff --git a/mysql-test/suite/rpl/t/rpl_timezone.test b/mysql-test/suite/rpl/t/rpl_timezone.test
new file mode 100644
index 00000000000..4b8c8152c82
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_timezone.test
@@ -0,0 +1,142 @@
+#######################################
+# Change Author: JBM
+# Change Date: 2006-01-17
+# Change: Added order by
+#######################################
+# Test of replication of time zones.
+######################################
+# There is currently some bug possibly in prepared statements (this
+# test fails with --ps-protocol): sys_var_thd_time_zone::value_ptr()
+# is called only at prepare time, not at execution time. So,
+# thd->time_zone_used is not equal to 1 (it is back to 0, because of
+# reset_thd_for_next_command called at execution time), so the
+# timezone used in CONVERT_TZ is not binlogged. To debug (by Guilhem
+# and possibly Konstantin).
+
+--disable_ps_protocol
+
+source include/master-slave.inc;
+
+# Save original timezone
+set @my_time_zone= @@global.time_zone;
+
+# Some preparations
+let $VERSION=`select version()`;
+set timestamp=100000000; # for fixed output of mysqlbinlog
+create table t1 (t timestamp, n int not null auto_increment, PRIMARY KEY(n));
+create table t2 (t char(32), n int not null auto_increment, PRIMARY KEY(n));
+
+connection slave;
+select @@time_zone;
+#set time_zone='UTC';
+#select @@time_zone;
+#
+# Let us check how well replication works when we are saving datetime
+# value in TIMESTAMP field.
+#
+connection master;
+select @@time_zone;
+#set time_zone='UTC';
+#select @@time_zone;
+insert into t1 values ('20050101000000', NULL), ('20050611093902',NULL);
+insert into t1 values ('20040101000000',NULL), ('20040611093902',NULL);
+SELECT * FROM t1 ORDER BY n;
+sync_slave_with_master;
+#set time_zone='UTC';
+SELECT * FROM t1 ORDER BY n;
+
+# Let us check also that setting of time_zone back to default also works
+# well
+connection master;
+delete from t1;
+set time_zone='Europe/Moscow';
+insert into t1 values ('20040101000000',NULL), ('20040611093902',NULL);
+SELECT * FROM t1 ORDER BY n;
+sync_slave_with_master;
+set time_zone='Europe/Moscow';
+SELECT * FROM t1 ORDER BY n;
+connection master;
+# Change Author: JBM
+# Change Date: 2005-12-22
+# Change: Comment out the exec of the binlog so test works for both SBR and RBR
+#--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+#--exec $MYSQL_BINLOG --short-form $MYSQLTEST_VARDIR/log/master-bin.000001
+
+# Let us check with LOAD DATA INFILE
+# (we do it after mysqlbinlog because the temp files names are not constant)
+connection master;
+delete from t1;
+set time_zone='UTC';
+load data infile '../std_data_ln/rpl_timezone2.dat' into table t1;
+SELECT * FROM t1 ORDER BY n;
+sync_slave_with_master;
+set time_zone='UTC';
+SELECT * FROM t1 ORDER BY n;
+set time_zone='Europe/Moscow';
+
+# Put back values of before the LOAD
+connection master;
+set time_zone='Europe/Moscow';
+delete from t1;
+insert into t1 values ('20040101000000',NULL), ('20040611093902',NULL);
+
+#
+# Now let us check how well we replicate statments reading TIMESTAMP fields
+# (We should see the same data on master and on slave but it should differ
+# from originally inserted)
+#
+set time_zone='MET';
+insert into t2 (select * from t1);
+SELECT * FROM t1 ORDER BY n;
+sync_slave_with_master;
+SELECT * FROM t2 ORDER BY n;
+
+#
+# Now let us check how well we replicate various CURRENT_* functions
+#
+connection master;
+delete from t2;
+set timestamp=1000072000;
+insert into t2 values (current_timestamp,NULL), (current_date,NULL), (current_time,NULL);
+sync_slave_with_master;
+SELECT * FROM t2 ORDER BY n;
+
+#
+# At last let us check replication of FROM_UNIXTIME/UNIX_TIMESTAMP functions.
+#
+connection master;
+delete from t2;
+insert into t2 values (from_unixtime(1000000000),NULL),
+ (unix_timestamp('2001-09-09 03:46:40'),NULL);
+SELECT * FROM t2 ORDER BY n;
+sync_slave_with_master;
+# We should get same result on slave as on master
+SELECT * FROM t2 ORDER BY n;
+
+#
+# Let us check that we are allowing to set global time_zone with
+# replication
+#
+connection master;
+set global time_zone='MET';
+
+#
+# Let us see if CONVERT_TZ(@@time_zone) replicates
+#
+delete from t2;
+set time_zone='UTC';
+insert into t2 values(convert_tz('2004-01-01 00:00:00','MET',@@time_zone),NULL);
+insert into t2 values(convert_tz('2005-01-01 00:00:00','MET','Japan'),NULL);
+SELECT * FROM t2 ORDER BY n;
+sync_slave_with_master;
+SELECT * FROM t2 ORDER BY n;
+
+# Clean up
+connection master;
+drop table t1, t2;
+sync_slave_with_master;
+
+
+# Restore original timezone
+connection master;
+set global time_zone= @my_time_zone;
diff --git a/mysql-test/suite/rpl/t/rpl_trigger.test b/mysql-test/suite/rpl/t/rpl_trigger.test
new file mode 100644
index 00000000000..9f5f6fc9b4c
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_trigger.test
@@ -0,0 +1,477 @@
+#
+# Test of triggers with replication
+# Adding statement include due to Bug 12574
+# TODO: Remove statement include once 12574 is patched
+--source include/have_binlog_format_mixed_or_statement.inc
+--source include/master-slave.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t2;
+DROP TABLE IF EXISTS t3;
+
+--enable_warnings
+
+#
+# #12482: Triggers has side effects with auto_increment values
+#
+
+create table t1 (a int auto_increment, primary key (a), b int, rand_value double not null);
+create table t2 (a int auto_increment, primary key (a), b int);
+create table t3 (a int auto_increment, primary key (a), name varchar(64) not null, old_a int, old_b int, rand_value double not null);
+
+delimiter |;
+create trigger t1 before insert on t1 for each row
+begin
+ insert into t3 values (NULL, "t1", new.a, new.b, rand());
+end|
+
+create trigger t2 after insert on t2 for each row
+begin
+ insert into t3 values (NULL, "t2", new.a, new.b, rand());
+end|
+delimiter ;|
+
+insert into t3 values(100,"log",0,0,0);
+
+# Ensure we always have same random numbers
+SET @@RAND_SEED1=658490765, @@RAND_SEED2=635893186;
+
+# Emulate that we have rows 2-9 deleted on the slave
+insert into t1 values(1,1,rand()),(NULL,2,rand());
+insert into t2 (b) values(last_insert_id());
+insert into t2 values(3,0),(NULL,0);
+insert into t2 values(NULL,0),(500,0);
+
+select a,b, truncate(rand_value,4) from t1;
+select * from t2;
+select a,name, old_a, old_b, truncate(rand_value,4) from t3;
+save_master_pos;
+connection slave;
+sync_with_master;
+--disable_query_log
+select "--- On slave --" as "";
+--enable_query_log
+select a,b, truncate(rand_value,4) from t1;
+select * from t2;
+select a,name, old_a, old_b, truncate(rand_value,4) from t3;
+connection master;
+drop table t1,t2,t3;
+
+#
+# #12480: NOW() is not constant in a trigger
+# #12481: Using NOW() in a stored function breaks statement based replication
+#
+
+# Start by getting a lock on 'bug12480' to be able to use get_lock() as sleep()
+connect (con2,localhost,root,,);
+connection con2;
+select get_lock("bug12480",2);
+connection default;
+
+create table t1 (a datetime,b datetime, c datetime);
+--disable_warnings
+drop function if exists bug12480;
+--enable_warnings
+
+delimiter |;
+
+create function bug12480() returns datetime
+begin
+ set @a=get_lock("bug12480",2);
+ return now();
+end|
+
+create trigger t1_first before insert on t1
+for each row begin
+ set @a=get_lock("bug12480",2);
+ set new.b= now();
+ set new.c= bug12480();
+end
+|
+
+delimiter ;|
+insert into t1 set a = now();
+select a=b && a=c from t1;
+let $time=`select a from t1`;
+
+# Check that definer attribute is replicated properly:
+# - dump definers on the master;
+# - wait for the slave to synchronize with the master;
+# - dump definers on the slave;
+
+SELECT routine_name, definer
+FROM information_schema.routines;
+
+SELECT trigger_name, definer
+FROM information_schema.triggers;
+
+save_master_pos;
+connection slave;
+sync_with_master;
+--disable_query_log
+select "--- On slave --" as "";
+--enable_query_log
+
+# XXX: Definers of stored procedures and functions are not replicated. WL#2897
+# (Complete definer support in the stored routines) addresses this issue. So,
+# the result file is expected to be changed after implementation of this WL
+# item.
+
+SELECT routine_name, definer
+FROM information_schema.routines;
+
+SELECT trigger_name, definer
+FROM information_schema.triggers;
+
+select a=b && a=c from t1;
+--disable_query_log
+eval select a='$time' as 'test' from t1;
+--enable_query_log
+
+connection master;
+disconnect con2;
+
+truncate table t1;
+drop trigger t1_first;
+
+insert into t1 values ("2003-03-03","2003-03-03","2003-03-03"),(bug12480(),bug12480(),bug12480()),(now(),now(),now());
+select a=b && a=c from t1;
+
+drop function bug12480;
+drop table t1;
+
+#
+# #14614: Replication of tables with trigger generates error message if databases is changed
+# Note. The error message is emitted by _myfree() using fprintf() to the stderr
+# and because of that does not fall into the .result file.
+#
+
+create table t1 (i int);
+create table t2 (i int);
+
+delimiter |;
+create trigger tr1 before insert on t1 for each row
+begin
+ insert into t2 values (1);
+end|
+delimiter ;|
+
+create database other;
+use other;
+insert into test.t1 values (1);
+
+save_master_pos;
+connection slave;
+sync_with_master;
+
+connection master;
+use test;
+drop table t1,t2;
+drop database other;
+
+
+#
+# Test specific triggers including SELECT into var with replication
+# BUG#13227:
+# slave performs an update to the replicatable table, t1,
+# and modifies its local data, t3, by mean of its local trigger that uses
+# another local table t2.
+# Expected values are commented into queries.
+#
+# Body of the test executes in a loop since the problem occurred randomly.
+#
+
+let $max_rows=5;
+let $rnd=10;
+
+--echo test case for BUG#13227
+while ($rnd)
+{
+ --echo -------------------
+ echo $rnd;
+ --echo -------------------
+
+### SETUP
+
+--disable_warnings
+ connection master;
+ eval drop table if exists t1$rnd;
+ connection slave;
+ eval drop table if exists t2$rnd,t3$rnd;
+--enable_warnings
+
+ connection master;
+ eval create table t1$rnd (f1 int) /* 2 replicate */;
+ let $i=$max_rows;
+ while ($i)
+ {
+ eval insert into t1$rnd values (-$i);
+ dec $i;
+ }
+
+ sync_slave_with_master;
+#connection slave;
+ eval select * from t1$rnd;
+ delimiter |;
+ eval create trigger trg1$rnd before update on t1$rnd /* slave local */
+ for each row
+ begin
+ DECLARE r integer;
+ SELECT f2 INTO r FROM t2$rnd where f1=NEW.f1;
+ INSERT INTO t3$rnd values (r);
+ end|
+ delimiter ;|
+ eval create table t2$rnd (f1 int, f2 int) /* slave local */;
+ eval create table t3$rnd (f3 int) /* slave local */;
+ let $i=$max_rows;
+ while ($i)
+ {
+ eval insert into t2$rnd values ($i, $i*100);
+ dec $i;
+ }
+
+### Test
+
+#connection slave;
+
+# trigger works as specified when updates from slave
+ eval select * from t2$rnd;
+ eval UPDATE t1$rnd SET f1=$max_rows where f1=-$max_rows;
+ eval SELECT * from t1$rnd /* must be f1 $max_rows, 1 - $max_rows 2 - $max_rows ... -1 */;
+ eval SELECT * from t3$rnd /* must be f3 $max_rows*100 */;
+
+ connection master;
+ let $i=$max_rows;
+ while ($i)
+ {
+ eval UPDATE t1$rnd SET f1=$i where f1=-$i;
+ dec $i;
+ }
+
+ sync_slave_with_master;
+#connection slave;
+ eval SELECT * from t1$rnd /* must be f1 $max_rows ... 1 */;
+ eval SELECT * from t3$rnd /* must be f3 $max_rows * 100 ... 100 */;
+
+### CLEANUP
+#connection slave;
+ eval drop trigger trg1$rnd;
+ eval drop table t2$rnd,t3$rnd;
+
+ connection master;
+ eval drop table t1$rnd;
+
+ dec $rnd;
+}
+
+
+#
+# BUG#16266: Definer is not fully qualified error during replication.
+#
+# The idea of this test is to emulate replication of a trigger from the old
+# master (master w/o "DEFINER in triggers" support) to the new slave and check
+# that:
+# 1. the trigger on the slave will be replicated w/o errors;
+# 2. the trigger on the slave will be non-SUID (will have no DEFINER);
+# 3. the trigger can be activated later on the slave w/o errors.
+#
+# In order to emulate this kind of replication, we make the slave playing the binlog,
+# recorded by 5.0.16 master. This binlog contains the following statements:
+# CREATE TABLE t1(c INT);
+# CREATE TABLE t2(s CHAR(200));
+# CREATE TRIGGER trg1 AFTER INSERT ON t1
+# FOR EACH ROW
+# INSERT INTO t2 VALUES(CURRENT_USER());
+# INSERT INTO t1 VALUES(1);
+#
+
+# 1. Check that the trigger's replication is succeeded.
+
+# Stop the slave.
+
+connection slave;
+STOP SLAVE;
+
+# Replace master's binlog.
+
+connection master;
+FLUSH LOGS;
+exec cp $MYSQL_TEST_DIR/std_data/bug16266.000001 $MYSQLTEST_VARDIR/log/master-bin.000001;
+
+# Make the slave to replay the new binlog.
+
+connection slave;
+RESET SLAVE;
+START SLAVE;
+
+SELECT MASTER_POS_WAIT('master-bin.000001', 513) >= 0;
+
+# Check that the replication succeeded.
+
+SHOW TABLES LIKE 't_';
+SHOW TRIGGERS;
+SELECT * FROM t1;
+SELECT * FROM t2;
+
+# 2. Check that the trigger is non-SUID on the slave;
+# 3. Check that the trigger can be activated on the slave.
+
+INSERT INTO t1 VALUES(2);
+
+SELECT * FROM t1;
+SELECT * FROM t2;
+
+# That's all, cleanup.
+
+DROP TRIGGER trg1;
+DROP TABLE t1;
+DROP TABLE t2;
+
+STOP SLAVE;
+RESET SLAVE;
+
+# The master should be clean.
+
+connection master;
+SHOW TABLES LIKE 't_';
+SHOW TRIGGERS;
+
+RESET MASTER;
+
+# Restart slave.
+
+connection slave;
+START SLAVE;
+
+
+#
+# BUG#20438: CREATE statements for views, stored routines and triggers can be
+# not replicable.
+#
+
+--echo
+--echo ---> Test for BUG#20438
+
+# Prepare environment.
+
+--echo
+--echo ---> Preparing environment...
+--echo ---> connection: master
+--connection master
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t2;
+--enable_warnings
+
+--echo
+--echo ---> Synchronizing slave with master...
+
+--save_master_pos
+--connection slave
+--sync_with_master
+
+--echo
+--echo ---> connection: master
+--connection master
+
+# Test.
+
+--echo
+--echo ---> Creating objects...
+
+CREATE TABLE t1(c INT);
+CREATE TABLE t2(c INT);
+
+/*!50003 CREATE TRIGGER t1_bi BEFORE INSERT ON t1
+ FOR EACH ROW
+ INSERT INTO t2 VALUES(NEW.c * 10) */;
+
+--echo
+--echo ---> Inserting value...
+
+INSERT INTO t1 VALUES(1);
+
+--echo
+--echo ---> Checking on master...
+
+SELECT * FROM t1;
+SELECT * FROM t2;
+
+--echo
+--echo ---> Synchronizing slave with master...
+
+--save_master_pos
+--connection slave
+--sync_with_master
+
+--echo ---> connection: master
+
+--echo
+--echo ---> Checking on slave...
+
+SELECT * FROM t1;
+SELECT * FROM t2;
+
+# Cleanup.
+
+--echo
+--echo ---> connection: master
+--connection master
+
+--echo
+--echo ---> Cleaning up...
+
+DROP TABLE t1;
+DROP TABLE t2;
+
+--save_master_pos
+--connection slave
+--sync_with_master
+--connection master
+
+#
+# BUG#23703: DROP TRIGGER needs an IF EXISTS
+#
+
+connection master;
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+create table t1(a int, b varchar(50));
+
+-- error ER_TRG_DOES_NOT_EXIST
+drop trigger not_a_trigger;
+
+drop trigger if exists not_a_trigger;
+
+create trigger t1_bi before insert on t1
+for each row set NEW.b := "In trigger t1_bi";
+
+insert into t1 values (1, "a");
+drop trigger if exists t1_bi;
+insert into t1 values (2, "b");
+drop trigger if exists t1_bi;
+insert into t1 values (3, "c");
+
+select * from t1;
+
+save_master_pos;
+connection slave;
+sync_with_master;
+
+select * from t1;
+
+connection master;
+
+drop table t1;
+
+#
+# End of tests
+#
+save_master_pos;
+connection slave;
+sync_with_master;
diff --git a/mysql-test/suite/rpl/t/rpl_trunc_temp.test b/mysql-test/suite/rpl/t/rpl_trunc_temp.test
new file mode 100644
index 00000000000..28bcb0c06c3
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_trunc_temp.test
@@ -0,0 +1,35 @@
+# Requires statement logging
+-- source include/have_binlog_format_mixed_or_statement.inc
+
+source include/master-slave.inc;
+
+#
+# Bug#17137 Running "truncate table" on temporary table
+# leaves the table open on a slave
+#
+
+create temporary table t1 (n int);
+insert into t1 values(1);
+sync_slave_with_master;
+show status like 'Slave_open_temp_tables';
+
+# Perform a delete from temp table
+connection master;
+delete from t1;
+sync_slave_with_master;
+show status like 'Slave_open_temp_tables';
+
+# Perform truncate on temp table
+connection master;
+truncate t1;
+sync_slave_with_master;
+show status like 'Slave_open_temp_tables';
+
+# Disconnect the master, temp table on slave should dissapear
+disconnect master;
+--real_sleep 3 # time for DROP to be read by slave
+connection slave;
+show status like 'Slave_open_temp_tables';
+
+
+# End of 4.1 tests
diff --git a/mysql-test/suite/rpl/t/rpl_truncate_2myisam.test b/mysql-test/suite/rpl/t/rpl_truncate_2myisam.test
new file mode 100644
index 00000000000..a0f0ea04f44
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_truncate_2myisam.test
@@ -0,0 +1,4 @@
+--source include/not_ndb_default.inc
+let $engine=MyISAM;
+--source extra/rpl_tests/rpl_truncate.test
+
diff --git a/mysql-test/suite/rpl/t/rpl_truncate_3innodb.test b/mysql-test/suite/rpl/t/rpl_truncate_3innodb.test
new file mode 100644
index 00000000000..a31fd62a29a
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_truncate_3innodb.test
@@ -0,0 +1,6 @@
+
+--source include/have_innodb.inc
+--source include/not_ndb_default.inc
+
+let $engine=InnoDB;
+--source extra/rpl_tests/rpl_truncate.test
diff --git a/mysql-test/suite/rpl/t/rpl_truncate_7ndb_2-master.opt b/mysql-test/suite/rpl/t/rpl_truncate_7ndb_2-master.opt
new file mode 100644
index 00000000000..01cf3e0520f
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_truncate_7ndb_2-master.opt
@@ -0,0 +1 @@
+--binlog-format=mixed
diff --git a/mysql-test/suite/rpl/t/rpl_truncate_7ndb_2.test b/mysql-test/suite/rpl/t/rpl_truncate_7ndb_2.test
new file mode 100644
index 00000000000..4ee6c98d463
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_truncate_7ndb_2.test
@@ -0,0 +1,6 @@
+# Same test as rpl_truncate_7ndb.test, but with mixed mode
+# This is marked with 'big_test' just because the rpl_truncate_7ndb test is
+# so slow...
+
+--source include/big_test.inc
+--source t/rpl_truncate_7ndb.test
diff --git a/mysql-test/suite/rpl/t/rpl_udf-master.opt b/mysql-test/suite/rpl/t/rpl_udf-master.opt
new file mode 100644
index 00000000000..7d8786c156a
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_udf-master.opt
@@ -0,0 +1 @@
+$UDF_EXAMPLE_LIB_OPT
diff --git a/mysql-test/suite/rpl/t/rpl_udf-slave.opt b/mysql-test/suite/rpl/t/rpl_udf-slave.opt
new file mode 100644
index 00000000000..7d8786c156a
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_udf-slave.opt
@@ -0,0 +1 @@
+$UDF_EXAMPLE_LIB_OPT
diff --git a/mysql-test/suite/rpl/t/rpl_udf.test b/mysql-test/suite/rpl/t/rpl_udf.test
new file mode 100644
index 00000000000..262ad04630c
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_udf.test
@@ -0,0 +1,22 @@
+###################################################################
+# Author: Chuck Bell #
+# Date: 2006-12-21 #
+# Purpose: To test that UDFs are replicated in both row based and #
+# statement based format. This tests work completed in WL#3629. #
+###################################################################
+
+--source include/not_embedded.inc
+--source include/master-slave.inc
+
+let $engine_type= MyISAM;
+
+set binlog_format=row;
+
+# Embedded server doesn't support binlogging
+--source include/rpl_udf.inc
+
+set binlog_format=statement;
+
+# Embedded server doesn't support binlogging
+--source include/rpl_udf.inc
+
diff --git a/mysql-test/suite/rpl/t/rpl_user_variables.test b/mysql-test/suite/rpl/t/rpl_user_variables.test
new file mode 100644
index 00000000000..539f9c88e0d
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_user_variables.test
@@ -0,0 +1,362 @@
+###################################
+#
+# Test of replicating user variables
+#
+###################################
+
+-- source include/master-slave.inc
+# Disable PS as the log positions differs
+--disable_ps_protocol
+
+
+# Clean up old slave's binlogs.
+# The slave is started with --log-slave-updates
+# and this test does SHOW BINLOG EVENTS on the slave's
+# binlog. But previous tests can influence the current test's
+# binlog (e.g. a temporary table in the previous test has not
+# been explicitly deleted, or it has but the slave hasn't had
+# enough time to catch it before STOP SLAVE,
+# and at the beginning of the current
+# test the slave immediately writes DROP TEMPORARY TABLE this_old_table).
+# We wait for the slave to have written all he wants to the binlog
+# (otherwise RESET MASTER may come too early).
+save_master_pos;
+connection slave;
+sync_with_master;
+reset master;
+connection master;
+
+create table t1(n char(30));
+set @i1:=12345678901234, @i2:=-12345678901234, @i3:=0, @i4:=-1;
+set @s1:='This is a test', @r1:=12.5, @r2:=-12.5;
+set @n1:=null;
+set @s2:='', @s3:='abc\'def', @s4:= 'abc\\def', @s5:= 'abc''def';
+insert into t1 values (@i1), (@i2), (@i3), (@i4);
+insert into t1 values (@r1), (@r2);
+insert into t1 values (@s1), (@s2), (@s3), (@s4), (@s5);
+insert into t1 values (@n1);
+insert into t1 values (@n2); # not explicitely set before
+insert into t1 values (@a:=0), (@a:=@a+1), (@a:=@a+1);
+insert into t1 values (@a+(@b:=@a+1));
+set @q:='abc';
+insert t1 values (@q), (@q:=concat(@q, 'n1')), (@q:=concat(@q, 'n2'));
+set @a:=5;
+insert into t1 values (@a),(@a);
+# To flush the pending event, we add the following statement. RBR can
+# concatenate the result of several statements, which SBR cannot.
+select * from t1 where n = '<nonexistant>';
+connection master1; # see if variable is reset in binlog when thread changes
+insert into t1 values (@a),(@a),(@a*5);
+SELECT * FROM t1 ORDER BY n;
+sync_slave_with_master;
+SELECT * FROM t1 ORDER BY n;
+connection master;
+insert into t1 select * FROM (select @var1 union select @var2) AS t2;
+drop table t1;
+--echo End of 4.1 tests.
+
+# BUG#20141
+# The following tests ensure that if user-defined variables are used in SF/Triggers
+# that they are replicated correctly. These tests should be run in both SBR and RBR
+# modes.
+
+# This test uses a procedure that inserts data values based on the value of a
+# user-defined variable. It also has a trigger that inserts data based on the
+# same variable. Successful test runs show that the @var is replicated
+# properly and that the procedure and trigger insert the correct data on the
+# slave.
+#
+# The test of stored procedure was included for completeness. Replication of stored
+# procedures was not directly affected by BUG#20141.
+#
+# This test was constructed for BUG#20141
+
+--disable_warnings
+DROP TABLE IF EXISTS t20;
+DROP TABLE IF EXISTS t21;
+DROP PROCEDURE IF EXISTS test.insert;
+--enable_warnings
+
+CREATE TABLE t20 (a VARCHAR(20));
+CREATE TABLE t21 (a VARCHAR(20));
+DELIMITER |;
+
+# Create a procedure that uses the @var for flow control
+
+CREATE PROCEDURE test.insert()
+BEGIN
+ IF (@VAR)
+ THEN
+ INSERT INTO test.t20 VALUES ('SP_TRUE');
+ ELSE
+ INSERT INTO test.t20 VALUES ('SP_FALSE');
+ END IF;
+END|
+
+# Create a trigger that uses the @var for flow control
+
+CREATE TRIGGER test.insert_bi BEFORE INSERT
+ ON test.t20 FOR EACH ROW
+ BEGIN
+ IF (@VAR)
+ THEN
+ INSERT INTO test.t21 VALUES ('TRIG_TRUE');
+ ELSE
+ INSERT INTO test.t21 VALUES ('TRIG_FALSE');
+ END IF;
+ END|
+DELIMITER ;|
+
+sync_slave_with_master;
+connection master;
+
+# Set @var and call the procedure, repeat with different values
+
+SET @VAR=0;
+CALL test.insert();
+SET @VAR=1;
+CALL test.insert();
+
+--echo On master: Check the tables for correct data
+
+SELECT * FROM t20;
+SELECT * FROM t21;
+
+sync_slave_with_master;
+
+--echo On slave: Check the tables for correct data and it matches master
+
+SELECT * FROM t20;
+SELECT * FROM t21;
+connection master;
+
+# Cleanup
+
+DROP TABLE t20;
+DROP TABLE t21;
+DROP PROCEDURE test.insert;
+
+# This test uses a stored function that uses user-defined variables to return data
+# This test was constructed for BUG#20141
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+DROP FUNCTION IF EXISTS test.square;
+--enable_warnings
+
+CREATE TABLE t1 (i INT);
+
+# Create function that returns a value from @var. In this case, the square function
+
+CREATE FUNCTION test.square() RETURNS INTEGER DETERMINISTIC RETURN
+(@var * @var);
+
+# Set the @var to different values and insert them into a table
+
+SET @var = 1;
+INSERT INTO t1 VALUES (square());
+SET @var = 2;
+INSERT INTO t1 VALUES (square());
+SET @var = 3;
+INSERT INTO t1 VALUES (square());
+SET @var = 4;
+INSERT INTO t1 VALUES (square());
+SET @var = 5;
+INSERT INTO t1 VALUES (square());
+
+--echo On master: Retrieve the values from the table
+
+SELECT * FROM t1;
+
+sync_slave_with_master;
+
+--echo On slave: Retrieve the values from the table and verify they are the same as on master
+
+SELECT * FROM t1;
+
+connection master;
+
+# Cleanup
+
+DROP TABLE t1;
+DROP FUNCTION test.square;
+
+# This test uses stored functions that uses user-defined variables to return data
+# based on the use of @vars inside a function body.
+# This test was constructed for BUG#14914
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+DROP FUNCTION IF EXISTS f1;
+DROP FUNCTION IF EXISTS f2;
+--enable_warnings
+
+CREATE TABLE t1(a int);
+DELIMITER |;
+
+# Create a function that simply returns the value of an @var.
+# Create a function that uses an @var for flow control, creates and uses another
+# @var and sets its value to a value based on another @var.
+
+CREATE FUNCTION f1() returns int deterministic BEGIN
+ return @a;
+END |
+
+CREATE FUNCTION f2() returns int deterministic BEGIN
+ IF (@b > 0) then
+ SET @c = (@a + @b);
+ else
+ SET @c = (@a - 1);
+ END if;
+ return @c;
+END |
+DELIMITER ;|
+
+sync_slave_with_master;
+connection master;
+
+# Set an @var to a value and insert data into a table using the first function.
+# Set two more @vars to some values and insert data into a table using the second function.
+
+SET @a=500;
+INSERT INTO t1 values(f1());
+SET @b = 125;
+SET @c = 1;
+INSERT INTO t1 values(f2());
+
+--echo On master: Retrieve the values from the table
+
+sync_slave_with_master;
+connection master;
+
+SELECT * from t1;
+
+connection slave;
+
+--echo On slave: Check the tables for correct data and it matches master
+
+SELECT * from t1;
+
+connection master;
+
+# Cleanup
+
+DROP TABLE t1;
+DROP FUNCTION f1;
+DROP FUNCTION f2;
+
+# This test uses a function that changes a user-defined variable in its body. This test
+# will ensure the @vars are replicated when needed and not interrupt the normal execution
+# of the function on the slave. This also applies to procedures and triggers.
+
+# This test was constructed for BUG#25167
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t2;
+--enable_warnings
+CREATE TABLE t1 (i int);
+CREATE TABLE t2 (k int);
+DELIMITER |;
+
+# Create a trigger that inserts data into another table, changes the @var then inserts
+# another row with the modified value.
+
+CREATE trigger t1_bi before INSERT on t1 for each row BEGIN
+ INSERT INTO t2 values (@a);
+ SET @a:=42;
+ INSERT INTO t2 values (@a);
+END |
+DELIMITER ;|
+
+sync_slave_with_master;
+connection master;
+
+# Set the @var to a value then insert data into first table.
+
+SET @a:=100;
+INSERT INTO t1 values (5);
+
+--echo On master: Check to see that data was inserted correctly in both tables
+
+SELECT * from t1;
+SELECT * from t2;
+
+sync_slave_with_master;
+
+--echo On slave: Check the tables for correct data and it matches master
+
+SELECT * from t1;
+SELECT * from t2;
+
+connection master;
+drop table t1, t2;
+
+#
+# Bug #12826: Possible to get inconsistent slave using SQL syntax Prepared Statements
+#
+connection master;
+create table t1(a int, b int);
+prepare s1 from 'insert into t1 values (@x:=@x+1, ?)';
+set @x=1; execute s1 using @x;
+select * from t1;
+sync_slave_with_master;
+connection slave;
+select * from t1;
+connection master;
+drop table t1;
+
+--echo End of 5.0 tests.
+
+# This test uses a stored function that uses user-defined variables to return data
+# The test ensures the value of the user-defined variable is replicated correctly
+# and in the correct order of assignment.
+
+# This test was constructed for BUG#20141
+
+--disable_warnings
+DROP FUNCTION IF EXISTS f1;
+DROP FUNCTION IF EXISTS f2;
+--enable_warnings
+
+CREATE TABLE t1 (i INT);
+
+# Create two functions. One simply returns the user-defined variable. The other
+# returns a value based on the user-defined variable.
+
+CREATE FUNCTION f1() RETURNS INT RETURN @a; DELIMITER |; CREATE
+FUNCTION f2() RETURNS INT BEGIN
+ INSERT INTO t1 VALUES (10 + @a);
+ RETURN 0;
+END|
+DELIMITER ;|
+
+sync_slave_with_master;
+connection master;
+
+# Set the variable and execute the functions.
+
+SET @a:=123;
+SELECT f1(), f2();
+
+--echo On master: Check to see that data was inserted correctly
+
+INSERT INTO t1 VALUES(f1());
+SELECT * FROM t1;
+
+sync_slave_with_master;
+
+--echo On slave: Check the table for correct data and it matches master
+
+SELECT * FROM t1;
+
+connection master;
+
+# Cleanup
+
+DROP FUNCTION f1;
+DROP FUNCTION f2;
+DROP TABLE t1;
+
+sync_slave_with_master;
+stop slave;
diff --git a/mysql-test/suite/rpl/t/rpl_variables-master.opt b/mysql-test/suite/rpl/t/rpl_variables-master.opt
new file mode 100644
index 00000000000..a668c6bfbe8
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_variables-master.opt
@@ -0,0 +1 @@
+--slave-skip-errors=3,100,137,643,1752
diff --git a/mysql-test/suite/rpl/t/rpl_variables.test b/mysql-test/suite/rpl/t/rpl_variables.test
new file mode 100644
index 00000000000..84dc3acfe6e
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_variables.test
@@ -0,0 +1,20 @@
+source include/master-slave.inc;
+
+# Init for rstore of variable values
+set @my_slave_net_timeout =@@global.slave_net_timeout;
+
+set global slave_net_timeout=100;
+set global sql_slave_skip_counter=100;
+
+# End of 4.1 tests
+
+# BUG #7800: Add various-slave related variables to SHOW VARIABLES
+show variables like 'slave_compressed_protocol';
+--replace_column 2 SLAVE_LOAD_TMPDIR
+show variables like 'slave_load_tmpdir';
+# We just set some arbitrary values in variables-master.opt so we can test
+# that a list of values works correctly
+show variables like 'slave_skip_errors';
+
+# Cleanup
+set global slave_net_timeout=default;
diff --git a/mysql-test/suite/rpl/t/rpl_view-slave.opt b/mysql-test/suite/rpl/t/rpl_view-slave.opt
new file mode 100644
index 00000000000..79b3bf6174b
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_view-slave.opt
@@ -0,0 +1 @@
+--replicate-ignore-table=test.foo
diff --git a/mysql-test/suite/rpl/t/rpl_view.test b/mysql-test/suite/rpl/t/rpl_view.test
new file mode 100644
index 00000000000..51ad319b212
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_view.test
@@ -0,0 +1,167 @@
+# NYI - row-based cannot use CREATE ... SELECT
+
+source include/master-slave.inc;
+--disable_warnings
+drop table if exists t1,v1;
+drop view if exists t1,v1;
+sync_slave_with_master;
+reset master;
+--enable_warnings
+
+#
+# Check that creation drop of view is replicated, also check replication of
+# updating of view
+#
+connection master;
+create table t1 (a int);
+insert into t1 values (1);
+create view v1 as select a from t1;
+insert into v1 values (2);
+select * from v1 order by a;
+sync_slave_with_master;
+# view already have to be on slave
+select * from v1 order by a;
+connection master;
+update v1 set a=3 where a=1;
+select * from v1 order by a;
+sync_slave_with_master;
+select * from v1 order by a;
+connection master;
+delete from v1 where a=2;
+select * from v1 order by a;
+sync_slave_with_master;
+select * from v1 order by a;
+connection master;
+# 'alter view' internally maped to creation, but still check that it works
+alter view v1 as select a as b from t1;
+sync_slave_with_master;
+select * from v1 order by 1;
+connection master;
+drop view v1;
+sync_slave_with_master;
+#error, because view have to be removed from slave
+-- error 1146
+select * from v1 order by a;
+connection master;
+drop table t1;
+sync_slave_with_master;
+# Change Author: JBM
+# Change Date: 2005-12-22
+# Change: Commented out binlog events to work with SBR and RBR
+#--replace_column 2 # 5 #
+# show binlog events limit 1,100;
+
+#
+# BUG#20438: CREATE statements for views, stored routines and triggers can be
+# not replicable.
+#
+
+--echo
+--echo ---> Test for BUG#20438
+
+# Prepare environment.
+
+--echo
+--echo ---> Preparing environment...
+--echo ---> connection: master
+--connection master
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+DROP VIEW IF EXISTS v1;
+--enable_warnings
+
+--echo
+--echo ---> Synchronizing slave with master...
+
+--save_master_pos
+--connection slave
+--sync_with_master
+
+--echo
+--echo ---> connection: master
+--connection master
+
+# Test.
+
+--echo
+--echo ---> Creating objects...
+
+CREATE TABLE t1(c INT);
+
+/*!50003 CREATE VIEW v1 AS SELECT * FROM t1 */;
+
+--echo
+--echo ---> Inserting value...
+
+INSERT INTO t1 VALUES(1);
+
+--echo
+--echo ---> Checking on master...
+
+SELECT * FROM t1;
+
+--echo
+--echo ---> Synchronizing slave with master...
+
+--save_master_pos
+--connection slave
+--sync_with_master
+
+--echo ---> connection: master
+
+--echo
+--echo ---> Checking on slave...
+
+SELECT * FROM t1;
+
+# Cleanup.
+
+--echo
+--echo ---> connection: master
+--connection master
+
+--echo
+--echo ---> Cleaning up...
+
+DROP VIEW v1;
+DROP TABLE t1;
+
+--save_master_pos
+--connection slave
+--sync_with_master
+--connection master
+
+#
+# BUG#19419: "VIEW: View that the column name is different
+# by master and slave is made".
+#
+connection master;
+create table t1(a int, b int);
+insert into t1 values (1, 1), (1, 2), (1, 3);
+create view v1(a, b) as select a, sum(b) from t1 group by a;
+
+sync_slave_with_master;
+explain v1;
+show create table v1;
+select * from v1;
+
+connection master;
+drop table t1;
+drop view v1;
+
+sync_slave_with_master;
+
+#
+# BUG#28244 CREATE VIEW breaks replication when view exists
+#
+connection master;
+CREATE TABLE t1(a INT);
+CREATE VIEW v1 AS SELECT * FROM t1;
+--error ER_TABLE_EXISTS_ERROR
+CREATE VIEW v1 AS SELECT * FROM t1;
+DROP VIEW v1;
+DROP TABLE t1;
+sync_slave_with_master;
+
+--echo End of 5.0 tests