summaryrefslogtreecommitdiff
path: root/mysql-test/t
diff options
context:
space:
mode:
Diffstat (limited to 'mysql-test/t')
-rw-r--r--mysql-test/t/alter_table.test64
-rw-r--r--mysql-test/t/archive.test209
-rw-r--r--mysql-test/t/archive_bitfield.test98
-rw-r--r--mysql-test/t/auto_increment.test11
-rw-r--r--mysql-test/t/backup.test2
-rw-r--r--mysql-test/t/bdb.test47
-rw-r--r--mysql-test/t/binlog.test49
-rw-r--r--mysql-test/t/binlog_row_binlog-master.opt (renamed from mysql-test/t/binlog-master.opt)0
-rw-r--r--mysql-test/t/binlog_row_binlog.test5
-rw-r--r--mysql-test/t/binlog_row_blackhole.test11
-rw-r--r--mysql-test/t/binlog_row_ctype_cp932.test5
-rw-r--r--mysql-test/t/binlog_row_ctype_ucs.test6
-rw-r--r--mysql-test/t/binlog_row_drop_tmp_tbl.test5
-rw-r--r--mysql-test/t/binlog_row_innodb_stat-master.opt1
-rw-r--r--mysql-test/t/binlog_row_innodb_stat.test5
-rw-r--r--mysql-test/t/binlog_row_insert_select.test10
-rw-r--r--mysql-test/t/binlog_row_mix_innodb_myisam-master.opt (renamed from mysql-test/t/mix_innodb_myisam_binlog-master.opt)0
-rw-r--r--mysql-test/t/binlog_row_mix_innodb_myisam.test31
-rw-r--r--mysql-test/t/binlog_stm_binlog-master.opt1
-rw-r--r--mysql-test/t/binlog_stm_binlog.test18
-rw-r--r--mysql-test/t/binlog_stm_blackhole.test6
-rw-r--r--mysql-test/t/binlog_stm_ctype_cp932.test6
-rw-r--r--mysql-test/t/binlog_stm_ctype_ucs.test6
-rw-r--r--mysql-test/t/binlog_stm_drop_tmp_tbl.test5
-rw-r--r--mysql-test/t/binlog_stm_innodb_stat-master.opt1
-rw-r--r--mysql-test/t/binlog_stm_innodb_stat.test5
-rw-r--r--mysql-test/t/binlog_stm_insert_select.test5
-rw-r--r--mysql-test/t/binlog_stm_mix_innodb_myisam-master.opt1
-rw-r--r--mysql-test/t/binlog_stm_mix_innodb_myisam.test23
-rw-r--r--mysql-test/t/blackhole.test142
-rw-r--r--mysql-test/t/case.test2
-rw-r--r--mysql-test/t/cast.test2
-rw-r--r--mysql-test/t/connect.test4
-rw-r--r--mysql-test/t/contributors.test1
-rw-r--r--mysql-test/t/create.test7
-rw-r--r--mysql-test/t/create_select_tmp.test3
-rw-r--r--mysql-test/t/csv.test176
-rw-r--r--mysql-test/t/ctype_cp932.test415
-rw-r--r--mysql-test/t/ctype_cp932_binlog.test57
-rw-r--r--mysql-test/t/ctype_cp932_binlog_row.test5
-rw-r--r--mysql-test/t/ctype_cp932_binlog_stm.test29
-rw-r--r--mysql-test/t/ctype_cp932_notembedded.test32
-rw-r--r--mysql-test/t/ctype_filename.test21
-rw-r--r--mysql-test/t/ctype_sjis.test2
-rw-r--r--mysql-test/t/ctype_ucs_binlog.test20
-rw-r--r--mysql-test/t/ctype_ujis.test4
-rw-r--r--mysql-test/t/date_formats.test3
-rw-r--r--mysql-test/t/disabled.def35
-rw-r--r--mysql-test/t/drop_temp_table.test31
-rw-r--r--mysql-test/t/events.test378
-rw-r--r--mysql-test/t/events_bugs.test175
-rw-r--r--mysql-test/t/events_grant.test105
-rw-r--r--mysql-test/t/events_logs_tests-master.opt1
-rw-r--r--mysql-test/t/events_logs_tests.test95
-rw-r--r--mysql-test/t/events_microsec.test15
-rw-r--r--mysql-test/t/events_scheduling.test40
-rw-r--r--mysql-test/t/events_stress.test126
-rw-r--r--mysql-test/t/exampledb.test4
-rw-r--r--mysql-test/t/federated.test2
-rw-r--r--mysql-test/t/federated_archive.test2
-rw-r--r--mysql-test/t/federated_bug_13118.test2
-rw-r--r--mysql-test/t/federated_transactions.test40
-rw-r--r--mysql-test/t/flush_table.test55
-rw-r--r--mysql-test/t/fulltext.test12
-rw-r--r--mysql-test/t/func_system.test2
-rw-r--r--mysql-test/t/func_time.test31
-rw-r--r--mysql-test/t/grant2.test11
-rw-r--r--mysql-test/t/having.test2
-rw-r--r--mysql-test/t/im_cmd_line.imtest68
-rw-r--r--mysql-test/t/im_daemon_life_cycle-im.opt1
-rw-r--r--mysql-test/t/im_daemon_life_cycle.imtest3
-rw-r--r--mysql-test/t/im_instance_conf-im.opt1
-rw-r--r--mysql-test/t/im_instance_conf.imtest228
-rw-r--r--mysql-test/t/im_life_cycle-im.opt1
-rw-r--r--mysql-test/t/im_life_cycle.imtest99
-rw-r--r--mysql-test/t/im_options.imtest268
-rw-r--r--mysql-test/t/im_options_set.imtest142
-rw-r--r--mysql-test/t/im_options_unset.imtest150
-rw-r--r--mysql-test/t/im_utils-im.opt1
-rw-r--r--mysql-test/t/im_utils.imtest8
-rw-r--r--mysql-test/t/information_schema.test24
-rw-r--r--mysql-test/t/information_schema_inno.test32
-rw-r--r--mysql-test/t/information_schema_part.test123
-rw-r--r--mysql-test/t/innodb-master.opt2
-rw-r--r--mysql-test/t/innodb.test318
-rw-r--r--mysql-test/t/innodb_concurrent-master.opt1
-rw-r--r--mysql-test/t/innodb_concurrent.test346
-rw-r--r--mysql-test/t/innodb_unsafe_binlog-master.opt2
-rw-r--r--mysql-test/t/innodb_unsafe_binlog.test213
-rw-r--r--mysql-test/t/insert.test11
-rw-r--r--mysql-test/t/insert_select-binlog.test35
-rw-r--r--mysql-test/t/key.test58
-rw-r--r--mysql-test/t/loaddata.test24
-rw-r--r--mysql-test/t/lock_multi.test19
-rw-r--r--mysql-test/t/log_tables-master.opt1
-rw-r--r--mysql-test/t/log_tables.test178
-rw-r--r--mysql-test/t/merge.test3
-rw-r--r--mysql-test/t/mix_innodb_myisam_binlog.test295
-rw-r--r--mysql-test/t/multi_update.test6
-rw-r--r--mysql-test/t/myisam-system.test21
-rw-r--r--mysql-test/t/myisam.test80
-rw-r--r--mysql-test/t/mysql_client_test-master.opt1
-rw-r--r--mysql-test/t/mysql_client_test.opt1
-rw-r--r--mysql-test/t/mysqlbinlog.test6
-rw-r--r--mysql-test/t/mysqlbinlog2.test19
-rw-r--r--mysql-test/t/mysqlbinlog_base64.test38
-rw-r--r--mysql-test/t/mysqlcheck.test6
-rw-r--r--mysql-test/t/mysqldump.test135
-rw-r--r--mysql-test/t/mysqlslap.test16
-rw-r--r--mysql-test/t/mysqltest.test40
-rw-r--r--mysql-test/t/ndb_alter_table.test149
-rw-r--r--mysql-test/t/ndb_alter_table2.test4
-rw-r--r--mysql-test/t/ndb_alter_table3.test49
-rw-r--r--mysql-test/t/ndb_autodiscover.test4
-rw-r--r--mysql-test/t/ndb_autodiscover3.test17
-rw-r--r--mysql-test/t/ndb_basic.test31
-rw-r--r--mysql-test/t/ndb_binlog_basic.test72
-rw-r--r--mysql-test/t/ndb_binlog_basic2.test14
-rw-r--r--mysql-test/t/ndb_binlog_ddl_multi.test191
-rw-r--r--mysql-test/t/ndb_binlog_discover.test19
-rw-r--r--mysql-test/t/ndb_binlog_ignore_db-master.opt1
-rw-r--r--mysql-test/t/ndb_binlog_ignore_db.test15
-rw-r--r--mysql-test/t/ndb_binlog_multi.test76
-rw-r--r--mysql-test/t/ndb_bitfield.test2
-rw-r--r--mysql-test/t/ndb_condition_pushdown.test2
-rw-r--r--mysql-test/t/ndb_config.test1
-rw-r--r--mysql-test/t/ndb_config2.test7
-rw-r--r--mysql-test/t/ndb_database.test28
-rw-r--r--mysql-test/t/ndb_dd_backuprestore.test173
-rw-r--r--mysql-test/t/ndb_dd_basic.test366
-rw-r--r--mysql-test/t/ndb_dd_ddl.test301
-rw-r--r--mysql-test/t/ndb_dd_disk2memory.test186
-rw-r--r--mysql-test/t/ndb_dd_dump.test246
-rw-r--r--mysql-test/t/ndb_index_ordered.test74
-rw-r--r--mysql-test/t/ndb_index_unique.test20
-rw-r--r--mysql-test/t/ndb_lock.test36
-rw-r--r--mysql-test/t/ndb_multi.test18
-rw-r--r--mysql-test/t/ndb_multi_row.test76
-rw-r--r--mysql-test/t/ndb_rename.test36
-rw-r--r--mysql-test/t/ndb_restore.test240
-rw-r--r--mysql-test/t/ndb_restore_compat.test43
-rw-r--r--mysql-test/t/ndb_temporary.test38
-rw-r--r--mysql-test/t/ndb_view.test29
-rw-r--r--mysql-test/t/partition.test1097
-rw-r--r--mysql-test/t/partition_02myisam.test25
-rw-r--r--mysql-test/t/partition_03ndb.test26
-rw-r--r--mysql-test/t/partition_charset.test21
-rw-r--r--mysql-test/t/partition_error.test777
-rw-r--r--mysql-test/t/partition_grant.test51
-rw-r--r--mysql-test/t/partition_hash.test111
-rw-r--r--mysql-test/t/partition_list.test126
-rw-r--r--mysql-test/t/partition_mgm_err.test213
-rw-r--r--mysql-test/t/partition_mgm_err2.test26
-rw-r--r--mysql-test/t/partition_order.test828
-rw-r--r--mysql-test/t/partition_pruning.test568
-rw-r--r--mysql-test/t/partition_range.test418
-rw-r--r--mysql-test/t/ps.test2
-rw-r--r--mysql-test/t/ps_1general.test5
-rw-r--r--mysql-test/t/query_cache.test8
-rw-r--r--mysql-test/t/raid.test224
-rw-r--r--mysql-test/t/renamedb.test18
-rw-r--r--mysql-test/t/rpl000001.test131
-rw-r--r--mysql-test/t/rpl000004.test25
-rw-r--r--mysql-test/t/rpl000005.test24
-rw-r--r--mysql-test/t/rpl000006.test47
-rw-r--r--mysql-test/t/rpl000013-slave.opt1
-rw-r--r--mysql-test/t/rpl000013.test10
-rw-r--r--mysql-test/t/rpl000017.test6
-rwxr-xr-xmysql-test/t/rpl_000015-slave.sh (renamed from mysql-test/t/rpl000015-slave.sh)0
-rw-r--r--mysql-test/t/rpl_000015.slave-mi (renamed from mysql-test/t/rpl000015.slave-mi)0
-rw-r--r--mysql-test/t/rpl_000015.test (renamed from mysql-test/t/rpl000015.test)14
-rw-r--r--mysql-test/t/rpl_EE_err.test7
-rw-r--r--mysql-test/t/rpl_EE_error.test32
-rw-r--r--mysql-test/t/rpl_LD_INFILE.test38
-rw-r--r--mysql-test/t/rpl_alter_db.test10
-rw-r--r--mysql-test/t/rpl_auto_increment-slave.opt (renamed from mysql-test/t/rpl000001-slave.opt)0
-rw-r--r--mysql-test/t/rpl_auto_increment.test116
-rw-r--r--mysql-test/t/rpl_bit.test94
-rw-r--r--mysql-test/t/rpl_bit_npk.test116
-rw-r--r--mysql-test/t/rpl_change_master.test4
-rw-r--r--mysql-test/t/rpl_charset.test173
-rw-r--r--mysql-test/t/rpl_commit_after_flush.test30
-rw-r--r--mysql-test/t/rpl_create_database.test9
-rw-r--r--mysql-test/t/rpl_ddl.test484
-rw-r--r--mysql-test/t/rpl_deadlock.test119
-rw-r--r--mysql-test/t/rpl_deadlock_innodb-slave.opt (renamed from mysql-test/t/rpl_deadlock-slave.opt)0
-rw-r--r--mysql-test/t/rpl_deadlock_innodb.test11
-rw-r--r--mysql-test/t/rpl_delete_all.test43
-rw-r--r--mysql-test/t/rpl_delete_no_where.test6
-rw-r--r--mysql-test/t/rpl_do_grant.test54
-rw-r--r--mysql-test/t/rpl_drop.test2
-rw-r--r--mysql-test/t/rpl_drop_db.test5
-rw-r--r--mysql-test/t/rpl_drop_temp.test14
-rw-r--r--mysql-test/t/rpl_empty_master_crash.test2
-rw-r--r--mysql-test/t/rpl_err_ignoredtable-slave.opt (renamed from mysql-test/t/rpl_error_ignored_table-slave.opt)0
-rw-r--r--mysql-test/t/rpl_err_ignoredtable.test (renamed from mysql-test/t/rpl_error_ignored_table.test)28
-rw-r--r--mysql-test/t/rpl_failed_optimize.test34
-rw-r--r--mysql-test/t/rpl_flush_tables.test56
-rw-r--r--mysql-test/t/rpl_flushlog_loop-master.opt (renamed from mysql-test/t/rpl_flush_log_loop-master.opt)0
-rwxr-xr-xmysql-test/t/rpl_flushlog_loop-master.sh (renamed from mysql-test/t/rpl_flush_log_loop-master.sh)0
-rw-r--r--mysql-test/t/rpl_flushlog_loop-slave.opt (renamed from mysql-test/t/rpl_flush_log_loop-slave.opt)0
-rwxr-xr-xmysql-test/t/rpl_flushlog_loop-slave.sh (renamed from mysql-test/t/rpl_flush_log_loop-slave.sh)0
-rw-r--r--mysql-test/t/rpl_flushlog_loop.test (renamed from mysql-test/t/rpl_flush_log_loop.test)37
-rw-r--r--mysql-test/t/rpl_foreign_key_innodb-slave.opt1
-rw-r--r--mysql-test/t/rpl_foreign_key_innodb.test11
-rw-r--r--mysql-test/t/rpl_heap.test9
-rw-r--r--mysql-test/t/rpl_ignore_table.test2
-rw-r--r--mysql-test/t/rpl_ignore_table_update-slave.opt (renamed from mysql-test/t/rpl000008-slave.opt)0
-rw-r--r--mysql-test/t/rpl_ignore_table_update.test (renamed from mysql-test/t/rpl000008.test)0
-rw-r--r--mysql-test/t/rpl_insert_id.test163
-rw-r--r--mysql-test/t/rpl_insert_id_pk-slave.opt1
-rw-r--r--mysql-test/t/rpl_insert_id_pk.test11
-rw-r--r--mysql-test/t/rpl_insert_ignore.test79
-rw-r--r--mysql-test/t/rpl_load_from_master-slave.opt (renamed from mysql-test/t/rpl000009-slave.opt)0
-rw-r--r--mysql-test/t/rpl_load_from_master.test (renamed from mysql-test/t/rpl000009.test)30
-rw-r--r--mysql-test/t/rpl_load_table_from_master.test98
-rw-r--r--mysql-test/t/rpl_loaddata.test161
-rw-r--r--mysql-test/t/rpl_loaddata2.test14
-rw-r--r--mysql-test/t/rpl_loaddata_m-master.opt (renamed from mysql-test/t/rpl_loaddata_rule_m-master.opt)0
-rw-r--r--mysql-test/t/rpl_loaddata_m.test52
-rw-r--r--mysql-test/t/rpl_loaddata_rule_m.test33
-rw-r--r--mysql-test/t/rpl_loaddata_rule_s.test25
-rw-r--r--mysql-test/t/rpl_loaddata_s-slave.opt (renamed from mysql-test/t/rpl_loaddata_rule_s-slave.opt)0
-rw-r--r--mysql-test/t/rpl_loaddata_s.test30
-rw-r--r--mysql-test/t/rpl_loaddatalocal.test4
-rw-r--r--mysql-test/t/rpl_loadfile.test52
-rw-r--r--mysql-test/t/rpl_log.test113
-rw-r--r--mysql-test/t/rpl_log_pos.test21
-rw-r--r--mysql-test/t/rpl_max_relay_size.test96
-rw-r--r--mysql-test/t/rpl_mixed_ddl_dml.test (renamed from mysql-test/t/rpl000002.test)5
-rw-r--r--mysql-test/t/rpl_multi_delete.test29
-rw-r--r--mysql-test/t/rpl_multi_delete2.test2
-rw-r--r--mysql-test/t/rpl_multi_engine-slave.opt1
-rw-r--r--mysql-test/t/rpl_multi_engine.test108
-rw-r--r--mysql-test/t/rpl_multi_query.test32
-rw-r--r--mysql-test/t/rpl_multi_update.test56
-rw-r--r--mysql-test/t/rpl_multi_update2.test71
-rw-r--r--mysql-test/t/rpl_multi_update3.test232
-rw-r--r--mysql-test/t/rpl_multi_update4.test7
-rw-r--r--mysql-test/t/rpl_mystery22.test40
-rw-r--r--mysql-test/t/rpl_ndb_2innodb-master.opt1
-rw-r--r--mysql-test/t/rpl_ndb_2innodb-slave.opt1
-rw-r--r--mysql-test/t/rpl_ndb_2innodb.test16
-rw-r--r--mysql-test/t/rpl_ndb_2myisam-master.opt1
-rw-r--r--mysql-test/t/rpl_ndb_2myisam-slave.opt1
-rw-r--r--mysql-test/t/rpl_ndb_2myisam.test13
-rw-r--r--mysql-test/t/rpl_ndb_UUID.test6
-rw-r--r--mysql-test/t/rpl_ndb_auto_inc.test116
-rw-r--r--mysql-test/t/rpl_ndb_bank.test180
-rw-r--r--mysql-test/t/rpl_ndb_basic.test180
-rw-r--r--mysql-test/t/rpl_ndb_blob.test142
-rw-r--r--mysql-test/t/rpl_ndb_blob2.test9
-rw-r--r--mysql-test/t/rpl_ndb_charset.test6
-rw-r--r--mysql-test/t/rpl_ndb_commit_afterflush.test9
-rw-r--r--mysql-test/t/rpl_ndb_dd_advance.test578
-rw-r--r--mysql-test/t/rpl_ndb_dd_basic.test85
-rw-r--r--mysql-test/t/rpl_ndb_ddl.test34
-rw-r--r--mysql-test/t/rpl_ndb_delete_nowhere.test8
-rw-r--r--mysql-test/t/rpl_ndb_func003.test11
-rw-r--r--mysql-test/t/rpl_ndb_idempotent.test116
-rw-r--r--mysql-test/t/rpl_ndb_innodb2ndb-master.opt1
-rw-r--r--mysql-test/t/rpl_ndb_innodb2ndb-slave.opt1
-rw-r--r--mysql-test/t/rpl_ndb_innodb2ndb.test16
-rw-r--r--mysql-test/t/rpl_ndb_insert_ignore.test8
-rw-r--r--mysql-test/t/rpl_ndb_load.test66
-rw-r--r--mysql-test/t/rpl_ndb_log-master.opt (renamed from mysql-test/t/rpl_log-master.opt)0
-rw-r--r--mysql-test/t/rpl_ndb_log.test12
-rw-r--r--mysql-test/t/rpl_ndb_multi.test71
-rw-r--r--mysql-test/t/rpl_ndb_multi_update2-slave.opt1
-rw-r--r--mysql-test/t/rpl_ndb_multi_update2.test12
-rw-r--r--mysql-test/t/rpl_ndb_multi_update3.test8
-rw-r--r--mysql-test/t/rpl_ndb_myisam2ndb-master.opt1
-rw-r--r--mysql-test/t/rpl_ndb_myisam2ndb-slave.opt1
-rw-r--r--mysql-test/t/rpl_ndb_myisam2ndb.test15
-rw-r--r--mysql-test/t/rpl_ndb_relayrotate-slave.opt3
-rw-r--r--mysql-test/t/rpl_ndb_relayrotate.test8
-rw-r--r--mysql-test/t/rpl_ndb_row_001.test6
-rw-r--r--mysql-test/t/rpl_ndb_sp003.test9
-rw-r--r--mysql-test/t/rpl_ndb_sp006.test9
-rw-r--r--mysql-test/t/rpl_ndb_sync.test102
-rw-r--r--mysql-test/t/rpl_ndb_trig004.test15
-rw-r--r--mysql-test/t/rpl_openssl.test4
-rw-r--r--mysql-test/t/rpl_optimize.test13
-rw-r--r--mysql-test/t/rpl_ps.test11
-rw-r--r--mysql-test/t/rpl_rbr_to_sbr.test47
-rw-r--r--mysql-test/t/rpl_redirect.test14
-rw-r--r--mysql-test/t/rpl_relay_space_innodb-master.opt1
-rw-r--r--mysql-test/t/rpl_relay_space_innodb-slave.opt1
-rw-r--r--mysql-test/t/rpl_relay_space_innodb.test22
-rw-r--r--mysql-test/t/rpl_relay_space_myisam.test21
-rw-r--r--mysql-test/t/rpl_relayrotate.test85
-rw-r--r--mysql-test/t/rpl_replicate_do.test5
-rw-r--r--mysql-test/t/rpl_replicate_ignore_db-slave.opt1
-rw-r--r--mysql-test/t/rpl_replicate_ignore_db.test30
-rw-r--r--mysql-test/t/rpl_reset_slave.test51
-rw-r--r--mysql-test/t/rpl_rewrt_db-slave.opt (renamed from mysql-test/t/rpl_rewrite_db-slave.opt)0
-rw-r--r--mysql-test/t/rpl_rewrt_db.test (renamed from mysql-test/t/rpl_rewrite_db.test)5
-rw-r--r--mysql-test/t/rpl_rotate_logs.test9
-rw-r--r--mysql-test/t/rpl_row_001.test7
-rw-r--r--mysql-test/t/rpl_row_4_bytes-master.opt1
-rw-r--r--mysql-test/t/rpl_row_4_bytes.test33
-rw-r--r--mysql-test/t/rpl_row_NOW.test73
-rw-r--r--mysql-test/t/rpl_row_USER.test58
-rw-r--r--mysql-test/t/rpl_row_UUID.test7
-rw-r--r--mysql-test/t/rpl_row_basic_11bugs-master.opt1
-rw-r--r--mysql-test/t/rpl_row_basic_11bugs.test38
-rw-r--r--mysql-test/t/rpl_row_basic_2myisam.test3
-rw-r--r--mysql-test/t/rpl_row_basic_3innodb-slave.opt1
-rw-r--r--mysql-test/t/rpl_row_basic_3innodb.test6
-rw-r--r--mysql-test/t/rpl_row_basic_7ndb.test4
-rw-r--r--mysql-test/t/rpl_row_basic_8partition.test205
-rw-r--r--mysql-test/t/rpl_row_blob_innodb-slave.opt1
-rw-r--r--mysql-test/t/rpl_row_blob_innodb.test12
-rw-r--r--mysql-test/t/rpl_row_blob_myisam.test11
-rw-r--r--mysql-test/t/rpl_row_charset.test7
-rw-r--r--mysql-test/t/rpl_row_create_table.test119
-rw-r--r--mysql-test/t/rpl_row_delayed_ins.test7
-rw-r--r--mysql-test/t/rpl_row_drop.test48
-rw-r--r--mysql-test/t/rpl_row_err_daisychain-master.opt1
-rw-r--r--mysql-test/t/rpl_row_err_daisychain-slave.opt1
-rw-r--r--mysql-test/t/rpl_row_flsh_tbls.test17
-rw-r--r--mysql-test/t/rpl_row_func001.test57
-rw-r--r--mysql-test/t/rpl_row_func002.test103
-rw-r--r--mysql-test/t/rpl_row_func003-slave.opt1
-rw-r--r--mysql-test/t/rpl_row_func003.test11
-rw-r--r--mysql-test/t/rpl_row_inexist_tbl.test27
-rw-r--r--mysql-test/t/rpl_row_log-master.opt1
-rw-r--r--mysql-test/t/rpl_row_log-slave.opt (renamed from mysql-test/t/rpl_log-slave.opt)0
-rw-r--r--mysql-test/t/rpl_row_log.test16
-rw-r--r--mysql-test/t/rpl_row_log_innodb-master.opt1
-rw-r--r--mysql-test/t/rpl_row_log_innodb-slave.opt1
-rw-r--r--mysql-test/t/rpl_row_log_innodb.test13
-rw-r--r--mysql-test/t/rpl_row_max_relay_size.test10
-rw-r--r--mysql-test/t/rpl_row_mysqlbinlog-master.opt1
-rw-r--r--mysql-test/t/rpl_row_mysqlbinlog.test319
-rw-r--r--mysql-test/t/rpl_row_mystery22.test45
-rw-r--r--mysql-test/t/rpl_row_reset_slave.test5
-rw-r--r--mysql-test/t/rpl_row_sp001.test146
-rw-r--r--mysql-test/t/rpl_row_sp002_innodb-master.opt1
-rw-r--r--mysql-test/t/rpl_row_sp002_innodb-slave.opt1
-rw-r--r--mysql-test/t/rpl_row_sp002_innodb.test11
-rw-r--r--mysql-test/t/rpl_row_sp003-master.opt1
-rw-r--r--mysql-test/t/rpl_row_sp003-slave.opt1
-rw-r--r--mysql-test/t/rpl_row_sp003.test11
-rw-r--r--mysql-test/t/rpl_row_sp005.test110
-rw-r--r--mysql-test/t/rpl_row_sp006_InnoDB-slave.opt1
-rw-r--r--mysql-test/t/rpl_row_sp006_InnoDB.test11
-rw-r--r--mysql-test/t/rpl_row_sp007_innodb-slave.opt1
-rw-r--r--mysql-test/t/rpl_row_sp007_innodb.test11
-rw-r--r--mysql-test/t/rpl_row_sp008.test56
-rw-r--r--mysql-test/t/rpl_row_sp009.test105
-rw-r--r--mysql-test/t/rpl_row_sp010.test80
-rw-r--r--mysql-test/t/rpl_row_sp011.test111
-rw-r--r--mysql-test/t/rpl_row_sp012.test74
-rw-r--r--mysql-test/t/rpl_row_stop_middle.test44
-rw-r--r--mysql-test/t/rpl_row_stop_middle_update-master.opt1
-rw-r--r--mysql-test/t/rpl_row_stop_middle_update-slave.opt1
-rw-r--r--mysql-test/t/rpl_row_stop_middle_update.test31
-rw-r--r--mysql-test/t/rpl_row_trig001.test100
-rw-r--r--mysql-test/t/rpl_row_trig002.test80
-rw-r--r--mysql-test/t/rpl_row_trig003.test152
-rw-r--r--mysql-test/t/rpl_row_trig004.test18
-rw-r--r--mysql-test/t/rpl_row_until.test87
-rw-r--r--mysql-test/t/rpl_row_view01.test88
-rw-r--r--mysql-test/t/rpl_server_id1.test2
-rw-r--r--mysql-test/t/rpl_skip_error.test14
-rw-r--r--mysql-test/t/rpl_slave_status.test25
-rw-r--r--mysql-test/t/rpl_sp.test14
-rw-r--r--mysql-test/t/rpl_sp004.test97
-rw-r--r--mysql-test/t/rpl_sp_effects.test42
-rw-r--r--mysql-test/t/rpl_sporadic_master.test5
-rw-r--r--mysql-test/t/rpl_stm_000001-slave.opt1
-rw-r--r--mysql-test/t/rpl_stm_000001.test2
-rw-r--r--mysql-test/t/rpl_stm_EE_err2.test8
-rw-r--r--mysql-test/t/rpl_stm_charset.test2
-rw-r--r--mysql-test/t/rpl_stm_flsh_tbls.test8
-rw-r--r--mysql-test/t/rpl_stm_log-master.opt1
-rw-r--r--mysql-test/t/rpl_stm_log-slave.opt1
-rw-r--r--mysql-test/t/rpl_stm_log.test8
-rw-r--r--mysql-test/t/rpl_stm_max_relay_size.test11
-rw-r--r--mysql-test/t/rpl_stm_multi_query.test12
-rw-r--r--mysql-test/t/rpl_stm_mystery22.test66
-rw-r--r--mysql-test/t/rpl_stm_no_op.test93
-rw-r--r--mysql-test/t/rpl_stm_reset_slave.test6
-rw-r--r--mysql-test/t/rpl_stm_until.test (renamed from mysql-test/t/rpl_until.test)11
-rw-r--r--mysql-test/t/rpl_switch_stm_row_mixed.test216
-rw-r--r--mysql-test/t/rpl_temp_table.test (renamed from mysql-test/t/rpl000012.test)36
-rw-r--r--mysql-test/t/rpl_temporary.test16
-rw-r--r--mysql-test/t/rpl_timezone.test77
-rw-r--r--mysql-test/t/rpl_trigger.test12
-rw-r--r--mysql-test/t/rpl_trunc_temp.test3
-rw-r--r--mysql-test/t/rpl_user_variables.test29
-rw-r--r--mysql-test/t/rpl_view.test11
-rw-r--r--mysql-test/t/show_check.test86
-rw-r--r--mysql-test/t/sp-destruct.test8
-rw-r--r--mysql-test/t/sp-error.test18
-rw-r--r--mysql-test/t/sp-prelocking.test4
-rw-r--r--mysql-test/t/sp.test12
-rw-r--r--mysql-test/t/sql_mode.test24
-rw-r--r--mysql-test/t/strict.test8
-rw-r--r--mysql-test/t/system_mysql_db.test4
-rw-r--r--mysql-test/t/system_mysql_db_fix.test15
-rw-r--r--mysql-test/t/temp_table.test12
-rw-r--r--mysql-test/t/trigger-compat.test3
-rw-r--r--mysql-test/t/trigger-grant.test154
-rw-r--r--mysql-test/t/trigger.test2
-rw-r--r--mysql-test/t/upgrade.test49
-rw-r--r--mysql-test/t/user_var-binlog.test7
-rw-r--r--mysql-test/t/variables.test8
-rw-r--r--mysql-test/t/view.test5
-rw-r--r--mysql-test/t/view_grant.test8
-rw-r--r--mysql-test/t/warnings.test14
-rw-r--r--mysql-test/t/xml.test345
413 files changed, 17961 insertions, 4686 deletions
diff --git a/mysql-test/t/alter_table.test b/mysql-test/t/alter_table.test
index cfa6182543b..efe58579785 100644
--- a/mysql-test/t/alter_table.test
+++ b/mysql-test/t/alter_table.test
@@ -232,9 +232,9 @@ DROP TABLE t1;
#
create table t1 (a int);
--error 1103
-alter table t1 rename to `t1\\`;
+alter table t1 rename to ``;
--error 1103
-rename table t1 to `t1\\`;
+rename table t1 to ``;
drop table t1;
#
@@ -414,6 +414,33 @@ desc t1;
drop table t1;
#
+# Some additional tests for new, faster alter table. Note that most of the
+# whole alter table code is being tested all around the test suite already.
+#
+
+create table t1 (v varchar(32));
+insert into t1 values ('def'),('abc'),('hij'),('3r4f');
+select * from t1;
+# Fast alter, no copy performed
+alter table t1 change v v2 varchar(32);
+select * from t1;
+# Fast alter, no copy performed
+alter table t1 change v2 v varchar(64);
+select * from t1;
+update t1 set v = 'lmn' where v = 'hij';
+select * from t1;
+# Regular alter table
+alter table t1 add i int auto_increment not null primary key first;
+select * from t1;
+update t1 set i=5 where i=3;
+select * from t1;
+alter table t1 change i i bigint;
+select * from t1;
+alter table t1 add unique key (i, v);
+select * from t1 where i between 2 and 4 and v in ('def','3r4f','lmn');
+drop table t1;
+
+#
# Bug#6073 "ALTER table minor glich": ALTER TABLE complains that an index
# without # prefix is not allowed for TEXT columns, while index
# is defined with prefix.
@@ -422,3 +449,36 @@ create table t1 (t varchar(255) default null, key t (t(80)))
engine=myisam default charset=latin1;
alter table t1 change t t text;
drop table t1;
+
+#
+# Bug#18038 MySQL server corrupts binary columns data
+#
+
+CREATE TABLE t1 (s CHAR(8) BINARY);
+INSERT INTO t1 VALUES ('test');
+SELECT LENGTH(s) FROM t1;
+ALTER TABLE t1 MODIFY s CHAR(10) BINARY;
+SELECT LENGTH(s) FROM t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (s BINARY(8));
+INSERT INTO t1 VALUES ('test');
+SELECT LENGTH(s) FROM t1;
+SELECT HEX(s) FROM t1;
+ALTER TABLE t1 MODIFY s BINARY(10);
+SELECT HEX(s) FROM t1;
+SELECT LENGTH(s) FROM t1;
+DROP TABLE t1;
+
+#
+# Bug#19386: Multiple alter causes crashed table
+# The trailing column would get corrupted data, or server could not even read
+# it.
+#
+
+CREATE TABLE t1 (v VARCHAR(3), b INT);
+INSERT INTO t1 VALUES ('abc', 5);
+SELECT * FROM t1;
+ALTER TABLE t1 MODIFY COLUMN v VARCHAR(4);
+SELECT * FROM t1;
+DROP TABLE t1;
diff --git a/mysql-test/t/archive.test b/mysql-test/t/archive.test
index ba2ad3ed8aa..c89d31c69b9 100644
--- a/mysql-test/t/archive.test
+++ b/mysql-test/t/archive.test
@@ -1,11 +1,11 @@
#
# Simple test for archive example
-# Taken from the select test
+# Taken FROM the select test
#
-- source include/have_archive.inc
--disable_warnings
-drop table if exists t1,t2;
+drop table if exists t1,t2,t3;
--enable_warnings
CREATE TABLE t1 (
@@ -15,9 +15,9 @@ CREATE TABLE t1 (
INSERT INTO t1 VALUES (9410,9412);
-select period from t1;
-select * from t1;
-select t1.* from t1;
+select period FROM t1;
+select * FROM t1;
+select t1.* FROM t1;
#
# Create test table
@@ -1243,64 +1243,64 @@ INSERT INTO t2 VALUES (1193,000000,00,'nondecreasing','implant','thrillingly',''
# Search with a key
#
-select t2.fld3 from t2 where companynr = 58 and fld3 like "%imaginable%";
-select fld3 from t2 where fld3 like "%cultivation" ;
+select t2.fld3 FROM t2 where companynr = 58 and fld3 like "%imaginable%";
+select fld3 FROM t2 where fld3 like "%cultivation" ;
#
# Search with a key using sorting and limit the same time
#
-select t2.fld3,companynr from t2 where companynr = 57+1 order by fld3;
-select fld3,companynr from t2 where companynr = 58 order by fld3;
+select t2.fld3,companynr FROM t2 where companynr = 57+1 order by fld3;
+select fld3,companynr FROM t2 where companynr = 58 order by fld3;
-select fld3 from t2 order by fld3 desc limit 10;
-select fld3 from t2 order by fld3 desc limit 5;
-select fld3 from t2 order by fld3 desc limit 5,5;
+select fld3 FROM t2 order by fld3 desc limit 10;
+select fld3 FROM t2 order by fld3 desc limit 5;
+select fld3 FROM t2 order by fld3 desc limit 5,5;
#
# Search with a key having a constant with each unique key.
# The table is read directly with read-next on fld3
#
-select t2.fld3 from t2 where fld3 = 'honeysuckle';
-select t2.fld3 from t2 where fld3 LIKE 'honeysuckl_';
-select t2.fld3 from t2 where fld3 LIKE 'hon_ysuckl_';
-select t2.fld3 from t2 where fld3 LIKE 'honeysuckle%';
-select t2.fld3 from t2 where fld3 LIKE 'h%le';
+select t2.fld3 FROM t2 where fld3 = 'honeysuckle';
+select t2.fld3 FROM t2 where fld3 LIKE 'honeysuckl_';
+select t2.fld3 FROM t2 where fld3 LIKE 'hon_ysuckl_';
+select t2.fld3 FROM t2 where fld3 LIKE 'honeysuckle%';
+select t2.fld3 FROM t2 where fld3 LIKE 'h%le';
-select t2.fld3 from t2 where fld3 LIKE 'honeysuckle_';
-select t2.fld3 from t2 where fld3 LIKE 'don_t_find_me_please%';
+select t2.fld3 FROM t2 where fld3 LIKE 'honeysuckle_';
+select t2.fld3 FROM t2 where fld3 LIKE 'don_t_find_me_please%';
#
# Test sorting with a used key (there is no need for sorting)
#
-select t2.fld3 from t2 where fld3 >= 'honeysuckle' and fld3 <= 'honoring' order by fld3;
-select fld1,fld3 from t2 where fld3="Colombo" or fld3 = "nondecreasing" order by fld3;
+select t2.fld3 FROM t2 where fld3 >= 'honeysuckle' and fld3 <= 'honoring' order by fld3;
+select fld1,fld3 FROM t2 where fld3="Colombo" or fld3 = "nondecreasing" order by fld3;
#
# Search with a key with LIKE constant
# If the like starts with a certain letter key will be used.
#
-select fld1,fld3 from t2 where companynr = 37 and fld3 like 'f%';
-select fld3 from t2 where fld3 like "L%" and fld3 = "ok";
-select fld3 from t2 where (fld3 like "C%" and fld3 = "Chantilly");
-select fld1,fld3 from t2 where fld1 like "25050%";
-select fld1,fld3 from t2 where fld1 like "25050_";
+select fld1,fld3 FROM t2 where companynr = 37 and fld3 like 'f%';
+select fld3 FROM t2 where fld3 like "L%" and fld3 = "ok";
+select fld3 FROM t2 where (fld3 like "C%" and fld3 = "Chantilly");
+select fld1,fld3 FROM t2 where fld1 like "25050%";
+select fld1,fld3 FROM t2 where fld1 like "25050_";
#
# Test rename of table
#
-create table t3 engine=archive select * from t2;
-select * from t3 where fld3='bonfire';
-select count(*) from t3;
+create table t3 engine=archive select * FROM t2;
+select * FROM t3 where fld3='bonfire';
+select count(*) FROM t3;
# Clean up path in error message
--replace_result $MYSQL_TEST_DIR . /var/master-data/ /
rename table t3 to t4;
-select * from t4 where fld3='bonfire';
-select count(*) from t4;
+select * FROM t4 where fld3='bonfire';
+select count(*) FROM t4;
# End of 4.1 tests
@@ -1344,17 +1344,156 @@ CHECK TABLE t2;
SELECT * FROM t2;
-# Just test syntax, we will never know if the output is right or wrong
-# Must be the last test
+# We won't know exactly about what is going on internally,
+# but we will see if the row makes it in!!
INSERT DELAYED INTO t2 VALUES (4,011403,37,'intercepted','audiology','tinily','');
+FLUSH TABLE t2;
+SELECT * FROM t2;
# Adding test for alter table
ALTER TABLE t2 DROP COLUMN fld6;
SHOW CREATE TABLE t2;
-SELECT * from t2;
+SELECT * FROM t2;
+
+
+# Adding tests for autoincrement
+# First the simple stuff
+
+CREATE TABLE `t5` (
+`a` int(11) NOT NULL auto_increment,
+b char(12),
+PRIMARY KEY (`a`)
+) ENGINE=ARCHIVE DEFAULT CHARSET=latin1;
+
+INSERT INTO t5 VALUES (NULL, "foo");
+INSERT INTO t5 VALUES (NULL, "foo");
+INSERT INTO t5 VALUES (NULL, "foo");
+INSERT INTO t5 VALUES (NULL, "foo");
+INSERT INTO t5 VALUES (NULL, "foo");
+INSERT INTO t5 VALUES (32, "foo");
+INSERT INTO t5 VALUES (23, "foo");
+INSERT INTO t5 VALUES (NULL, "foo");
+INSERT INTO t5 VALUES (NULL, "foo");
+--error 1022
+INSERT INTO t5 VALUES (3, "foo");
+INSERT INTO t5 VALUES (NULL, "foo");
+SELECT * FROM t5;
+
+SELECT * FROM t5 WHERE a=3;
+
+DROP TABLE t5;
+
+CREATE TABLE `t5` (
+`a` int(11) NOT NULL auto_increment,
+b char(12),
+KEY (`a`)
+) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 AUTO_INCREMENT=5;
+
+INSERT INTO t5 VALUES (NULL, "foo");
+INSERT INTO t5 VALUES (NULL, "foo");
+INSERT INTO t5 VALUES (NULL, "foo");
+INSERT INTO t5 VALUES (NULL, "foo");
+INSERT INTO t5 VALUES (NULL, "foo");
+INSERT INTO t5 VALUES (32, "foo");
+INSERT INTO t5 VALUES (23, "foo");
+INSERT INTO t5 VALUES (NULL, "foo");
+INSERT INTO t5 VALUES (NULL, "foo");
+INSERT INTO t5 VALUES (3, "foo");
+INSERT INTO t5 VALUES (NULL, "foo");
+SELECT * FROM t5;
+OPTIMIZE TABLE t5;
+SELECT * FROM t5;
+
+SELECT * FROM t5 WHERE a=32;
+SELECT * FROM t5 WHERE a=3;
+
+DROP TABLE t5;
+
+CREATE TABLE `t5` (
+`a` int(11) NOT NULL auto_increment,
+b blob(12),
+KEY (`a`)
+) ENGINE=ARCHIVE DEFAULT CHARSET=latin1;
+
+INSERT INTO t5 VALUES (NULL, "foo");
+INSERT INTO t5 VALUES (NULL, "We the people");
+INSERT INTO t5 VALUES (NULL, "in order to form a more pefect union");
+INSERT INTO t5 VALUES (NULL, "establish justice");
+INSERT INTO t5 VALUES (NULL, "foo grok ");
+INSERT INTO t5 VALUES (32, "ensure domestic tranquility");
+INSERT INTO t5 VALUES (23, "provide for the common defense");
+INSERT INTO t5 VALUES (NULL, "fo fooo");
+INSERT INTO t5 VALUES (NULL, "foo just naother bit of text");
+INSERT INTO t5 VALUES (3, "foo this is mine to think about");
+INSERT INTO t5 VALUES (NULL, "promote the general welfare");
+SELECT * FROM t5;
+SELECT b FROM t5;
+SELECT b FROM t5 WHERE a =3;
+SELECT b FROM t5 WHERE a IN (32, 23, 5);
+
+
+#More blob tests
+
+DROP TABLE t5;
+
+CREATE TABLE `t5` (
+`a` int(11) NOT NULL auto_increment,
+b blob(12),
+c blob(12),
+KEY (`a`)
+) ENGINE=ARCHIVE DEFAULT CHARSET=latin1;
+
+INSERT INTO t5 VALUES (NULL, "foo", "grok this!");
+INSERT INTO t5 VALUES (NULL, "We the people", NULL);
+INSERT INTO t5 VALUES (NULL, "in order to form a more peefect union", "secure the blessing of liberty");
+INSERT INTO t5 VALUES (NULL, "establish justice", "to ourselves and");
+INSERT INTO t5 VALUES (32, "ensure domestic tranquility", NULL);
+INSERT INTO t5 VALUES (23, "provide for the common defense", "posterity");
+INSERT INTO t5 VALUES (NULL, "promote the general welfare", "do ordain");
+SELECT * FROM t5;
+SELECT b FROM t5;
+SELECT b FROM t5 WHERE a =3;
+SELECT b FROM t5 WHERE a IN (32, 23, 5);
+SELECT c FROM t5;
+SELECT c FROM t5 WHERE a =3;
+SELECT c FROM t5 WHERE a IN (32, 23, 5);
+
+# Adding this in case someone tries to add fast alter table and doesn't tes
+# it.
+# Some additional tests for new, faster alter table. Note that most of the
+# whole alter table code is being tested all around the test suite already.
+#
+
+drop table t1;
+create table t1 (v varchar(32));
+insert into t1 values ('def'),('abc'),('hij'),('3r4f');
+select * from t1;
+# Fast alter, no copy performed
+alter table t1 change v v2 varchar(32);
+select * from t1;
+# Fast alter, no copy performed
+alter table t1 change v2 v varchar(64);
+select * from t1;
+update t1 set v = 'lmn' where v = 'hij';
+select * from t1;
+# Regular alter table
+alter table t1 add i int auto_increment not null primary key first;
+select * from t1;
+update t1 set i=5 where i=3;
+select * from t1;
+alter table t1 change i i bigint;
+select * from t1;
+alter table t1 add unique key (i, v);
+select * from t1 where i between 2 and 4 and v in ('def','3r4f','lmn');
+
+alter table t1 data directory="$MYSQLTEST_VARDIR/tmp";
+select * from t1;
+
#
# Cleanup, test is over
#
-drop table t1, t2, t4;
+--disable_warnings
+drop table t1, t2, t4, t5;
+--enable_warnings
diff --git a/mysql-test/t/archive_bitfield.test b/mysql-test/t/archive_bitfield.test
new file mode 100644
index 00000000000..1e4692270b5
--- /dev/null
+++ b/mysql-test/t/archive_bitfield.test
@@ -0,0 +1,98 @@
+-- source include/have_archive.inc
+-- source include/not_embedded.inc
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+create table t1 (
+ pk1 int not null auto_increment primary key,
+ b bit(64)
+) engine=archive;
+
+show create table t1;
+insert into t1 values
+(NULL,b'1111111111111111111111111111111111111111111111111111111111111111'),
+(NULL,b'1000000000000000000000000000000000000000000000000000000000000000'),
+(NULL,b'0000000000000000000000000000000000000000000000000000000000000001'),
+(NULL,b'1010101010101010101010101010101010101010101010101010101010101010'),
+(NULL,b'0101010101010101010101010101010101010101010101010101010101010101');
+select hex(b) from t1 order by pk1;
+drop table t1;
+
+create table t1 (
+ pk1 int not null auto_increment primary key,
+ b bit(9)
+) engine=archive;
+insert into t1 values
+(NULL,b'000000000'),
+(NULL,b'000000001'),
+(NULL,b'000000010'),
+(NULL,b'000000011'),
+(NULL,b'000000100');
+select hex(b) from t1 order by pk1;
+drop table t1;
+
+create table t1 (a bit(7), b bit(9)) engine = archive;
+insert into t1 values
+(94, 46), (31, 438), (61, 152), (78, 123), (88, 411), (122, 118), (0, 177),
+(75, 42), (108, 67), (79, 349), (59, 188), (68, 206), (49, 345), (118, 380),
+(111, 368), (94, 468), (56, 379), (77, 133), (29, 399), (9, 363), (23, 36),
+(116, 390), (119, 368), (87, 351), (123, 411), (24, 398), (34, 202), (28, 499),
+(30, 83), (5, 178), (60, 343), (4, 245), (104, 280), (106, 446), (127, 403),
+(44, 307), (68, 454), (57, 135);
+select a+0 from t1 order by a;
+select b+0 from t1 order by b;
+drop table t1;
+
+create table t1 (
+ dummyKey INTEGER NOT NULL AUTO_INCREMENT,
+ a001 TINYINT,
+ a010 TINYINT,
+ a012 TINYINT,
+ a015 TINYINT,
+ a016 TINYINT,
+ a017 TINYINT,
+ a019 TINYINT,
+ a029 TINYINT,
+ a030 TINYINT,
+ a031 TINYINT,
+ a032 TINYINT,
+ a042 TINYINT,
+ a043 TINYINT,
+ a044 TINYINT,
+ a3001 TINYINT,
+ a3002 TINYINT,
+ a3003 TINYINT,
+ a3004 TINYINT,
+ a3005 TINYINT,
+ a3021 TINYINT,
+ a3022 TINYINT,
+ a BIT(6),
+ b BIT(6),
+ c BIT(6),
+ d TINYINT,
+ e TINYINT,
+ f TINYINT,
+ g TINYINT,
+ h TINYINT,
+ i TINYINT,
+ j TINYINT,
+ k TINYINT,
+ l TINYINT,
+ m TINYINT,
+ n TINYINT,
+ o TINYINT,
+ a034 TINYINT,
+PRIMARY KEY USING HASH (dummyKey) ) engine=archive;
+INSERT INTO `t1` VALUES
+(NULL,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b'000001',b'111111',b'111110',4,5,5,5,5,5,5,5,5,5,3,2,1),
+(NULL,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b'000010',b'000000',b'111101',4,5,5,5,5,5,5,5,5,5,3,2,1),
+(NULL,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b'000100',b'001111',b'111011',4,5,5,5,5,5,5,5,5,5,3,2,1),
+(NULL,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b'001000',b'110000',b'110111',4,5,5,5,5,5,5,5,5,5,3,2,1),
+(NULL,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b'010000',b'100001',b'101111',4,5,5,5,5,5,5,5,5,5,3,2,1),
+(NULL,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b'100000',b'010010',b'011111',4,5,5,5,5,5,5,5,5,5,3,2,1),
+(NULL,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b'000000',b'001100',b'111111',4,5,5,5,5,5,5,5,5,5,3,2,1),
+(NULL,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'000000',4,5,5,5,5,5,5,5,5,5,3,2,1);
+--exec $MYSQL_DUMP --hex-blob --compact --order-by-primary --skip-extended-insert --no-create-info test t1
+drop table t1;
diff --git a/mysql-test/t/auto_increment.test b/mysql-test/t/auto_increment.test
index 26b103b0107..e0b024d021b 100644
--- a/mysql-test/t/auto_increment.test
+++ b/mysql-test/t/auto_increment.test
@@ -275,3 +275,14 @@ update t1 set a=2 where a=1;
insert into t1 (val) values (1);
select * from t1;
drop table t1;
+
+#
+# Test key duplications with auto-increment in ALTER TABLE
+# bug #14573
+#
+CREATE TABLE t1 (t1 INT(10) PRIMARY KEY, t2 INT(10));
+INSERT INTO t1 VALUES(0, 0);
+INSERT INTO t1 VALUES(1, 1);
+--error ER_DUP_ENTRY
+ALTER TABLE t1 CHANGE t1 t1 INT(10) auto_increment;
+DROP TABLE t1;
diff --git a/mysql-test/t/backup.test b/mysql-test/t/backup.test
index 053e83528e0..917c3f98ebb 100644
--- a/mysql-test/t/backup.test
+++ b/mysql-test/t/backup.test
@@ -10,7 +10,7 @@ connect (con2,localhost,root,,);
connection con1;
set SQL_LOG_BIN=0;
--disable_warnings
-drop table if exists t1, t2, t3;
+drop table if exists t1, t2, t3, t4;
--enable_warnings
create table t4(n int);
--replace_result ": 1" ": X" ": 2" ": X" ": 22" ": X" ": 23" ": X" $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
diff --git a/mysql-test/t/bdb.test b/mysql-test/t/bdb.test
index d017d91bfb1..dbf5559943a 100644
--- a/mysql-test/t/bdb.test
+++ b/mysql-test/t/bdb.test
@@ -147,6 +147,32 @@ insert into t1 values (6);
-- error 1062
insert into t1 values (4);
select n from t1;
+set autocommit=0;
+#
+# savepoints
+#
+begin;
+savepoint `my_savepoint`;
+insert into t1 values (7);
+savepoint `savept2`;
+insert into t1 values (3);
+select n from t1;
+savepoint savept3;
+rollback to savepoint savept2;
+--error 1305
+rollback to savepoint savept3;
+rollback to savepoint savept2;
+release savepoint `my_savepoint`;
+select n from t1;
+-- error 1305
+rollback to savepoint `my_savepoint`;
+--error 1305
+rollback to savepoint savept2;
+insert into t1 values (8);
+savepoint sv;
+commit;
+savepoint sv;
+set autocommit=1;
# nop
rollback;
drop table t1;
@@ -1020,3 +1046,24 @@ alter table t1 add primary key(a);
drop table t1;
--echo End of 5.0 tests
+
+#
+# Bug #7955: SET TRANSACTION ISIOLATION LEVEL lives longer than next
+# transaciton
+#
+create table t1 (a int) engine=bdb;
+set session transaction isolation level repeatable read;
+set transaction isolation level serializable;
+begin;
+select @@tx_isolation;
+insert into t1 values (1);
+--error ER_CANT_CHANGE_TX_ISOLATION
+set transaction isolation level read committed;
+rollback;
+begin;
+select @@tx_isolation;
+insert into t1 values (1);
+rollback;
+drop table t1;
+
+--echo End of 5.1 tests
diff --git a/mysql-test/t/binlog.test b/mysql-test/t/binlog.test
deleted file mode 100644
index 1063940d378..00000000000
--- a/mysql-test/t/binlog.test
+++ /dev/null
@@ -1,49 +0,0 @@
-#
-# misc binlogging tests that do not require a slave running
-#
--- source include/not_embedded.inc
--- source include/have_bdb.inc
--- source include/have_innodb.inc
-
---disable_warnings
-drop table if exists t1, t2;
---enable_warnings
-reset master;
-
-create table t1 (a int) engine=bdb;
-create table t2 (a int) engine=innodb;
-begin;
-insert t1 values (5);
-commit;
-begin;
-insert t2 values (5);
-commit;
-# first COMMIT must be Query_log_event, second - Xid_log_event
---replace_result "xid=21" "xid=12"
---replace_column 2 # 5 #
-show binlog events from 98;
-drop table t1,t2;
-
-#
-# binlog rotation after one big transaction
-#
-reset master;
-let $1=100;
-
-create table t1 (n int) engine=innodb;
-begin;
---disable_query_log
-while ($1)
-{
- eval insert into t1 values($1 + 4);
- dec $1;
-}
---enable_query_log
-commit;
-drop table t1;
---replace_result "xid=32" "xid=19"
---replace_column 2 # 5 #
-show binlog events in 'master-bin.000001' from 98;
---replace_column 2 # 5 #
-show binlog events in 'master-bin.000002' from 98;
-
diff --git a/mysql-test/t/binlog-master.opt b/mysql-test/t/binlog_row_binlog-master.opt
index ad2c6a647b5..ad2c6a647b5 100644
--- a/mysql-test/t/binlog-master.opt
+++ b/mysql-test/t/binlog_row_binlog-master.opt
diff --git a/mysql-test/t/binlog_row_binlog.test b/mysql-test/t/binlog_row_binlog.test
new file mode 100644
index 00000000000..8adc8eee5c1
--- /dev/null
+++ b/mysql-test/t/binlog_row_binlog.test
@@ -0,0 +1,5 @@
+# This is a wrapper for binlog.test so that the same test case can be used
+# For both statement and row based bin logs 9/19/2005 [jbm]
+
+-- source include/have_binlog_format_row.inc
+-- source extra/binlog_tests/binlog.test
diff --git a/mysql-test/t/binlog_row_blackhole.test b/mysql-test/t/binlog_row_blackhole.test
new file mode 100644
index 00000000000..d5355ad1ff0
--- /dev/null
+++ b/mysql-test/t/binlog_row_blackhole.test
@@ -0,0 +1,11 @@
+# This is a wrapper for binlog.test so that the same test case can be used
+# For both statement and row based bin logs 9/19/2005 [jbm]
+
+-- source include/have_binlog_format_row.inc
+
+# 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
+-- source extra/binlog_tests/blackhole.test
+--enable_ps_protocol
diff --git a/mysql-test/t/binlog_row_ctype_cp932.test b/mysql-test/t/binlog_row_ctype_cp932.test
new file mode 100644
index 00000000000..595af5a3114
--- /dev/null
+++ b/mysql-test/t/binlog_row_ctype_cp932.test
@@ -0,0 +1,5 @@
+# This is a wrapper for binlog.test so that the same test case can be used
+# For both statement and row based bin logs 9/19/2005 [jbm]
+
+-- source include/have_binlog_format_row.inc
+-- source extra/binlog_tests/ctype_cp932.test
diff --git a/mysql-test/t/binlog_row_ctype_ucs.test b/mysql-test/t/binlog_row_ctype_ucs.test
new file mode 100644
index 00000000000..96e14ed8882
--- /dev/null
+++ b/mysql-test/t/binlog_row_ctype_ucs.test
@@ -0,0 +1,6 @@
+# This is a wrapper for binlog.test so that the same test case can be used
+# For both statement and row based bin logs 9/19/2005 [jbm]
+
+-- source include/have_binlog_format_row.inc
+-- source extra/binlog_tests/ctype_ucs_binlog.test
+
diff --git a/mysql-test/t/binlog_row_drop_tmp_tbl.test b/mysql-test/t/binlog_row_drop_tmp_tbl.test
new file mode 100644
index 00000000000..5b503b78d85
--- /dev/null
+++ b/mysql-test/t/binlog_row_drop_tmp_tbl.test
@@ -0,0 +1,5 @@
+# This is a wrapper for binlog.test so that the same test case can be used
+# For both statement and row based bin logs 9/19/2005 [jbm]
+
+-- source include/have_binlog_format_row.inc
+-- source extra/binlog_tests/drop_temp_table.test
diff --git a/mysql-test/t/binlog_row_innodb_stat-master.opt b/mysql-test/t/binlog_row_innodb_stat-master.opt
new file mode 100644
index 00000000000..4cb927540bf
--- /dev/null
+++ b/mysql-test/t/binlog_row_innodb_stat-master.opt
@@ -0,0 +1 @@
+--binlog_cache_size=32768
diff --git a/mysql-test/t/binlog_row_innodb_stat.test b/mysql-test/t/binlog_row_innodb_stat.test
new file mode 100644
index 00000000000..e4e6762226b
--- /dev/null
+++ b/mysql-test/t/binlog_row_innodb_stat.test
@@ -0,0 +1,5 @@
+# This is a wrapper for binlog.test so that the same test case can be used
+# For both statement and row based bin logs 9/19/2005 [jbm]
+
+-- source include/have_binlog_format_row.inc
+-- source extra/binlog_tests/innodb_stat.test
diff --git a/mysql-test/t/binlog_row_insert_select.test b/mysql-test/t/binlog_row_insert_select.test
new file mode 100644
index 00000000000..806d495c8fb
--- /dev/null
+++ b/mysql-test/t/binlog_row_insert_select.test
@@ -0,0 +1,10 @@
+# This is a wrapper for binlog.test so that the same test case can be used
+# For both statement and row based bin logs 9/19/2005 [jbm]
+
+-- source include/have_binlog_format_row.inc
+# 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
+-- source extra/binlog_tests/insert_select-binlog.test
+--enable_ps_protocol
diff --git a/mysql-test/t/mix_innodb_myisam_binlog-master.opt b/mysql-test/t/binlog_row_mix_innodb_myisam-master.opt
index cb48f1aaf60..cb48f1aaf60 100644
--- a/mysql-test/t/mix_innodb_myisam_binlog-master.opt
+++ b/mysql-test/t/binlog_row_mix_innodb_myisam-master.opt
diff --git a/mysql-test/t/binlog_row_mix_innodb_myisam.test b/mysql-test/t/binlog_row_mix_innodb_myisam.test
new file mode 100644
index 00000000000..e04d53a2209
--- /dev/null
+++ b/mysql-test/t/binlog_row_mix_innodb_myisam.test
@@ -0,0 +1,31 @@
+# This is a wrapper for binlog.test so that the same test case can be used
+# For both statement and row based bin logs 9/19/2005 [jbm]
+
+-- source include/have_binlog_format_row.inc
+
+# 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
+
+-- source extra/binlog_tests/mix_innodb_myisam_binlog.test
+
+--enable_ps_protocol
+
+# This piece below cannot be put into
+# extra/binlog_tests/mix_innodb_myisam_binlog.test
+# because the argument of --start-position differs between statement-
+# and row-based (and "eval --exec" doesn't work).
+# we check that the error code of the "ROLLBACK" event is 0 and not
+# ER_SERVER_SHUTDOWN (i.e. disconnection just rolls back transaction
+# and does not make slave to stop)
+--exec $MYSQL_BINLOG --start-position=516 $MYSQLTEST_VARDIR/log/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/mix_innodb_myisam_binlog.output
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+eval select
+(@a:=load_file("$MYSQLTEST_VARDIR/tmp/mix_innodb_myisam_binlog.output"))
+is not null;
+--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
+eval select
+@a like "%#%error_code=0%ROLLBACK;%ROLLBACK /* added by mysqlbinlog */;%",
+@a not like "%#%error_code=%error_code=%";
+drop table t1, t2;
diff --git a/mysql-test/t/binlog_stm_binlog-master.opt b/mysql-test/t/binlog_stm_binlog-master.opt
new file mode 100644
index 00000000000..ad2c6a647b5
--- /dev/null
+++ b/mysql-test/t/binlog_stm_binlog-master.opt
@@ -0,0 +1 @@
+-O max_binlog_size=4096
diff --git a/mysql-test/t/binlog_stm_binlog.test b/mysql-test/t/binlog_stm_binlog.test
new file mode 100644
index 00000000000..f22e7e45aea
--- /dev/null
+++ b/mysql-test/t/binlog_stm_binlog.test
@@ -0,0 +1,18 @@
+# REQUIREMENT
+# replace_regex should replace output of SHOW BINLOG EVENTS
+
+create table t1 (a int, b int) engine=innodb;
+begin;
+insert into t1 values (1,2);
+commit;
+--replace_regex /\/\* xid=.* \*\//\/* XID *\// /Server ver: .*, Binlog ver: .*/Server ver: #, Binlog ver: #/ /table_id: [0-9]+/table_id: #/
+show binlog events;
+drop table t1;
+
+# This is a wrapper for binlog.test so that the same test case can be used
+# For both statement and row based bin logs 9/19/2005 [jbm]
+
+-- source include/not_embedded.inc
+-- source include/have_binlog_format_statement.inc
+-- source extra/binlog_tests/binlog.test
+
diff --git a/mysql-test/t/binlog_stm_blackhole.test b/mysql-test/t/binlog_stm_blackhole.test
new file mode 100644
index 00000000000..6047d8ca2fc
--- /dev/null
+++ b/mysql-test/t/binlog_stm_blackhole.test
@@ -0,0 +1,6 @@
+# This is a wrapper for binlog.test so that the same test case can be used
+# For both statement and row based bin logs 9/19/2005 [jbm]
+
+-- source include/not_embedded.inc
+-- source include/have_binlog_format_statement.inc
+-- source extra/binlog_tests/blackhole.test
diff --git a/mysql-test/t/binlog_stm_ctype_cp932.test b/mysql-test/t/binlog_stm_ctype_cp932.test
new file mode 100644
index 00000000000..436f95a2453
--- /dev/null
+++ b/mysql-test/t/binlog_stm_ctype_cp932.test
@@ -0,0 +1,6 @@
+# This is a wrapper for binlog.test so that the same test case can be used
+# For both statement and row based bin logs 9/19/2005 [jbm]
+
+-- source include/not_embedded.inc
+-- source include/have_binlog_format_statement.inc
+-- source extra/binlog_tests/ctype_cp932.test
diff --git a/mysql-test/t/binlog_stm_ctype_ucs.test b/mysql-test/t/binlog_stm_ctype_ucs.test
new file mode 100644
index 00000000000..a32ac3155c7
--- /dev/null
+++ b/mysql-test/t/binlog_stm_ctype_ucs.test
@@ -0,0 +1,6 @@
+# This is a wrapper for binlog.test so that the same test case can be used
+# For both statement and row based bin logs 9/19/2005 [jbm]
+
+-- source include/have_binlog_format_statement.inc
+-- source extra/binlog_tests/ctype_ucs_binlog.test
+
diff --git a/mysql-test/t/binlog_stm_drop_tmp_tbl.test b/mysql-test/t/binlog_stm_drop_tmp_tbl.test
new file mode 100644
index 00000000000..e8acd00c779
--- /dev/null
+++ b/mysql-test/t/binlog_stm_drop_tmp_tbl.test
@@ -0,0 +1,5 @@
+# This is a wrapper for binlog.test so that the same test case can be used
+# For both statement and row based bin logs 9/19/2005 [jbm]
+
+-- source include/have_binlog_format_statement.inc
+-- source extra/binlog_tests/drop_temp_table.test
diff --git a/mysql-test/t/binlog_stm_innodb_stat-master.opt b/mysql-test/t/binlog_stm_innodb_stat-master.opt
new file mode 100644
index 00000000000..4cb927540bf
--- /dev/null
+++ b/mysql-test/t/binlog_stm_innodb_stat-master.opt
@@ -0,0 +1 @@
+--binlog_cache_size=32768
diff --git a/mysql-test/t/binlog_stm_innodb_stat.test b/mysql-test/t/binlog_stm_innodb_stat.test
new file mode 100644
index 00000000000..c6017246e6d
--- /dev/null
+++ b/mysql-test/t/binlog_stm_innodb_stat.test
@@ -0,0 +1,5 @@
+# This is a wrapper for binlog.test so that the same test case can be used
+# For both statement and row based bin logs 9/19/2005 [jbm]
+
+-- source include/have_binlog_format_statement.inc
+-- source extra/binlog_tests/innodb_stat.test
diff --git a/mysql-test/t/binlog_stm_insert_select.test b/mysql-test/t/binlog_stm_insert_select.test
new file mode 100644
index 00000000000..06792990a55
--- /dev/null
+++ b/mysql-test/t/binlog_stm_insert_select.test
@@ -0,0 +1,5 @@
+# This is a wrapper for binlog.test so that the same test case can be used
+# For both statement and row based bin logs 9/19/2005 [jbm]
+
+-- source include/have_binlog_format_statement.inc
+-- source extra/binlog_tests/insert_select-binlog.test
diff --git a/mysql-test/t/binlog_stm_mix_innodb_myisam-master.opt b/mysql-test/t/binlog_stm_mix_innodb_myisam-master.opt
new file mode 100644
index 00000000000..cb48f1aaf60
--- /dev/null
+++ b/mysql-test/t/binlog_stm_mix_innodb_myisam-master.opt
@@ -0,0 +1 @@
+--loose-innodb_lock_wait_timeout=2
diff --git a/mysql-test/t/binlog_stm_mix_innodb_myisam.test b/mysql-test/t/binlog_stm_mix_innodb_myisam.test
new file mode 100644
index 00000000000..829cf50fe1e
--- /dev/null
+++ b/mysql-test/t/binlog_stm_mix_innodb_myisam.test
@@ -0,0 +1,23 @@
+# This is a wrapper for binlog.test so that the same test case can be used
+# For both statement and row based bin logs 9/19/2005 [jbm]
+
+-- source include/have_binlog_format_statement.inc
+-- source extra/binlog_tests/mix_innodb_myisam_binlog.test
+
+# This piece below cannot be put into
+# extra/binlog_tests/mix_innodb_myisam_binlog.test
+# because the argument of --start-position differs between statement-
+# and row-based (and "eval --exec" doesn't work).
+# we check that the error code of the "ROLLBACK" event is 0 and not
+# ER_SERVER_SHUTDOWN (i.e. disconnection just rolls back transaction
+# and does not make slave to stop)
+--exec $MYSQL_BINLOG --start-position=551 $MYSQLTEST_VARDIR/log/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/mix_innodb_myisam_binlog.output
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+eval select
+(@a:=load_file("$MYSQLTEST_VARDIR/tmp/mix_innodb_myisam_binlog.output"))
+is not null;
+--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
+eval select
+@a like "%#%error_code=0%ROLLBACK;%ROLLBACK /* added by mysqlbinlog */;%",
+@a not like "%#%error_code=%error_code=%";
+drop table t1, t2;
diff --git a/mysql-test/t/blackhole.test b/mysql-test/t/blackhole.test
deleted file mode 100644
index 493f74ded3e..00000000000
--- a/mysql-test/t/blackhole.test
+++ /dev/null
@@ -1,142 +0,0 @@
-#
-# Simple test for blackhole example
-# Taken from the select test
-#
--- source include/not_embedded.inc
--- source include/have_blackhole.inc
-
---disable_warnings
-drop table if exists t1,t2;
---enable_warnings
-
-CREATE TABLE t1 (
- Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL,
- Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL
-) ENGINE=blackhole;
-
-INSERT INTO t1 VALUES (9410,9412);
-
-select period from t1;
-select * from t1;
-select t1.* from t1;
-
-#
-# Create test table
-#
-
-CREATE TABLE t2 (
- auto int NOT NULL auto_increment,
- fld1 int(6) unsigned zerofill DEFAULT '000000' NOT NULL,
- companynr tinyint(2) unsigned zerofill DEFAULT '00' NOT NULL,
- fld3 char(30) DEFAULT '' NOT NULL,
- fld4 char(35) DEFAULT '' NOT NULL,
- fld5 char(35) DEFAULT '' NOT NULL,
- fld6 char(4) DEFAULT '' NOT NULL,
- primary key (auto)
-) ENGINE=blackhole;
-
-INSERT INTO t2 VALUES (1192,068305,00,'Colombo','hardware','colicky','');
-INSERT INTO t2 VALUES (1193,000000,00,'nondecreasing','implant','thrillingly','');
---enable_query_log
-
-#
-# Search with a key
-#
-
-select t2.fld3 from t2 where companynr = 58 and fld3 like "%imaginable%";
-select fld3 from t2 where fld3 like "%cultivation" ;
-
-#
-# Search with a key using sorting and limit the same time
-#
-
-select t2.fld3,companynr from t2 where companynr = 57+1 order by fld3;
-select fld3,companynr from t2 where companynr = 58 order by fld3;
-
-select fld3 from t2 order by fld3 desc limit 10;
-select fld3 from t2 order by fld3 desc limit 5;
-select fld3 from t2 order by fld3 desc limit 5,5;
-
-#
-# Search with a key having a constant with each unique key.
-# The table is read directly with read-next on fld3
-#
-
-select t2.fld3 from t2 where fld3 = 'honeysuckle';
-select t2.fld3 from t2 where fld3 LIKE 'honeysuckl_';
-select t2.fld3 from t2 where fld3 LIKE 'hon_ysuckl_';
-select t2.fld3 from t2 where fld3 LIKE 'honeysuckle%';
-select t2.fld3 from t2 where fld3 LIKE 'h%le';
-
-select t2.fld3 from t2 where fld3 LIKE 'honeysuckle_';
-select t2.fld3 from t2 where fld3 LIKE 'don_t_find_me_please%';
-
-#
-# Test sorting with a used key (there is no need for sorting)
-#
-
-select t2.fld3 from t2 where fld3 >= 'honeysuckle' and fld3 <= 'honoring' order by fld3;
-select fld1,fld3 from t2 where fld3="Colombo" or fld3 = "nondecreasing" order by fld3;
-
-
-# Test for fulltext
-DROP TABLE t1;
-CREATE TABLE t1 (a VARCHAR(200), b TEXT, FULLTEXT (a,b));
-INSERT INTO t1 VALUES('MySQL has now support', 'for full-text search'),
- ('Full-text indexes', 'are called collections'),
- ('Only MyISAM tables','support collections'),
- ('Function MATCH ... AGAINST()','is used to do a search'),
- ('Full-text search in MySQL', 'implements vector space model');
-SHOW INDEX FROM t1;
-
-# nl search
-
-select * from t1 where MATCH(a,b) AGAINST ("collections");
-explain extended select * from t1 where MATCH(a,b) AGAINST ("collections");
-select * from t1 where MATCH(a,b) AGAINST ("indexes");
-select * from t1 where MATCH(a,b) AGAINST ("indexes collections");
-select * from t1 where MATCH(a,b) AGAINST ("only");
-
-# Test that every DML (except SELECT) and DDL gets into binlog
-# so that blackhole can be used as "binlog propagator"
-
-reset master;
-drop table t1,t2;
-create table t1 (a int) engine=blackhole;
-delete from t1 where a=10;
-update t1 set a=11 where a=15;
-insert into t1 values(1);
-insert ignore into t1 values(1);
-replace into t1 values(100);
-create table t2 (a varchar(200)) engine=blackhole;
-load data infile '../std_data_ln/words.dat' into table t2;
-alter table t1 add b int;
-alter table t1 drop b;
-create table t3 like t1;
-insert into t1 select * from t3;
-replace into t1 select * from t3;
-# Just to verify
-select * from t1;
-select * from t2;
-select * from t3;
-
-let $VERSION=`select version()`;
---replace_result $VERSION VERSION
---replace_column 2 # 5 #
-show binlog events;
-
-drop table t1,t2,t3;
-
-# End of 4.1 tests
-
-#
-# BUG#10952 - alter table ... lost data without errors and warnings
-#
-drop table if exists t1;
-create table t1 (c char(20)) engine=MyISAM;
-insert into t1 values ("Monty"),("WAX"),("Walrus");
---error 1031
-alter table t1 engine=blackhole;
-drop table t1;
-
-# End of 5.0 tests
diff --git a/mysql-test/t/case.test b/mysql-test/t/case.test
index fbe1ee2b8c8..1bdfc5cc10f 100644
--- a/mysql-test/t/case.test
+++ b/mysql-test/t/case.test
@@ -3,7 +3,7 @@
#
--disable_warnings
-drop table if exists t1;
+drop table if exists t1,t2;
--enable_warnings
select CASE "b" when "a" then 1 when "b" then 2 END;
diff --git a/mysql-test/t/cast.test b/mysql-test/t/cast.test
index 533da542855..b733a23f398 100644
--- a/mysql-test/t/cast.test
+++ b/mysql-test/t/cast.test
@@ -47,7 +47,7 @@ select cast('1a' as signed);
select cast('' as signed);
#
-# Character set convertion
+# Character set conversion
#
set names binary;
select cast(_latin1'test' as char character set latin2);
diff --git a/mysql-test/t/connect.test b/mysql-test/t/connect.test
index fef9d4552e6..5ee3d64e56f 100644
--- a/mysql-test/t/connect.test
+++ b/mysql-test/t/connect.test
@@ -5,6 +5,10 @@
# This test makes no sense with the embedded server
--source include/not_embedded.inc
+# check that CSV engine was compiled in, as the test relies on the presence
+# of the log tables (which are CSV-based). By connect mysql; show tables;
+--source include/have_csv.inc
+
--disable_warnings
drop table if exists t1,t2;
--enable_warnings
diff --git a/mysql-test/t/contributors.test b/mysql-test/t/contributors.test
new file mode 100644
index 00000000000..e463c4a888b
--- /dev/null
+++ b/mysql-test/t/contributors.test
@@ -0,0 +1 @@
+SHOW CONTRIBUTORS;
diff --git a/mysql-test/t/create.test b/mysql-test/t/create.test
index e22c2b5c426..fe8cfe70c4e 100644
--- a/mysql-test/t/create.test
+++ b/mysql-test/t/create.test
@@ -41,8 +41,11 @@ create table t1 (ordid int(8) not null auto_increment, ord varchar(50) not null
-- error 1049
create table not_existing_database.test (a int);
---error 1103
create table `a/a` (a int);
+show create table `a/a`;
+create table t1 like `a/a`;
+drop table `a/a`;
+drop table `t1`;
--error 1103
create table `aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa int);
--error 1059
@@ -304,8 +307,6 @@ create table non_existing_database.t1 like t1;
create table t3 like non_existing_table;
--error 1050
create temporary table t3 like t1;
---error 1103
-create table t3 like `a/a`;
drop table t1, t2, t3;
drop table t3;
drop database mysqltest;
diff --git a/mysql-test/t/create_select_tmp.test b/mysql-test/t/create_select_tmp.test
index c527548e282..144bccc5871 100644
--- a/mysql-test/t/create_select_tmp.test
+++ b/mysql-test/t/create_select_tmp.test
@@ -5,6 +5,9 @@
# binlog if it was a transactional table, it resulted in an
# inconsistency between binlog and the internal list of temp tables.
+# This does not work for RBR yet.
+--source include/have_binlog_format_statement.inc
+
-- source include/have_innodb.inc
--disable_warnings
drop table if exists t1, t2;
diff --git a/mysql-test/t/csv.test b/mysql-test/t/csv.test
index a028f6ced6d..9ba99167ab9 100644
--- a/mysql-test/t/csv.test
+++ b/mysql-test/t/csv.test
@@ -2,7 +2,7 @@
# Test for the CSV engine
#
--- source include/have_csv.inc
+--source include/have_csv.inc
#
# Simple select test
@@ -1354,6 +1354,154 @@ DROP TABLE bug14672;
# End of 4.1 tests
#
+# Test CONCURRENT INSERT (5.1)
+#
+
+CREATE TABLE test_concurrent_insert ( val integer ) ENGINE = CSV;
+
+connect (con1,localhost,root,,);
+connect (con2,localhost,root,,);
+
+connection con1;
+# obtain TL_READ lock on the table
+LOCK TABLES test_concurrent_insert READ LOCAL;
+
+connection con2;
+# should pass despite of the lock
+INSERT INTO test_concurrent_insert VALUES (1);
+SELECT * FROM test_concurrent_insert;
+
+connection con1;
+# first connection should not notice the changes
+SELECT * FROM test_concurrent_insert;
+
+UNLOCK TABLES;
+
+# Now check that we see our own changes
+
+LOCK TABLES test_concurrent_insert WRITE;
+INSERT INTO test_concurrent_insert VALUES (2);
+SELECT * FROM test_concurrent_insert;
+UNLOCK TABLES;
+
+# cleanup
+DROP TABLE test_concurrent_insert;
+
+#
+# Test REPAIR/CHECK TABLE (5.1)
+#
+
+# Check that repair on the newly created table works fine
+
+CREATE TABLE test_repair_table ( val integer ) ENGINE = CSV;
+
+CHECK TABLE test_repair_table;
+REPAIR TABLE test_repair_table;
+
+DROP TABLE test_repair_table;
+
+#
+# Check autorepair. Here we also check that we can work w/o metafile
+# restore the meta-file
+#
+
+CREATE TABLE test_repair_table2 ( val integer ) ENGINE = CSV;
+--exec rm $MYSQLTEST_VARDIR/master-data/test/test_repair_table2.CSM
+
+# Should give a warning and perform autorepair. We also disable ps-protocol
+# here, as mysql-test eats up warnings in ps-protocol mode
+
+--disable_ps_protocol
+SELECT * from test_repair_table2;
+--enable_ps_protocol
+# this should work ok, as the table is already repaired
+SELECT * from test_repair_table2;
+# check that the metafile appeared again. chop the path to it
+--exec ls $MYSQLTEST_VARDIR/master-data/test/test_repair_table2.CSM | perl -pi -e "s/.*\///"
+CHECK TABLE test_repair_table2;
+DROP TABLE test_repair_table2;
+
+
+# Corrupt csv file and see if we can repair it
+CREATE TABLE test_repair_table3 ( val integer ) ENGINE = CSV;
+--exec perl -e 'print "\"1\"\n\"4\"\n\"3";' > $MYSQLTEST_VARDIR/master-data/test/test_repair_table3.CSV
+CHECK TABLE test_repair_table3;
+REPAIR TABLE test_repair_table3;
+SELECT * FROM test_repair_table3;
+DROP TABLE test_repair_table3;
+
+# Test with more sophisticated table
+
+CREATE TABLE test_repair_table4 (
+ num int not null,
+ magic_no int(4) unsigned zerofill DEFAULT '0000' NOT NULL,
+ company_name char(30) DEFAULT '' NOT NULL,
+ founded char(4) DEFAULT '' NOT NULL
+) ENGINE = CSV;
+
+--exec rm $MYSQLTEST_VARDIR/master-data/test/test_repair_table4.CSM
+--disable_ps_protocol
+SELECT * FROM test_repair_table4;
+--enable_ps_protocol
+SELECT * FROM test_repair_table4;
+CHECK TABLE test_repair_table4;
+
+INSERT INTO test_repair_table4 VALUES (2,101,'SAP','1972');
+INSERT INTO test_repair_table4 VALUES (1,101,'Microsoft','1978');
+INSERT INTO test_repair_table4 VALUES (2,101,'MySQL','1995');
+
+# list table content
+SELECT * FROM test_repair_table4;
+CHECK TABLE test_repair_table4;
+REPAIR TABLE test_repair_table4;
+# check that nothing changed
+SELECT * FROM test_repair_table4;
+# verify that check/repair did non corrupt the table itself
+CHECK TABLE test_repair_table4;
+REPAIR TABLE test_repair_table4;
+SELECT * FROM test_repair_table4;
+DROP TABLE test_repair_table4;
+
+# Run CHECK/REPAIR on the CSV file with a single row, which misses a column.
+
+CREATE TABLE test_repair_table5 (
+ num int not null,
+ magic_no int(4) unsigned zerofill DEFAULT '0000' NOT NULL,
+ company_name char(30) DEFAULT '' NOT NULL,
+ founded char(4) DEFAULT '' NOT NULL
+) ENGINE = CSV;
+
+# Corrupt a table -- put a file with wrong # of columns
+--exec perl -e 'print "\"1\",\"101\",\"IBM\"\n";' > $MYSQLTEST_VARDIR/master-data/test/test_repair_table5.CSV
+
+CHECK TABLE test_repair_table5;
+REPAIR TABLE test_repair_table5;
+SELECT * FROM test_repair_table5;
+INSERT INTO test_repair_table5 VALUES (1, 102, "CORRECT", 1876);
+SELECT * FROM test_repair_table5;
+
+# Corrupt a table -- put a row with wrong # of columns at end of file
+--exec perl -e 'print "\"1\",\"101\",\"IBM\"\n";' >> $MYSQLTEST_VARDIR/master-data/test/test_repair_table5.CSV
+
+FLUSH TABLES;
+CHECK TABLE test_repair_table5;
+REPAIR TABLE test_repair_table5;
+# The correct record inserted should still be in the file
+SELECT * FROM test_repair_table5;
+INSERT INTO test_repair_table5 VALUES (1, 102, "CORRECT2", 1876);
+SELECT * FROM test_repair_table5;
+
+# Corrupt table again -- put a row with wrong # of columns at end of file
+--exec perl -e 'print "\"1\",\"101\",\"IBM\"\n";' >> $MYSQLTEST_VARDIR/master-data/test/test_repair_table5.CSV
+
+FLUSH TABLES;
+CHECK TABLE test_repair_table5;
+REPAIR TABLE test_repair_table5;
+# The two correct records inserted should still be in the file
+SELECT * FROM test_repair_table5;
+DROP TABLE test_repair_table5;
+
+#
# BUG#13406 - incorrect amount of "records deleted"
#
@@ -1384,3 +1532,29 @@ truncate table t1; -- truncate
--disable_info
drop table t1;
+#
+# Some additional tests for new, faster alter table. Note that most of the
+# whole alter table code is being tested all around the test suite already.
+#
+
+create table t1 (v varchar(32));
+insert into t1 values ('def'),('abc'),('hij'),('3r4f');
+select * from t1;
+# Fast alter, no copy performed
+alter table t1 change v v2 varchar(32);
+select * from t1;
+# Fast alter, no copy performed
+alter table t1 change v2 v varchar(64);
+select * from t1;
+update t1 set v = 'lmn' where v = 'hij';
+select * from t1;
+# Regular alter table
+alter table t1 add i int auto_increment not null primary key first;
+select * from t1;
+update t1 set i=5 where i=3;
+select * from t1;
+alter table t1 change i i bigint;
+select * from t1;
+alter table t1 add unique key (i, v);
+select * from t1 where i between 2 and 4 and v in ('def','3r4f','lmn');
+drop table t1;
diff --git a/mysql-test/t/ctype_cp932.test b/mysql-test/t/ctype_cp932.test
deleted file mode 100644
index 688d06c4dde..00000000000
--- a/mysql-test/t/ctype_cp932.test
+++ /dev/null
@@ -1,415 +0,0 @@
--- source include/have_cp932.inc
-
---character_set cp932
---disable_warnings
-drop table if exists t1;
-drop table if exists t2;
-drop table if exists t3;
-drop table if exists t4;
---enable_warnings
-
-set names cp932;
-set character_set_database = cp932;
-
-CREATE TABLE t1(c1 CHAR(1)) DEFAULT CHARACTER SET = cp932;
-
-#Characters which are converted to Unicode ambiguously
-INSERT INTO t1 VALUES
-(0x05),(0x7E),(0x815C),(0x815F),(0x8160),(0x8161),(0x817C),(0x8191),(0x8192),(0x81CA);
-
-#NEC ROW 13 characters (0x8740 - 0x879C)
-INSERT INTO t1 VALUES
-(0x8740),(0x8741),(0x8742),(0x8743),(0x8744),(0x8745),(0x8746),(0x8747),
-(0x8748),(0x8749),(0x874A),(0x874B),(0x874C),(0x874D),(0x874E),(0x874F),
-(0x8750),(0x8751),(0x8752),(0x8753),(0x8754),(0x8755),(0x8756),(0x8757),
-(0x8758),(0x8759),(0x875A),(0x875B),(0x875C),(0x875D),(0x875F),
-(0x8760),(0x8761),(0x8762),(0x8763),(0x8764),(0x8765),(0x8766),(0x8767),
-(0x8768),(0x8769),(0x876A),(0x876B),(0x876C),(0x876D),(0x876E),(0x876F),
-(0x8770),(0x8771),(0x8772),(0x8773),(0x8774),(0x8775),(0x877E),
-(0x8780),(0x8781),(0x8782),(0x8783),(0x8784),(0x8785),(0x8786),(0x8787),
-(0x8788),(0x8789),(0x878A),(0x878B),(0x878C),(0x878D),(0x878E),(0x878F),
-(0x8790),(0x8791),(0x8792),(0x8793),(0x8794),(0x8795),(0x8796),(0x8797),
-(0x8798),(0x8799),(0x879A),(0x879B),(0x879C);
-
-#IBM selected characters kanji & non-kanji, NEC implementation (0xED40 - 0xEEFC)
-INSERT INTO t1 VALUES
-(0xED40),(0xED41),(0xED42),(0xED43),(0xED44),(0xED45),(0xED46),(0xED47),
-(0xED48),(0xED49),(0xED4A),(0xED4B),(0xED4C),(0xED4D),(0xED4E),(0xED4F),
-(0xED50),(0xED51),(0xED52),(0xED53),(0xED54),(0xED55),(0xED56),(0xED57),
-(0xED58),(0xED59),(0xED5A),(0xED5B),(0xED5C),(0xED5D),(0xED5E),(0xED5F),
-(0xED60),(0xED61),(0xED62),(0xED63),(0xED64),(0xED65),(0xED66),(0xED67),
-(0xED68),(0xED69),(0xED6A),(0xED6B),(0xED6C),(0xED6D),(0xED6E),(0xED6F),
-(0xED70),(0xED71),(0xED72),(0xED73),(0xED74),(0xED75),(0xED76),(0xED77),
-(0xED78),(0xED79),(0xED7A),(0xED7B),(0xED7C),(0xED7D),(0xED7E),
-(0xED80),(0xED81),(0xED82),(0xED83),(0xED84),(0xED85),(0xED86),(0xED87),
-(0xED88),(0xED89),(0xED8A),(0xED8B),(0xED8C),(0xED8D),(0xED8E),(0xED8F),
-(0xED90),(0xED91),(0xED92),(0xED93),(0xED94),(0xED95),(0xED96),(0xED97),
-(0xED98),(0xED99),(0xED9A),(0xED9B),(0xED9C),(0xED9D),(0xED9E),(0xED9F),
-(0xEDA0),(0xEDA1),(0xEDA2),(0xEDA3),(0xEDA4),(0xEDA5),(0xEDA6),(0xEDA7),
-(0xEDA8),(0xEDA9),(0xEDAA),(0xEDAB),(0xEDAC),(0xEDAD),(0xEDAE),(0xEDAF),
-(0xEDB0),(0xEDB1),(0xEDB2),(0xEDB3),(0xEDB4),(0xEDB5),(0xEDB6),(0xEDB7),
-(0xEDB8),(0xEDB9),(0xEDBA),(0xEDBB),(0xEDBC),(0xEDBD),(0xEDBE),(0xEDBF),
-(0xEDC0),(0xEDC1),(0xEDC2),(0xEDC3),(0xEDC4),(0xEDC5),(0xEDC6),(0xEDC7),
-(0xEDC8),(0xEDC9),(0xEDCA),(0xEDCB),(0xEDCC),(0xEDCD),(0xEDCE),(0xEDCF),
-(0xEDD0),(0xEDD1),(0xEDD2),(0xEDD3),(0xEDD4),(0xEDD5),(0xEDD6),(0xEDD7),
-(0xEDD8),(0xEDD9),(0xEDDA),(0xEDDB),(0xEDDC),(0xEDDD),(0xEDDE),(0xEDDF),
-(0xEDE0),(0xEDE1),(0xEDE2),(0xEDE3),(0xEDE4),(0xEDE5),(0xEDE6),(0xEDE7),
-(0xEDE8),(0xEDE9),(0xEDEA),(0xEDEB),(0xEDEC),(0xEDED),(0xEDEE),(0xEDEF),
-(0xEDF0),(0xEDF1),(0xEDF2),(0xEDF3),(0xEDF4),(0xEDF5),(0xEDF6),(0xEDF7),
-(0xEDF8),(0xEDF9),(0xEDFA),(0xEDFB),(0xEDFC),
-(0xEE40),(0xEE41),(0xEE42),(0xEE43),(0xEE44),(0xEE45),(0xEE46),(0xEE47),
-(0xEE48),(0xEE49),(0xEE4A),(0xEE4B),(0xEE4C),(0xEE4D),(0xEE4E),(0xEE4F),
-(0xEE50),(0xEE51),(0xEE52),(0xEE53),(0xEE54),(0xEE55),(0xEE56),(0xEE57),
-(0xEE58),(0xEE59),(0xEE5A),(0xEE5B),(0xEE5C),(0xEE5D),(0xEE5E),(0xEE5F),
-(0xEE60),(0xEE61),(0xEE62),(0xEE63),(0xEE64),(0xEE65),(0xEE66),(0xEE67),
-(0xEE68),(0xEE69),(0xEE6A),(0xEE6B),(0xEE6C),(0xEE6D),(0xEE6E),(0xEE6F),
-(0xEE70),(0xEE71),(0xEE72),(0xEE73),(0xEE74),(0xEE75),(0xEE76),(0xEE77),
-(0xEE78),(0xEE79),(0xEE7A),(0xEE7B),(0xEE7C),(0xEE7D),(0xEE7E),
-(0xEE80),(0xEE81),(0xEE82),(0xEE83),(0xEE84),(0xEE85),(0xEE86),(0xEE87),
-(0xEE88),(0xEE89),(0xEE8A),(0xEE8B),(0xEE8C),(0xEE8D),(0xEE8E),(0xEE8F),
-(0xEE90),(0xEE91),(0xEE92),(0xEE93),(0xEE94),(0xEE95),(0xEE96),(0xEE97),
-(0xEE98),(0xEE99),(0xEE9A),(0xEE9B),(0xEE9C),(0xEE9D),(0xEE9E),(0xEE9F),
-(0xEEA0),(0xEEA1),(0xEEA2),(0xEEA3),(0xEEA4),(0xEEA5),(0xEEA6),(0xEEA7),
-(0xEEA8),(0xEEA9),(0xEEAA),(0xEEAB),(0xEEAC),(0xEEAD),(0xEEAE),(0xEEAF),
-(0xEEB0),(0xEEB1),(0xEEB2),(0xEEB3),(0xEEB4),(0xEEB5),(0xEEB6),(0xEEB7),
-(0xEEB8),(0xEEB9),(0xEEBA),(0xEEBB),(0xEEBC),(0xEEBD),(0xEEBE),(0xEEBF),
-(0xEEC0),(0xEEC1),(0xEEC2),(0xEEC3),(0xEEC4),(0xEEC5),(0xEEC6),(0xEEC7),
-(0xEEC8),(0xEEC9),(0xEECA),(0xEECB),(0xEECC),(0xEECD),(0xEECE),(0xEECF),
-(0xEED0),(0xEED1),(0xEED2),(0xEED3),(0xEED4),(0xEED5),(0xEED6),(0xEED7),
-(0xEED8),(0xEED9),(0xEEDA),(0xEEDB),(0xEEDC),(0xEEDD),(0xEEDE),(0xEEDF),
-(0xEEE0),(0xEEE1),(0xEEE2),(0xEEE3),(0xEEE4),(0xEEE5),(0xEEE6),(0xEEE7),
-(0xEEE8),(0xEEE9),(0xEEEA),(0xEEEB),(0xEEEC),(0xEEEF),
-(0xEEF0),(0xEEF1),(0xEEF2),(0xEEF3),(0xEEF4),(0xEEF5),(0xEEF6),(0xEEF7),
-(0xEEF8),(0xEEF9),(0xEEFA),(0xEEFB),(0xEEFC);
-
-#IBM selected kanji & non-kanji (0xFA40 - 0xFC4B)
-INSERT INTO t1 VALUES
-(0xFA40),(0xFA41),(0xFA42),(0xFA43),(0xFA44),(0xFA45),(0xFA46),(0xFA47),
-(0xFA48),(0xFA49),(0xFA4A),(0xFA4B),(0xFA4C),(0xFA4D),(0xFA4E),(0xFA4F),
-(0xFA50),(0xFA51),(0xFA52),(0xFA53),(0xFA54),(0xFA55),(0xFA56),(0xFA57),
-(0xFA58),(0xFA59),(0xFA5A),(0xFA5B),(0xFA5C),(0xFA5D),(0xFA5E),(0xFA5F),
-(0xFA60),(0xFA61),(0xFA62),(0xFA63),(0xFA64),(0xFA65),(0xFA66),(0xFA67),
-(0xFA68),(0xFA69),(0xFA6A),(0xFA6B),(0xFA6C),(0xFA6D),(0xFA6E),(0xFA6F),
-(0xFA70),(0xFA71),(0xFA72),(0xFA73),(0xFA74),(0xFA75),(0xFA76),(0xFA77),
-(0xFA78),(0xFA79),(0xFA7A),(0xFA7B),(0xFA7C),(0xFA7D),(0xFA7E),
-(0xFA80),(0xFA81),(0xFA82),(0xFA83),(0xFA84),(0xFA85),(0xFA86),(0xFA87),
-(0xFA88),(0xFA89),(0xFA8A),(0xFA8B),(0xFA8C),(0xFA8D),(0xFA8E),(0xFA8F),
-(0xFA90),(0xFA91),(0xFA92),(0xFA93),(0xFA94),(0xFA95),(0xFA96),(0xFA97),
-(0xFA98),(0xFA99),(0xFA9A),(0xFA9B),(0xFA9C),(0xFA9D),(0xFA9E),(0xFA9F),
-(0xFAA0),(0xFAA1),(0xFAA2),(0xFAA3),(0xFAA4),(0xFAA5),(0xFAA6),(0xFAA7),
-(0xFAA8),(0xFAA9),(0xFAAA),(0xFAAB),(0xFAAC),(0xFAAD),(0xFAAE),(0xFAAF),
-(0xFAB0),(0xFAB1),(0xFAB2),(0xFAB3),(0xFAB4),(0xFAB5),(0xFAB6),(0xFAB7),
-(0xFAB8),(0xFAB9),(0xFABA),(0xFABB),(0xFABC),(0xFABD),(0xFABE),(0xFABF),
-(0xFAC0),(0xFAC1),(0xFAC2),(0xFAC3),(0xFAC4),(0xFAC5),(0xFAC6),(0xFAC7),
-(0xFAC8),(0xFAC9),(0xFACA),(0xFACB),(0xFACC),(0xFACD),(0xFACE),(0xFACF),
-(0xFAD0),(0xFAD1),(0xFAD2),(0xFAD3),(0xFAD4),(0xFAD5),(0xFAD6),(0xFAD7),
-(0xFAD8),(0xFAD9),(0xFADA),(0xFADB),(0xFADC),(0xFADD),(0xFADE),(0xFADF),
-(0xFAE0),(0xFAE1),(0xFAE2),(0xFAE3),(0xFAE4),(0xFAE5),(0xFAE6),(0xFAE7),
-(0xFAE8),(0xFAE9),(0xFAEA),(0xFAEB),(0xFAEC),(0xFAED),(0xFAEE),(0xFAEF),
-(0xFAF0),(0xFAF1),(0xFAF2),(0xFAF3),(0xFAF4),(0xFAF5),(0xFAF6),(0xFAF7),
-(0xFAF8),(0xFAF9),(0xFAFA),(0xFAFB),(0xFAFC),
-(0xFB40),(0xFB41),(0xFB42),(0xFB43),(0xFB44),(0xFB45),(0xFB46),(0xFB47),
-(0xFB48),(0xFB49),(0xFB4A),(0xFB4B),(0xFB4C),(0xFB4D),(0xFB4E),(0xFB4F),
-(0xFB50),(0xFB51),(0xFB52),(0xFB53),(0xFB54),(0xFB55),(0xFB56),(0xFB57),
-(0xFB58),(0xFB59),(0xFB5A),(0xFB5B),(0xFB5C),(0xFB5D),(0xFB5E),(0xFB5F),
-(0xFB60),(0xFB61),(0xFB62),(0xFB63),(0xFB64),(0xFB65),(0xFB66),(0xFB67),
-(0xFB68),(0xFB69),(0xFB6A),(0xFB6B),(0xFB6C),(0xFB6D),(0xFB6E),(0xFB6F),
-(0xFB70),(0xFB71),(0xFB72),(0xFB73),(0xFB74),(0xFB75),(0xFB76),(0xFB77),
-(0xFB78),(0xFB79),(0xFB7A),(0xFB7B),(0xFB7C),(0xFB7D),(0xFB7E),
-(0xFB80),(0xFB81),(0xFB82),(0xFB83),(0xFB84),(0xFB85),(0xFB86),(0xFB87),
-(0xFB88),(0xFB89),(0xFB8A),(0xFB8B),(0xFB8C),(0xFB8D),(0xFB8E),(0xFB8F),
-(0xFB90),(0xFB91),(0xFB92),(0xFB93),(0xFB94),(0xFB95),(0xFB96),(0xFB97),
-(0xFB98),(0xFB99),(0xFB9A),(0xFB9B),(0xFB9C),(0xFB9D),(0xFB9E),(0xFB9F),
-(0xFBA0),(0xFBA1),(0xFBA2),(0xFBA3),(0xFBA4),(0xFBA5),(0xFBA6),(0xFBA7),
-(0xFBA8),(0xFBA9),(0xFBAA),(0xFBAB),(0xFBAC),(0xFBAD),(0xFBAE),(0xFBAF),
-(0xFBB0),(0xFBB1),(0xFBB2),(0xFBB3),(0xFBB4),(0xFBB5),(0xFBB6),(0xFBB7),
-(0xFBB8),(0xFBB9),(0xFBBA),(0xFBBB),(0xFBBC),(0xFBBD),(0xFBBE),(0xFBBF),
-(0xFBC0),(0xFBC1),(0xFBC2),(0xFBC3),(0xFBC4),(0xFBC5),(0xFBC6),(0xFBC7),
-(0xFBC8),(0xFBC9),(0xFBCA),(0xFBCB),(0xFBCC),(0xFBCD),(0xFBCE),(0xFBCF),
-(0xFBD0),(0xFBD1),(0xFBD2),(0xFBD3),(0xFBD4),(0xFBD5),(0xFBD6),(0xFBD7),
-(0xFBD8),(0xFBD9),(0xFBDA),(0xFBDB),(0xFBDC),(0xFBDD),(0xFBDE),(0xFBDF),
-(0xFBE0),(0xFBE1),(0xFBE2),(0xFBE3),(0xFBE4),(0xFBE5),(0xFBE6),(0xFBE7),
-(0xFBE8),(0xFBE9),(0xFBEA),(0xFBEB),(0xFBEC),(0xFBED),(0xFBEE),(0xFBEF),
-(0xFBF0),(0xFBF1),(0xFBF2),(0xFBF3),(0xFBF4),(0xFBF5),(0xFBF6),(0xFBF7),
-(0xFBF8),(0xFBF9),(0xFBFA),(0xFBFB),(0xFBFC),
-(0xFC40),(0xFC41),(0xFC42),(0xFC43),(0xFC44),(0xFC45),(0xFC46),(0xFC47),
-(0xFC48),(0xFC49),(0xFC4A),(0xFC4B);
-
-#User defined characters (0xF040-0xF9FC)
-INSERT INTO t1 VALUES
-(0xF040),(0xF041),(0xF042),(0xF043),(0xF044),(0xF045),(0xF046),(0xF047),
-(0xF048),(0xF049),(0xF04A),(0xF04B),(0xF04C),(0xF04D),(0xF04E),(0xF04F),
-(0xF050),(0xF051),(0xF052),(0xF053),(0xF054),(0xF055),(0xF056),(0xF057),
-(0xF058),(0xF059),(0xF05A),(0xF05B),(0xF05C),(0xF05D),(0xF05E),(0xF05F),
-(0xF060),(0xF061),(0xF062),(0xF063),(0xF064),(0xF065),(0xF066),(0xF067),
-(0xF068),(0xF069),(0xF06A),(0xF06B),(0xF06C),(0xF06D),(0xF06E),(0xF06F),
-(0xF070),(0xF071),(0xF072),(0xF073),(0xF074),(0xF075),(0xF076),(0xF077),
-(0xF078),(0xF079),(0xF07A),(0xF07B),(0xF07C),(0xF07D),(0xF07E),
-(0xF080),(0xF081),(0xF082),(0xF083),(0xF084),(0xF085),(0xF086),(0xF087),
-(0xF088),(0xF089),(0xF08A),(0xF08B),(0xF08C),(0xF08D),(0xF08E),(0xF08F),
-(0xF090),(0xF091),(0xF092),(0xF093),(0xF094),(0xF095),(0xF096),(0xF097),
-(0xF098),(0xF099),(0xF09A),(0xF09B),(0xF09C),(0xF09D),(0xF09E),(0xF09F),
-(0xF0A0),(0xF0A1),(0xF0A2),(0xF0A3),(0xF0A4),(0xF0A5),(0xF0A6),(0xF0A7),
-(0xF0A8),(0xF0A9),(0xF0AA),(0xF0AB),(0xF0AC),(0xF0AD),(0xF0AE),(0xF0AF),
-(0xF0B0),(0xF0B1),(0xF0B2),(0xF0B3),(0xF0B4),(0xF0B5),(0xF0B6),(0xF0B7),
-(0xF0B8),(0xF0B9),(0xF0BA),(0xF0BB),(0xF0BC),(0xF0BD),(0xF0BE),(0xF0BF),
-(0xF0C0),(0xF0C1),(0xF0C2),(0xF0C3),(0xF0C4),(0xF0C5),(0xF0C6),(0xF0C7),
-(0xF0C8),(0xF0C9),(0xF0CA),(0xF0CB),(0xF0CC),(0xF0CD),(0xF0CE),(0xF0CF),
-(0xF0D0),(0xF0D1),(0xF0D2),(0xF0D3),(0xF0D4),(0xF0D5),(0xF0D6),(0xF0D7),
-(0xF0D8),(0xF0D9),(0xF0DA),(0xF0DB),(0xF0DC),(0xF0DD),(0xF0DE),(0xF0DF),
-(0xF0E0),(0xF0E1),(0xF0E2),(0xF0E3),(0xF0E4),(0xF0E5),(0xF0E6),(0xF0E7),
-(0xF0E8),(0xF0E9),(0xF0EA),(0xF0EB),(0xF0EC),(0xF0ED),(0xF0EE),(0xF0EF),
-(0xF0F0),(0xF0F1),(0xF0F2),(0xF0F3),(0xF0F4),(0xF0F5),(0xF0F6),(0xF0F7),
-(0xF0F8),(0xF0F9),(0xF0FA),(0xF0FB),(0xF0FC),
-(0xF140),(0xF141),(0xF142),(0xF143),(0xF144),(0xF145),(0xF146),(0xF147),
-(0xF148),(0xF149),(0xF14A),(0xF14B),(0xF14C),(0xF14D),(0xF14E),(0xF14F),
-(0xF150),(0xF151),(0xF152),(0xF153),(0xF154),(0xF155),(0xF156),(0xF157),
-(0xF158),(0xF159),(0xF15A),(0xF15B),(0xF15C),(0xF15D),(0xF15E),(0xF15F),
-(0xF160),(0xF161),(0xF162),(0xF163),(0xF164),(0xF165),(0xF166),(0xF167),
-(0xF168),(0xF169),(0xF16A),(0xF16B),(0xF16C),(0xF16D),(0xF16E),(0xF16F),
-(0xF170),(0xF171),(0xF172),(0xF173),(0xF174),(0xF175),(0xF176),(0xF177),
-(0xF178),(0xF179),(0xF17A),(0xF17B),(0xF17C),(0xF17D),(0xF17E),
-(0xF180),(0xF181),(0xF182),(0xF183),(0xF184),(0xF185),(0xF186),(0xF187),
-(0xF188),(0xF189),(0xF18A),(0xF18B),(0xF18C),(0xF18D),(0xF18E),(0xF18F),
-(0xF190),(0xF191),(0xF192),(0xF193),(0xF194),(0xF195),(0xF196),(0xF197),
-(0xF198),(0xF199),(0xF19A),(0xF19B),(0xF19C),(0xF19D),(0xF19E),(0xF19F),
-(0xF1A0),(0xF1A1),(0xF1A2),(0xF1A3),(0xF1A4),(0xF1A5),(0xF1A6),(0xF1A7),
-(0xF1A8),(0xF1A9),(0xF1AA),(0xF1AB),(0xF1AC),(0xF1AD),(0xF1AE),(0xF1AF),
-(0xF1B0),(0xF1B1),(0xF1B2),(0xF1B3),(0xF1B4),(0xF1B5),(0xF1B6),(0xF1B7),
-(0xF1B8),(0xF1B9),(0xF1BA),(0xF1BB),(0xF1BC),(0xF1BD),(0xF1BE),(0xF1BF),
-(0xF1C0),(0xF1C1),(0xF1C2),(0xF1C3),(0xF1C4),(0xF1C5),(0xF1C6),(0xF1C7),
-(0xF1C8),(0xF1C9),(0xF1CA),(0xF1CB),(0xF1CC),(0xF1CD),(0xF1CE),(0xF1CF),
-(0xF1D0),(0xF1D1),(0xF1D2),(0xF1D3),(0xF1D4),(0xF1D5),(0xF1D6),(0xF1D7),
-(0xF1D8),(0xF1D9),(0xF1DA),(0xF1DB),(0xF1DC),(0xF1DD),(0xF1DE),(0xF1DF),
-(0xF1E0),(0xF1E1),(0xF1E2),(0xF1E3),(0xF1E4),(0xF1E5),(0xF1E6),(0xF1E7),
-(0xF1E8),(0xF1E9),(0xF1EA),(0xF1EB),(0xF1EC),(0xF1ED),(0xF1EE),(0xF1EF),
-(0xF1F0),(0xF1F1),(0xF1F2),(0xF1F3),(0xF1F4),(0xF1F5),(0xF1F6),(0xF1F7),
-(0xF1F8),(0xF1F9),(0xF1FA),(0xF1FB),(0xF1FC),
-(0xF240),(0xF241),(0xF242),(0xF243),(0xF244),(0xF245),(0xF246),(0xF247),
-(0xF248),(0xF249),(0xF24A),(0xF24B),(0xF24C),(0xF24D),(0xF24E),(0xF24F),
-(0xF250),(0xF251),(0xF252),(0xF253),(0xF254),(0xF255),(0xF256),(0xF257),
-(0xF258),(0xF259),(0xF25A),(0xF25B),(0xF25C),(0xF25D),(0xF25E),(0xF25F),
-(0xF260),(0xF261),(0xF262),(0xF263),(0xF264),(0xF265),(0xF266),(0xF267),
-(0xF268),(0xF269),(0xF26A),(0xF26B),(0xF26C),(0xF26D),(0xF26E),(0xF26F),
-(0xF270),(0xF271),(0xF272),(0xF273),(0xF274),(0xF275),(0xF276),(0xF277),
-(0xF278),(0xF279),(0xF27A),(0xF27B),(0xF27C),(0xF27D),(0xF27E),
-(0xF280),(0xF281),(0xF282),(0xF283),(0xF284),(0xF285),(0xF286),(0xF287),
-(0xF288),(0xF289),(0xF28A),(0xF28B),(0xF28C),(0xF28D),(0xF28E),(0xF28F),
-(0xF290),(0xF291),(0xF292),(0xF293),(0xF294),(0xF295),(0xF296),(0xF297),
-(0xF298),(0xF299),(0xF29A),(0xF29B),(0xF29C),(0xF29D),(0xF29E),(0xF29F),
-(0xF2A0),(0xF2A1),(0xF2A2),(0xF2A3),(0xF2A4),(0xF2A5),(0xF2A6),(0xF2A7),
-(0xF2A8),(0xF2A9),(0xF2AA),(0xF2AB),(0xF2AC),(0xF2AD),(0xF2AE),(0xF2AF),
-(0xF2B0),(0xF2B1),(0xF2B2),(0xF2B3),(0xF2B4),(0xF2B5),(0xF2B6),(0xF2B7),
-(0xF2B8),(0xF2B9),(0xF2BA),(0xF2BB),(0xF2BC),(0xF2BD),(0xF2BE),(0xF2BF),
-(0xF2C0),(0xF2C1),(0xF2C2),(0xF2C3),(0xF2C4),(0xF2C5),(0xF2C6),(0xF2C7),
-(0xF2C8),(0xF2C9),(0xF2CA),(0xF2CB),(0xF2CC),(0xF2CD),(0xF2CE),(0xF2CF),
-(0xF2D0),(0xF2D1),(0xF2D2),(0xF2D3),(0xF2D4),(0xF2D5),(0xF2D6),(0xF2D7),
-(0xF2D8),(0xF2D9),(0xF2DA),(0xF2DB),(0xF2DC),(0xF2DD),(0xF2DE),(0xF2DF),
-(0xF2E0),(0xF2E1),(0xF2E2),(0xF2E3),(0xF2E4),(0xF2E5),(0xF2E6),(0xF2E7),
-(0xF2E8),(0xF2E9),(0xF2EA),(0xF2EB),(0xF2EC),(0xF2ED),(0xF2EE),(0xF2EF),
-(0xF2F0),(0xF2F1),(0xF2F2),(0xF2F3),(0xF2F4),(0xF2F5),(0xF2F6),(0xF2F7),
-(0xF2F8),(0xF2F9),(0xF2FA),(0xF2FB),(0xF2FC),
-(0xF340),(0xF341),(0xF342),(0xF343),(0xF344),(0xF345),(0xF346),(0xF347),
-(0xF348),(0xF349),(0xF34A),(0xF34B),(0xF34C),(0xF34D),(0xF34E),(0xF34F),
-(0xF350),(0xF351),(0xF352),(0xF353),(0xF354),(0xF355),(0xF356),(0xF357),
-(0xF358),(0xF359),(0xF35A),(0xF35B),(0xF35C),(0xF35D),(0xF35E),(0xF35F),
-(0xF360),(0xF361),(0xF362),(0xF363),(0xF364),(0xF365),(0xF366),(0xF367),
-(0xF368),(0xF369),(0xF36A),(0xF36B),(0xF36C),(0xF36D),(0xF36E),(0xF36F),
-(0xF370),(0xF371),(0xF372),(0xF373),(0xF374),(0xF375),(0xF376),(0xF377),
-(0xF378),(0xF379),(0xF37A),(0xF37B),(0xF37C),(0xF37D),(0xF37E),
-(0xF380),(0xF381),(0xF382),(0xF383),(0xF384),(0xF385),(0xF386),(0xF387),
-(0xF388),(0xF389),(0xF38A),(0xF38B),(0xF38C),(0xF38D),(0xF38E),(0xF38F),
-(0xF390),(0xF391),(0xF392),(0xF393),(0xF394),(0xF395),(0xF396),(0xF397),
-(0xF398),(0xF399),(0xF39A),(0xF39B),(0xF39C),(0xF39D),(0xF39E),(0xF39F),
-(0xF3A0),(0xF3A1),(0xF3A2),(0xF3A3),(0xF3A4),(0xF3A5),(0xF3A6),(0xF3A7),
-(0xF3A8),(0xF3A9),(0xF3AA),(0xF3AB),(0xF3AC),(0xF3AD),(0xF3AE),(0xF3AF),
-(0xF3B0),(0xF3B1),(0xF3B2),(0xF3B3),(0xF3B4),(0xF3B5),(0xF3B6),(0xF3B7),
-(0xF3B8),(0xF3B9),(0xF3BA),(0xF3BB),(0xF3BC),(0xF3BD),(0xF3BE),(0xF3BF),
-(0xF3C0),(0xF3C1),(0xF3C2),(0xF3C3),(0xF3C4),(0xF3C5),(0xF3C6),(0xF3C7),
-(0xF3C8),(0xF3C9),(0xF3CA),(0xF3CB),(0xF3CC),(0xF3CD),(0xF3CE),(0xF3CF),
-(0xF3D0),(0xF3D1),(0xF3D2),(0xF3D3),(0xF3D4),(0xF3D5),(0xF3D6),(0xF3D7),
-(0xF3D8),(0xF3D9),(0xF3DA),(0xF3DB),(0xF3DC),(0xF3DD),(0xF3DE),(0xF3DF),
-(0xF3E0),(0xF3E1),(0xF3E2),(0xF3E3),(0xF3E4),(0xF3E5),(0xF3E6),(0xF3E7),
-(0xF3E8),(0xF3E9),(0xF3EA),(0xF3EB),(0xF3EC),(0xF3ED),(0xF3EE),(0xF3EF),
-(0xF3F0),(0xF3F1),(0xF3F2),(0xF3F3),(0xF3F4),(0xF3F5),(0xF3F6),(0xF3F7),
-(0xF3F8),(0xF3F9),(0xF3FA),(0xF3FB),(0xF3FC),
-(0xF440),(0xF441),(0xF442),(0xF443),(0xF444),(0xF445),(0xF446),(0xF447),
-(0xF448),(0xF449),(0xF44A),(0xF44B),(0xF44C),(0xF44D),(0xF44E),(0xF44F),
-(0xF450),(0xF451),(0xF452),(0xF453),(0xF454),(0xF455),(0xF456),(0xF457),
-(0xF458),(0xF459),(0xF45A),(0xF45B),(0xF45C),(0xF45D),(0xF45E),(0xF45F),
-(0xF460),(0xF461),(0xF462),(0xF463),(0xF464),(0xF465),(0xF466),(0xF467),
-(0xF468),(0xF469),(0xF46A),(0xF46B),(0xF46C),(0xF46D),(0xF46E),(0xF46F),
-(0xF470),(0xF471),(0xF472),(0xF473),(0xF474),(0xF475),(0xF476),(0xF477),
-(0xF478),(0xF479),(0xF47A),(0xF47B),(0xF47C),(0xF47D),(0xF47E),
-(0xF480),(0xF481),(0xF482),(0xF483),(0xF484),(0xF485),(0xF486),(0xF487),
-(0xF488),(0xF489),(0xF48A),(0xF48B),(0xF48C),(0xF48D),(0xF48E),(0xF48F),
-(0xF490),(0xF491),(0xF492),(0xF493),(0xF494),(0xF495),(0xF496),(0xF497),
-(0xF498),(0xF499),(0xF49A),(0xF49B),(0xF49C),(0xF49D),(0xF49E),(0xF49F),
-(0xF4A0),(0xF4A1),(0xF4A2),(0xF4A3),(0xF4A4),(0xF4A5),(0xF4A6),(0xF4A7),
-(0xF4A8),(0xF4A9),(0xF4AA),(0xF4AB),(0xF4AC),(0xF4AD),(0xF4AE),(0xF4AF),
-(0xF4B0),(0xF4B1),(0xF4B2),(0xF4B3),(0xF4B4),(0xF4B5),(0xF4B6),(0xF4B7),
-(0xF4B8),(0xF4B9),(0xF4BA),(0xF4BB),(0xF4BC),(0xF4BD),(0xF4BE),(0xF4BF),
-(0xF4C0),(0xF4C1),(0xF4C2),(0xF4C3),(0xF4C4),(0xF4C5),(0xF4C6),(0xF4C7),
-(0xF4C8),(0xF4C9),(0xF4CA),(0xF4CB),(0xF4CC),(0xF4CD),(0xF4CE),(0xF4CF),
-(0xF4D0),(0xF4D1),(0xF4D2),(0xF4D3),(0xF4D4),(0xF4D5),(0xF4D6),(0xF4D7),
-(0xF4D8),(0xF4D9),(0xF4DA),(0xF4DB),(0xF4DC),(0xF4DD),(0xF4DE),(0xF4DF),
-(0xF4E0),(0xF4E1),(0xF4E2),(0xF4E3),(0xF4E4),(0xF4E5),(0xF4E6),(0xF4E7),
-(0xF4E8),(0xF4E9),(0xF4EA),(0xF4EB),(0xF4EC),(0xF4ED),(0xF4EE),(0xF4EF),
-(0xF4F0),(0xF4F1),(0xF4F2),(0xF4F3),(0xF4F4),(0xF4F5),(0xF4F6),(0xF4F7),
-(0xF4F8),(0xF4F9),(0xF4FA),(0xF4FB),(0xF4FC),
-(0xF540),(0xF541),(0xF542),(0xF543),(0xF544),(0xF545),(0xF546),(0xF547),
-(0xF548),(0xF549),(0xF54A),(0xF54B),(0xF54C),(0xF54D),(0xF54E),(0xF54F),
-(0xF550),(0xF551),(0xF552),(0xF553),(0xF554),(0xF555),(0xF556),(0xF557),
-(0xF558),(0xF559),(0xF55A),(0xF55B),(0xF55C),(0xF55D),(0xF55E),(0xF55F),
-(0xF560),(0xF561),(0xF562),(0xF563),(0xF564),(0xF565),(0xF566),(0xF567),
-(0xF568),(0xF569),(0xF56A),(0xF56B),(0xF56C),(0xF56D),(0xF56E),(0xF56F),
-(0xF570),(0xF571),(0xF572),(0xF573),(0xF574),(0xF575),(0xF576),(0xF577),
-(0xF578),(0xF579),(0xF57A),(0xF57B),(0xF57C),(0xF57D),(0xF57E),
-(0xF580),(0xF581),(0xF582),(0xF583),(0xF584),(0xF585),(0xF586),(0xF587),
-(0xF588),(0xF589),(0xF58A),(0xF58B),(0xF58C),(0xF58D),(0xF58E),(0xF58F),
-(0xF590),(0xF591),(0xF592),(0xF593),(0xF594),(0xF595),(0xF596),(0xF597),
-(0xF598),(0xF599),(0xF59A),(0xF59B),(0xF59C),(0xF59D),(0xF59E),(0xF59F),
-(0xF5A0),(0xF5A1),(0xF5A2),(0xF5A3),(0xF5A4),(0xF5A5),(0xF5A6),(0xF5A7),
-(0xF5A8),(0xF5A9),(0xF5AA),(0xF5AB),(0xF5AC),(0xF5AD),(0xF5AE),(0xF5AF),
-(0xF5B0),(0xF5B1),(0xF5B2),(0xF5B3),(0xF5B4),(0xF5B5),(0xF5B6),(0xF5B7),
-(0xF5B8),(0xF5B9),(0xF5BA),(0xF5BB),(0xF5BC),(0xF5BD),(0xF5BE),(0xF5BF),
-(0xF5C0),(0xF5C1),(0xF5C2),(0xF5C3),(0xF5C4),(0xF5C5),(0xF5C6),(0xF5C7),
-(0xF5C8),(0xF5C9),(0xF5CA),(0xF5CB),(0xF5CC),(0xF5CD),(0xF5CE),(0xF5CF),
-(0xF5D0),(0xF5D1),(0xF5D2),(0xF5D3),(0xF5D4),(0xF5D5),(0xF5D6),(0xF5D7),
-(0xF5D8),(0xF5D9),(0xF5DA),(0xF5DB),(0xF5DC),(0xF5DD),(0xF5DE),(0xF5DF),
-(0xF5E0),(0xF5E1),(0xF5E2),(0xF5E3),(0xF5E4),(0xF5E5),(0xF5E6),(0xF5E7),
-(0xF5E8),(0xF5E9),(0xF5EA),(0xF5EB),(0xF5EC),(0xF5ED),(0xF5EE),(0xF5EF),
-(0xF5F0),(0xF5F1),(0xF5F2),(0xF5F3),(0xF5F4),(0xF5F5),(0xF5F6),(0xF5F7),
-(0xF5F8),(0xF5F9),(0xF5FA),(0xF5FB),(0xF5FC),
-(0xF640),(0xF641),(0xF642),(0xF643),(0xF644),(0xF645),(0xF646),(0xF647),
-(0xF648),(0xF649),(0xF64A),(0xF64B),(0xF64C),(0xF64D),(0xF64E),(0xF64F),
-(0xF650),(0xF651),(0xF652),(0xF653),(0xF654),(0xF655),(0xF656),(0xF657),
-(0xF658),(0xF659),(0xF65A),(0xF65B),(0xF65C),(0xF65D),(0xF65E),(0xF65F),
-(0xF660),(0xF661),(0xF662),(0xF663),(0xF664),(0xF665),(0xF666),(0xF667),
-(0xF668),(0xF669),(0xF66A),(0xF66B),(0xF66C),(0xF66D),(0xF66E),(0xF66F),
-(0xF670),(0xF671),(0xF672),(0xF673),(0xF674),(0xF675),(0xF676),(0xF677),
-(0xF678),(0xF679),(0xF67A),(0xF67B),(0xF67C),(0xF67D),(0xF67E),
-(0xF680),(0xF681),(0xF682),(0xF683),(0xF684),(0xF685),(0xF686),(0xF687),
-(0xF688),(0xF689),(0xF68A),(0xF68B),(0xF68C),(0xF68D),(0xF68E),(0xF68F),
-(0xF690),(0xF691),(0xF692),(0xF693),(0xF694),(0xF695),(0xF696),(0xF697),
-(0xF698),(0xF699),(0xF69A),(0xF69B),(0xF69C),(0xF69D),(0xF69E),(0xF69F),
-(0xF6A0),(0xF6A1),(0xF6A2),(0xF6A3),(0xF6A4),(0xF6A5),(0xF6A6),(0xF6A7),
-(0xF6A8),(0xF6A9),(0xF6AA),(0xF6AB),(0xF6AC),(0xF6AD),(0xF6AE),(0xF6AF),
-(0xF6B0),(0xF6B1),(0xF6B2),(0xF6B3),(0xF6B4),(0xF6B5),(0xF6B6),(0xF6B7),
-(0xF6B8),(0xF6B9),(0xF6BA),(0xF6BB),(0xF6BC),(0xF6BD),(0xF6BE),(0xF6BF),
-(0xF6C0),(0xF6C1),(0xF6C2),(0xF6C3),(0xF6C4),(0xF6C5),(0xF6C6),(0xF6C7),
-(0xF6C8),(0xF6C9),(0xF6CA),(0xF6CB),(0xF6CC),(0xF6CD),(0xF6CE),(0xF6CF),
-(0xF6D0),(0xF6D1),(0xF6D2),(0xF6D3),(0xF6D4),(0xF6D5),(0xF6D6),(0xF6D7),
-(0xF6D8),(0xF6D9),(0xF6DA),(0xF6DB),(0xF6DC),(0xF6DD),(0xF6DE),(0xF6DF),
-(0xF6E0),(0xF6E1),(0xF6E2),(0xF6E3),(0xF6E4),(0xF6E5),(0xF6E6),(0xF6E7),
-(0xF6E8),(0xF6E9),(0xF6EA),(0xF6EB),(0xF6EC),(0xF6ED),(0xF6EE),(0xF6EF),
-(0xF6F0),(0xF6F1),(0xF6F2),(0xF6F3),(0xF6F4),(0xF6F5),(0xF6F6),(0xF6F7),
-(0xF6F8),(0xF6F9),(0xF6FA),(0xF6FB),(0xF6FC),
-(0xF740),(0xF741),(0xF742),(0xF743),(0xF744),(0xF745),(0xF746),(0xF747),
-(0xF748),(0xF749),(0xF74A),(0xF74B),(0xF74C),(0xF74D),(0xF74E),(0xF74F),
-(0xF750),(0xF751),(0xF752),(0xF753),(0xF754),(0xF755),(0xF756),(0xF757),
-(0xF758),(0xF759),(0xF75A),(0xF75B),(0xF75C),(0xF75D),(0xF75E),(0xF75F),
-(0xF760),(0xF761),(0xF762),(0xF763),(0xF764),(0xF765),(0xF766),(0xF767),
-(0xF768),(0xF769),(0xF76A),(0xF76B),(0xF76C),(0xF76D),(0xF76E),(0xF76F),
-(0xF770),(0xF771),(0xF772),(0xF773),(0xF774),(0xF775),(0xF776),(0xF777),
-(0xF778),(0xF779),(0xF77A),(0xF77B),(0xF77C),(0xF77D),(0xF77E),
-(0xF780),(0xF781),(0xF782),(0xF783),(0xF784),(0xF785),(0xF786),(0xF787),
-(0xF788),(0xF789),(0xF78A),(0xF78B),(0xF78C),(0xF78D),(0xF78E),(0xF78F),
-(0xF790),(0xF791),(0xF792),(0xF793),(0xF794),(0xF795),(0xF796),(0xF797),
-(0xF798),(0xF799),(0xF79A),(0xF79B),(0xF79C),(0xF79D),(0xF79E),(0xF79F),
-(0xF7A0),(0xF7A1),(0xF7A2),(0xF7A3),(0xF7A4),(0xF7A5),(0xF7A6),(0xF7A7),
-(0xF7A8),(0xF7A9),(0xF7AA),(0xF7AB),(0xF7AC),(0xF7AD),(0xF7AE),(0xF7AF),
-(0xF7B0),(0xF7B1),(0xF7B2),(0xF7B3),(0xF7B4),(0xF7B5),(0xF7B6),(0xF7B7),
-(0xF7B8),(0xF7B9),(0xF7BA),(0xF7BB),(0xF7BC),(0xF7BD),(0xF7BE),(0xF7BF),
-(0xF7C0),(0xF7C1),(0xF7C2),(0xF7C3),(0xF7C4),(0xF7C5),(0xF7C6),(0xF7C7),
-(0xF7C8),(0xF7C9),(0xF7CA),(0xF7CB),(0xF7CC),(0xF7CD),(0xF7CE),(0xF7CF),
-(0xF7D0),(0xF7D1),(0xF7D2),(0xF7D3),(0xF7D4),(0xF7D5),(0xF7D6),(0xF7D7),
-(0xF7D8),(0xF7D9),(0xF7DA),(0xF7DB),(0xF7DC),(0xF7DD),(0xF7DE),(0xF7DF),
-(0xF7E0),(0xF7E1),(0xF7E2),(0xF7E3),(0xF7E4),(0xF7E5),(0xF7E6),(0xF7E7),
-(0xF7E8),(0xF7E9),(0xF7EA),(0xF7EB),(0xF7EC),(0xF7ED),(0xF7EE),(0xF7EF),
-(0xF7F0),(0xF7F1),(0xF7F2),(0xF7F3),(0xF7F4),(0xF7F5),(0xF7F6),(0xF7F7),
-(0xF7F8),(0xF7F9),(0xF7FA),(0xF7FB),(0xF7FC),
-(0xF840),(0xF841),(0xF842),(0xF843),(0xF844),(0xF845),(0xF846),(0xF847),
-(0xF848),(0xF849),(0xF84A),(0xF84B),(0xF84C),(0xF84D),(0xF84E),(0xF84F),
-(0xF850),(0xF851),(0xF852),(0xF853),(0xF854),(0xF855),(0xF856),(0xF857),
-(0xF858),(0xF859),(0xF85A),(0xF85B),(0xF85C),(0xF85D),(0xF85E),(0xF85F),
-(0xF860),(0xF861),(0xF862),(0xF863),(0xF864),(0xF865),(0xF866),(0xF867),
-(0xF868),(0xF869),(0xF86A),(0xF86B),(0xF86C),(0xF86D),(0xF86E),(0xF86F),
-(0xF870),(0xF871),(0xF872),(0xF873),(0xF874),(0xF875),(0xF876),(0xF877),
-(0xF878),(0xF879),(0xF87A),(0xF87B),(0xF87C),(0xF87D),(0xF87E),
-(0xF880),(0xF881),(0xF882),(0xF883),(0xF884),(0xF885),(0xF886),(0xF887),
-(0xF888),(0xF889),(0xF88A),(0xF88B),(0xF88C),(0xF88D),(0xF88E),(0xF88F),
-(0xF890),(0xF891),(0xF892),(0xF893),(0xF894),(0xF895),(0xF896),(0xF897),
-(0xF898),(0xF899),(0xF89A),(0xF89B),(0xF89C),(0xF89D),(0xF89E),(0xF89F),
-(0xF8A0),(0xF8A1),(0xF8A2),(0xF8A3),(0xF8A4),(0xF8A5),(0xF8A6),(0xF8A7),
-(0xF8A8),(0xF8A9),(0xF8AA),(0xF8AB),(0xF8AC),(0xF8AD),(0xF8AE),(0xF8AF),
-(0xF8B0),(0xF8B1),(0xF8B2),(0xF8B3),(0xF8B4),(0xF8B5),(0xF8B6),(0xF8B7),
-(0xF8B8),(0xF8B9),(0xF8BA),(0xF8BB),(0xF8BC),(0xF8BD),(0xF8BE),(0xF8BF),
-(0xF8C0),(0xF8C1),(0xF8C2),(0xF8C3),(0xF8C4),(0xF8C5),(0xF8C6),(0xF8C7),
-(0xF8C8),(0xF8C9),(0xF8CA),(0xF8CB),(0xF8CC),(0xF8CD),(0xF8CE),(0xF8CF),
-(0xF8D0),(0xF8D1),(0xF8D2),(0xF8D3),(0xF8D4),(0xF8D5),(0xF8D6),(0xF8D7),
-(0xF8D8),(0xF8D9),(0xF8DA),(0xF8DB),(0xF8DC),(0xF8DD),(0xF8DE),(0xF8DF),
-(0xF8E0),(0xF8E1),(0xF8E2),(0xF8E3),(0xF8E4),(0xF8E5),(0xF8E6),(0xF8E7),
-(0xF8E8),(0xF8E9),(0xF8EA),(0xF8EB),(0xF8EC),(0xF8ED),(0xF8EE),(0xF8EF),
-(0xF8F0),(0xF8F1),(0xF8F2),(0xF8F3),(0xF8F4),(0xF8F5),(0xF8F6),(0xF8F7),
-(0xF8F8),(0xF8F9),(0xF8FA),(0xF8FB),(0xF8FC),
-(0xF940),(0xF941),(0xF942),(0xF943),(0xF944),(0xF945),(0xF946),(0xF947),
-(0xF948),(0xF949),(0xF94A),(0xF94B),(0xF94C),(0xF94D),(0xF94E),(0xF94F),
-(0xF950),(0xF951),(0xF952),(0xF953),(0xF954),(0xF955),(0xF956),(0xF957),
-(0xF958),(0xF959),(0xF95A),(0xF95B),(0xF95C),(0xF95D),(0xF95E),(0xF95F),
-(0xF960),(0xF961),(0xF962),(0xF963),(0xF964),(0xF965),(0xF966),(0xF967),
-(0xF968),(0xF969),(0xF96A),(0xF96B),(0xF96C),(0xF96D),(0xF96E),(0xF96F),
-(0xF970),(0xF971),(0xF972),(0xF973),(0xF974),(0xF975),(0xF976),(0xF977),
-(0xF978),(0xF979),(0xF97A),(0xF97B),(0xF97C),(0xF97D),(0xF97E),
-(0xF980),(0xF981),(0xF982),(0xF983),(0xF984),(0xF985),(0xF986),(0xF987),
-(0xF988),(0xF989),(0xF98A),(0xF98B),(0xF98C),(0xF98D),(0xF98E),(0xF98F),
-(0xF990),(0xF991),(0xF992),(0xF993),(0xF994),(0xF995),(0xF996),(0xF997),
-(0xF998),(0xF999),(0xF99A),(0xF99B),(0xF99C),(0xF99D),(0xF99E),(0xF99F),
-(0xF9A0),(0xF9A1),(0xF9A2),(0xF9A3),(0xF9A4),(0xF9A5),(0xF9A6),(0xF9A7),
-(0xF9A8),(0xF9A9),(0xF9AA),(0xF9AB),(0xF9AC),(0xF9AD),(0xF9AE),(0xF9AF),
-(0xF9B0),(0xF9B1),(0xF9B2),(0xF9B3),(0xF9B4),(0xF9B5),(0xF9B6),(0xF9B7),
-(0xF9B8),(0xF9B9),(0xF9BA),(0xF9BB),(0xF9BC),(0xF9BD),(0xF9BE),(0xF9BF),
-(0xF9C0),(0xF9C1),(0xF9C2),(0xF9C3),(0xF9C4),(0xF9C5),(0xF9C6),(0xF9C7),
-(0xF9C8),(0xF9C9),(0xF9CA),(0xF9CB),(0xF9CC),(0xF9CD),(0xF9CE),(0xF9CF),
-(0xF9D0),(0xF9D1),(0xF9D2),(0xF9D3),(0xF9D4),(0xF9D5),(0xF9D6),(0xF9D7),
-(0xF9D8),(0xF9D9),(0xF9DA),(0xF9DB),(0xF9DC),(0xF9DD),(0xF9DE),(0xF9DF),
-(0xF9E0),(0xF9E1),(0xF9E2),(0xF9E3),(0xF9E4),(0xF9E5),(0xF9E6),(0xF9E7),
-(0xF9E8),(0xF9E9),(0xF9EA),(0xF9EB),(0xF9EC),(0xF9ED),(0xF9EE),(0xF9EF),
-(0xF9F0),(0xF9F1),(0xF9F2),(0xF9F3),(0xF9F4),(0xF9F5),(0xF9F6),(0xF9F7),
-(0xF9F8),(0xF9F9),(0xF9FA),(0xF9FB),(0xF9FC);
-
-#Test that all the characters are stored correctly
-SELECT HEX(c1) FROM t1;
-
-#Test conversion to ucs2
-CREATE TABLE t2 SELECT CONVERT(c1 USING ucs2) AS c1 FROM t1;
-SELECT HEX(c1) FROM t2;
-
-#Test round trip conversion
-CREATE TABLE t3 SELECT CONVERT(c1 USING cp932) AS c1 FROM t2;
-SELECT HEX(c1) FROM t3;
-
-#Test conversion to eucjpms
-CREATE TABLE t4 SELECT CONVERT(c1 USING eucjpms) AS c1 FROM t1;
-SELECT HEX(c1) FROM t4;
-
-DROP TABLE t1;
-DROP TABLE t2;
-DROP TABLE t3;
-DROP TABLE t4;
-
-SET collation_connection='cp932_japanese_ci';
--- source include/ctype_filesort.inc
-SET collation_connection='cp932_bin';
--- source include/ctype_filesort.inc
-
-#
-# Bug#12547: Inserting long string into varchar causes table crash in cp932
-#
-create table t1 (col1 varchar(1)) character set cp932;
-insert into t1 values ('a');
-insert into t1 values ('ab');
-select * from t1;
-insert into t1 values ('abc');
-select * from t1;
-drop table t1;
diff --git a/mysql-test/t/ctype_cp932_binlog.test b/mysql-test/t/ctype_cp932_binlog.test
deleted file mode 100644
index 3bbbe94f0e3..00000000000
--- a/mysql-test/t/ctype_cp932_binlog.test
+++ /dev/null
@@ -1,57 +0,0 @@
--- source include/not_embedded.inc
--- source include/have_cp932.inc
-
---character_set cp932
---disable_warnings
-drop table if exists t1;
---enable_warnings
-
-set names cp932;
-set character_set_database = cp932;
-
-# Test prepared statement with 0x8300 sequence in parameter while
-# running with cp932 client character set.
-RESET MASTER;
-CREATE TABLE t1(f1 blob);
-PREPARE stmt1 FROM 'INSERT INTO t1 VALUES(?)';
-SET @var1= x'8300';
-# TODO: Note that this doesn't actually test the code which was added for
-# bug#11338 because this syntax for prepared statements causes the PS to
-# be replicated differently than if we executed the PS from C or Java.
-# Using this syntax, variable names are inserted into the binlog instead
-# of values. The real goal of this test is to check the code that was
-# added to Item_param::query_val_str() in order to do hex encoding of
-# PS parameters when the client character set is cp932;
-# Bug#11338 has an example java program which can be used to verify this
-# code (and I have used it to test the fix) until there is some way to
-# exercise this code from mysql-test-run.
-EXECUTE stmt1 USING @var1;
-SHOW BINLOG EVENTS FROM 98;
-SELECT HEX(f1) FROM t1;
-DROP table t1;
-# end test for bug#11338
-
-# End of 4.1 tests
-
-#
-# Bug#18293: Values in stored procedure written to binlog unescaped
-#
-
-delimiter |;
-CREATE TABLE t4 (s1 CHAR(50) CHARACTER SET latin1,
- s2 CHAR(50) CHARACTER SET cp932,
- d DECIMAL(10,2))|
-CREATE PROCEDURE bug18293 (IN ins1 CHAR(50),
- IN ins2 CHAR(50) CHARACTER SET cp932,
- IN ind DECIMAL(10,2))
- BEGIN
- INSERT INTO t4 VALUES (ins1, ins2, ind);
- END|
-CALL bug18293("Foo's a Bar", _cp932 0xED40ED41ED42, 47.93)|
-SELECT HEX(s1),HEX(s2),d FROM t4|
-DROP PROCEDURE bug18293|
-DROP TABLE t4|
-SHOW BINLOG EVENTS FROM 393|
-delimiter ;|
-
-# End of 5.0 tests
diff --git a/mysql-test/t/ctype_cp932_binlog_row.test b/mysql-test/t/ctype_cp932_binlog_row.test
new file mode 100644
index 00000000000..38614ea45c0
--- /dev/null
+++ b/mysql-test/t/ctype_cp932_binlog_row.test
@@ -0,0 +1,5 @@
+# This is a wrapper for binlog.test so that the same test case can be used
+# For both statement and row based bin logs 11/07/2005 [jbm]
+
+-- source include/have_binlog_format_row.inc
+-- source extra/binlog_tests/ctype_cp932_binlog.test
diff --git a/mysql-test/t/ctype_cp932_binlog_stm.test b/mysql-test/t/ctype_cp932_binlog_stm.test
new file mode 100644
index 00000000000..7a0ac671417
--- /dev/null
+++ b/mysql-test/t/ctype_cp932_binlog_stm.test
@@ -0,0 +1,29 @@
+# This is a wrapper for binlog.test so that the same test case can be used
+# For both statement and row based bin logs 11/07/2005 [jbm]
+
+-- source include/have_binlog_format_statement.inc
+-- source extra/binlog_tests/ctype_cp932_binlog.test
+
+#
+# Bug#18293: Values in stored procedure written to binlog unescaped
+#
+
+delimiter |;
+CREATE TABLE t4 (s1 CHAR(50) CHARACTER SET latin1,
+ s2 CHAR(50) CHARACTER SET cp932,
+ d DECIMAL(10,2))|
+CREATE PROCEDURE bug18293 (IN ins1 CHAR(50),
+ IN ins2 CHAR(50) CHARACTER SET cp932,
+ IN ind DECIMAL(10,2))
+ BEGIN
+ INSERT INTO t4 VALUES (ins1, ins2, ind);
+ END|
+CALL bug18293("Foo's a Bar", _cp932 0xED40ED41ED42, 47.93)|
+SELECT HEX(s1),HEX(s2),d FROM t4|
+DROP PROCEDURE bug18293|
+DROP TABLE t4|
+SHOW BINLOG EVENTS FROM 397|
+delimiter ;|
+
+# End of 5.0 tests
+
diff --git a/mysql-test/t/ctype_cp932_notembedded.test b/mysql-test/t/ctype_cp932_notembedded.test
deleted file mode 100644
index 52e7acc3f01..00000000000
--- a/mysql-test/t/ctype_cp932_notembedded.test
+++ /dev/null
@@ -1,32 +0,0 @@
--- source include/not_embedded.inc
--- source include/have_cp932.inc
-
---character_set cp932
---disable_warnings
-drop table if exists t1;
---enable_warnings
-
-set names cp932;
-set character_set_database = cp932;
-
-# Test prepared statement with 0x8300 sequence in parameter while
-# running with cp932 client character set.
-RESET MASTER;
-CREATE TABLE t1(f1 blob);
-PREPARE stmt1 FROM 'INSERT INTO t1 VALUES(?)';
-SET @var1= x'8300';
-# TODO: Note that this doesn't actually test the code which was added for
-# bug#11338 because this syntax for prepared statements causes the PS to
-# be replicated differently than if we executed the PS from C or Java.
-# Using this syntax, variable names are inserted into the binlog instead
-# of values. The real goal of this test is to check the code that was
-# added to Item_param::query_val_str() in order to do hex encoding of
-# PS parameters when the client character set is cp932;
-# Bug#11338 has an example java program which can be used to verify this
-# code (and I have used it to test the fix) until there is some way to
-# exercise this code from mysql-test-run.
-EXECUTE stmt1 USING @var1;
-SHOW BINLOG EVENTS FROM 98;
-SELECT HEX(f1) FROM t1;
-DROP table t1;
-# end test for bug#11338
diff --git a/mysql-test/t/ctype_filename.test b/mysql-test/t/ctype_filename.test
new file mode 100644
index 00000000000..436ccfc4f2e
--- /dev/null
+++ b/mysql-test/t/ctype_filename.test
@@ -0,0 +1,21 @@
+--disable_warnings
+drop table if exists con, aux, nul, lpt1, com1, `clock$`;
+--enable_warnings
+
+create table con (a int);
+drop table con;
+
+create table aux (a int);
+drop table aux;
+
+create table nul (a int);
+drop table nul;
+
+create table lpt1 (a int);
+drop table lpt1;
+
+create table com1 (a int);
+drop table com1;
+
+create table `clock$` (a int);
+drop table `clock$`;
diff --git a/mysql-test/t/ctype_sjis.test b/mysql-test/t/ctype_sjis.test
index 1d807b5e9a8..01e0b334554 100644
--- a/mysql-test/t/ctype_sjis.test
+++ b/mysql-test/t/ctype_sjis.test
@@ -78,6 +78,6 @@ SET collation_connection='sjis_bin';
--character_set sjis
SET NAMES sjis;
-SELECT HEX('@\\') FROM DUAL;
+SELECT HEX('@\') FROM DUAL;
# End of 4.1 tests
diff --git a/mysql-test/t/ctype_ucs_binlog.test b/mysql-test/t/ctype_ucs_binlog.test
deleted file mode 100644
index 2467d34386c..00000000000
--- a/mysql-test/t/ctype_ucs_binlog.test
+++ /dev/null
@@ -1,20 +0,0 @@
---source include/not_embedded.inc
---source include/have_ucs2.inc
-
-#
-# Check correct binlogging of UCS2 user variables (BUG#3875)
-#
-SET TIMESTAMP=10000;
-create table t2 (c char(30)) charset=ucs2;
-set @v=convert('abc' using ucs2);
-reset master;
-insert into t2 values (@v);
-show binlog events from 98;
-# more important than SHOW BINLOG EVENTS, mysqlbinlog (where we
-# absolutely need variables names to be quoted and strings to be
-# escaped).
---replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
---exec $MYSQL_BINLOG --short-form $MYSQLTEST_VARDIR/log/master-bin.000001
-drop table t2;
-
-# End of 4.1 tests
diff --git a/mysql-test/t/ctype_ujis.test b/mysql-test/t/ctype_ujis.test
index 14b37569b11..347587faee6 100644
--- a/mysql-test/t/ctype_ujis.test
+++ b/mysql-test/t/ctype_ujis.test
@@ -94,7 +94,7 @@ CREATE TABLE t1
b VARCHAR(50) NOT NULL DEFAULT '',
PRIMARY KEY (a),
KEY b (b(10))
-) TYPE=InnoDB CHARACTER SET 'ujis' COLLATE 'ujis_japanese_ci';
+) ENGINE=InnoDB CHARACTER SET 'ujis' COLLATE 'ujis_japanese_ci';
--enable_warnings
INSERT INTO t1 (a, b) VALUES (0, 'aaabbbcccddd');
INSERT INTO t1 (a, b) VALUES (1, 'eeefffggghhh');
@@ -110,7 +110,7 @@ CREATE TABLE t1
b VARCHAR(50) NOT NULL DEFAULT '',
PRIMARY KEY (a),
KEY b (b(10))
-) TYPE=MyISAM CHARACTER SET 'ujis' COLLATE 'ujis_japanese_ci';
+) ENGINE=MyISAM CHARACTER SET 'ujis' COLLATE 'ujis_japanese_ci';
--enable_warnings
INSERT INTO t1 (a, b) VALUES (0, 'aaabbbcccddd');
INSERT INTO t1 (a, b) VALUES (1, 'eeefffggghhh');
diff --git a/mysql-test/t/date_formats.test b/mysql-test/t/date_formats.test
index c3dd68abb86..39a530ba733 100644
--- a/mysql-test/t/date_formats.test
+++ b/mysql-test/t/date_formats.test
@@ -6,7 +6,9 @@
drop table if exists t1;
--enable_warnings
+--replace_result ROW <format> STATEMENT <format>
SHOW GLOBAL VARIABLES LIKE "%_format%";
+--replace_result ROW <format> STATEMENT <format>
SHOW SESSION VARIABLES LIKE "%_format%";
#
@@ -34,6 +36,7 @@ set datetime_format= '%H:%i:%s.%f %m-%d-%Y';
set datetime_format= '%h:%i:%s %p %Y-%m-%d';
set datetime_format= '%h:%i:%s.%f %p %Y-%m-%d';
+--replace_result ROW <format> STATEMENT <format>
SHOW SESSION VARIABLES LIKE "%format";
--error 1231
diff --git a/mysql-test/t/disabled.def b/mysql-test/t/disabled.def
index 007847fab37..77ca2e29669 100644
--- a/mysql-test/t/disabled.def
+++ b/mysql-test/t/disabled.def
@@ -1,13 +1,40 @@
##############################################################################
#
-# List the test cases that are to be disabled temporarely.
+# List the test cases that are to be disabled temporarily.
#
# Separate the test case name and the comment with ':'.
#
-# <testcasename> : Comment test
+# <testcasename> : BUG#<xxxx> <date disabled> <disabler> <comment>
#
-# Don't use any TAB characters for whitespace.
+# Do not use any TAB characters for whitespace.
#
##############################################################################
+#events_bugs : BUG#17619 2006-02-21 andrey Race conditions
+#events_stress : BUG#17619 2006-02-21 andrey Race conditions
+#events : BUG#17619 2006-02-21 andrey Race conditions
+#events_scheduling : BUG#19170 2006-04-26 andrey Test case of 19170 fails on some platforms. Has to be checked.
+ndb_autodiscover : BUG#18952 2006-02-16 jmiller Needs to be fixed w.r.t binlog
+ndb_autodiscover2 : BUG#18952 2006-02-16 jmiller Needs to be fixed w.r.t binlog
+#ndb_binlog_discover : BUG#19395 2006-04-28 tomas/knielsen mysqld does not always detect cluster shutdown
+#ndb_cache2 : BUG#18597 2006-03-28 brian simultaneous drop table and ndb statistics update triggers node failure
+#ndb_cache_multi2 : BUG#18597 2006-04-10 kent simultaneous drop table and ndb statistics update triggers node failure
+ndb_load : BUG#17233 2006-05-04 tomas failed load data from infile causes mysqld dbug_assert, binlog not flushed
+partition_03ndb : BUG#16385 2006-03-24 mikael Partitions: crash when updating a range partitioned NDB table
+ps_7ndb : BUG#18950 2006-02-16 jmiller create table like does not obtain LOCK_open
+rpl_ndb_2innodb : BUG#19227 2006-04-20 pekka pk delete apparently not replicated
+rpl_ndb_2myisam : BUG#19227 2006-04-20 pekka pk delete apparently not replicated
+rpl_ndb_auto_inc : BUG#17086 2006-02-16 jmiller CR: auto_increment_increment and auto_increment_offset produce duplicate key er
+#rpl_ndb_commit_afterflush : BUG#19328 2006-05-04 tomas Slave timeout with COM_REGISTER_SLAVE error causing stop
+rpl_ndb_dd_partitions : BUG#19259 2006-04-21 rpl_ndb_dd_partitions fails on s/AMD
+rpl_ndb_ddl : BUG#18946 result file needs update + test needs to checked
+rpl_ndb_innodb2ndb : Bug #19710 Cluster replication to partition table fails on DELETE FROM statement
+#rpl_ndb_log : BUG#18947 2006-03-21 tomas CRBR: order in binlog of create table and insert (on different table) not determ
+rpl_ndb_myisam2ndb : Bug #19710 Cluster replication to partition table fails on DELETE FROM statement
+rpl_switch_stm_row_mixed : BUG#18590 2006-03-28 brian
+rpl_row_blob_innodb : BUG#18980 2006-04-10 kent Test fails randomly
+rpl_row_func003 : BUG#19074 2006-13-04 andrei test failed
+rpl_row_inexist_tbl : BUG#18948 2006-03-09 mats Disabled since patch makes this test wait forever
+rpl_sp : BUG#16456 2006-02-16 jmiller
-ndb_load : Bug#17233
+# the below testcase have been reworked to avoid the bug, test contains comment, keep bug open
+#ndb_binlog_ddl_multi : BUG#18976 2006-04-10 kent CRBR: multiple binlog, second binlog may miss schema log events
diff --git a/mysql-test/t/drop_temp_table.test b/mysql-test/t/drop_temp_table.test
deleted file mode 100644
index bc06de4096c..00000000000
--- a/mysql-test/t/drop_temp_table.test
+++ /dev/null
@@ -1,31 +0,0 @@
-# Embedded server doesn't support binlog
--- source include/not_embedded.inc
-
---disable_warnings
-drop database if exists `drop-temp+table-test`;
---enable_warnings
-
-connect (con1,localhost,root,,);
-connect (con2,localhost,root,,);
-connection con1;
-reset master;
-create database `drop-temp+table-test`;
-use `drop-temp+table-test`;
-create temporary table shortn1 (a int);
-create temporary table `table:name` (a int);
-create temporary table shortn2 (a int);
-select get_lock("a",10);
-disconnect con1;
-
-connection con2;
-# We want to SHOW BINLOG EVENTS, to know what was logged. But there is no
-# guarantee that logging of the terminated con1 has been done yet.
-# To be sure that logging has been done, we use a user lock.
-select get_lock("a",10);
-let $VERSION=`select version()`;
---replace_result $VERSION VERSION
---replace_column 2 # 5 #
-show binlog events;
-drop database `drop-temp+table-test`;
-
-# End of 4.1 tests
diff --git a/mysql-test/t/events.test b/mysql-test/t/events.test
new file mode 100644
index 00000000000..a3e2bbc0998
--- /dev/null
+++ b/mysql-test/t/events.test
@@ -0,0 +1,378 @@
+create database if not exists events_test;
+use events_test;
+
+#
+# START: BUG #17289 Events: missing privilege check for drop database
+#
+CREATE USER pauline@localhost;
+CREATE DATABASE db_x;
+GRANT EVENT ON db_x.* TO pauline@localhost;
+USE db_x;
+CREATE TABLE x_table(a int);
+connect (priv_conn,localhost,pauline,,db_x);
+CREATE EVENT e_x1 ON SCHEDULE EVERY 1 SECOND DO DROP DATABASE db_x;
+CREATE EVENT e_x2 ON SCHEDULE EVERY 1 SECOND DO DROP TABLE x_table;
+connection default;
+SHOW DATABASES LIKE 'db_x';
+SET GLOBAL event_scheduler=1;
+--sleep 1.5
+SHOW DATABASES LIKE 'db_x';
+SHOW TABLES FROM db_x;
+SET GLOBAL event_scheduler=2;
+connection priv_conn;
+DROP EVENT e_x1;
+DROP EVENT e_x2;
+disconnect priv_conn;
+connection default;
+DROP DATABASE db_x;
+DROP USER pauline@localhost;
+USE events_test;
+#
+# END: BUG #17289 Events: missing privilege check for drop database
+#
+SET GLOBAL event_scheduler=2;
+drop event if exists event1;
+create event event1 on schedule every 15 minute starts now() ends date_add(now(), interval 5 hour) DO begin end;
+alter event event1 rename to event2 enable;
+alter event event2 disable;
+alter event event2 enable;
+alter event event2 on completion not preserve;
+delimiter __;
+alter event event2 on schedule every 1 year on completion preserve rename to event3 comment "new comment" do begin select 1; end__
+delimiter ;__
+alter event event3 rename to event2;
+
+drop event event2;
+create event event2 on schedule every 2 second starts now() ends date_add(now(), interval 5 hour) comment "some" DO begin end;
+drop event event2;
+
+# BUG #16537 (Events: mysql.event.starts is null)
+CREATE EVENT event_starts_test ON SCHEDULE EVERY 10 SECOND COMMENT "" DO SELECT 1;
+--replace_column 8 # 9 #
+SHOW EVENTS;
+SELECT starts IS NULL, ends IS NULL, comment FROM mysql.event WHERE db='events_test' AND name='event_starts_test';
+ALTER EVENT event_starts_test ON SCHEDULE AT '2020-02-02 20:00:02';
+--replace_column 8 # 9 #
+SHOW EVENTS;
+SELECT starts IS NULL, ends IS NULL, comment FROM mysql.event WHERE db='events_test' AND name='event_starts_test';
+ALTER EVENT event_starts_test COMMENT "non-empty comment";
+--replace_column 8 # 9 #
+SHOW EVENTS;
+SELECT starts IS NULL, ends IS NULL, comment FROM mysql.event WHERE db='events_test' AND name='event_starts_test';
+ALTER EVENT event_starts_test COMMENT "";
+--replace_column 8 # 9 #
+SHOW EVENTS;
+SELECT starts IS NULL, ends IS NULL, comment FROM mysql.event WHERE db='events_test' AND name='event_starts_test';
+DROP EVENT event_starts_test;
+CREATE EVENT event_starts_test ON SCHEDULE EVERY 20 SECOND STARTS '2020-02-02 20:00:02' ENDS '2022-02-02 20:00:02' DO SELECT 2;
+--replace_column 8 # 9 #
+SHOW EVENTS;
+SELECT starts IS NULL, ends IS NULL, comment FROM mysql.event WHERE db='events_test' AND name='event_starts_test';
+ALTER EVENT event_starts_test COMMENT "non-empty comment";
+--replace_column 8 # 9 #
+SHOW EVENTS;
+SELECT starts IS NULL, ends IS NULL, comment FROM mysql.event WHERE db='events_test' AND name='event_starts_test';
+ALTER EVENT event_starts_test COMMENT "";
+--replace_column 8 # 9 #
+SHOW EVENTS;
+DROP EVENT event_starts_test;
+#
+#
+create event e_43 on schedule every 1 second do set @a = 5;
+set global event_scheduler = 1;
+--sleep 2
+alter event e_43 do alter event e_43 do set @a = 4;
+--sleep 2
+select db, name, body, status, interval_field, interval_value from mysql.event;
+drop event e_43;
+--sleep 1
+
+--echo "Let's check whether we can use non-qualified names"
+create table non_qualif(a int);
+create event non_qualif_ev on schedule every 10 minute do insert into non_qualif values (800219);
+--sleep 1
+select * from non_qualif;
+drop event non_qualif_ev;
+drop table non_qualif;
+set global event_scheduler = 2;
+
+create table t_event3 (a int, b float);
+drop event if exists event3;
+create event event3 on schedule every 50 + 10 minute starts date_add("20100101", interval 5 minute) ends date_add("20151010", interval 5 day) comment "portokala_comment" DO insert into t_event3 values (unix_timestamp(), rand());
+select count(*) from t_event3;
+drop event event3;
+drop table t_event3;
+
+
+set names utf8;
+#
+# SHOW CREATE EVENT test begin
+#
+CREATE EVENT root6 ON SCHEDULE EVERY '10:20' MINUTE_SECOND ON COMPLETION PRESERVE ENABLE COMMENT 'some comment' DO select 1;
+SHOW CREATE EVENT root6;
+create event root7 on schedule every 2 year do select 1;
+SHOW CREATE EVENT root7;
+create event root8 on schedule every '2:5' year_month do select 1;
+SHOW CREATE EVENT root8;
+create event root8_1 on schedule every '2:15' year_month do select 1;
+SHOW CREATE EVENT root8_1;
+create event root9 on schedule every 2 week ON COMPLETION PRESERVE DISABLE COMMENT 'коментар на кирилица' do select 1;
+SHOW CREATE EVENT root9;
+create event root10 on schedule every '20:5' day_hour do select 1;
+SHOW CREATE EVENT root10;
+create event root11 on schedule every '20:25' day_hour do select 1;
+SHOW CREATE EVENT root11;
+create event root12 on schedule every '20:25' hour_minute do select 1;
+SHOW CREATE EVENT root12;
+create event root13 on schedule every '25:25' hour_minute do select 1;
+SHOW CREATE EVENT root13;
+create event root13_1 on schedule every '11:65' hour_minute do select 1;
+SHOW CREATE EVENT root13_1;
+create event root14 on schedule every '35:35' minute_second do select 1;
+SHOW CREATE EVENT root14;
+create event root15 on schedule every '35:66' minute_second do select 1;
+SHOW CREATE EVENT root15;
+create event root16 on schedule every '35:56' day_minute do select 1;
+SHOW CREATE EVENT root16;
+create event root17 on schedule every '35:12:45' day_minute do select 1;
+SHOW CREATE EVENT root17;
+create event root17_1 on schedule every '35:25:65' day_minute do select 1;
+SHOW CREATE EVENT root17_1;
+create event root18 on schedule every '35:12:45' hour_second do select 1;
+SHOW CREATE EVENT root18;
+create event root19 on schedule every '15:59:85' hour_second do select 1;
+SHOW CREATE EVENT root19;
+create event root20 on schedule every '50:20:12:45' day_second do select 1;
+SHOW CREATE EVENT root20;
+set names cp1251;
+create event 21 on schedule every '50:23:59:95' day_second COMMENT ' 1251 ' do select 1;
+SHOW CREATE EVENT 21;
+insert into mysql.event (db, name, body, definer, interval_value, interval_field) values (database(), "root22", "select 1", user(), 100, "SECOND_MICROSECOND");
+--error ER_NOT_SUPPORTED_YET
+show create event root22;
+--error ER_NOT_SUPPORTED_YET
+SHOW EVENTS;
+drop event root22;
+drop event root6;
+drop event root7;
+drop event root8;
+drop event root8_1;
+drop event root9;
+drop event root10;
+drop event root11;
+drop event root12;
+drop event root13;
+drop event root13_1;
+drop event root14;
+drop event root15;
+drop event root16;
+drop event root17;
+drop event root17_1;
+drop event root18;
+drop event root19;
+drop event root20;
+drop event 21;
+
+set names latin1;
+#
+# SHOW CREATE EVENT test end
+#
+
+#
+# mysql.event intact checking start
+#
+# There should be at least 1 second between the ALTERs or we can't catch the change of create_time!!
+#
+CREATE EVENT intact_check ON SCHEDULE EVERY 10 HOUR DO SELECT "nothing";
+--replace_column 8 # 9 #
+SHOW EVENTS;
+ALTER TABLE mysql.event ADD dummy INT FIRST;
+--error ER_COL_COUNT_DOESNT_MATCH_CORRUPTED
+SHOW EVENTS;
+ALTER TABLE mysql.event DROP dummy, ADD dummy2 VARCHAR(64) FIRST;
+--error ER_COL_COUNT_DOESNT_MATCH_CORRUPTED
+SHOW EVENTS;
+ALTER TABLE mysql.event DROP dummy2;
+--replace_column 8 # 9 #
+SHOW EVENTS;
+CREATE TABLE event_like LIKE mysql.event;
+INSERT INTO event_like SELECT * FROM mysql.event;
+#sleep a bit or we won't catch the change of time
+--sleep 1
+ALTER TABLE mysql.event MODIFY db char(64) character set cp1251 default '';
+--error ER_CANNOT_LOAD_FROM_TABLE
+SELECT event_name FROM INFORMATION_SCHEMA.EVENTS;
+ALTER TABLE mysql.event MODIFY db char(20) character set utf8 collate utf8_bin default '';
+#wait a bit or we won't see the difference because of seconds resolution
+--sleep 1
+SHOW CREATE TABLE mysql.event;
+--error ER_CANNOT_LOAD_FROM_TABLE
+SELECT event_name FROM INFORMATION_SCHEMA.EVENTS;
+--sleep 1
+ALTER TABLE mysql.event MODIFY db char(64) character set utf8 collate utf8_bin default '';
+--sleep 1
+--echo "This should work"
+--replace_column 8 # 9 #
+SHOW EVENTS;
+--sleep 1
+ALTER TABLE mysql.event MODIFY db char(64) character set cp1251 default '';
+--error ER_CANNOT_LOAD_FROM_TABLE
+SELECT event_name FROM INFORMATION_SCHEMA.EVENTS;
+--sleep 1
+ALTER TABLE mysql.event MODIFY db varchar(64) character set utf8 collate utf8_bin default '';
+--sleep 1
+--error ER_CANNOT_LOAD_FROM_TABLE
+SELECT event_name FROM INFORMATION_SCHEMA.EVENTS;
+--sleep 1
+ALTER TABLE mysql.event DROP comment, DROP starts;
+--sleep 1
+--error ER_COL_COUNT_DOESNT_MATCH_CORRUPTED
+SELECT event_name FROM INFORMATION_SCHEMA.EVENTS;
+DROP TABLE mysql.event;
+CREATE TABLE mysql.event like event_like;
+INSERT INTO mysql.event SELECT * FROM event_like;
+DROP TABLE event_like;
+--replace_column 8 # 9 #
+SHOW EVENTS;
+DROP EVENT intact_check;
+#
+# mysql.event intact checking end
+#
+
+create event e_26 on schedule at '2017-01-01 00:00:00' disable do set @a = 5;
+select db, name, body, definer, convert_tz(execute_at, 'UTC', 'SYSTEM'), on_completion from mysql.event;
+drop event e_26;
+--error ER_WRONG_VALUE
+create event e_26 on schedule at NULL disabled do set @a = 5;
+--error ER_WRONG_VALUE
+create event e_26 on schedule at 'definitely not a datetime' disabled do set @a = 5;
+
+set names utf8;
+create event задачка on schedule every 123 minute starts now() ends now() + interval 1 month do select 1;
+drop event задачка;
+
+# event_scheduler is a global var
+--error ER_GLOBAL_VARIABLE
+set event_scheduler=2;
+# event_scheduler could be only either 1 or 2
+--error ER_WRONG_VALUE_FOR_VAR
+set global event_scheduler=3;
+
+--echo "DISABLE the scheduler. Testing that it does not work when the variable is 0"
+set global event_scheduler=2;
+select definer, name, db from mysql.event;
+select get_lock("test_lock1", 20);
+create event закачка on schedule every 10 hour do select get_lock("test_lock1", 20);
+--echo "Should return 1 row"
+select definer, name, db from mysql.event;
+
+--echo "Should be only 1 process"
+select /*1*/ user, host, db, command, state, info from information_schema.processlist where info is null or info not like '%processlist%' order by info;
+select release_lock("test_lock1");
+drop event закачка;
+--echo "Should have 0 events"
+select count(*) from mysql.event;
+
+#
+#
+#
+--echo "ENABLE the scheduler and get a lock"
+set global event_scheduler=1;
+select get_lock("test_lock2", 20);
+--echo "Create an event which tries to acquire a mutex. The event locks on the mutex"
+create event закачка on schedule every 10 hour do select get_lock("test_lock2", 20);
+--echo "Let some time pass to the event starts"
+--sleep 1
+--echo "Should have only 2 processes: the scheduler and the locked event"
+select /*2*/ user, host, db, command, state, info from information_schema.processlist where info is null or info not like '%processlist%' order by info;--echo "Release the mutex, the event worker should finish."
+--echo "Release the mutex, the event worker should finish."
+select release_lock("test_lock2");
+drop event закачка;
+
+##
+## 1. get a lock
+## 2. create an event
+## 3. sleep so it has time to start
+## 4. should appear in processlist
+## 5. kill the scheduler, it will wait for the child to stop
+## 6. both processes should be there on show processlist
+## 7. release the lock and sleep, both scheduler and child should end
+set global event_scheduler=1;
+select get_lock("test_lock2_1", 20);
+create event закачка21 on schedule every 10 hour do select get_lock("test_lock2_1", 20);
+--sleep 1
+--echo "Should have only 3 processes: the scheduler, our conn and the locked event"
+select /*3*/ user, host, db, command, state, info from information_schema.processlist where info is null or info not like '%processlist%' order by info;
+set global event_scheduler=2;
+--echo "Should have only our process now:"
+select /*4*/ user, host, db, command, state, info from information_schema.processlist where info is null or info not like '%processlist%' order by info;
+drop event закачка21;
+
+####
+# Bug #16410 Events: CREATE EVENT is legal in a CREATE TRIGGER statement
+#
+create table t_16 (s1 int);
+--error 1422
+create trigger t_16_bi before insert on t_16 for each row create event e_16 on schedule every 1 second do set @a=5;
+drop table t_16;
+#
+# end of test case
+####
+
+#
+# START: BUG #17453: Creating Event crash the server
+#
+create event white_space
+on schedule every 10 hour
+disable
+do
+select 1;
+select event_schema, event_name, definer, event_body from information_schema.events where event_name='white_space';
+drop event white_space;
+create event white_space on schedule every 10 hour disable do
+
+select 2;
+select event_schema, event_name, definer, event_body from information_schema.events where event_name='white_space';
+drop event white_space;
+create event white_space on schedule every 10 hour disable do select 3;
+select event_schema, event_name, definer, event_body from information_schema.events where event_name='white_space';
+drop event white_space;
+#
+# END: BUG #17453: Creating Event crash the server
+#
+
+#
+# Bug#17403 "Events: packets out of order with show create event"
+#
+create event e1 on schedule every 1 year do set @a = 5;
+create table t1 (s1 int);
+--error ER_SP_NO_RETSET
+create trigger t1_ai after insert on t1 for each row show create event e1;
+drop table t1;
+drop event e1;
+
+##set global event_scheduler=1;
+##select get_lock("test_lock3", 20);
+##create event закачка on schedule every 10 hour do select get_lock("test_lock3", 20);
+##select sleep(2);
+##select /*5*/ user, host, db, command, state, info from information_schema.processlist where info is null or info not like '%processlist%' order by info;
+##drop event закачка;
+##select release_lock("test_lock3");
+
+#
+# test with very often occuring event
+# (disabled for now, locks)
+##select get_lock("test_lock4", 20);
+##create event закачка4 on schedule every 1 second do select get_lock("test_lock4", 20);
+##select sleep(3);
+##select /*6*/ user, host, db, command, state, info from information_schema.processlist where info is null or info not like '%processlist%' order by info;
+##drop event закачка4;
+##select release_lock("test_lock4");
+
+##set global event_scheduler=2;
+##select sleep(2);
+##--replace_column 1 # 6 #
+##show processlist;
+##select count(*) from mysql.event;
+
+drop database events_test;
diff --git a/mysql-test/t/events_bugs.test b/mysql-test/t/events_bugs.test
new file mode 100644
index 00000000000..e3b79a6bd13
--- /dev/null
+++ b/mysql-test/t/events_bugs.test
@@ -0,0 +1,175 @@
+create database if not exists events_test;
+use events_test;
+
+#
+# START - 16415: Events: event names are case sensitive
+#
+CREATE EVENT lower_case ON SCHEDULE EVERY 1 MINUTE DO SELECT 1;
+--error ER_EVENT_ALREADY_EXISTS
+CREATE EVENT Lower_case ON SCHEDULE EVERY 2 MINUTE DO SELECT 2;
+DROP EVENT Lower_case;
+SET NAMES cp1251;
+CREATE EVENT __1251 ON SCHEDULE EVERY 1 YEAR DO SELECT 100;
+--error ER_EVENT_ALREADY_EXISTS
+CREATE EVENT __1251 ON SCHEDULE EVERY 2 YEAR DO SELECT 200;
+DROP EVENT __1251;
+SET NAMES utf8;
+CREATE EVENT долен_регистър_утф8 ON SCHEDULE EVERY 3 YEAR DO SELECT 300;
+--error ER_EVENT_ALREADY_EXISTS
+CREATE EVENT ДОЛЕН_регистър_утф8 ON SCHEDULE EVERY 4 YEAR DO SELECT 400;
+DROP EVENT ДОЛЕН_регистър_утф8;
+SET NAMES latin1;
+#
+# END - 16415: Events: event names are case sensitive
+#
+
+#
+# START - BUG#16408: Events: crash for an event in a procedure
+#
+set @a=3;
+CREATE PROCEDURE p_16 () CREATE EVENT e_16 ON SCHEDULE EVERY @a SECOND DO SET @a=5;
+call p_16();
+--echo "Here we used to crash!"
+--error ER_EVENT_ALREADY_EXISTS
+call p_16();
+--error ER_EVENT_ALREADY_EXISTS
+call p_16();
+DROP EVENT e_16;
+CALL p_16();
+--error ER_EVENT_ALREADY_EXISTS
+CALL p_16();
+DROP PROCEDURE p_16;
+DROP EVENT e_16;
+#
+# END - BUG#16408: Events: crash for an event in a procedure
+#
+
+#
+# Start - 16396: Events: Distant-future dates become past dates
+#
+--error ER_WRONG_VALUE
+create event e_55 on schedule at 99990101000000 do drop table t;
+--error ER_WRONG_VALUE
+create event e_55 on schedule every 10 hour starts 99990101000000 do drop table t;
+--error ER_EVENT_ENDS_BEFORE_STARTS
+create event e_55 on schedule every 10 minute ends 99990101000000 do drop table t;
+#
+# End - 16396: Events: Distant-future dates become past dates
+#
+
+#
+# Start - 16407: Events: Changes in sql_mode won't be taken into account
+#
+set global event_scheduler=2;
+--echo "Wait a bit to settle down"
+--sleep 1
+delete from mysql.event;
+set global event_scheduler= 1;
+set @old_sql_mode:=@@sql_mode;
+set sql_mode=ansi;
+select get_lock('test_bug16407', 60);
+delimiter |;
+create event e_16407 on schedule every 60 second do
+begin
+ select get_lock('test_bug16407', 60);
+ drop table "hashed_num";
+end|
+delimiter ;|
+--sleep 1
+--echo "Now if everything is fine the event has compiled and is locked
+select /*1*/ user, host, db, command, state, info from information_schema.processlist where info is null or info not like '%processlist%' order by info;
+select release_lock('test_bug16407');
+set global event_scheduler= 2;
+select event_schema, event_name, sql_mode from information_schema.events order by event_schema, event_name;
+--echo "Let's check whether we change the sql_mode on ALTER EVENT"
+set sql_mode='traditional';
+alter event e_16407 do select 1;
+select event_schema, event_name, sql_mode from information_schema.events order by event_schema, event_name;
+drop event e_16407;
+
+--echo "Another sql_mode test"
+set sql_mode="traditional";
+create table events_smode_test(ev_name char(10), a date) engine=myisam;
+--echo "This should never insert something"
+delimiter |;
+create event ee_16407_2 on schedule every 60 second do
+begin
+ select get_lock('ee_16407_2', 60) /*ee_16407_2*/;
+ insert into events_test.events_smode_test values('ee_16407_2','1980-19-02');
+end|
+--error ER_TRUNCATED_WRONG_VALUE
+insert into events_smode_test values ('test','1980-19-02')|
+--echo "This is ok"
+create event ee_16407_3 on schedule every 60 second do
+begin
+ select get_lock('ee_16407_2', 60) /*ee_16407_3*/;
+ insert into events_test.events_smode_test values ('ee_16407_3','1980-02-19');
+ insert into events_test.events_smode_test values ('ee_16407_3','1980-02-29');
+end|
+set sql_mode=""|
+--echo "This will insert rows but they will be truncated"
+create event ee_16407_4 on schedule every 60 second do
+begin
+ select get_lock('ee_16407_2', 60) /*ee_16407_4*/;
+ insert into events_test.events_smode_test values ('ee_16407_4','10-11-1956');
+end|
+delimiter ;|
+select event_schema, event_name, sql_mode from information_schema.events order by event_schema, event_name;
+set sql_mode="ansi";
+select get_lock('ee_16407_2', 60);
+set global event_scheduler= 1;
+--sleep 1
+select /*2*/ user, host, db, command, state, info from information_schema.processlist where info is null or info not like '%processlist%' order by info;
+select release_lock('ee_16407_2');
+--sleep 2
+select /*3*/ user, host, db, command, state, info from information_schema.processlist where info is null or info not like '%processlist%' order by info;
+set global event_scheduler= 2;
+select * from events_smode_test order by ev_name, a;
+--echo "OK, last check before we drop them"
+select event_schema, event_name, sql_mode from information_schema.events order by event_schema, event_name;
+drop event ee_16407_2;
+drop event ee_16407_3;
+drop event ee_16407_4;
+
+
+--echo "And now one last test regarding sql_mode and call of SP from an event"
+delete from events_smode_test;
+set sql_mode='traditional';
+delimiter |;
+create procedure ee_16407_5_pendant() begin insert into events_test.events_smode_test values('ee_16407_5','2001-02-29'); end|
+create procedure ee_16407_6_pendant() begin insert into events_test.events_smode_test values('ee_16407_6','2004-02-29'); end|
+create event ee_16407_5 on schedule every 60 second do
+begin
+ select get_lock('ee_16407_5', 60) /*ee_16407_5*/;
+ call events_test.ee_16407_5_pendant();
+end|
+create event ee_16407_6 on schedule every 60 second do
+begin
+ select get_lock('ee_16407_5', 60) /*ee_16407_6*/;
+ call events_test.ee_16407_6_pendant();
+end|
+delimiter ;|
+set sql_mode='ansi';
+select get_lock('ee_16407_5', 60);
+set global event_scheduler= 1;
+--sleep 1
+--echo "Should have 2 locked processes"
+select /*4*/ user, host, db, command, state, info from information_schema.processlist where info is null or info not like '%processlist%' order by info;
+select release_lock('ee_16407_5');
+--sleep 2
+--echo "Should have 0 processes locked"
+select /*5*/ user, host, db, command, state, info from information_schema.processlist where info is null or info not like '%processlist%' order by info;
+select * from events_smode_test order by ev_name, a;
+--echo "And here we check one more time before we drop the events"
+select event_schema, event_name, sql_mode from information_schema.events order by event_schema, event_name;
+drop event ee_16407_5;
+drop event ee_16407_6;
+drop procedure ee_16407_5_pendant;
+drop procedure ee_16407_6_pendant;
+set global event_scheduler= 2;
+drop table events_smode_test;
+set sql_mode=@old_sql_mode;
+#
+# End - 16407: Events: Changes in sql_mode won't be taken into account
+#
+drop database events_test;
diff --git a/mysql-test/t/events_grant.test b/mysql-test/t/events_grant.test
new file mode 100644
index 00000000000..ba94944a3cf
--- /dev/null
+++ b/mysql-test/t/events_grant.test
@@ -0,0 +1,105 @@
+CREATE DATABASE IF NOT EXISTS events_test;
+use events_test;
+#
+# Events grants test begin
+#
+CREATE EVENT one_event ON SCHEDULE EVERY 10 SECOND DO SELECT 123;
+--replace_column 8 # 9 #
+SHOW EVENTS;
+SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT from information_schema.events;
+CREATE DATABASE events_test2;
+CREATE USER ev_test@localhost;
+GRANT ALL ON events_test.* to ev_test@localhost;
+GRANT ALL ON events_test2.* to ev_test@localhost;
+REVOKE EVENT ON events_test2.* FROM ev_test@localhost;
+#now we are on con1
+connect (ev_con1,localhost,ev_test,,events_test2);
+select "NEW CONNECTION";
+SELECT USER(), DATABASE();
+SHOW GRANTS;
+--echo "Here comes an error:";
+#NO EVENT_ACL on events_test2
+--error 1044
+SHOW EVENTS;
+USE events_test;
+--echo "We should see one event";
+--replace_column 8 # 9 #
+SHOW EVENTS;
+#now create an event with the same name but we are different user
+SELECT CONCAT("Let's create some new events from the name of ", USER());
+--error ER_EVENT_ALREADY_EXISTS
+CREATE EVENT one_event ON SCHEDULE EVERY 20 SECOND DO SELECT 123;
+CREATE EVENT two_event ON SCHEDULE EVERY 20 SECOND ON COMPLETION NOT PRESERVE COMMENT "two event" DO SELECT 123;
+CREATE EVENT three_event ON SCHEDULE EVERY 20 SECOND ON COMPLETION PRESERVE COMMENT "three event" DO SELECT 123;
+
+--echo "Now we should see 3 events:";
+--replace_column 8 # 9 #
+SHOW EVENTS;
+
+--echo "This should show us only 2 events:";
+--replace_column 8 # 9 #
+SHOW EVENTS LIKE 't%event';
+
+--echo "This should show us no events:";
+--replace_column 8 # 9 #
+SHOW EVENTS FROM test LIKE '%';
+#ok, we are back
+connection default;
+GRANT EVENT ON events_test2.* TO ev_test@localhost;
+connection ev_con1;
+USE events_test2;
+CREATE EVENT four_event ON SCHEDULE EVERY 20 SECOND DO SELECT 42;
+connection default;
+USE events_test;
+--echo "We should see 4 events : one_event, two_event, three_event & four_event"
+SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS;
+DROP DATABASE events_test2;
+--echo "We should see 3 events : one_event, two_event, three_event"
+SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS;
+
+connection default;
+CREATE DATABASE events_test2;
+USE events_test2;
+CREATE EVENT five_event ON SCHEDULE EVERY 20 SECOND DO SELECT 42;
+
+connection ev_con1;
+--echo "Should see 4 events - one, two, three & five"
+SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS;
+connection default;
+REVOKE EVENT ON events_test2.* FROM ev_test@localhost;
+connection ev_con1;
+USE test;
+--echo "Should see 3 events - one, two & three"
+SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS;
+--echo "Let's test ALTER EVENT which changes the definer"
+USE events_test;
+ALTER EVENT one_event ON SCHEDULE EVERY 10 SECOND;
+--echo "The definer should be ev_test@localhost"
+SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_NAME='one_event';
+connection default;
+USE events_test;
+ALTER EVENT one_event COMMENT "comment";
+connection ev_con1;
+--echo "The definer should be root@localhost"
+SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_NAME='one_event';
+ALTER EVENT one_event DO SELECT 12;
+--echo "The definer should be ev_test@localhost"
+SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_NAME='one_event';
+connection default;
+--echo "make the definer again root@localhost"
+ALTER EVENT one_event COMMENT "new comment";
+connection ev_con1;
+--echo "test DROP by another user"
+DROP EVENT one_event;
+connection default;
+--echo "One event should not be there"
+SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS;
+disconnect ev_con1;
+connection default;
+DROP USER ev_test@localhost;
+DROP DATABASE events_test2;
+#
+## EVENTS grants test end
+#
+
+DROP DATABASE events_test;
diff --git a/mysql-test/t/events_logs_tests-master.opt b/mysql-test/t/events_logs_tests-master.opt
new file mode 100644
index 00000000000..35ff7911705
--- /dev/null
+++ b/mysql-test/t/events_logs_tests-master.opt
@@ -0,0 +1 @@
+--log-slow-queries
diff --git a/mysql-test/t/events_logs_tests.test b/mysql-test/t/events_logs_tests.test
new file mode 100644
index 00000000000..6d3b3292630
--- /dev/null
+++ b/mysql-test/t/events_logs_tests.test
@@ -0,0 +1,95 @@
+create database if not exists events_test;
+use events_test;
+--echo "We use procedure here because its statements won't be logged into the general log"
+--echo "If we had used normal select that are logged in different ways depending on whether"
+--echo "the test suite is run in normal mode or with --ps-protocol"
+delimiter |;
+CREATE procedure select_general_log()
+BEGIN
+ SELECT user_host, argument FROM mysql.general_log WHERE argument LIKE '%alabala%';
+END|
+delimiter ;|
+--echo "Check General Query Log"
+SET GLOBAL event_scheduler=2;
+create event log_general on schedule every 1 minute do SELect 'alabala', sleep(3) from dual;
+TRUNCATE mysql.general_log;
+--echo "1 row, the current statement!"
+--replace_column 1 USER_HOST
+call select_general_log();
+SET GLOBAL event_scheduler=1;
+--echo "Wait the scheduler to start"
+--echo "Should see 3 rows - the 'SELect' is in the middle. The other two are selects from general_log"
+--sleep 2
+--replace_column 1 USER_HOST
+call select_general_log();
+DROP PROCEDURE select_general_log;
+DROP EVENT log_general;
+SET GLOBAL event_scheduler=2;
+--sleep 1
+
+--echo "Check slow query log"
+--disable_query_log
+DELIMITER |;
+CREATE FUNCTION get_value()
+ returns INT
+ deterministic
+BEGIN
+ DECLARE var_name CHAR(255);
+ DECLARE var_val INT;
+ DECLARE done INT DEFAULT 0;
+ DECLARE cur1 CURSOR FOR SHOW GLOBAL VARIABLES LIKE 'long_query_time';
+ DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done = 1;
+ OPEN cur1;
+ FETCH cur1 INTO var_name, var_val;
+ CLOSE cur1;
+ RETURN var_val;
+end|
+DELIMITER ;|
+--enable_query_log
+--echo "Save the values"
+SET @old_global_long_query_time:=(select get_value());
+SET @old_session_long_query_time:=@@long_query_time;
+SHOW VARIABLES LIKE 'log_slow_queries';
+DROP FUNCTION get_value;
+TRUNCATE mysql.slow_log;
+--replace_column 1 USER_HOST
+SELECT user_host, query_time, db, sql_text FROM mysql.slow_log;
+--echo "Set new values"
+SET GLOBAL long_query_time=4;
+SET SESSION long_query_time=1;
+--echo "Check that logging is working"
+SELECT SLEEP(2);
+--replace_column 1 USER_HOST 2 SLEEPVAL
+SELECT user_host, query_time, db, sql_text FROM mysql.slow_log;
+TRUNCATE mysql.slow_log;
+CREATE TABLE slow_event_test (slo_val tinyint, val tinyint);
+--echo "This won't go to the slow log"
+CREATE EVENT long_event ON SCHEDULE EVERY 1 MINUTE DO INSERT INTO slow_event_test SELECT @@long_query_time, SLEEP(3);
+SELECT * FROM slow_event_test;
+SET GLOBAL event_scheduler=1;
+--echo "Sleep some more time than the actual event run will take"
+--sleep 5
+SHOW VARIABLES LIKE 'event_scheduler';
+--echo "Check our table. Should see 1 row"
+SELECT * FROM slow_event_test;
+--echo "Check slow log. Should not see anything because 3 is under the threshold of 4 for GLOBAL, though over SESSION which is 2"
+SELECT user_host, query_time, db, sql_text FROM mysql.slow_log;
+--echo "This should go to the slow log"
+SET SESSION long_query_time=10;
+SET GLOBAL long_query_time=1;
+DROP EVENT long_event;
+CREATE EVENT long_event2 ON SCHEDULE EVERY 1 MINUTE DO INSERT INTO slow_event_test SELECT @@long_query_time, SLEEP(2);
+--echo "Sleep some more time than the actual event run will take"
+--sleep 3
+--echo "Check our table. Should see 2 rows"
+SELECT * FROM slow_event_test;
+--echo "Check slow log. Should see 1 row because 4 is over the threshold of 3 for GLOBAL, though under SESSION which is 10"
+--replace_column 1 USER_HOST 2 SLEEPVAL
+SELECT user_host, query_time, db, sql_text FROM mysql.slow_log;
+DROP EVENT long_event2;
+SET GLOBAL long_query_time =@old_global_long_query_time;
+SET SESSION long_query_time =@old_session_long_query_time;
+TRUNCATE mysql.slow_log;
+DROP TABLE slow_event_test;
+
+drop database events_test;
diff --git a/mysql-test/t/events_microsec.test b/mysql-test/t/events_microsec.test
new file mode 100644
index 00000000000..e01120a0756
--- /dev/null
+++ b/mysql-test/t/events_microsec.test
@@ -0,0 +1,15 @@
+create database if not exists events_test;
+use events_test;
+
+--error ER_NOT_SUPPORTED_YET
+CREATE EVENT micro_test ON SCHEDULE EVERY 100 MICROSECOND DO SELECT 1;
+--error ER_NOT_SUPPORTED_YET
+CREATE EVENT micro_test ON SCHEDULE EVERY 100 DAY_MICROSECOND DO SELECT 1;
+--error ER_NOT_SUPPORTED_YET
+CREATE EVENT micro_test ON SCHEDULE EVERY 100 HOUR_MICROSECOND DO SELECT 1;
+--error ER_NOT_SUPPORTED_YET
+CREATE EVENT micro_test ON SCHEDULE EVERY 100 MINUTE_MICROSECOND DO SELECT 1;
+--error ER_NOT_SUPPORTED_YET
+CREATE EVENT micro_test ON SCHEDULE EVERY 100 SECOND_MICROSECOND DO SELECT 1;
+
+drop database events_test;
diff --git a/mysql-test/t/events_scheduling.test b/mysql-test/t/events_scheduling.test
new file mode 100644
index 00000000000..a73d25cd8ee
--- /dev/null
+++ b/mysql-test/t/events_scheduling.test
@@ -0,0 +1,40 @@
+CREATE DATABASE IF NOT EXISTS events_test;
+USE events_test;
+CREATE TABLE table_1(a int);
+CREATE TABLE table_2(a int);
+CREATE TABLE table_3(a int);
+CREATE TABLE table_4(a int);
+CREATE TABLE T19170(s1 TIMESTAMP);
+SET GLOBAL event_scheduler=1;
+CREATE EVENT E19170 ON SCHEDULE EVERY 1 SECOND DO INSERT INTO T19170 VALUES(CURRENT_TIMESTAMP);
+CREATE EVENT two_sec ON SCHEDULE EVERY 2 SECOND DO INSERT INTO table_1 VALUES(1);
+CREATE EVENT start_n_end
+ ON SCHEDULE EVERY 1 SECOND
+ ENDS NOW() + INTERVAL 6 SECOND
+ ON COMPLETION PRESERVE
+ DO INSERT INTO table_2 VALUES(1);
+--sleep 5
+CREATE EVENT only_one_time ON SCHEDULE EVERY 2 SECOND ENDS NOW() + INTERVAL 1 SECOND DO INSERT INTO table_3 VALUES(1);
+CREATE EVENT two_time ON SCHEDULE EVERY 1 SECOND ENDS NOW() + INTERVAL 1 SECOND ON COMPLETION PRESERVE DO INSERT INTO table_4 VALUES(1);
+--sleep 5
+SELECT IF(SUM(a) >= 4, 'OK', 'ERROR') FROM table_1;
+SELECT IF(SUM(a) >= 5, 'OK', 'ERROR') FROM table_2;
+SELECT IF(SUM(a) > 0, 'OK', 'ERROR') FROM table_3;
+SELECT IF(SUM(a) > 0, 'OK', 'ERROR') FROM table_4;
+DROP EVENT two_sec;
+SELECT IF(TIME_TO_SEC(TIMEDIFF(ENDS,STARTS))=6, 'OK', 'ERROR') FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_SCHEMA=DATABASE() AND EVENT_NAME='start_n_end' AND ENDS IS NOT NULL;
+SELECT IF(LAST_EXECUTED-ENDS < 3, 'OK', 'ERROR') FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_SCHEMA=DATABASE() AND EVENT_NAME='start_n_end' AND ENDS IS NOT NULL;
+DROP EVENT start_n_end;
+--echo "Already dropped because ended. Therefore an error."
+--error ER_EVENT_DOES_NOT_EXIST
+DROP EVENT only_one_time;
+--echo "Should be preserved"
+SELECT EVENT_NAME, STATUS FROM INFORMATION_SCHEMA.EVENTS;
+DROP EVENT two_time;
+DROP TABLE table_1;
+DROP TABLE table_2;
+DROP TABLE table_3;
+DROP TABLE table_4;
+--echo "Checking for multiple executions in one second, should not happen -> 0 as result"
+SELECT COUNT(*) FROM (SELECT s1, COUNT(*) AS cnt FROM T19170 GROUP BY s1) AS tmp WHERE tmp.cnt > 1;
+DROP DATABASE events_test;
diff --git a/mysql-test/t/events_stress.test b/mysql-test/t/events_stress.test
new file mode 100644
index 00000000000..8d0034c232e
--- /dev/null
+++ b/mysql-test/t/events_stress.test
@@ -0,0 +1,126 @@
+CREATE DATABASE IF NOT EXISTS events_test;
+#
+# DROP DATABASE test start (bug #16406)
+#
+CREATE DATABASE events_conn1_test2;
+CREATE TABLE events_test.fill_it(test_name varchar(20), occur datetime);
+CREATE USER event_user2@localhost;
+CREATE DATABASE events_conn2_db;
+GRANT ALL ON *.* TO event_user2@localhost;
+CREATE USER event_user3@localhost;
+CREATE DATABASE events_conn3_db;
+GRANT ALL ON *.* TO event_user3@localhost;
+connect (conn2,localhost,event_user2,,events_conn2_db);
+--echo "In the second connection we create some events which won't be dropped till the end"
+--disable_query_log
+let $1= 50;
+while ($1)
+{
+ eval CREATE EVENT conn2_ev$1 ON SCHEDULE EVERY 1 SECOND DO INSERT INTO events_test.fill_it VALUES("conn2_ev$1", NOW());
+ dec $1;
+}
+--enable_query_log
+connect (conn3,localhost,event_user3,,events_conn3_db);
+--echo "In the second connection we create some events which won't be dropped till the end"
+--disable_query_log
+let $1= 50;
+while ($1)
+{
+ eval CREATE EVENT conn3_ev$1 ON SCHEDULE EVERY 1 SECOND DO INSERT INTO events_test.fill_it VALUES("conn3_ev$1", NOW());
+ dec $1;
+}
+--enable_query_log
+connection default;
+USE events_conn1_test2;
+CREATE EVENT ev_drop1 ON SCHEDULE EVERY 10 MINUTE DISABLE DO SELECT 1;
+CREATE EVENT ev_drop2 ON SCHEDULE EVERY 10 MINUTE DISABLE DO SELECT 1;
+CREATE EVENT ev_drop3 ON SCHEDULE EVERY 10 MINUTE DISABLE DO SELECT 1;
+USE events_test;
+SELECT COUNT(*) FROM INFORMATION_SCHEMA.EVENTS;
+SELECT COUNT(*) FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_SCHEMA='events_conn1_test2';
+DROP DATABASE events_conn1_test2;
+SELECT COUNT(*) FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_SCHEMA='events_conn1_test2';
+
+--echo "Now testing stability - dropping db -> events while they are running"
+CREATE DATABASE events_conn1_test2;
+USE events_conn1_test2;
+--disable_query_log
+let $1= 50;
+while ($1)
+{
+ eval CREATE EVENT conn1_round1_ev$1 ON SCHEDULE EVERY 1 SECOND DO INSERT INTO events_test.fill_it VALUES("conn1_round1_ev$1", NOW());
+ dec $1;
+}
+--enable_query_log
+SELECT COUNT(*) FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_SCHEMA='events_conn1_test2';
+SET GLOBAL event_scheduler=1;
+--sleep 6
+DROP DATABASE events_conn1_test2;
+
+SET GLOBAL event_scheduler=2;
+SELECT COUNT(*) FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_SCHEMA='events_conn1_test2';
+CREATE DATABASE events_conn1_test3;
+USE events_conn1_test3;
+--disable_query_log
+let $1= 50;
+while ($1)
+{
+ eval CREATE EVENT conn1_round2_ev$1 ON SCHEDULE EVERY 1 SECOND DO INSERT INTO events_test.fill_it VALUES("conn1_round2_ev$1", NOW());
+ dec $1;
+}
+--enable_query_log
+SET GLOBAL event_scheduler=1;
+SELECT COUNT(*) FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_SCHEMA='events_conn1_test3';
+CREATE DATABASE events_conn1_test4;
+USE events_conn1_test4;
+--disable_query_log
+let $1= 50;
+while ($1)
+{
+ eval CREATE EVENT conn1_round3_ev$1 ON SCHEDULE EVERY 1 SECOND DO INSERT INTO events_test.fill_it VALUES("conn1_round3_ev$1", NOW());
+ dec $1;
+}
+--enable_query_log
+
+CREATE DATABASE events_conn1_test2;
+USE events_conn1_test2;
+--disable_query_log
+let $1= 50;
+while ($1)
+{
+ eval CREATE EVENT ev_round4_drop$1 ON SCHEDULE EVERY 1 SECOND DO INSERT INTO events_test.fill_it VALUES("conn1_round4_ev$1", NOW());
+ dec $1;
+}
+--enable_query_log
+SELECT COUNT(*) FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_SCHEMA='events_conn1_test2';
+--sleep 6
+connection conn2;
+--send
+DROP DATABASE events_conn2_db;
+connection conn3;
+--send
+DROP DATABASE events_conn3_db;
+connection default;
+--send
+DROP DATABASE events_conn1_test2;
+DROP DATABASE events_conn1_test3;
+SET GLOBAL event_scheduler=2;
+DROP DATABASE events_conn1_test4;
+SET GLOBAL event_scheduler=1;
+connection conn2;
+reap;
+disconnect conn2;
+connection conn3;
+reap;
+disconnect conn3;
+connection default;
+USE events_test;
+DROP TABLE fill_it;
+--disable_query_log
+DROP USER event_user2@localhost;
+DROP USER event_user3@localhost;
+--enable_query_log
+#
+# DROP DATABASE test end (bug #16406)
+#
+DROP DATABASE events_test;
diff --git a/mysql-test/t/exampledb.test b/mysql-test/t/exampledb.test
index 946d25325dc..fbb2a18f344 100644
--- a/mysql-test/t/exampledb.test
+++ b/mysql-test/t/exampledb.test
@@ -5,6 +5,10 @@
-- source include/have_exampledb.inc
--disable_warnings
+# Clean up if event's test fails
+drop database if exists events_test;
+drop database if exists events_test2;
+
drop table if exists t1;
--enable_warnings
diff --git a/mysql-test/t/federated.test b/mysql-test/t/federated.test
index 80b31c610a2..3c43fb1d1f9 100644
--- a/mysql-test/t/federated.test
+++ b/mysql-test/t/federated.test
@@ -1,3 +1,5 @@
+# should work with embedded server after mysqltest is fixed
+-- source include/not_embedded.inc
source include/federated.inc;
connection slave;
diff --git a/mysql-test/t/federated_archive.test b/mysql-test/t/federated_archive.test
index 6d80664fef7..f8df5f1c51a 100644
--- a/mysql-test/t/federated_archive.test
+++ b/mysql-test/t/federated_archive.test
@@ -1,3 +1,5 @@
+# should work with embedded server after mysqltest is fixed
+-- source include/not_embedded.inc
source include/have_archive.inc;
source include/federated.inc;
diff --git a/mysql-test/t/federated_bug_13118.test b/mysql-test/t/federated_bug_13118.test
index deec79becd2..e429a660489 100644
--- a/mysql-test/t/federated_bug_13118.test
+++ b/mysql-test/t/federated_bug_13118.test
@@ -1,3 +1,5 @@
+# should work with embedded server after mysqltest is fixed
+-- source include/not_embedded.inc
source include/federated.inc;
diff --git a/mysql-test/t/federated_transactions.test b/mysql-test/t/federated_transactions.test
new file mode 100644
index 00000000000..5095c8ce9c3
--- /dev/null
+++ b/mysql-test/t/federated_transactions.test
@@ -0,0 +1,40 @@
+# should work with embedded server after mysqltest is fixed
+-- source include/not_embedded.inc
+source include/have_bdb.inc;
+source include/federated.inc;
+
+connection slave;
+DROP TABLE IF EXISTS federated.t1;
+#SHOW ENGINES;
+CREATE TABLE federated.t1 (
+ `id` int(20) NOT NULL,
+ `name` varchar(32) NOT NULL default ''
+ )
+ DEFAULT CHARSET=latin1 ENGINE=BerkeleyDB;
+
+connection master;
+DROP TABLE IF EXISTS federated.t1;
+# # correct connection, same named tables
+--replace_result $SLAVE_MYPORT SLAVE_PORT
+eval CREATE TABLE federated.t1 (
+ `id` int(20) NOT NULL,
+ `name` varchar(32) NOT NULL default ''
+ )
+ ENGINE="FEDERATED" DEFAULT CHARSET=latin1
+ CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/t1';
+
+set autocommit=0;
+INSERT INTO federated.t1 (id, name) VALUES (1, 'foo');
+INSERT INTO federated.t1 (id, name) VALUES (2, 'fee');
+COMMIT;
+INSERT INTO federated.t1 (id, name) VALUES (3, 'fie');
+INSERT INTO federated.t1 (id, name) VALUES (4, 'fum');
+ROLLBACK;
+set autocommit=1;
+INSERT INTO federated.t1 (id, name) VALUES (5, 'foe');
+INSERT INTO federated.t1 (id, name) VALUES (6, 'fig');
+
+SELECT * FROM federated.t1;
+DELETE FROM federated.t1;
+
+source include/federated_cleanup.inc;
diff --git a/mysql-test/t/flush_table.test b/mysql-test/t/flush_table.test
index e46b67ad3d0..50e7e91419a 100644
--- a/mysql-test/t/flush_table.test
+++ b/mysql-test/t/flush_table.test
@@ -4,15 +4,70 @@
# Test of flush table
#
+# Should work in embedded server after mysqltest is fixed
+-- source include/not_embedded.inc
--disable_warnings
drop table if exists t1,t2;
--enable_warnings
create table t1 (a int not null auto_increment primary key);
insert into t1 values(0);
+
+# Test for with read lock + flush
+
lock table t1 read;
flush table t1;
check table t1;
+unlock tables;
+
+# Test for with 2 read lock in different thread + flush
+
+lock table t1 read;
+connect (locker,localhost,root,,test);
+connection locker;
+lock table t1 read;
+connection default;
+send flush table t1;
+connection locker;
+--sleep 2
+select * from t1;
+unlock tables;
+connection default;
+reap;
+select * from t1;
+unlock tables;
+
+# Test for with a write lock and a waiting read lock + flush
+
+lock table t1 write;
+connection locker;
+send lock table t1 read;
+connection default;
+sleep 2;
+flush table t1;
+select * from t1;
+unlock tables;
+connection locker;
+reap;
+unlock tables;
+connection default;
+
+# Test for with a read lock and a waiting write lock + flush
+
+lock table t1 read;
+connection locker;
+send lock table t1 write;
+connection default;
+sleep 2;
+flush table t1;
+select * from t1;
+unlock tables;
+connection locker;
+reap;
+unlock tables;
+select * from t1;
+connection default;
drop table t1;
+disconnect locker;
#
# In the following test FLUSH TABLES produces a deadlock
diff --git a/mysql-test/t/fulltext.test b/mysql-test/t/fulltext.test
index 0f7835e9e7e..626f5f2b81c 100644
--- a/mysql-test/t/fulltext.test
+++ b/mysql-test/t/fulltext.test
@@ -28,6 +28,12 @@ select * from t1 where MATCH(a,b) AGAINST ("collections" WITH QUERY EXPANSION);
select * from t1 where MATCH(a,b) AGAINST ("indexes" WITH QUERY EXPANSION);
select * from t1 where MATCH(a,b) AGAINST ("indexes collections" WITH QUERY EXPANSION);
+# IN NATURAL LANGUAGE MODE
+select * from t1 where MATCH(a,b) AGAINST ("indexes" IN NATURAL LANGUAGE MODE);
+select * from t1 where MATCH(a,b) AGAINST ("indexes" IN NATURAL LANGUAGE MODE WITH QUERY EXPANSION);
+--error 1064
+select * from t1 where MATCH(a,b) AGAINST ("indexes" IN BOOLEAN MODE WITH QUERY EXPANSION);
+
# add_ft_keys() tests
explain select * from t1 where MATCH(a,b) AGAINST ("collections");
@@ -355,6 +361,12 @@ SET myisam_repair_threads=@@global.myisam_repair_threads;
INSERT INTO t1 VALUES('testword\'\'');
SELECT a FROM t1 WHERE MATCH a AGAINST('testword' IN BOOLEAN MODE);
SELECT a FROM t1 WHERE MATCH a AGAINST('testword\'\'' IN BOOLEAN MODE);
+
+#
+# BUG#14194: Problem with fulltext boolean search and apostrophe
+#
+INSERT INTO t1 VALUES('test\'s');
+SELECT a FROM t1 WHERE MATCH a AGAINST('test' IN BOOLEAN MODE);
DROP TABLE t1;
#
diff --git a/mysql-test/t/func_system.test b/mysql-test/t/func_system.test
index 4a526935491..a5041a83623 100644
--- a/mysql-test/t/func_system.test
+++ b/mysql-test/t/func_system.test
@@ -19,7 +19,7 @@ select version()>=_latin1"3.23.29";
select charset(version());
explain extended select database(), user();
-create table t1 (version char(40)) select database(), user(), version() as 'version';
+create table t1 (version char(60)) select database(), user(), version() as 'version';
show create table t1;
drop table t1;
diff --git a/mysql-test/t/func_time.test b/mysql-test/t/func_time.test
index 1c7f387e354..5c993028cb4 100644
--- a/mysql-test/t/func_time.test
+++ b/mysql-test/t/func_time.test
@@ -367,20 +367,12 @@ select last_day('2005-01-00');
select monthname(str_to_date(null, '%m')), monthname(str_to_date(null, '%m')),
monthname(str_to_date(1, '%m')), monthname(str_to_date(0, '%m'));
-# End of 4.1 tests
+--echo End of 4.1 tests
explain extended select timestampdiff(SQL_TSI_WEEK, '2001-02-01', '2001-05-01') as a1,
timestampdiff(SQL_TSI_FRAC_SECOND, '2001-02-01 12:59:59.120000', '2001-05-01 12:58:58.119999') as a2;
#
-# Bug #10568
-#
-
-select last_day('2005-00-00');
-select last_day('2005-00-01');
-select last_day('2005-01-00');
-
-#
# Bug #10590: %h, %I, and %l format specifies should all return results in
# the 0-11 range
#
@@ -482,4 +474,23 @@ SELECT * FROM t1, t2
DROP TABLE t1,t2;
-# End of 5.0 tests
+--echo End of 5.0 tests
+
+#
+# Bug #18997
+#
+
+select date_sub("0050-01-01 00:00:01",INTERVAL 2 SECOND);
+select date_sub("0199-01-01 00:00:01",INTERVAL 2 SECOND);
+select date_add("0199-12-31 23:59:59",INTERVAL 2 SECOND);
+select date_sub("0200-01-01 00:00:01",INTERVAL 2 SECOND);
+select date_sub("0200-01-01 00:00:01",INTERVAL 1 SECOND);
+select date_sub("0200-01-01 00:00:01",INTERVAL 2 SECOND);
+select date_add("2001-01-01 23:59:59",INTERVAL -2000 YEAR);
+select date_sub("50-01-01 00:00:01",INTERVAL 2 SECOND);
+select date_sub("90-01-01 00:00:01",INTERVAL 2 SECOND);
+select date_sub("0069-01-01 00:00:01",INTERVAL 2 SECOND);
+select date_sub("0169-01-01 00:00:01",INTERVAL 2 SECOND);
+
+
+--echo End of 5.1 tests
diff --git a/mysql-test/t/grant2.test b/mysql-test/t/grant2.test
index 2b9a273df7e..b3e2d2f7998 100644
--- a/mysql-test/t/grant2.test
+++ b/mysql-test/t/grant2.test
@@ -439,13 +439,10 @@ create database TESTDB;
create table t2(a int);
create temporary table t1 as select * from mysql.user;
delete from mysql.user where host='localhost';
-INSERT INTO mysql.user VALUES
-('%','mysqltest_1',password('password'),'N','N','N','N','N','N',
-'N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N',
-'','','','',0,0,0,0);
-INSERT INTO mysql.db VALUES
-('%','TESTDB','mysqltest_1','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','N','Y','Y','Y','
-Y','N');
+INSERT INTO mysql.user (host, user, password) VALUES
+('%','mysqltest_1',password('password'));
+INSERT INTO mysql.db (host, db, user, select_priv) VALUES
+('%','TESTDB','mysqltest_1','Y');
FLUSH PRIVILEGES;
connect (con1,localhost,mysqltest_1,password,TESTDB);
diff --git a/mysql-test/t/having.test b/mysql-test/t/having.test
index 9bea78a7bca..41266cc6d32 100644
--- a/mysql-test/t/having.test
+++ b/mysql-test/t/having.test
@@ -401,7 +401,7 @@ create table t1(f1 int);
select f1 from t1 having max(f1)=f1;
select f1 from t1 group by f1 having max(f1)=f1;
set session sql_mode='ONLY_FULL_GROUP_BY';
---error 1463
+--error ER_NON_GROUPING_FIELD_USED
select f1 from t1 having max(f1)=f1;
select f1 from t1 group by f1 having max(f1)=f1;
set session sql_mode='';
diff --git a/mysql-test/t/im_cmd_line.imtest b/mysql-test/t/im_cmd_line.imtest
new file mode 100644
index 00000000000..00e8351535e
--- /dev/null
+++ b/mysql-test/t/im_cmd_line.imtest
@@ -0,0 +1,68 @@
+###########################################################################
+#
+# Tests for user-management command-line options.
+#
+###########################################################################
+
+--source include/im_check_os.inc
+
+###########################################################################
+
+# List users so we are sure about starting conditions.
+
+--echo --> Listing users...
+--exec $IM_EXE --defaults-file="$IM_DEFAULTS_PATH" --list-users 2>&1 >/dev/null
+--echo
+
+# Add a new user.
+
+--echo ==> Adding user 'testuser'...
+--exec $IM_EXE --defaults-file="$IM_DEFAULTS_PATH" --add-user --username=testuser --password=abc 2>&1 >/dev/null
+--echo
+
+--echo --> IM password file:
+--exec cat $IM_PASSWORD_PATH
+--echo --> EOF
+--echo
+
+--echo --> Printing out line for 'testuser'...
+--exec $IM_EXE --defaults-file="$IM_DEFAULTS_PATH" --passwd --username=testuser --password=abc | tail -1
+--echo
+
+--echo --> Listing users...
+--exec $IM_EXE --defaults-file="$IM_DEFAULTS_PATH" --list-users 2>&1 >/dev/null
+--echo
+
+# Edit user's attributes.
+
+--echo ==> Changing the password of 'testuser'...
+--exec $IM_EXE --defaults-file="$IM_DEFAULTS_PATH" --edit-user --username=testuser --password=xyz 2>&1 >/dev/null
+--echo
+
+--echo --> IM password file:
+--exec cat $IM_PASSWORD_PATH
+--echo --> EOF
+--echo
+
+--echo --> Printing out line for 'testuser'...
+--exec $IM_EXE --defaults-file="$IM_DEFAULTS_PATH" --passwd --username=testuser --password=xyz | tail -1
+--echo
+
+--echo --> Listing users...
+--exec $IM_EXE --defaults-file="$IM_DEFAULTS_PATH" --list-users 2>&1 >/dev/null
+--echo
+
+# Drop user.
+
+--echo ==> Dropping user 'testuser'...
+--exec $IM_EXE --defaults-file="$IM_DEFAULTS_PATH" --drop-user --username=testuser 2>&1 >/dev/null
+--echo
+
+--echo --> IM password file:
+--exec cat $IM_PASSWORD_PATH
+--echo --> EOF
+--echo
+
+--echo --> Listing users...
+--exec $IM_EXE --defaults-file="$IM_DEFAULTS_PATH" --list-users 2>&1 >/dev/null
+--echo
diff --git a/mysql-test/t/im_daemon_life_cycle-im.opt b/mysql-test/t/im_daemon_life_cycle-im.opt
index 21c01191e4c..3a45c7a41f7 100644
--- a/mysql-test/t/im_daemon_life_cycle-im.opt
+++ b/mysql-test/t/im_daemon_life_cycle-im.opt
@@ -1,2 +1,3 @@
--run-as-service
--log=$MYSQLTEST_VARDIR/log/im.log
+--monitoring-interval=1
diff --git a/mysql-test/t/im_daemon_life_cycle.imtest b/mysql-test/t/im_daemon_life_cycle.imtest
index 87388d7c1e6..d173ce2a6e2 100644
--- a/mysql-test/t/im_daemon_life_cycle.imtest
+++ b/mysql-test/t/im_daemon_life_cycle.imtest
@@ -10,6 +10,9 @@
###########################################################################
+--sleep 3
+# should be longer than monitoring interval and enough to start instance.
+
SHOW INSTANCES;
--exec $MYSQL_TEST_DIR/t/kill_n_check.sh $IM_PATH_PID restarted
diff --git a/mysql-test/t/im_instance_conf-im.opt b/mysql-test/t/im_instance_conf-im.opt
new file mode 100644
index 00000000000..34b74ce0c95
--- /dev/null
+++ b/mysql-test/t/im_instance_conf-im.opt
@@ -0,0 +1 @@
+--monitoring-interval=1
diff --git a/mysql-test/t/im_instance_conf.imtest b/mysql-test/t/im_instance_conf.imtest
new file mode 100644
index 00000000000..17703fdd303
--- /dev/null
+++ b/mysql-test/t/im_instance_conf.imtest
@@ -0,0 +1,228 @@
+###########################################################################
+#
+# This test suite checks the following statements:
+# - CREATE INSTANCE <instance_name> [option1[=option1_value], ...];
+# - DROP INSTANCE <instance_name>;
+#
+# For CREATE INSTANCE we check that:
+# - CREATE INSTANCE succeeds for non-existing instance;
+# - CREATE INSTANCE fails for existing instance;
+# - CREATE INSTANCE can get additional options with and w/o values;
+# - CREATE INSTANCE parses options and handles grammar errors correctly.
+# Check that strings with spaces are handled correctly, unknown (for
+# mysqld) options should also be handled;
+# - CREATE INSTANCE updates both config file and internal configuration cache;
+# - CREATE INSTANCE allows to create instances only with properly formed
+# names (mysqld*);
+#
+# For DROP INSTANCE we check that:
+# - DROP INSTANCE succeeds for existing instance;
+# - DROP INSTANCE fails for non-existing instance;
+# - DROP INSTANCE fails for active instance.
+# - DROP INSTANCE updates both config file and internal configuration cache;
+#
+###########################################################################
+
+--source include/im_check_os.inc
+
+###########################################################################
+#
+# Check starting conditions.
+#
+###########################################################################
+
+# Check that the configuration file contains only instances that we expect.
+
+--echo --------------------------------------------------------------------
+--exec grep server_id $MYSQLTEST_VARDIR/im.cnf;
+--echo --------------------------------------------------------------------
+
+# Check that mysqld1 is reported as running.
+
+--sleep 3
+# should be longer than monitoring interval and enough to start instance.
+
+SHOW INSTANCES;
+
+# Check that the expected mysqld instance is actually run (check that we can
+# connect and execute something).
+
+--echo
+--echo ---> connection: mysql1_con
+--connect (mysql1_con,localhost,root,,mysql,$IM_MYSQLD1_PORT,$IM_MYSQLD1_SOCK)
+--connection mysql1_con
+
+SHOW VARIABLES LIKE 'server_id';
+
+--disconnect mysql1_con
+
+--echo
+--echo ---> connection: default
+--connection default
+
+###########################################################################
+#
+# CREATE INSTANCE tests.
+#
+###########################################################################
+
+# Check that CREATE INSTANCE succeeds for non-existing instance and also check
+# that both config file and internal configuration cache have been updated.
+
+CREATE INSTANCE mysqld3;
+
+SHOW INSTANCES;
+
+--echo --------------------------------------------------------------------
+--exec grep server_id $MYSQLTEST_VARDIR/im.cnf ;
+--echo --------------------------------------------------------------------
+
+# Check that CREATE INSTANCE fails for existing instance. Let's all three
+# existing instances (running one, stopped one and just created one). Just in
+# case...
+
+--error 3012 # ER_CREATE_EXISTING_INSTANCE
+CREATE INSTANCE mysqld1;
+
+--error 3012 # ER_CREATE_EXISTING_INSTANCE
+CREATE INSTANCE mysqld2;
+
+--error 3012 # ER_CREATE_EXISTING_INSTANCE
+CREATE INSTANCE mysqld3;
+
+# Check that CREATE INSTANCE can get additional options with and w/o values.
+# Ensure that config file is updated properly.
+
+# - without values;
+
+--echo --------------------------------------------------------------------
+--exec grep nonguarded $MYSQLTEST_VARDIR/im.cnf;
+--echo --------------------------------------------------------------------
+
+CREATE INSTANCE mysqld4 nonguarded;
+
+SHOW INSTANCES;
+
+--echo --------------------------------------------------------------------
+--exec grep nonguarded $MYSQLTEST_VARDIR/im.cnf;
+--echo --------------------------------------------------------------------
+
+# - with value;
+
+--echo --------------------------------------------------------------------
+--exec grep test-A $MYSQLTEST_VARDIR/im.cnf || true;
+--echo --------------------------------------------------------------------
+--exec grep test-B $MYSQLTEST_VARDIR/im.cnf || true;
+--echo --------------------------------------------------------------------
+
+CREATE INSTANCE mysqld5 test-A = 000, test-B = test;
+
+SHOW INSTANCES;
+
+--echo --------------------------------------------------------------------
+--exec grep test-A $MYSQLTEST_VARDIR/im.cnf;
+--echo --------------------------------------------------------------------
+--exec grep test-B $MYSQLTEST_VARDIR/im.cnf;
+--echo --------------------------------------------------------------------
+
+# Check that CREATE INSTANCE parses options and handles grammar errors
+# correctly. Check that strings with spaces are handled correctly,
+# unknown (for mysqld) options should also be handled.
+
+# - check handling of extra spaces;
+
+--echo --------------------------------------------------------------------
+--exec grep test-C $MYSQLTEST_VARDIR/im.cnf || true;
+--echo --------------------------------------------------------------------
+
+CREATE INSTANCE mysqld6 test-C1 = 10 , test-C2 = 02 ;
+
+SHOW INSTANCES;
+
+--echo --------------------------------------------------------------------
+--exec grep test-C1 $MYSQLTEST_VARDIR/im.cnf;
+--echo --------------------------------------------------------------------
+--exec grep test-C2 $MYSQLTEST_VARDIR/im.cnf;
+--echo --------------------------------------------------------------------
+
+# - check handling of grammar error;
+
+--echo --------------------------------------------------------------------
+--exec grep test-D $MYSQLTEST_VARDIR/im.cnf || true;
+--echo --------------------------------------------------------------------
+--exec grep test-E $MYSQLTEST_VARDIR/im.cnf || true;
+--echo --------------------------------------------------------------------
+
+--error ER_SYNTAX_ERROR
+CREATE INSTANCE mysqld7 test-D = test-D-value ;
+SHOW INSTANCES;
+
+--error ER_SYNTAX_ERROR
+CREATE INSTANCE mysqld8 test-E 0 ;
+SHOW INSTANCES;
+
+--error ER_SYNTAX_ERROR
+CREATE INSTANCE mysqld8 test-F = ;
+SHOW INSTANCES;
+
+--echo --------------------------------------------------------------------
+--exec grep test-D $MYSQLTEST_VARDIR/im.cnf || true;
+--echo --------------------------------------------------------------------
+--exec grep test-E $MYSQLTEST_VARDIR/im.cnf || true;
+--echo --------------------------------------------------------------------
+
+# - check parsing of string option values
+
+--echo --------------------------------------------------------------------
+--exec grep test-1 $MYSQLTEST_VARDIR/im.cnf || true;
+--echo --------------------------------------------------------------------
+--exec grep test-2 $MYSQLTEST_VARDIR/im.cnf || true;
+--echo --------------------------------------------------------------------
+--exec grep test-3 $MYSQLTEST_VARDIR/im.cnf || true;
+--echo --------------------------------------------------------------------
+--exec grep test-4 $MYSQLTEST_VARDIR/im.cnf || true;
+--echo --------------------------------------------------------------------
+
+CREATE INSTANCE mysqld9 test-1=" hello world ", test-2=' ';
+SHOW INSTANCES;
+
+CREATE INSTANCE mysqld9a test-3='\b\babc\sdef';
+# test-3='abc def'
+SHOW INSTANCES;
+
+CREATE INSTANCE mysqld9b test-4='abc\tdef', test-5='abc\ndef';
+SHOW INSTANCES;
+
+CREATE INSTANCE mysqld9c test-6="abc\rdef", test-7="abc\\def";
+# test-6=abc
+SHOW INSTANCES;
+
+--error ER_SYNTAX_ERROR
+CREATE INSTANCE mysqld10 test-bad=' \ ';
+SHOW INSTANCES;
+
+--echo --------------------------------------------------------------------
+--exec grep test-1 $MYSQLTEST_VARDIR/im.cnf;
+--echo --------------------------------------------------------------------
+--exec grep test-2 $MYSQLTEST_VARDIR/im.cnf;
+--echo --------------------------------------------------------------------
+--exec grep test-3 $MYSQLTEST_VARDIR/im.cnf;
+--echo --------------------------------------------------------------------
+--exec grep test-4 $MYSQLTEST_VARDIR/im.cnf;
+--echo --------------------------------------------------------------------
+--exec grep test-5 $MYSQLTEST_VARDIR/im.cnf;
+--echo --------------------------------------------------------------------
+--exec grep test-6 $MYSQLTEST_VARDIR/im.cnf;
+--echo --------------------------------------------------------------------
+--exec grep test-7 $MYSQLTEST_VARDIR/im.cnf;
+--echo --------------------------------------------------------------------
+--exec grep test-bad $MYSQLTEST_VARDIR/im.cnf || true;
+--echo --------------------------------------------------------------------
+
+
+# Check that CREATE INSTANCE allows to create instances only with properly
+# formed names (mysqld*).
+
+--error 3014 # ER_MALFORMED_INSTANCE_NAME
+CREATE INSTANCE qqq1;
+
diff --git a/mysql-test/t/im_life_cycle-im.opt b/mysql-test/t/im_life_cycle-im.opt
new file mode 100644
index 00000000000..34b74ce0c95
--- /dev/null
+++ b/mysql-test/t/im_life_cycle-im.opt
@@ -0,0 +1 @@
+--monitoring-interval=1
diff --git a/mysql-test/t/im_life_cycle.imtest b/mysql-test/t/im_life_cycle.imtest
index 445ae7f72fa..d71cdc86624 100644
--- a/mysql-test/t/im_life_cycle.imtest
+++ b/mysql-test/t/im_life_cycle.imtest
@@ -17,11 +17,15 @@
#
###########################################################################
+--echo
+--echo --------------------------------------------------------------------
+--echo -- 1.1.1.
+--echo --------------------------------------------------------------------
+
+--sleep 3
+# should be longer than monitoring interval and enough to start instance.
+
SHOW INSTANCES;
---replace_column 3 VERSION
-SHOW INSTANCE STATUS mysqld1;
---replace_column 3 VERSION
-SHOW INSTANCE STATUS mysqld2;
###########################################################################
#
@@ -33,20 +37,22 @@ SHOW INSTANCE STATUS mysqld2;
#
###########################################################################
+--echo
+--echo --------------------------------------------------------------------
+--echo -- 1.1.2.
+--echo --------------------------------------------------------------------
+
START INSTANCE mysqld2;
-# FIXME
+# FIXME: START INSTANCE should be synchronous.
--sleep 3
+# should be longer than monitoring interval and enough to start instance.
SHOW INSTANCES;
---replace_column 3 VERSION
-SHOW INSTANCE STATUS mysqld1;
---replace_column 3 VERSION
-SHOW INSTANCE STATUS mysqld2;
---connect (mysql_con,localhost,root,,mysql,$IM_MYSQLD1_PORT,$IM_MYSQLD1_SOCK)
+--connect (mysql_con,localhost,root,,mysql,$IM_MYSQLD2_PORT,$IM_MYSQLD2_SOCK)
--connection mysql_con
---replace_result $IM_MYSQLD1_PORT IM_MYSQLD1_PORT
+--replace_result $IM_MYSQLD2_PORT IM_MYSQLD2_PORT
SHOW VARIABLES LIKE 'port';
--connection default
@@ -61,14 +67,20 @@ SHOW VARIABLES LIKE 'port';
#
###########################################################################
+--echo
+--echo --------------------------------------------------------------------
+--echo -- 1.1.3.
+--echo --------------------------------------------------------------------
+
STOP INSTANCE mysqld2;
-# FIXME
+# FIXME: STOP INSTANCE should be synchronous.
--sleep 3
+# should be longer than monitoring interval and enough to stop instance.
SHOW INSTANCES;
---replace_column 3 VERSION
+--replace_column 3 VERSION_NUMBER 4 VERSION
SHOW INSTANCE STATUS mysqld1;
---replace_column 3 VERSION
+--replace_column 3 VERSION_NUMBER 4 VERSION
SHOW INSTANCE STATUS mysqld2;
###########################################################################
@@ -81,16 +93,17 @@ SHOW INSTANCE STATUS mysqld2;
#
###########################################################################
---error 3000
+--echo
+--echo --------------------------------------------------------------------
+--echo -- 1.1.4.
+--echo --------------------------------------------------------------------
+
+--error 3000 # ER_BAD_INSTANCE_NAME
START INSTANCE mysqld3;
---error 3002
+--error 3002 # ER_INSTANCE_ALREADY_STARTED
START INSTANCE mysqld1;
-# FIXME TODO
-# BUG#12813: START/STOP INSTANCE commands accept a list as argument
-# START INSTANCE mysqld1, mysqld2;
-
###########################################################################
#
# 1.1.5. Check that Instance Manager reports correct errors for 'STOP INSTANCE'
@@ -101,39 +114,54 @@ START INSTANCE mysqld1;
#
###########################################################################
---error 3000
+--echo
+--echo --------------------------------------------------------------------
+--echo -- 1.1.5.
+--echo --------------------------------------------------------------------
+
+--error 3000 # ER_BAD_INSTANCE_NAME
STOP INSTANCE mysqld3;
# TODO: IM should be fixed.
# BUG#12673: Instance Manager allows to stop the instance many times
-# --error 3002
+# --error 3002 # ER_INSTANCE_ALREADY_STARTED
# STOP INSTANCE mysqld2;
-# FIXME TODO
-# BUG#12813: START/STOP INSTANCE commands accept a list as argument
-# STOP INSTANCE mysqld1, mysqld2;
-
###########################################################################
#
# 1.1.6. Check that Instance Manager is able to restart guarded instances.
#
###########################################################################
+--echo
+--echo --------------------------------------------------------------------
+--echo -- 1.1.6.
+--echo --------------------------------------------------------------------
+
SHOW INSTANCES;
--exec $MYSQL_TEST_DIR/t/kill_n_check.sh $IM_MYSQLD1_PATH_PID restarted
+--sleep 3
+# should be longer than monitoring interval and enough to start instance.
+
###########################################################################
#
# 1.1.7. Check that Instance Manager does not restart non-guarded instance.
#
###########################################################################
+--echo
+--echo --------------------------------------------------------------------
+--echo -- 1.1.7.
+--echo --------------------------------------------------------------------
+
SHOW INSTANCES;
START INSTANCE mysqld2;
-# FIXME
+# FIXME: START INSTANCE should be synchronous.
--sleep 3
+# should be longer than monitoring interval and enough to start instance.
SHOW INSTANCES;
@@ -147,7 +175,13 @@ SHOW INSTANCES;
# incomplete SHOW INSTANCE STATUS command.
#
###########################################################################
---error 1149
+
+--echo
+--echo --------------------------------------------------------------------
+--echo -- 1.1.8.
+--echo --------------------------------------------------------------------
+
+--error ER_SYNTAX_ERROR
SHOW INSTANCE STATUS;
#
@@ -159,8 +193,13 @@ SHOW INSTANCE STATUS;
# a list as argument.
#
---error 1149
+--echo
+--echo --------------------------------------------------------------------
+--echo -- BUG#12813
+--echo --------------------------------------------------------------------
+
+--error ER_SYNTAX_ERROR
START INSTANCE mysqld1,mysqld2,mysqld3;
---error 1149
+--error ER_SYNTAX_ERROR
STOP INSTANCE mysqld1,mysqld2,mysqld3;
diff --git a/mysql-test/t/im_options.imtest b/mysql-test/t/im_options.imtest
new file mode 100644
index 00000000000..cd905416cda
--- /dev/null
+++ b/mysql-test/t/im_options.imtest
@@ -0,0 +1,268 @@
+###########################################################################
+#
+# This test suite checks the following statements:
+# - SET <instance id>.<option name> = <option value>;
+# - UNSET <instance id>.<option name> = <option value>;
+# - FLUSH INSTANCES;
+#
+# For SET/UNSET we check that:
+# - SET ignores spaces correctly;
+# - UNSET does not allow option-value part (= <option value>);
+# - SET/UNSET can be applied several times w/o error;
+# - SET/UNSET is allowed only for stopped instances;
+# - SET/UNSET updates both the configuration cache in IM and
+# the configuration file;
+#
+# For FLUSH INSTANCES we check that:
+# - FLUSH INSTANCES is allowed only when all instances are stopped;
+#
+# According to the IM implementation details, we should play at least with the
+# following options:
+# - server_id
+# - port
+# - nonguarded
+
+# Let's test SET statement on the option 'server_id'. It's expected that
+# originally the instances have the following server ids and states:
+# - mysqld1: server_id: 1; running (online)
+# - mysqld2: server_id: 2; stopped (offline)
+#
+###########################################################################
+
+--source include/im_check_os.inc
+
+###########################################################################
+#
+# Check starting conditions.
+#
+###########################################################################
+
+# - check the configuration file;
+
+--echo --------------------------------------------------------------------
+--exec grep server_id $MYSQLTEST_VARDIR/im.cnf ;
+--echo --------------------------------------------------------------------
+
+# - check the running instances.
+
+--connect (mysql1_con,localhost,root,,mysql,$IM_MYSQLD1_PORT,$IM_MYSQLD1_SOCK)
+
+--connection mysql1_con
+
+SHOW VARIABLES LIKE 'server_id';
+
+--connection default
+
+# - check the internal cache.
+
+SHOW INSTANCES;
+
+###########################################################################
+#
+# Check that SET/UNSET is allowed only for stopped instances.
+#
+###########################################################################
+
+# - check that SET/UNSET is denied for running instances;
+
+--error 3015 # ER_INSTANCE_IS_ACTIVE
+UNSET mysqld1.server_id;
+
+--error 3015 # ER_INSTANCE_IS_ACTIVE
+SET mysqld1.server_id = 11;
+
+# - check that SET/UNSET is denied for active instances:
+# - create dummy misconfigured instance;
+# - start it;
+# - try to set/unset options;
+
+CREATE INSTANCE mysqld3 datadir = '/';
+START INSTANCE mysqld3;
+
+# FIXME: START INSTANCE should be synchronous.
+--sleep 3
+# should be longer than monitoring interval and enough to start instance.
+
+# NOTE: We can not analyze state of the instance here -- it can be Failed or
+# Starting because Instance Manager is trying to start the misconfigured
+# instance several times.
+
+--error 3015 # ER_INSTANCE_IS_ACTIVE
+UNSET mysqld3.server_id;
+
+--error 3015 # ER_INSTANCE_IS_ACTIVE
+SET mysqld3.server_id = 11;
+
+STOP INSTANCE mysqld3;
+
+# FIXME: STOP INSTANCE should be synchronous.
+--sleep 3
+# should be longer than monitoring interval and enough to stop instance.
+
+--replace_column 3 VERSION_NUMBER 4 VERSION
+SHOW INSTANCE STATUS mysqld3;
+
+# - check that SET/UNSET succeed for stopped instances;
+# - check that SET/UNSET can be applied multiple times;
+
+UNSET mysqld2.server_id;
+UNSET mysqld2.server_id;
+
+--replace_column 2 option_value
+SHOW INSTANCE OPTIONS mysqld2;
+
+SET mysqld2.server_id = 2;
+SET mysqld2.server_id = 2;
+
+--replace_column 2 option_value
+SHOW INSTANCE OPTIONS mysqld2;
+
+# - check that UNSET does not allow option-value part (= <option value>);
+
+--error ER_SYNTAX_ERROR
+UNSET mysqld2.server_id = 11;
+
+# - check that SET/UNSET working properly with multiple options;
+
+SET mysqld2.aaa, mysqld3.bbb, mysqld2.ccc = 0010, mysqld3.ddd = 0020;
+
+--echo --------------------------------------------------------------------
+--exec grep aaa $MYSQLTEST_VARDIR/im.cnf ;
+--echo --------------------------------------------------------------------
+--exec grep bbb $MYSQLTEST_VARDIR/im.cnf ;
+--echo --------------------------------------------------------------------
+--exec grep ccc $MYSQLTEST_VARDIR/im.cnf ;
+--echo --------------------------------------------------------------------
+--exec grep ddd $MYSQLTEST_VARDIR/im.cnf ;
+--echo --------------------------------------------------------------------
+
+UNSET mysqld2.aaa, mysqld3.bbb, mysqld2.ccc, mysqld3.ddd;
+
+--echo --------------------------------------------------------------------
+--exec grep aaa $MYSQLTEST_VARDIR/im.cnf || true;
+--echo --------------------------------------------------------------------
+--exec grep bbb $MYSQLTEST_VARDIR/im.cnf || true;
+--echo --------------------------------------------------------------------
+--exec grep ccc $MYSQLTEST_VARDIR/im.cnf || true;
+--echo --------------------------------------------------------------------
+--exec grep ddd $MYSQLTEST_VARDIR/im.cnf || true;
+--echo --------------------------------------------------------------------
+
+# - check that if some instance name is invalid or the active is active,
+# whole SET-statement will not be executed;
+
+--error 3000 # ER_BAD_INSTANCE_NAME
+SET mysqld2.aaa, mysqld3.bbb, mysqld.ccc = 0010;
+
+--echo --------------------------------------------------------------------
+--exec grep aaa $MYSQLTEST_VARDIR/im.cnf || true;
+--echo --------------------------------------------------------------------
+--exec grep bbb $MYSQLTEST_VARDIR/im.cnf || true;
+--echo --------------------------------------------------------------------
+--exec grep ccc $MYSQLTEST_VARDIR/im.cnf || true;
+--echo --------------------------------------------------------------------
+
+--error 3015 # ER_INSTANCE_IS_ACTIVE
+SET mysqld2.aaa, mysqld3.bbb, mysqld1.ccc = 0010;
+
+--echo --------------------------------------------------------------------
+--exec grep aaa $MYSQLTEST_VARDIR/im.cnf || true;
+--echo --------------------------------------------------------------------
+--exec grep bbb $MYSQLTEST_VARDIR/im.cnf || true;
+--echo --------------------------------------------------------------------
+--exec grep ccc $MYSQLTEST_VARDIR/im.cnf || true;
+--echo --------------------------------------------------------------------
+
+# - check that if some instance name is invalid or the active is active,
+# whole UNSET-statement will not be executed;
+
+--error 3000 # ER_BAD_INSTANCE_NAME
+UNSET mysqld2.server_id, mysqld3.server_id, mysqld.ccc;
+
+--echo --------------------------------------------------------------------
+--exec grep server_id $MYSQLTEST_VARDIR/im.cnf;
+--echo --------------------------------------------------------------------
+
+--error 3015 # ER_INSTANCE_IS_ACTIVE
+UNSET mysqld2.server_id, mysqld3.server_id, mysqld1.ccc;
+
+--echo --------------------------------------------------------------------
+--exec grep server_id $MYSQLTEST_VARDIR/im.cnf;
+--echo --------------------------------------------------------------------
+
+DROP INSTANCE mysqld3;
+
+# - check that spaces are handled correctly;
+
+SET mysqld2.server_id=222;
+SET mysqld2.server_id = 222;
+SET mysqld2.server_id = 222 ;
+SET mysqld2 . server_id = 222 ;
+SET mysqld2 . server_id = 222 , mysqld2 . aaa , mysqld2 . bbb ;
+
+--echo --------------------------------------------------------------------
+--exec grep server_id $MYSQLTEST_VARDIR/im.cnf ;
+--echo --------------------------------------------------------------------
+--exec grep aaa $MYSQLTEST_VARDIR/im.cnf ;
+--echo --------------------------------------------------------------------
+--exec grep bbb $MYSQLTEST_VARDIR/im.cnf ;
+--echo --------------------------------------------------------------------
+
+UNSET mysqld2 . aaa , mysqld2 . bbb ;
+
+--echo --------------------------------------------------------------------
+--exec grep server_id $MYSQLTEST_VARDIR/im.cnf ;
+--echo --------------------------------------------------------------------
+--exec grep aaa $MYSQLTEST_VARDIR/im.cnf || true;
+--echo --------------------------------------------------------------------
+--exec grep bbb $MYSQLTEST_VARDIR/im.cnf || true;
+--echo --------------------------------------------------------------------
+
+###########################################################################
+#
+# Check that SET/UNSET updates both the configuration cache in IM and
+# the configuration file.
+#
+###########################################################################
+
+# - check that the configuration file has been updated (i.e. contains
+# server_id=SERVER_ID for mysqld2);
+
+--echo --------------------------------------------------------------------
+--exec grep server_id $MYSQLTEST_VARDIR/im.cnf ;
+--echo --------------------------------------------------------------------
+
+# - (for mysqld1) check that the running instance has not been affected:
+# connect to the instance and check that 'SHOW VARIABLES LIKE 'server_id''
+# returns zero;
+
+--connection mysql1_con
+
+SHOW VARIABLES LIKE 'server_id';
+
+--connection default
+
+# - check that internal cache of Instance Manager has been affected;
+# TODO: we should check only server_id option here.
+
+# SHOW INSTANCE OPTIONS mysqld2;
+
+###########################################################################
+#
+# Check that FLUSH INSTANCES is allowed only when all instances are stopped.
+#
+###########################################################################
+
+SHOW INSTANCES;
+
+--error 3016 # ER_THERE_IS_ACTIVE_INSTACE
+FLUSH INSTANCES;
+
+STOP INSTANCE mysqld1;
+# FIXME: STOP INSTANCE should be synchronous.
+--sleep 3
+# should be longer than monitoring interval and enough to stop instance.
+
+SHOW INSTANCES;
+
+FLUSH INSTANCES;
diff --git a/mysql-test/t/im_options_set.imtest b/mysql-test/t/im_options_set.imtest
deleted file mode 100644
index a9b64861f99..00000000000
--- a/mysql-test/t/im_options_set.imtest
+++ /dev/null
@@ -1,142 +0,0 @@
-###########################################################################
-#
-# This file contains test for (3) test suite.
-#
-# Consult WL#2789 for more information.
-#
-###########################################################################
-
-#
-# Check the options-management commands:
-# - SET;
-# - FLUSH INSTANCES;
-#
-# Let's test the commands on the option 'server_id'. It's expected that
-# originally the instances have the following server ids:
-# - mysqld1: 1
-# - mysqld2: 2
-#
-# 1. SET <instance_id>.server_id= SERVER_ID); where SERVER_ID is 11 or 12.
-# 1.1. check that the configuration file has been updated (i.e. contains
-# server_id=SERVER_ID for the instance);
-# 1.2. (for mysqld1) check that the running instance has not been affected:
-# connect to the instance and check that 'SHOW VARIABLES LIKE 'server_id''
-# returns zero;
-# 1.3. check that internal cache of Instance Manager has not been affected
-# (i.e. SHOW INSTANCE OPTIONS <instance> does not contain updated value).
-#
-# 2. FLUSH INSTANCES;
-# 2.1. check that the configuration file has not been updated;
-# 2.2. (for mysqld1) check that the running instance has not been affected:
-# connect to the instance and check that 'SHOW VARIABLES LIKE 'server_id''
-# returns zero value;
-# 2.3. check that internal cache of Instance Manager has been updated (i.e.
-# SHOW INSTANCE OPTIONS <instance> contains 'server_id=SERVER_ID' line).
-#
-# 3. Restore options.
-#
-
-###########################################################################
-
---source include/im_check_os.inc
-
-###########################################################################
-#
-# 0. Check starting conditions.
-#
-###########################################################################
-
-# - check the configuration file;
-
---exec grep server_id $MYSQLTEST_VARDIR/im.cnf ;
-
-# - check the running instances.
-
---connect (mysql1_con,localhost,root,,mysql,$IM_MYSQLD1_PORT,$IM_MYSQLD1_SOCK)
-
---connection mysql1_con
-
-SHOW VARIABLES LIKE 'server_id';
-
---connection default
-
-# - check the internal cache.
-# TODO: we should check only server_id option here.
-
-# SHOW INSTANCE OPTIONS mysqld1;
-# SHOW INSTANCE OPTIONS mysqld2;
-
-###########################################################################
-#
-# 1. SET <instance_id>.server_id= SERVER_ID); where SERVER_ID is 11 or 12.
-#
-###########################################################################
-
-# * mysqld1
-
-SET mysqld1.server_id = 11;
-
-# - check that the configuration file has been updated (i.e. contains
-# server_id=SERVER_ID for the instance);
-
---exec grep server_id $MYSQLTEST_VARDIR/im.cnf ;
-
-# - (for mysqld1) check that the running instance has not been affected:
-# connect to the instance and check that 'SHOW VARIABLES LIKE 'server_id''
-# returns zero;
-
---connection mysql1_con
-
-SHOW VARIABLES LIKE 'server_id';
-
---connection default
-
-# - check that internal cache of Instance Manager has not been affected
-# (i.e. SHOW INSTANCE OPTIONS <instance> does not contain updated value).
-# TODO: we should check only server_id option here.
-
-# SHOW INSTANCE OPTIONS mysqld1;
-
-# * mysqld2
-
-SET mysqld2.server_id = 12;
-
-# - check that the configuration file has been updated (i.e. contains
-# server_id=SERVER_ID for the instance);
-
---exec grep server_id $MYSQLTEST_VARDIR/im.cnf ;
-
-# - check that internal cache of Instance Manager has not been affected
-# (i.e. SHOW INSTANCE OPTIONS <instance> does not contain updated value).
-# TODO: we should check only server_id option here.
-
-# SHOW INSTANCE OPTIONS mysqld2;
-
-###########################################################################
-#
-# 2. FLUSH INSTANCES;
-#
-###########################################################################
-
-FLUSH INSTANCES;
-
-# - check that the configuration file has not been updated;
-
---exec grep server_id $MYSQLTEST_VARDIR/im.cnf ;
-
-# - (for mysqld1) check that the running instance has not been affected:
-# connect to the instance and check that 'SHOW VARIABLES LIKE 'server_id''
-# returns zero value;
-
---connection mysql1_con
-
-SHOW VARIABLES LIKE 'server_id';
-
---connection default
-
-# - check that internal cache of Instance Manager has been updated (i.e.
-# SHOW INSTANCE OPTIONS <instance> contains 'server_id=' line).
-# TODO: we should check only server_id option here.
-
-# SHOW INSTANCE OPTIONS mysqld1;
-# SHOW INSTANCE OPTIONS mysqld2;
diff --git a/mysql-test/t/im_options_unset.imtest b/mysql-test/t/im_options_unset.imtest
deleted file mode 100644
index 40629805d45..00000000000
--- a/mysql-test/t/im_options_unset.imtest
+++ /dev/null
@@ -1,150 +0,0 @@
-###########################################################################
-#
-# This file contains test for (3) test suite.
-#
-# Consult WL#2789 for more information.
-#
-###########################################################################
-
-#
-# Check the options-management commands:
-# - UNSET;
-# - FLUSH INSTANCES;
-#
-# Let's test the commands on the option 'server_id'. It's expected that
-# originally the instances have the following server ids:
-# - mysqld1: 1
-# - mysqld2: 2
-#
-# The test case:
-#
-# 1. UNSET <instance_id>.server_id;
-#
-# Do the step for both instances.
-#
-# 1.1. check that the configuration file has been updated (i.e. does not
-# contain 'server_id=' line for the instance);
-# 1.2. (for mysqld1) check that the running instance has not been affected:
-# connect to the instance and check that 'SHOW VARIABLES LIKE 'server_id''
-# returns non-zero value;
-# 1.3. check that internal cache of Instance Manager is not affected (i.e.
-# SHOW INSTANCE OPTIONS <instance> contains non-zero value for server_id);
-#
-# 2. FLUSH INSTANCES;
-#
-# Do the step for both instances.
-#
-# 2.1. check that the configuration file has not been updated (i.e. does not
-# contain 'server_id=' for the instance);
-# 2.2. (for mysqld1) check that the running instance has not been affected:
-# connect to the instance and check that 'SHOW VARIABLES LIKE 'server_id''
-# returns non-zero value;
-# 2.3. check that internal cache of Instance Manager has been updated (i.e.
-# SHOW INSTANCE OPTIONS <instance> does not contain 'server_id=' line).
-#
-
-###########################################################################
-
---source include/im_check_os.inc
-
-###########################################################################
-#
-# 0. Check starting conditions.
-#
-###########################################################################
-
-# - check the configuration file;
-
---exec grep server_id $MYSQLTEST_VARDIR/im.cnf ;
-
-# - check the running instances.
-
---connect (mysql1_con,localhost,root,,mysql,$IM_MYSQLD1_PORT,$IM_MYSQLD1_SOCK)
-
---connection mysql1_con
-
-SHOW VARIABLES LIKE 'server_id';
-
---connection default
-
-# - check the internal cache.
-# TODO: we should check only server_id option here.
-
-# SHOW INSTANCE OPTIONS mysqld1;
-# SHOW INSTANCE OPTIONS mysqld2;
-
-###########################################################################
-#
-# 1. UNSET <instance_id>.server_id;
-#
-###########################################################################
-
-# * mysqld1
-
-UNSET mysqld1.server_id;
-
-# - check that the configuration file has been updated (i.e. does not
-# contain 'server_id=' line for the instance);
-
---exec grep server_id $MYSQLTEST_VARDIR/im.cnf ;
-
-# - check that the running instance has not been affected: connect to the
-# instance and check that 'SHOW VARIABLES LIKE 'server_id'' returns non-zero
-# value;
-
---connection mysql1_con
-
-SHOW VARIABLES LIKE 'server_id';
-
---connection default
-
-# - check that internal cache of Instance Manager is not affected (i.e. SHOW
-# INSTANCE OPTIONS <instance> contains non-zero value for server_id);
-# TODO: we should check only server_id option here.
-
-# SHOW INSTANCE OPTIONS mysqld1;
-
-# * mysqld2
-
-UNSET mysqld2.server_id;
-
-# - check that the configuration file has been updated (i.e. does not
-# contain 'server_id=' line for the instance);
-
---exec grep server_id $MYSQLTEST_VARDIR/im.cnf || true;
-
-# - check that internal cache of Instance Manager is not affected (i.e. SHOW
-# INSTANCE OPTIONS <instance> contains non-zero value for server_id);
-# TODO: we should check only server_id option here.
-
-# SHOW INSTANCE OPTIONS mysqld2;
-
-###########################################################################
-#
-# 2. FLUSH INSTANCES;
-#
-###########################################################################
-
-FLUSH INSTANCES;
-
-# - check that the configuration file has not been updated (i.e. does not
-# contain 'server_id=' for the instance);
-
---exec grep server_id $MYSQLTEST_VARDIR/im.cnf || true;
-
-# - (for mysqld1) check that the running instance has not been affected:
-# connect to the instance and check that 'SHOW VARIABLES LIKE 'server_id''
-# returns non-zero value;
-
---connection mysql1_con
-
-SHOW VARIABLES LIKE 'server_id';
-
---connection default
-
-# - check that internal cache of Instance Manager has been updated (i.e.
-# SHOW INSTANCE OPTIONS <instance> does not contain 'server_id=' line).
-# TODO: we should check only server_id option here.
-
-# SHOW INSTANCE OPTIONS mysqld1;
-# SHOW INSTANCE OPTIONS mysqld2;
diff --git a/mysql-test/t/im_utils-im.opt b/mysql-test/t/im_utils-im.opt
new file mode 100644
index 00000000000..34b74ce0c95
--- /dev/null
+++ b/mysql-test/t/im_utils-im.opt
@@ -0,0 +1 @@
+--monitoring-interval=1
diff --git a/mysql-test/t/im_utils.imtest b/mysql-test/t/im_utils.imtest
index dc6fb93c4ff..8e8d475cfee 100644
--- a/mysql-test/t/im_utils.imtest
+++ b/mysql-test/t/im_utils.imtest
@@ -17,6 +17,9 @@
# - the second instance is offline;
#
+--sleep 3
+# should be longer than monitoring interval and enough to start instance.
+
SHOW INSTANCES;
#
@@ -41,8 +44,9 @@ SHOW INSTANCE OPTIONS mysqld2;
START INSTANCE mysqld2;
-# FIXME
--- sleep 3
+# FIXME: START INSTANCE should be synchronous.
+--sleep 3
+# should be longer than monitoring interval and enough to start instance.
STOP INSTANCE mysqld2;
diff --git a/mysql-test/t/information_schema.test b/mysql-test/t/information_schema.test
index 48dd28bf6da..acb877e1e74 100644
--- a/mysql-test/t/information_schema.test
+++ b/mysql-test/t/information_schema.test
@@ -1,6 +1,10 @@
# This test uses grants, which can't get tested for embedded server
-- source include/not_embedded.inc
+# check that CSV engine was compiled in, as the result of the test depends
+# on the presence of the log tables (which are CSV-based).
+--source include/have_csv.inc
+
# Test for information_schema.schemata &
# show databases
@@ -821,6 +825,25 @@ delete from proc where name='';
use test;
#
+# End of 5.0 tests.
+#
+# Show engines
+#
+
+select * from information_schema.engines WHERE ENGINE="MyISAM";
+
+#
+# INFORMATION_SCHEMA.PROCESSLIST
+#
+
+grant select on *.* to user3148@localhost;
+connect (con3148,localhost,user3148,,test);
+connection con3148;
+select user,db from information_schema.processlist;
+connection default;
+drop user user3148@localhost;
+
+#
# Bug#16681 information_schema shows forbidden VIEW details
#
grant select on test.* to mysqltest_1@localhost;
@@ -838,3 +861,4 @@ connection default;
drop view v1, v2;
drop table t1;
drop user mysqltest_1@localhost;
+
diff --git a/mysql-test/t/information_schema_inno.test b/mysql-test/t/information_schema_inno.test
index 9cd64a54ad9..195bf57a880 100644
--- a/mysql-test/t/information_schema_inno.test
+++ b/mysql-test/t/information_schema_inno.test
@@ -21,3 +21,35 @@ select * from information_schema.KEY_COLUMN_USAGE where
TABLE_SCHEMA= "test";
drop table t3, t2, t1;
+
+#
+# Test for REFERENTIAL_CONSTRAINTS table
+#
+CREATE TABLE t1(a1 INT NOT NULL, a2 INT NOT NULL,
+ PRIMARY KEY(a1, a2)) ENGINE=INNODB;
+CREATE TABLE t2(b1 INT, b2 INT, INDEX (b1, b2),
+ CONSTRAINT A1
+ FOREIGN KEY (b1, b2) REFERENCES t1(a1, a2)
+ ON UPDATE CASCADE ON DELETE NO ACTION) ENGINE=INNODB;
+CREATE TABLE t3(b1 INT, b2 INT, INDEX (b1, b2),
+ CONSTRAINT A2
+ FOREIGN KEY (b1, b2) REFERENCES t2(b1, b2)
+ ON UPDATE SET NULL ON DELETE RESTRICT) ENGINE=INNODB;
+CREATE TABLE t4(b1 INT, b2 INT, INDEX (b1, b2),
+ CONSTRAINT A3
+ FOREIGN KEY (b1, b2) REFERENCES t3(b1, b2)
+ ON UPDATE NO ACTION ON DELETE SET NULL) ENGINE=INNODB;
+CREATE TABLE t5(b1 INT, b2 INT, INDEX (b1, b2),
+ CONSTRAINT A4
+ FOREIGN KEY (b1, b2) REFERENCES t4(b1, b2)
+ ON UPDATE RESTRICT ON DELETE CASCADE) ENGINE=INNODB;
+
+
+select a.CONSTRAINT_SCHEMA, b.TABLE_NAME, CONSTRAINT_TYPE,
+ b.CONSTRAINT_NAME, UNIQUE_CONSTRAINT_SCHEMA, UNIQUE_CONSTRAINT_NAME,
+ MATCH_OPTION, UPDATE_RULE, DELETE_RULE
+from information_schema.TABLE_CONSTRAINTS a,
+ information_schema.REFERENTIAL_CONSTRAINTS b
+where a.CONSTRAINT_SCHEMA = 'test' and a.CONSTRAINT_SCHEMA = b.CONSTRAINT_SCHEMA and
+a.CONSTRAINT_NAME = b.CONSTRAINT_NAME;
+drop tables t5, t4, t3, t2, t1;
diff --git a/mysql-test/t/information_schema_part.test b/mysql-test/t/information_schema_part.test
new file mode 100644
index 00000000000..4cbf21ca1d3
--- /dev/null
+++ b/mysql-test/t/information_schema_part.test
@@ -0,0 +1,123 @@
+
+-- source include/have_partition.inc
+
+--disable_warnings
+drop table if exists t1,t2,t3,t4;
+--enable_warnings
+
+create table t1 (a int not null,b int not null,c int not null, primary key(a,b))
+partition by list (b*a)
+(partition x1 values in (1) tablespace ts1,
+ partition x2 values in (3, 11, 5, 7) tablespace ts2,
+ partition x3 values in (16, 8, 5+19, 70-43) tablespace ts3);
+
+--replace_column 16 # 19 # 20 #
+select * from information_schema.partitions where table_schema="test"
+and table_name="t1";
+
+create table t2 (a int not null,b int not null,c int not null, primary key(a,b))
+partition by range (a)
+partitions 3
+(partition x1 values less than (5) tablespace ts1,
+ partition x2 values less than (10) tablespace ts2,
+ partition x3 values less than maxvalue tablespace ts3);
+--replace_column 16 # 19 # 20 #
+select * from information_schema.partitions where table_schema="test"
+and table_name="t2";
+
+create table t3 (f1 date)
+partition by hash(month(f1))
+partitions 3;
+--replace_column 16 # 19 # 20 #
+select * from information_schema.partitions where table_schema="test"
+and table_name="t3";
+
+create table t4 (f1 date, f2 int)
+partition by key(f1,f2)
+partitions 3;
+--replace_column 16 # 19 # 20 #
+select * from information_schema.partitions where table_schema="test"
+and table_name="t4";
+
+drop table t1,t2,t3,t4;
+
+create table t1 (a int not null,b int not null,c int not null,primary key (a,b))
+partition by range (a)
+subpartition by hash (a+b)
+( partition x1 values less than (1)
+ ( subpartition x11 tablespace t1,
+ subpartition x12 tablespace t2),
+ partition x2 values less than (5)
+ ( subpartition x21 tablespace t1,
+ subpartition x22 tablespace t2)
+);
+
+create table t2 (a int not null,b int not null,c int not null,primary key (a,b))
+partition by range (a)
+subpartition by key (a)
+( partition x1 values less than (1)
+ ( subpartition x11 tablespace t1,
+ subpartition x12 tablespace t2),
+ partition x2 values less than (5)
+ ( subpartition x21 tablespace t1,
+ subpartition x22 tablespace t2)
+);
+--replace_column 16 # 19 # 20 #
+select * from information_schema.partitions where table_schema="test";
+drop table t1,t2;
+
+create table t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key (a,b))
+partition by range (a)
+subpartition by hash (a+b)
+( partition x1 values less than (1)
+ ( subpartition x11 tablespace t1 nodegroup 0,
+ subpartition x12 tablespace t2 nodegroup 1),
+ partition x2 values less than (5)
+( subpartition x21 tablespace t1 nodegroup 0,
+ subpartition x22 tablespace t2 nodegroup 1)
+);
+
+--replace_column 16 # 19 # 20 #
+select * from information_schema.partitions where table_schema="test";
+show tables;
+drop table t1;
+
+create table t1(f1 int, f2 int);
+--replace_column 16 # 19 # 20 #
+select * from information_schema.partitions where table_schema="test";
+drop table t1;
+
+create table t1 (f1 date)
+partition by linear hash(month(f1))
+partitions 3;
+--replace_column 16 # 19 # 20 #
+select * from information_schema.partitions where table_schema="test"
+and table_name="t1";
+drop table t1;
+
+#
+# Bug 20161 Partitions: SUBPARTITION METHOD doesn't show LINEAR keyword
+#
+create table t1 (a int)
+PARTITION BY RANGE (a)
+SUBPARTITION BY LINEAR HASH (a)
+(PARTITION p0 VALUES LESS THAN (10));
+
+SHOW CREATE TABLE t1;
+select SUBPARTITION_METHOD FROM information_schema.partitions WHERE
+table_schema="test" AND table_name="t1";
+drop table t1;
+
+create table t1 (a int)
+PARTITION BY LIST (a)
+(PARTITION p0 VALUES IN
+(10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,
+ 32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53));
+SHOW CREATE TABLE t1;
+SELECT PARTITION_DESCRIPTION FROM information_schema.partitions WHERE
+table_schema = "test" AND table_name = "t1";
+drop table t1;
diff --git a/mysql-test/t/innodb-master.opt b/mysql-test/t/innodb-master.opt
index 4cb927540bf..4901efb416c 100644
--- a/mysql-test/t/innodb-master.opt
+++ b/mysql-test/t/innodb-master.opt
@@ -1 +1 @@
---binlog_cache_size=32768
+--binlog_cache_size=32768 --innodb_lock_wait_timeout=1
diff --git a/mysql-test/t/innodb.test b/mysql-test/t/innodb.test
index e4c8bf89cca..92e060eed92 100644
--- a/mysql-test/t/innodb.test
+++ b/mysql-test/t/innodb.test
@@ -914,10 +914,10 @@ insert into t2 (a) select b from t1;
insert into t1 (a) select b from t2;
select count(*) from t1;
--replace_column 9 #
-explain select * from t1 where c between 1 and 10000;
+explain select * from t1 where c between 1 and 2500;
update t1 set c=a;
--replace_column 9 #
-explain select * from t1 where c between 1 and 10000;
+explain select * from t1 where c between 1 and 2500;
drop table t1,t2;
#
@@ -1159,6 +1159,7 @@ drop table t2, t1;
# Actually this test has nothing to do with innodb per se, it just requires
# transactional table.
#
+flush status;
show status like "binlog_cache_use";
show status like "binlog_cache_disk_use";
@@ -2142,6 +2143,59 @@ disconnect a;
disconnect b;
#
+# Test that cascading updates leading to duplicate keys give the correct
+# error message (bug #9680)
+#
+
+CREATE TABLE t1 (
+ field1 varchar(8) NOT NULL DEFAULT '',
+ field2 varchar(8) NOT NULL DEFAULT '',
+ PRIMARY KEY (field1, field2)
+) ENGINE=InnoDB;
+
+CREATE TABLE t2 (
+ field1 varchar(8) NOT NULL DEFAULT '' PRIMARY KEY,
+ FOREIGN KEY (field1) REFERENCES t1 (field1)
+ ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB;
+
+INSERT INTO t1 VALUES ('old', 'somevalu');
+INSERT INTO t1 VALUES ('other', 'anyvalue');
+
+INSERT INTO t2 VALUES ('old');
+INSERT INTO t2 VALUES ('other');
+
+--error ER_FOREIGN_DUPLICATE_KEY
+UPDATE t1 SET field1 = 'other' WHERE field2 = 'somevalu';
+
+DROP TABLE t2;
+DROP TABLE t1;
+
+#
+# Bug#18477 - MySQL/InnoDB Ignoring Foreign Keys in ALTER TABLE
+#
+create table t1 (
+ c1 bigint not null,
+ c2 bigint not null,
+ primary key (c1),
+ unique key (c2)
+) engine=innodb;
+#
+create table t2 (
+ c1 bigint not null,
+ primary key (c1)
+) engine=innodb;
+#
+alter table t1 add constraint c2_fk foreign key (c2)
+ references t2(c1) on delete cascade;
+show create table t1;
+#
+alter table t1 drop foreign key c2_fk;
+show create table t1;
+#
+drop table t1, t2;
+
+#
# Bug #14360: problem with intervals
#
@@ -2153,6 +2207,256 @@ select * from t1, t2
where t2.a between t1.a - interval 2 day and t1.a + interval 2 day;
drop table t1, t2;
+create table t1 (id int not null, f_id int not null, f int not null,
+primary key(f_id, id)) engine=innodb;
+create table t2 (id int not null,s_id int not null,s varchar(200),
+primary key(id)) engine=innodb;
+INSERT INTO t1 VALUES (8, 1, 3);
+INSERT INTO t1 VALUES (1, 2, 1);
+INSERT INTO t2 VALUES (1, 0, '');
+INSERT INTO t2 VALUES (8, 1, '');
+commit;
+DELETE ml.* FROM t1 AS ml LEFT JOIN t2 AS mm ON (mm.id=ml.id)
+WHERE mm.id IS NULL;
+select ml.* from t1 as ml left join t2 as mm on (mm.id=ml.id)
+where mm.id is null lock in share mode;
+drop table t1,t2;
+
+#
+# Test case where X-locks on unused rows should be released in a
+# update (because READ COMMITTED isolation level)
+#
+
+connect (a,localhost,root,,);
+connect (b,localhost,root,,);
+connection a;
+create table t1(a int not null, b int, primary key(a)) engine=innodb;
+insert into t1 values(1,1),(2,2),(3,1),(4,2),(5,1),(6,2),(7,3);
+commit;
+set autocommit = 0;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+update t1 set b = 5 where b = 1;
+connection b;
+set autocommit = 0;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+#
+# X-lock to record (7,3) should be released in a update
+#
+select * from t1 where a = 7 and b = 3 for update;
+connection a;
+commit;
+connection b;
+commit;
+drop table t1;
+connection default;
+disconnect a;
+disconnect b;
+
+#
+# Test case where no locks should be released (because we are not
+# using READ COMMITTED isolation level)
+#
+
+connect (a,localhost,root,,);
+connect (b,localhost,root,,);
+connection a;
+create table t1(a int not null, b int, primary key(a)) engine=innodb;
+insert into t1 values(1,1),(2,2),(3,1),(4,2),(5,1),(6,2);
+commit;
+set autocommit = 0;
+select * from t1 lock in share mode;
+update t1 set b = 5 where b = 1;
+connection b;
+set autocommit = 0;
+#
+# S-lock to records (2,2),(4,2), and (6,2) should not be released in a update
+#
+--error 1205
+select * from t1 where a = 2 and b = 2 for update;
+#
+# X-lock to record (1,1),(3,1),(5,1) should not be released in a update
+#
+--error 1205
+connection a;
+commit;
+connection b;
+commit;
+connection default;
+disconnect a;
+disconnect b;
+drop table t1;
+
+#
+# Consistent read should be used in following selects
+#
+# 1) INSERT INTO ... SELECT
+# 2) UPDATE ... = ( SELECT ...)
+# 3) CREATE ... SELECT
+
+connect (a,localhost,root,,);
+connect (b,localhost,root,,);
+connection a;
+create table t1(a int not null, b int, primary key(a)) engine=innodb;
+insert into t1 values (1,2),(5,3),(4,2);
+create table t2(d int not null, e int, primary key(d)) engine=innodb;
+insert into t2 values (8,6),(12,1),(3,1);
+commit;
+set autocommit = 0;
+select * from t2 for update;
+connection b;
+set autocommit = 0;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+insert into t1 select * from t2;
+update t1 set b = (select e from t2 where a = d);
+create table t3(d int not null, e int, primary key(d)) engine=innodb
+select * from t2;
+commit;
+connection a;
+commit;
+connection default;
+disconnect a;
+disconnect b;
+drop table t1, t2, t3;
+
+#
+# Consistent read should not be used if
+#
+# (a) isolation level is serializable OR
+# (b) select ... lock in share mode OR
+# (c) select ... for update
+#
+# in following queries:
+#
+# 1) INSERT INTO ... SELECT
+# 2) UPDATE ... = ( SELECT ...)
+# 3) CREATE ... SELECT
+
+connect (a,localhost,root,,);
+connect (b,localhost,root,,);
+connect (c,localhost,root,,);
+connect (d,localhost,root,,);
+connect (e,localhost,root,,);
+connect (f,localhost,root,,);
+connect (g,localhost,root,,);
+connect (h,localhost,root,,);
+connect (i,localhost,root,,);
+connect (j,localhost,root,,);
+connection a;
+create table t1(a int not null, b int, primary key(a)) engine=innodb;
+insert into t1 values (1,2),(5,3),(4,2);
+create table t2(a int not null, b int, primary key(a)) engine=innodb;
+insert into t2 values (8,6),(12,1),(3,1);
+create table t3(d int not null, b int, primary key(d)) engine=innodb;
+insert into t3 values (8,6),(12,1),(3,1);
+create table t5(a int not null, b int, primary key(a)) engine=innodb;
+insert into t5 values (1,2),(5,3),(4,2);
+create table t6(d int not null, e int, primary key(d)) engine=innodb;
+insert into t6 values (8,6),(12,1),(3,1);
+create table t8(a int not null, b int, primary key(a)) engine=innodb;
+insert into t8 values (1,2),(5,3),(4,2);
+create table t9(d int not null, e int, primary key(d)) engine=innodb;
+insert into t9 values (8,6),(12,1),(3,1);
+commit;
+set autocommit = 0;
+select * from t2 for update;
+connection b;
+set autocommit = 0;
+SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
+--send
+insert into t1 select * from t2;
+connection c;
+set autocommit = 0;
+SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
+--send
+update t3 set b = (select b from t2 where a = d);
+connection d;
+set autocommit = 0;
+SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
+--send
+create table t4(a int not null, b int, primary key(a)) engine=innodb select * from t2;
+connection e;
+set autocommit = 0;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+--send
+insert into t5 (select * from t2 lock in share mode);
+connection f;
+set autocommit = 0;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+--send
+update t6 set e = (select b from t2 where a = d lock in share mode);
+connection g;
+set autocommit = 0;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+--send
+create table t7(a int not null, b int, primary key(a)) engine=innodb select * from t2 lock in share mode;
+connection h;
+set autocommit = 0;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+--send
+insert into t8 (select * from t2 for update);
+connection i;
+set autocommit = 0;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+--send
+update t9 set e = (select b from t2 where a = d for update);
+connection j;
+set autocommit = 0;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+--send
+create table t10(a int not null, b int, primary key(a)) engine=innodb select * from t2 for update;
+
+connection b;
+--error 1205
+reap;
+
+connection c;
+--error 1205
+reap;
+
+connection d;
+--error 1205
+reap;
+
+connection e;
+--error 1205
+reap;
+
+connection f;
+--error 1205
+reap;
+
+connection g;
+--error 1205
+reap;
+
+connection h;
+--error 1205
+reap;
+
+connection i;
+--error 1205
+reap;
+
+connection j;
+--error 1205
+reap;
+
+connection a;
+commit;
+
+connection default;
+disconnect a;
+disconnect b;
+disconnect c;
+disconnect d;
+disconnect e;
+disconnect f;
+disconnect g;
+disconnect h;
+disconnect i;
+disconnect j;
+drop table t1, t2, t3, t5, t6, t8, t9;
+
# bug 18934, "InnoDB crashes when table uses column names like DB_ROW_ID"
--error 1005
CREATE TABLE t1 (DB_ROW_ID int) engine=innodb;
@@ -2196,3 +2500,13 @@ drop table t2, t1;
#
--error ER_TABLE_CANT_HANDLE_SPKEYS
create table t1 (g geometry not null, spatial gk(g)) engine=innodb;
+
+#
+# Test optimize on table with open transaction
+#
+
+CREATE TABLE t1 ( a int ) ENGINE=innodb;
+BEGIN;
+INSERT INTO t1 VALUES (1);
+OPTIMIZE TABLE t1;
+DROP TABLE t1;
diff --git a/mysql-test/t/innodb_concurrent-master.opt b/mysql-test/t/innodb_concurrent-master.opt
new file mode 100644
index 00000000000..f76bada5208
--- /dev/null
+++ b/mysql-test/t/innodb_concurrent-master.opt
@@ -0,0 +1 @@
+--innodb_locks_unsafe_for_binlog
diff --git a/mysql-test/t/innodb_concurrent.test b/mysql-test/t/innodb_concurrent.test
new file mode 100644
index 00000000000..957276a44c7
--- /dev/null
+++ b/mysql-test/t/innodb_concurrent.test
@@ -0,0 +1,346 @@
+#
+# Concurrent InnoDB tests, mainly in UPDATE's
+# Bug#3300
+# Designed and tested by Sinisa Milivojevic, sinisa@mysql.com
+#
+# two non-interfering UPDATE's not changing result set
+#
+
+# test takes circa 5 minutes to run, so it's big
+-- source include/big_test.inc
+
+connection default;
+drop table if exists t1;
+create table t1(eta int(11) not null, tipo int(11), c varchar(255)) engine=innodb;
+connect (thread1, localhost, mysqltest,,);
+connection thread1;
+insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
+insert into t1 values (8,8, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
+insert into t1 values (10,1,"ccccccccccccccccccccccccccccccccccccccccccc");
+insert into t1 values (20,2,"ddddddddddddddddddddddddddddddddddddddddddd");
+insert into t1 values (30,1,"eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee");
+insert into t1 values (40,2,"fffffffffffffffffffffffffffffffffffffffffff");
+insert into t1 values (50,1,"ggggggggggggggggggggggggggggggggggggggggggg");
+insert into t1 values (60,2,"hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh");
+insert into t1 values (70,1,"iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii");
+insert into t1 values (80,22,"jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj");
+insert into t1 values (90,11,"kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk");
+select get_lock("hello",1);
+connect (thread2, localhost, mysqltest,,);
+connection thread2;
+begin;
+send update t1 set eta=1+get_lock("hello",1)*0 where tipo=11;
+sleep 1;
+connection thread1;
+begin;
+update t1 set eta=2 where tipo=22;
+select release_lock("hello");
+select * from t1;
+connection thread2;
+reap;
+select * from t1;
+send commit;
+connection thread1;
+select * from t1;
+commit;
+select * from t1;
+connection thread2;
+reap;
+select * from t1;
+connection thread1;
+select * from t1;
+connection default;
+drop table t1;
+
+#
+# two UPDATE's running and one changing result set
+#
+#connect (thread1, localhost, mysqltest,,);
+connection thread1;
+create table t1(eta int(11) not null, tipo int(11), c varchar(255)) engine=innodb;
+insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
+insert into t1 values (8,8, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
+insert into t1 values (10,1,"ccccccccccccccccccccccccccccccccccccccccccc");
+insert into t1 values (20,2,"ddddddddddddddddddddddddddddddddddddddddddd");
+insert into t1 values (30,1,"eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee");
+insert into t1 values (40,2,"fffffffffffffffffffffffffffffffffffffffffff");
+insert into t1 values (50,1,"ggggggggggggggggggggggggggggggggggggggggggg");
+insert into t1 values (60,2,"hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh");
+insert into t1 values (70,1,"iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii");
+insert into t1 values (80,22,"jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj");
+insert into t1 values (90,11,"kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk");
+select get_lock("hello",10);
+#connect (thread2, localhost, mysqltest,,);
+connection thread2;
+begin;
+send update t1 set eta=1+get_lock("hello",10)*0 where tipo=1;
+sleep 1;
+connection thread1;
+begin;
+update t1 set tipo=1 where tipo=2;
+select release_lock("hello");
+select * from t1;
+connection thread2;
+reap;
+select * from t1;
+send commit;
+connection thread1;
+select * from t1;
+commit;
+select * from t1;
+connection thread2;
+reap;
+select * from t1;
+connection thread1;
+select * from t1;
+connection default;
+drop table t1;
+
+
+#
+# One UPDATE and one INSERT .... Monty's test
+#
+
+#connect (thread1, localhost, mysqltest,,);
+connection thread1;
+create table t1 (a int not null, b int not null) engine=innodb;
+insert into t1 values (1,1),(2,1),(3,1),(4,1);
+select get_lock("hello2",1000);
+#connect (thread2, localhost, mysqltest,,);
+connection thread2;
+begin;
+send update t1 set b=10+get_lock(concat("hello",a),1000)*0 where
+a=2;
+sleep 1;
+connection thread1;
+insert into t1 values (1,1);
+select release_lock("hello2");
+select * from t1;
+connection thread2;
+reap;
+select * from t1;
+send commit;
+connection thread1;
+sleep 1;
+connection thread2;
+reap;
+connection default;
+drop table t1;
+
+#
+# one UPDATE changing result set and SELECT ... FOR UPDATE
+#
+#connect (thread1, localhost, mysqltest,,);
+connection thread1;
+create table t1(eta int(11) not null, tipo int(11), c varchar(255)) engine=innodb;
+insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
+insert into t1 values (8,8, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
+insert into t1 values (10,1,"ccccccccccccccccccccccccccccccccccccccccccc");
+insert into t1 values (20,2,"ddddddddddddddddddddddddddddddddddddddddddd");
+insert into t1 values (30,1,"eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee");
+insert into t1 values (40,2,"fffffffffffffffffffffffffffffffffffffffffff");
+insert into t1 values (50,1,"ggggggggggggggggggggggggggggggggggggggggggg");
+insert into t1 values (60,2,"hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh");
+insert into t1 values (70,1,"iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii");
+insert into t1 values (80,22,"jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj");
+insert into t1 values (90,11,"kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk");
+select get_lock("hello",10);
+#connect (thread2, localhost, mysqltest,,);
+connection thread2;
+begin;
+send select * from t1 where tipo=2 FOR UPDATE;
+sleep 1;
+connection thread1;
+begin;
+select release_lock("hello");
+--error 1205
+update t1 set tipo=1+get_lock("hello",10)*0 where tipo=2;
+select * from t1;
+connection thread2;
+reap;
+select * from t1;
+send commit;
+connection thread1;
+commit;
+connection thread2;
+reap;
+select * from t1;
+connection thread1;
+select * from t1;
+connection default;
+drop table t1;
+
+#
+# one UPDATE not changing result set and SELECT ... FOR UPDATE
+#
+#connect (thread1, localhost, mysqltest,,);
+connection thread1;
+create table t1(eta int(11) not null, tipo int(11), c varchar(255)) engine=innodb;
+insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
+insert into t1 values (8,8, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
+insert into t1 values (10,1,"ccccccccccccccccccccccccccccccccccccccccccc");
+insert into t1 values (20,2,"ddddddddddddddddddddddddddddddddddddddddddd");
+insert into t1 values (30,1,"eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee");
+insert into t1 values (40,2,"fffffffffffffffffffffffffffffffffffffffffff");
+insert into t1 values (50,1,"ggggggggggggggggggggggggggggggggggggggggggg");
+insert into t1 values (60,2,"hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh");
+insert into t1 values (70,1,"iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii");
+insert into t1 values (80,22,"jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj");
+insert into t1 values (90,11,"kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk");
+select get_lock("hello",10);
+#connect (thread2, localhost, mysqltest,,);
+connection thread2;
+begin;
+send select * from t1 where tipo=2 FOR UPDATE;
+sleep 1;
+connection thread1;
+begin;
+select release_lock("hello");
+--error 1205
+update t1 set tipo=11+get_lock("hello",10)*0 where tipo=22;
+select * from t1;
+connection thread2;
+reap;
+select * from t1;
+send commit;
+connection thread1;
+commit;
+connection thread2;
+reap;
+select * from t1;
+connection thread1;
+select * from t1;
+connection default;
+drop table t1;
+
+#
+# two SELECT ... FOR UPDATE
+#
+#connect (thread1, localhost, mysqltest,,);
+connection thread1;
+create table t1(eta int(11) not null, tipo int(11), c varchar(255)) engine=innodb;
+insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
+insert into t1 values (8,8, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
+insert into t1 values (10,1,"ccccccccccccccccccccccccccccccccccccccccccc");
+insert into t1 values (20,2,"ddddddddddddddddddddddddddddddddddddddddddd");
+insert into t1 values (30,1,"eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee");
+insert into t1 values (40,2,"fffffffffffffffffffffffffffffffffffffffffff");
+insert into t1 values (50,1,"ggggggggggggggggggggggggggggggggggggggggggg");
+insert into t1 values (60,2,"hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh");
+insert into t1 values (70,1,"iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii");
+insert into t1 values (80,22,"jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj");
+insert into t1 values (90,11,"kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk");
+select get_lock("hello",10);
+#connect (thread2, localhost, mysqltest,,);
+connection thread2;
+begin;
+send select * from t1 where tipo=2 FOR UPDATE;
+sleep 1;
+connection thread1;
+begin;
+select release_lock("hello");
+--error 1205
+select * from t1 where tipo=1 FOR UPDATE;
+connection thread2;
+reap;
+select * from t1;
+send commit;
+connection thread1;
+commit;
+connection thread2;
+reap;
+select * from t1;
+connection thread1;
+select * from t1;
+connection default;
+drop table t1;
+
+
+#
+# one UPDATE changing result set and DELETE
+#
+#connect (thread1, localhost, mysqltest,,);
+connection thread1;
+create table t1(eta int(11) not null, tipo int(11), c varchar(255)) engine=innodb;
+insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
+insert into t1 values (8,8, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
+insert into t1 values (10,1,"ccccccccccccccccccccccccccccccccccccccccccc");
+insert into t1 values (20,2,"ddddddddddddddddddddddddddddddddddddddddddd");
+insert into t1 values (30,1,"eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee");
+insert into t1 values (40,2,"fffffffffffffffffffffffffffffffffffffffffff");
+insert into t1 values (50,1,"ggggggggggggggggggggggggggggggggggggggggggg");
+insert into t1 values (60,2,"hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh");
+insert into t1 values (70,1,"iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii");
+insert into t1 values (80,22,"jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj");
+insert into t1 values (90,11,"kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk");
+select get_lock("hello",10);
+#connect (thread2, localhost, mysqltest,,);
+connection thread2;
+begin;
+send delete from t1 where tipo=2;
+sleep 1;
+connection thread1;
+begin;
+select release_lock("hello");
+--error 1205
+update t1 set tipo=1+get_lock("hello",10)*0 where tipo=2;
+select * from t1;
+connection thread2;
+reap;
+select * from t1;
+send commit;
+connection thread1;
+commit;
+connection thread2;
+reap;
+select * from t1;
+connection thread1;
+select * from t1;
+connection default;
+drop table t1;
+
+
+#
+# one UPDATE not changing result set and DELETE
+#
+#connect (thread1, localhost, mysqltest,,);
+connection thread1;
+create table t1(eta int(11) not null, tipo int(11), c varchar(255)) engine=innodb;
+insert into t1 values (7,7, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
+insert into t1 values (8,8, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
+insert into t1 values (10,1,"ccccccccccccccccccccccccccccccccccccccccccc");
+insert into t1 values (20,2,"ddddddddddddddddddddddddddddddddddddddddddd");
+insert into t1 values (30,1,"eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee");
+insert into t1 values (40,2,"fffffffffffffffffffffffffffffffffffffffffff");
+insert into t1 values (50,1,"ggggggggggggggggggggggggggggggggggggggggggg");
+insert into t1 values (60,2,"hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh");
+insert into t1 values (70,1,"iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii");
+insert into t1 values (80,22,"jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj");
+insert into t1 values (90,11,"kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk");
+select get_lock("hello",10);
+#connect (thread2, localhost, mysqltest,,);
+connection thread2;
+begin;
+send delete from t1 where tipo=2;
+sleep 1;
+connection thread1;
+begin;
+select release_lock("hello");
+update t1 set tipo=1+get_lock("hello",10)*0 where tipo=22;
+select * from t1;
+connection thread2;
+reap;
+select * from t1;
+send commit;
+connection thread1;
+commit;
+connection thread2;
+reap;
+select * from t1;
+connection thread1;
+select * from t1;
+connection default;
+sleep 1;
+drop table t1;
+disconnect thread1;
+disconnect thread2;
diff --git a/mysql-test/t/innodb_unsafe_binlog-master.opt b/mysql-test/t/innodb_unsafe_binlog-master.opt
index 5c0136b5db3..9581c225d6d 100644
--- a/mysql-test/t/innodb_unsafe_binlog-master.opt
+++ b/mysql-test/t/innodb_unsafe_binlog-master.opt
@@ -1 +1 @@
---loose-innodb_locks_unsafe_for_binlog=true
+--innodb_locks_unsafe_for_binlog=true --innodb_lock_wait_timeout=1
diff --git a/mysql-test/t/innodb_unsafe_binlog.test b/mysql-test/t/innodb_unsafe_binlog.test
index fa240eb7608..af1091e4421 100644
--- a/mysql-test/t/innodb_unsafe_binlog.test
+++ b/mysql-test/t/innodb_unsafe_binlog.test
@@ -1,8 +1,11 @@
-- source include/have_innodb.inc
#
-# Note that these tests uses a innodb_locks_unsafe_for_binlog option.
+# Note that these tests uses options
+# innodb_locks_unsafe_for_binlog = true
+# innodb_lock_timeout = 5
+
#
-# Test cases for a bug #15650 DELETE with LEFT JOIN crashes server
+# Test cases for a bug #15650
#
--disable_warnings
@@ -23,19 +26,6 @@ select ml.* from t1 as ml left join t2 as mm on (mm.id=ml.id)
where mm.id is null lock in share mode;
drop table t1,t2;
-create table t1 (id int not null, f_id int not null, f int not null,
-primary key(id),key(f_id)) engine=innodb;
-create table t2 (id int not null,s_id int not null,s varchar(200),
-primary key(id),key(s_id)) engine=innodb;
-INSERT INTO t1 VALUES (8, 1, 3);
-INSERT INTO t1 VALUES (1, 2, 1);
-INSERT INTO t2 VALUES (1, 0, '');
-INSERT INTO t2 VALUES (8, 1, '');
-commit;
-delete ml.* from t1 as ml left join t2 as mm on (mm.s_id=ml.f_id) where mm.s is null;
-select ml.* from t1 as ml left join t2 as mm on (mm.s_id=ml.f_id) where mm.s is null lock in share mode;
-drop table t1,t2;
-
#
# Test case for unlock row bug where unlock releases all locks granted for
# a row. Only the latest lock should be released.
@@ -45,7 +35,7 @@ connect (a,localhost,root,,);
connect (b,localhost,root,,);
connection a;
create table t1(a int not null, b int, primary key(a)) engine=innodb;
-insert into t1 values(1,1),(2,2),(3,1),(4,2),(5,1),(6,2);
+insert into t1 values(1,1),(2,2),(3,1),(4,2),(5,1),(6,2),(7,3);
commit;
set autocommit = 0;
select * from t1 lock in share mode;
@@ -62,6 +52,197 @@ commit;
connection b;
commit;
drop table t1;
+connection default;
+disconnect a;
+disconnect b;
+
+#
+# unlock row test
+#
+
+connect (a,localhost,root,,);
+connect (b,localhost,root,,);
+connection a;
+create table t1(a int not null, b int, primary key(a)) engine=innodb;
+insert into t1 values(1,1),(2,2),(3,1),(4,2),(5,1),(6,2),(7,3);
+commit;
+set autocommit = 0;
+update t1 set b = 5 where b = 1;
+connection b;
+set autocommit = 0;
+#
+# X-lock to record (7,3) should be released in a update
+#
+select * from t1 where a = 7 and b = 3 for update;
+commit;
+connection a;
+commit;
+drop table t1;
+connection default;
disconnect a;
disconnect b;
+
+#
+# Consistent read should be used in following selects
+#
+# 1) INSERT INTO ... SELECT
+# 2) UPDATE ... = ( SELECT ...)
+# 3) CREATE ... SELECT
+
+connect (a,localhost,root,,);
+connect (b,localhost,root,,);
+connection a;
+create table t1(a int not null, b int, primary key(a)) engine=innodb;
+insert into t1 values (1,2),(5,3),(4,2);
+create table t2(d int not null, e int, primary key(d)) engine=innodb;
+insert into t2 values (8,6),(12,1),(3,1);
+commit;
+set autocommit = 0;
+select * from t2 for update;
+connection b;
+set autocommit = 0;
+insert into t1 select * from t2;
+update t1 set b = (select e from t2 where a = d);
+create table t3(d int not null, e int, primary key(d)) engine=innodb
+select * from t2;
+commit;
+connection a;
+commit;
+connection default;
+disconnect a;
+disconnect b;
+drop table t1, t2, t3;
+
+#
+# Consistent read should not be used if
+#
+# (a) isolation level is serializable OR
+# (b) select ... lock in share mode OR
+# (c) select ... for update
+#
+# in following queries:
+#
+# 1) INSERT INTO ... SELECT
+# 2) UPDATE ... = ( SELECT ...)
+# 3) CREATE ... SELECT
+
+connect (a,localhost,root,,);
+connect (b,localhost,root,,);
+connect (c,localhost,root,,);
+connect (d,localhost,root,,);
+connect (e,localhost,root,,);
+connect (f,localhost,root,,);
+connect (g,localhost,root,,);
+connect (h,localhost,root,,);
+connect (i,localhost,root,,);
+connect (j,localhost,root,,);
+connection a;
+create table t1(a int not null, b int, primary key(a)) engine=innodb;
+insert into t1 values (1,2),(5,3),(4,2);
+create table t2(a int not null, b int, primary key(a)) engine=innodb;
+insert into t2 values (8,6),(12,1),(3,1);
+create table t3(d int not null, b int, primary key(d)) engine=innodb;
+insert into t3 values (8,6),(12,1),(3,1);
+create table t5(a int not null, b int, primary key(a)) engine=innodb;
+insert into t5 values (1,2),(5,3),(4,2);
+create table t6(d int not null, e int, primary key(d)) engine=innodb;
+insert into t6 values (8,6),(12,1),(3,1);
+create table t8(a int not null, b int, primary key(a)) engine=innodb;
+insert into t8 values (1,2),(5,3),(4,2);
+create table t9(d int not null, e int, primary key(d)) engine=innodb;
+insert into t9 values (8,6),(12,1),(3,1);
+commit;
+set autocommit = 0;
+select * from t2 for update;
+connection b;
+set autocommit = 0;
+SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
+--send
+insert into t1 select * from t2;
+connection c;
+set autocommit = 0;
+SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
+--send
+update t3 set b = (select b from t2 where a = d);
+connection d;
+set autocommit = 0;
+SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
+--send
+create table t4(a int not null, b int, primary key(a)) engine=innodb select * from t2;
+connection e;
+set autocommit = 0;
+--send
+insert into t5 (select * from t2 lock in share mode);
+connection f;
+set autocommit = 0;
+--send
+update t6 set e = (select b from t2 where a = d lock in share mode);
+connection g;
+set autocommit = 0;
+--send
+create table t7(a int not null, b int, primary key(a)) engine=innodb select * from t2 lock in share mode;
+connection h;
+set autocommit = 0;
+--send
+insert into t8 (select * from t2 for update);
+connection i;
+set autocommit = 0;
+--send
+update t9 set e = (select b from t2 where a = d for update);
+connection j;
+set autocommit = 0;
+--send
+create table t10(a int not null, b int, primary key(a)) engine=innodb select * from t2 for update;
+
+connection b;
+--error 1205
+reap;
+
+connection c;
+--error 1205
+reap;
+
+connection d;
+--error 1205
+reap;
+
+connection e;
+--error 1205
+reap;
+
+connection f;
+--error 1205
+reap;
+
+connection g;
+--error 1205
+reap;
+
+connection h;
+--error 1205
+reap;
+
+connection i;
+--error 1205
+reap;
+
+connection j;
+--error 1205
+reap;
+
+connection a;
+commit;
+
+connection default;
+disconnect a;
+disconnect b;
+disconnect c;
+disconnect d;
+disconnect e;
+disconnect f;
+disconnect g;
+disconnect h;
+disconnect i;
+disconnect j;
+drop table t1, t2, t3, t5, t6, t8, t9;
diff --git a/mysql-test/t/insert.test b/mysql-test/t/insert.test
index 0c64dd80bec..f3dd8e7e199 100644
--- a/mysql-test/t/insert.test
+++ b/mysql-test/t/insert.test
@@ -176,14 +176,3 @@ insert into t2 select t1.* from t1, t2 t, t3 where t1.id1 = t.id2 and t.id2 =
select count(*) from t2;
drop table t1,t2,t3;
-#
-# Test for INSERT DELAYED INTO a <view>
-# BUG#13683: INSERT DELAYED into a view creates an infinite loop
-#
-
-create table t1 (n int);
-create view v1 as select * from t1;
---error 1347
-insert delayed into v1 values (1);
-drop table t1;
-drop view v1;
diff --git a/mysql-test/t/insert_select-binlog.test b/mysql-test/t/insert_select-binlog.test
deleted file mode 100644
index d4041f86ab5..00000000000
--- a/mysql-test/t/insert_select-binlog.test
+++ /dev/null
@@ -1,35 +0,0 @@
-# Embedded server doesn't support binlog
--- source include/not_embedded.inc
-
-# Check if a partly-completed INSERT SELECT in a MyISAM table goes into the
-# binlog
-
-create table t1(a int, unique(a));
-insert into t1 values(2);
-create table t2(a int);
-insert into t2 values(1),(2);
-reset master;
---error 1062
-insert into t1 select * from t2;
-# The above should produce an error, but still be in the binlog;
-# verify the binlog :
-let $VERSION=`select version()`;
---replace_result $VERSION VERSION
-show binlog events;
-select * from t1;
-drop table t1, t2;
-
-# Verify that a partly-completed CREATE TABLE .. SELECT does not
-# get into the binlog (Bug #6682)
-create table t1(a int);
-insert into t1 values(1),(1);
-reset master;
---error 1062
-create table t2(unique(a)) select a from t1;
-# The above should produce an error, *and* not appear in the binlog
-let $VERSION=`select version()`;
---replace_result $VERSION VERSION
-show binlog events;
-drop table t1;
-
-# End of 4.1 tests
diff --git a/mysql-test/t/key.test b/mysql-test/t/key.test
index 31763b84379..f95cee8e8eb 100644
--- a/mysql-test/t/key.test
+++ b/mysql-test/t/key.test
@@ -372,3 +372,61 @@ desc t1;
drop table t1;
# End of 4.1 tests
+
+#
+# WL#1563 - Modify MySQL to support on-line CREATE/DROP INDEX
+# To test if this really works, you need to run with --debug
+# and check the trace file.
+#
+# Create a table with named and unnamed indexes.
+create table t1 (
+ c1 int,
+ c2 char(12),
+ c3 varchar(123),
+ c4 timestamp,
+ index (c1),
+ index i1 (c1),
+ index i2 (c2),
+ index i3 (c3),
+ unique i4 (c4),
+ index i5 (c1, c2, c3, c4),
+ primary key (c2, c3),
+ index (c2, c4));
+show create table t1;
+# Some simple tests.
+alter table t1 drop index c1;
+alter table t1 add index (c1);
+# This creates index 'c1_2'.
+alter table t1 add index (c1);
+alter table t1 drop index i3;
+alter table t1 add index i3 (c3);
+# Two indexes at the same time.
+alter table t1 drop index i2, drop index i4;
+alter table t1 add index i2 (c2), add index i4 (c4);
+# Three indexes, one of them reversely.
+alter table t1 drop index i2, drop index i4, add index i6 (c2, c4);
+alter table t1 add index i2 (c2), add index i4 (c4), drop index i6;
+# include an unique index.
+alter table t1 drop index i2, drop index i4, add unique i4 (c4);
+alter table t1 add index i2 (c2), drop index i4, add index i4 (c4);
+# Modify an index by changing its definition.
+alter table t1 drop index c2, add index (c2(4),c3(7));
+# Change nothing. The new key definition is the same as the old one.
+alter table t1 drop index c2, add index (c2(4),c3(7));
+# Test primary key handling.
+alter table t1 add primary key (c1, c2), drop primary key;
+alter table t1 drop primary key;
+# Drop is checked first. Primary key must exist.
+--error 1091
+alter table t1 add primary key (c1, c2), drop primary key;
+show create table t1;
+# Insert non-unique values.
+insert into t1 values(1, 'a', 'a', NULL);
+insert into t1 values(1, 'b', 'b', NULL);
+# Drop some indexes for new adds.
+alter table t1 drop index i3, drop index i2, drop index i1;
+# Add indexes, one is unique on non-unique values.
+--error 1062
+alter table t1 add index i3 (c3), add index i2 (c2), add unique index i1 (c1);
+drop table t1;
+
diff --git a/mysql-test/t/loaddata.test b/mysql-test/t/loaddata.test
index 27c8005ca0c..fcd127e3e98 100644
--- a/mysql-test/t/loaddata.test
+++ b/mysql-test/t/loaddata.test
@@ -114,3 +114,27 @@ select * from t1;
drop table t1, t2;
# End of 5.0 tests
+
+
+#
+# Bug#12448 LOAD DATA / SELECT INTO OUTFILE
+# doesn't work with multibyte path name
+#
+CREATE TABLE t1 (a int);
+INSERT INTO t1 VALUES (1);
+SET NAMES latin1;
+SET character_set_filesystem=filename;
+select @@character_set_filesystem;
+SELECT * INTO OUTFILE 't-1' FROM t1;
+DELETE FROM t1;
+LOAD DATA INFILE 't-1' INTO TABLE t1;
+SELECT * FROM t1;
+DELETE FROM t1;
+SET character_set_filesystem=latin1;
+select @@character_set_filesystem;
+LOAD DATA INFILE 't@002d1' INTO TABLE t1;
+SELECT * FROM t1;
+DROP TABLE t1;
+--exec rm $MYSQLTEST_VARDIR/master-data/test/t@002d1
+SET character_set_filesystem=default;
+select @@character_set_filesystem;
diff --git a/mysql-test/t/lock_multi.test b/mysql-test/t/lock_multi.test
index 3c829848bf3..a24ee8be64e 100644
--- a/mysql-test/t/lock_multi.test
+++ b/mysql-test/t/lock_multi.test
@@ -95,6 +95,25 @@ reap;
connection locker;
drop table t1;
+#
+# Same test as above, but with the dropped table locked twice
+#
+
+connection locker;
+create table t1 (a int);
+create table t2 (a int);
+lock table t1 write, t2 write, t1 as t1_2 write, t2 as t2_2 write;
+connection reader;
+send insert t1 select * from t2;
+connection locker;
+drop table t2;
+connection reader;
+--error 1146
+reap;
+connection locker;
+drop table t1;
+
+
# End of 4.1 tests
#
diff --git a/mysql-test/t/log_tables-master.opt b/mysql-test/t/log_tables-master.opt
new file mode 100644
index 00000000000..35ff7911705
--- /dev/null
+++ b/mysql-test/t/log_tables-master.opt
@@ -0,0 +1 @@
+--log-slow-queries
diff --git a/mysql-test/t/log_tables.test b/mysql-test/t/log_tables.test
new file mode 100644
index 00000000000..5b79e5e4625
--- /dev/null
+++ b/mysql-test/t/log_tables.test
@@ -0,0 +1,178 @@
+# this test needs multithreaded mysqltest
+-- source include/not_embedded.inc
+#
+# Basic log tables test
+#
+
+# check that CSV engine was compiled in
+--source include/have_csv.inc
+
+--disable_ps_protocol
+use mysql;
+
+#
+# Check that log tables work and we can do basic selects. This also
+# tests truncate, which works in a special mode with the log tables
+#
+
+truncate table general_log;
+--replace_column 1 TIMESTAMP 2 USER_HOST 3 THREAD_ID
+select * from general_log;
+truncate table slow_log;
+--replace_column 1 TIMESTAMP 2 USER_HOST
+select * from slow_log;
+
+#
+# We want to check that a record newly written to a log table shows up for
+# the query: since log tables use concurrent insert machinery and log tables
+# are always locked by artificial THD, this feature requires additional
+# check in ha_tina::write_row. This simple test should prove that the
+# log table flag in the table handler is triggered and working.
+#
+
+truncate table general_log;
+--replace_column 1 TIMESTAMP 2 USER_HOST 3 THREAD_ID
+select * from general_log where argument like '%general_log%';
+
+
+#
+# Check some basic queries interfering with the log tables.
+# In our test we'll use a tbale with verbose comments to the short
+# command type names, used in the tables
+#
+
+create table join_test (verbose_comment varchar (80), command_type varchar(64));
+
+insert into join_test values ("User performed a usual SQL query", "Query");
+insert into join_test values ("New DB connection was registered", "Connect");
+insert into join_test values ("Get the table info", "Field List");
+
+--replace_column 2 USER_HOST
+select verbose_comment, user_host, argument
+ from mysql.general_log join join_test
+ on (mysql.general_log.command_type = join_test.command_type);
+
+drop table join_test;
+
+#
+# check that flush of the log table work fine
+#
+
+flush logs;
+
+#
+# check locking of the log tables
+#
+
+--error ER_CANT_WRITE_LOCK_LOG_TABLE
+lock tables mysql.general_log WRITE;
+
+--error ER_CANT_WRITE_LOCK_LOG_TABLE
+lock tables mysql.slow_log WRITE;
+
+#
+# This attemts to get TL_READ_NO_INSERT lock, which is incompatible with
+# TL_WRITE_CONCURRENT_INSERT. This should fail. We issue this error as log
+# tables are always opened and locked by the logger.
+#
+
+--error ER_CANT_READ_LOCK_LOG_TABLE
+lock tables mysql.general_log READ;
+
+--error ER_CANT_READ_LOCK_LOG_TABLE
+lock tables mysql.slow_log READ;
+
+#
+# This call should result in TL_READ lock on the log table. This is ok and
+# should pass.
+#
+
+lock tables mysql.slow_log READ LOCAL, mysql.general_log READ LOCAL;
+
+unlock tables;
+
+#
+# check that FLUSH LOGS waits for all readers of the log table to vanish
+#
+
+connect (con1,localhost,root,,);
+connect (con2,localhost,root,,);
+
+connection con1;
+
+lock tables mysql.general_log READ LOCAL;
+
+connection con2;
+
+# this should wait for log tables to unlock
+send flush logs;
+
+connection con1;
+
+unlock tables;
+
+# this connection should be alive by the time
+connection con2;
+
+reap;
+
+select "Mark that we woke up from flush logs in the test"
+ as "test passed";
+
+#
+# perform the same check for TRUNCATE: it should also wait for readers
+# to disappear
+#
+
+connection con1;
+
+lock tables mysql.general_log READ LOCAL;
+
+connection con2;
+
+# this should wait for log tables to unlock
+send truncate mysql.general_log;
+
+connection con1;
+
+unlock tables;
+
+# this connection should be alive by the time
+connection con2;
+
+reap;
+
+select "Mark that we woke up from TRUNCATE in the test"
+ as "test passed";
+
+connection con1;
+
+use test;
+
+#
+# Bug #16905 Log tables: unicode statements are logged incorrectly
+#
+
+truncate table mysql.general_log;
+set names utf8;
+create table bug16905 (s char(15) character set utf8 default 'пусто');
+insert into bug16905 values ('новое');
+--replace_column 1 TIMESTAMP 2 USER_HOST 3 THREAD_ID
+select * from mysql.general_log;
+drop table bug16905;
+
+#
+# Bug #17600: Invalid data logged into mysql.slow_log
+#
+
+truncate table mysql.slow_log;
+set session long_query_time=1;
+select sleep(2);
+--replace_column 1 TIMESTAMP 2 USER_HOST 3 QUERY_TIME
+select * from mysql.slow_log;
+
+# kill all connections
+disconnect con1;
+disconnect con2;
+--enable_ps_protocol
+
diff --git a/mysql-test/t/merge.test b/mysql-test/t/merge.test
index 7ea14a811ed..9fee4a03b81 100644
--- a/mysql-test/t/merge.test
+++ b/mysql-test/t/merge.test
@@ -51,6 +51,9 @@ create table t4 (a int not null, b char(10), key(a)) engine=MERGE UNION=(t1,t2);
select * from t4;
--error 1168
alter table t4 add column c int;
+flush tables;
+--error 1168
+select * from t4;
#
# Test tables in different databases
diff --git a/mysql-test/t/mix_innodb_myisam_binlog.test b/mysql-test/t/mix_innodb_myisam_binlog.test
deleted file mode 100644
index 66440f1236e..00000000000
--- a/mysql-test/t/mix_innodb_myisam_binlog.test
+++ /dev/null
@@ -1,295 +0,0 @@
-# Check that binlog is ok when a transaction mixes updates to InnoDB and
-# MyISAM.
-# It would be nice to make this a replication test, but in 4.0 the
-# slave is always with --skip-innodb in the testsuite. I (Guilhem) however
-# did some tests manually on a slave; tables are replicated fine and
-# Exec_Master_Log_Pos advances as expected.
-
-# Embedded server doesn't support binlogging
--- source include/not_embedded.inc
-
--- source include/have_innodb.inc
-
---disable_warnings
-drop table if exists t1, t2;
---enable_warnings
-
-connect (con1,localhost,root,,);
-connect (con2,localhost,root,,);
-
-connection con1;
-create table t1 (a int) engine=innodb;
-create table t2 (a int) engine=myisam;
-
-reset master;
-
-begin;
-insert into t1 values(1);
-insert into t2 select * from t1;
-commit;
-
---replace_column 5 #
---replace_result "xid=15" "xid=8"
-show binlog events from 98;
-
-delete from t1;
-delete from t2;
-reset master;
-
-begin;
-insert into t1 values(2);
-insert into t2 select * from t1;
-# should say some changes to non-transact1onal tables couldn't be rolled back
-rollback;
-
---replace_column 5 #
-show binlog events from 98;
-
-delete from t1;
-delete from t2;
-reset master;
-
-begin;
-insert into t1 values(3);
-savepoint my_savepoint;
-insert into t1 values(4);
-insert into t2 select * from t1;
-rollback to savepoint my_savepoint;
-commit;
-
---replace_column 5 #
---replace_result "xid=48" "xid=25"
-show binlog events from 98;
-
-delete from t1;
-delete from t2;
-reset master;
-
-begin;
-insert into t1 values(5);
-savepoint my_savepoint;
-insert into t1 values(6);
-insert into t2 select * from t1;
-rollback to savepoint my_savepoint;
-insert into t1 values(7);
-commit;
-select a from t1 order by a; # check that savepoints work :)
-
---replace_column 5 #
---replace_result "xid=70" "xid=37"
-show binlog events from 98;
-
-# and when ROLLBACK is not explicit?
-delete from t1;
-delete from t2;
-reset master;
-
-select get_lock("a",10);
-begin;
-insert into t1 values(8);
-insert into t2 select * from t1;
-disconnect con1;
-
-connection con2;
-# We want to SHOW BINLOG EVENTS, to know what was logged. But there is no
-# guarantee that logging of the terminated con1 has been done yet (it may not
-# even be started, so con1 may have not even attempted to lock the binlog yet;
-# so SHOW BINLOG EVENTS may come before con1 does the loggin. To be sure that
-# logging has been done, we use a user lock.
-select get_lock("a",10);
---replace_column 5 #
-show binlog events from 98;
-
-# and when not in a transact1on?
-delete from t1;
-delete from t2;
-reset master;
-
-insert into t1 values(9);
-insert into t2 select * from t1;
-
---replace_column 5 #
---replace_result "xid=119" "xid=60"
-show binlog events from 98;
-
-# Check that when the query updat1ng the MyISAM table is the first in the
-# transaction, we log it immediately.
-delete from t1;
-delete from t2;
-reset master;
-
-insert into t1 values(10); # first make t1 non-empty
-begin;
-insert into t2 select * from t1;
---replace_column 5 #
---replace_result "xid=133" "xid=66"
-show binlog events from 98;
-insert into t1 values(11);
-commit;
-
---replace_column 5 #
---replace_result "xid=133" "xid=66" "xid=136" "xid=68"
-show binlog events from 98;
-
-
-# Check that things work like before this BEGIN/ROLLBACK code was added,
-# when t2 is INNODB
-
-alter table t2 engine=INNODB;
-
-delete from t1;
-delete from t2;
-reset master;
-
-begin;
-insert into t1 values(12);
-insert into t2 select * from t1;
-commit;
-
---replace_column 5 #
---replace_result "xid=155" "xid=78"
-show binlog events from 98;
-
-delete from t1;
-delete from t2;
-reset master;
-
-begin;
-insert into t1 values(13);
-insert into t2 select * from t1;
-rollback;
-
---replace_column 5 #
-show binlog events from 98;
-
-delete from t1;
-delete from t2;
-reset master;
-
-begin;
-insert into t1 values(14);
-savepoint my_savepoint;
-insert into t1 values(15);
-insert into t2 select * from t1;
-rollback to savepoint my_savepoint;
-commit;
-
---replace_column 5 #
---replace_result "xid=187" "xid=94"
-show binlog events from 98;
-
-delete from t1;
-delete from t2;
-reset master;
-
-begin;
-insert into t1 values(16);
-savepoint my_savepoint;
-insert into t1 values(17);
-insert into t2 select * from t1;
-rollback to savepoint my_savepoint;
-insert into t1 values(18);
-commit;
-select a from t1 order by a; # check that savepoints work :)
-
---replace_column 5 #
---replace_result "xid=208" "xid=105"
-show binlog events from 98;
-
-# Test for BUG#5714, where a MyISAM update in the transaction used to
-# release row-level locks in InnoDB
-
-connect (con3,localhost,root,,);
-
-connection con3;
-delete from t1;
-delete from t2;
---disable_warnings
-alter table t2 type=MyISAM;
---enable_warnings
-insert into t1 values (1);
-begin;
-select * from t1 for update;
-
-connection con2;
-select (@before:=unix_timestamp())*0; # always give repeatable output
-begin;
-send select * from t1 for update;
-
-connection con3;
-insert into t2 values (20);
-
-connection con2;
---error 1205
-reap;
-select (@after:=unix_timestamp())*0; # always give repeatable output
-# verify that innodb_lock_wait_timeout was exceeded. When there was
-# the bug, the reap would return immediately after the insert into t2.
-select (@after-@before) >= 2;
-
-drop table t1,t2;
-commit;
-
-# test for BUG#7947 - DO RELEASE_LOCK() not written to binlog on rollback in the middle
-# of a transaction
-
-connection con2;
-begin;
-create temporary table ti (a int) engine=innodb;
-rollback;
-insert into ti values(1);
-set autocommit=0;
-create temporary table t1 (a int) engine=myisam;
-commit;
-insert t1 values (1);
-rollback;
-create table t0 (n int);
-insert t0 select * from t1;
-set autocommit=1;
-insert into t0 select GET_LOCK("lock1",null);
-set autocommit=0;
-create table t2 (n int) engine=innodb;
-insert into t2 values (3);
-disconnect con2;
-connection con3;
-select get_lock("lock1",60);
---replace_column 5 #
---replace_result "xid=208" "xid=105" "xid=227" "xid=114" "xid=230" "xid=115" "xid=234" "xid=117" "xid=261" "xid=132"
-show binlog events from 98;
-do release_lock("lock1");
-drop table t0,t2;
-
-# End of 4.1 tests
-
-# Test for BUG#16559 (ROLLBACK should always have a zero error code in
-# binlog). Has to be here and not earlier, as the SELECTs influence
-# XIDs differently between normal and ps-protocol (and SHOW BINLOG
-# EVENTS above read XIDs).
-
-connect (con4,localhost,root,,);
-connection con3;
-reset master;
-create table t1 (a int) engine=innodb;
-create table t2 (a int) engine=myisam;
-select get_lock("a",10);
-begin;
-insert into t1 values(8);
-insert into t2 select * from t1;
-disconnect con3;
-
-connection con4;
-select get_lock("a",10); # wait for rollback to finish
-
-# we check that the error code of the "ROLLBACK" event is 0 and not
-# ER_SERVER_SHUTDOWN (i.e. disconnection just rolls back transaction
-# and does not make slave to stop)
---exec $MYSQL_BINLOG --start-position=547 $MYSQLTEST_VARDIR/log/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/mix_innodb_myisam_binlog.output
---replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
-eval select
-(@a:=load_file("$MYSQLTEST_VARDIR/tmp/mix_innodb_myisam_binlog.output"))
-is not null;
---replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
-eval select
-@a like "%#%error_code=0%ROLLBACK;%ROLLBACK /* added by mysqlbinlog */;%",
-@a not like "%#%error_code=%error_code=%";
-drop table t1, t2;
diff --git a/mysql-test/t/multi_update.test b/mysql-test/t/multi_update.test
index 5e3be6d45eb..acc816ae921 100644
--- a/mysql-test/t/multi_update.test
+++ b/mysql-test/t/multi_update.test
@@ -495,6 +495,11 @@ delete t1,t2 from t2,t1 where t1.a<'B' and t2.b=t1.b;
drop table t1,t2;
+#
+# Test alter table and a concurrent multi update
+# (This will force update to reopen tables)
+#
+
create table t1 (a int, b int);
insert into t1 values (1, 2), (2, 3), (3, 4);
create table t2 (a int);
@@ -511,6 +516,7 @@ send alter table t1 add column c int default 100 after a;
connect (updater,localhost,root,,test);
connection updater;
+sleep 2;
send update t1, v1 set t1.b=t1.a+t1.b+v1.b where t1.a=v1.a;
connection locker;
diff --git a/mysql-test/t/myisam-system.test b/mysql-test/t/myisam-system.test
new file mode 100644
index 00000000000..43fbaabf698
--- /dev/null
+++ b/mysql-test/t/myisam-system.test
@@ -0,0 +1,21 @@
+#
+# Test how DROP TABLE works if the index or data file doesn't exists
+
+# Initialise
+--disable_warnings
+drop table if exists t1,t2;
+--enable_warnings
+
+create table t1 (a int) engine=myisam;
+system rm $MYSQLTEST_VARDIR/master-data/test/t1.MYI ;
+drop table if exists t1;
+create table t1 (a int) engine=myisam;
+system rm $MYSQLTEST_VARDIR/master-data/test/t1.MYI ;
+--error 1051,6
+drop table t1;
+create table t1 (a int) engine=myisam;
+system rm $MYSQLTEST_VARDIR/master-data/test/t1.MYD ;
+--error 1105,6,29
+drop table t1;
+--error 1051
+drop table t1;
diff --git a/mysql-test/t/myisam.test b/mysql-test/t/myisam.test
index 15533ca00e6..a77537f3ff5 100644
--- a/mysql-test/t/myisam.test
+++ b/mysql-test/t/myisam.test
@@ -727,23 +727,6 @@ create table t1 (v varchar(65535));
eval set storage_engine=$default;
#
-# Test how DROP TABLE works if the index or data file doesn't exists
-
-create table t1 (a int) engine=myisam;
-system rm $MYSQLTEST_VARDIR/master-data/test/t1.MYI ;
-drop table if exists t1;
-create table t1 (a int) engine=myisam;
-system rm $MYSQLTEST_VARDIR/master-data/test/t1.MYI ;
---error 1051,6
-drop table t1;
-create table t1 (a int) engine=myisam;
-system rm $MYSQLTEST_VARDIR/master-data/test/t1.MYD ;
---error 1105,6,29
-drop table t1;
---error 1051
-drop table t1;
-
-#
# Test concurrent insert
# First with static record length
#
@@ -824,3 +807,66 @@ create table t3 (c1 int) engine=myisam pack_keys=default;
create table t4 (c1 int) engine=myisam pack_keys=2;
drop table t1, t2, t3;
+#
+# Test of key_block_size
+#
+
+create table t1 (a int not null, key `a` (a) key_block_size=1024);
+show create table t1;
+drop table t1;
+
+create table t1 (a int not null, key `a` (a) key_block_size=2048);
+show create table t1;
+drop table t1;
+
+create table t1 (a varchar(2048), key `a` (a));
+show create table t1;
+drop table t1;
+
+create table t1 (a varchar(2048), key `a` (a) key_block_size=1024);
+show create table t1;
+drop table t1;
+
+create table t1 (a int not null, b varchar(2048), key (a), key(b)) key_block_size=1024;
+show create table t1;
+alter table t1 key_block_size=2048;
+show create table t1;
+alter table t1 add c int, add key (c);
+show create table t1;
+alter table t1 key_block_size=0;
+alter table t1 add d int, add key (d);
+show create table t1;
+drop table t1;
+
+create table t1 (a int not null, b varchar(2048), key (a), key(b)) key_block_size=8192;
+show create table t1;
+drop table t1;
+
+create table t1 (a int not null, b varchar(2048), key (a) key_block_size=1024, key(b)) key_block_size=8192;
+show create table t1;
+drop table t1;
+
+create table t1 (a int not null, b int, key (a) key_block_size=1024, key(b) key_block_size=8192) key_block_size=16384;
+show create table t1;
+drop table t1;
+
+
+# Test limits and errors of key_block_size
+
+create table t1 (a int not null, key `a` (a) key_block_size=512);
+show create table t1;
+drop table t1;
+
+create table t1 (a varchar(2048), key `a` (a) key_block_size=1000000000000000000);
+show create table t1;
+drop table t1;
+
+create table t1 (a int not null, key `a` (a) key_block_size=1025);
+show create table t1;
+drop table t1;
+
+--error 1064
+create table t1 (a int not null, key key_block_size=1024 (a));
+--error 1064
+create table t1 (a int not null, key `a` key_block_size=1024 (a));
+
diff --git a/mysql-test/t/mysql_client_test-master.opt b/mysql-test/t/mysql_client_test-master.opt
new file mode 100644
index 00000000000..3711946168d
--- /dev/null
+++ b/mysql-test/t/mysql_client_test-master.opt
@@ -0,0 +1 @@
+--log --log-output=FILE
diff --git a/mysql-test/t/mysql_client_test.opt b/mysql-test/t/mysql_client_test.opt
deleted file mode 100644
index 968ba95c6cc..00000000000
--- a/mysql-test/t/mysql_client_test.opt
+++ /dev/null
@@ -1 +0,0 @@
---log
diff --git a/mysql-test/t/mysqlbinlog.test b/mysql-test/t/mysqlbinlog.test
index c2cd15c3f0f..ceba78bf762 100644
--- a/mysql-test/t/mysqlbinlog.test
+++ b/mysql-test/t/mysqlbinlog.test
@@ -1,4 +1,6 @@
# We are using .opt file since we need small binlog size
+# TODO: Need to look at making a row based version once the new row based client is completed. [jbm]
+-- source include/have_binlog_format_statement.inc
# Embedded server doesn't support binlogging
-- source include/not_embedded.inc
@@ -63,7 +65,7 @@ select "--- --database --" as "";
select "--- --position --" as "";
--enable_query_log
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
---exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --position=231 $MYSQLTEST_VARDIR/log/master-bin.000002
+--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --position=235 $MYSQLTEST_VARDIR/log/master-bin.000002
# These are tests for remote binlog.
# They should return the same as previous test.
@@ -95,7 +97,7 @@ select "--- --database --" as "";
select "--- --position --" as "";
--enable_query_log
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
---exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --read-from-remote-server --position=231 --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000002
+--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --read-from-remote-server --position=235 --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
diff --git a/mysql-test/t/mysqlbinlog2.test b/mysql-test/t/mysqlbinlog2.test
index 6afae538f04..91da502da02 100644
--- a/mysql-test/t/mysqlbinlog2.test
+++ b/mysql-test/t/mysqlbinlog2.test
@@ -1,6 +1,9 @@
# Test for the new options --start-datetime, stop-datetime,
# and a few others.
+# TODO: Need to look at making row based version once new binlog client is complete.
+-- source include/have_binlog_format_statement.inc
+
# Embedded server doesn't support binlogging
-- source include/not_embedded.inc
@@ -49,11 +52,11 @@ select "--- offset --" as "";
--disable_query_log
select "--- start-position --" as "";
--enable_query_log
---exec $MYSQL_BINLOG --short-form --start-position=600 $MYSQLTEST_VARDIR/log/master-bin.000001
+--exec $MYSQL_BINLOG --short-form --start-position=604 $MYSQLTEST_VARDIR/log/master-bin.000001
--disable_query_log
select "--- stop-position --" as "";
--enable_query_log
---exec $MYSQL_BINLOG --short-form --stop-position=600 $MYSQLTEST_VARDIR/log/master-bin.000001
+--exec $MYSQL_BINLOG --short-form --stop-position=604 $MYSQLTEST_VARDIR/log/master-bin.000001
--disable_query_log
select "--- start-datetime --" as "";
--enable_query_log
@@ -78,11 +81,11 @@ select "--- offset --" as "";
--disable_query_log
select "--- start-position --" as "";
--enable_query_log
---exec $MYSQL_BINLOG --short-form --start-position=600 $MYSQLTEST_VARDIR/log/master-bin.000001 $MYSQLTEST_VARDIR/log/master-bin.000002
+--exec $MYSQL_BINLOG --short-form --start-position=604 $MYSQLTEST_VARDIR/log/master-bin.000001 $MYSQLTEST_VARDIR/log/master-bin.000002
--disable_query_log
select "--- stop-position --" as "";
--enable_query_log
---exec $MYSQL_BINLOG --short-form --stop-position=126 $MYSQLTEST_VARDIR/log/master-bin.000001 $MYSQLTEST_VARDIR/log/master-bin.000002
+--exec $MYSQL_BINLOG --short-form --stop-position=130 $MYSQLTEST_VARDIR/log/master-bin.000001 $MYSQLTEST_VARDIR/log/master-bin.000002
--disable_query_log
select "--- start-datetime --" as "";
--enable_query_log
@@ -105,11 +108,11 @@ select "--- offset --" as "";
--disable_query_log
select "--- start-position --" as "";
--enable_query_log
---exec $MYSQL_BINLOG --short-form --start-position=600 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001
+--exec $MYSQL_BINLOG --short-form --start-position=604 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001
--disable_query_log
select "--- stop-position --" as "";
--enable_query_log
---exec $MYSQL_BINLOG --short-form --stop-position=600 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001
+--exec $MYSQL_BINLOG --short-form --stop-position=604 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001
--disable_query_log
select "--- start-datetime --" as "";
--enable_query_log
@@ -132,11 +135,11 @@ select "--- offset --" as "";
--disable_query_log
select "--- start-position --" as "";
--enable_query_log
---exec $MYSQL_BINLOG --short-form --start-position=600 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 master-bin.000002
+--exec $MYSQL_BINLOG --short-form --start-position=604 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 master-bin.000002
--disable_query_log
select "--- stop-position --" as "";
--enable_query_log
---exec $MYSQL_BINLOG --short-form --stop-position=126 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 master-bin.000002
+--exec $MYSQL_BINLOG --short-form --stop-position=130 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 master-bin.000002
--disable_query_log
select "--- start-datetime --" as "";
--enable_query_log
diff --git a/mysql-test/t/mysqlbinlog_base64.test b/mysql-test/t/mysqlbinlog_base64.test
new file mode 100644
index 00000000000..66aaff83254
--- /dev/null
+++ b/mysql-test/t/mysqlbinlog_base64.test
@@ -0,0 +1,38 @@
+-- source include/have_binlog_format_row.inc
+#
+# Write different events to binlog
+#
+create table t1 (a int);
+insert into t1 values (1);
+insert into t1 values (2);
+insert into t1 values (3);
+update t1 set a=a+2 where a=2;
+update t1 set a=a+2 where a=3;
+
+create table t2 (word varchar(20));
+load data infile '../std_data_ln/words.dat' into table t2;
+
+#
+# Save binlog
+#
+--exec $MYSQL_BINLOG --hexdump $MYSQLTEST_VARDIR/log/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/mysqlbinlog_base64.sql
+
+#
+# Clear database and restore from binlog
+#
+drop table t1;
+drop table t2;
+--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/mysqlbinlog_base64.sql
+
+#
+# Verify that all binlog events have been executed
+#
+select * from t1;
+select * from t2;
+
+#
+# Test cleanup
+#
+--exec rm $MYSQLTEST_VARDIR/tmp/mysqlbinlog_base64.sql
+drop table t1;
+drop table t2;
diff --git a/mysql-test/t/mysqlcheck.test b/mysql-test/t/mysqlcheck.test
index bc88be001ab..61d64c733d7 100644
--- a/mysql-test/t/mysqlcheck.test
+++ b/mysql-test/t/mysqlcheck.test
@@ -1,6 +1,12 @@
# Embedded server doesn't support external clients
--source include/not_embedded.inc
+# check that CSV engine was compiled in, as the result of the test
+# depends on the presence of the log tables (which are CSV-based).
+--source include/have_csv.inc
+
+DROP SCHEMA test;
+CREATE SCHEMA test;
#
# Bug #13783 mysqlcheck tries to optimize and analyze information_schema
#
diff --git a/mysql-test/t/mysqldump.test b/mysql-test/t/mysqldump.test
index d53022665a0..1aef8f6c176 100644
--- a/mysql-test/t/mysqldump.test
+++ b/mysql-test/t/mysqldump.test
@@ -11,7 +11,7 @@ drop view if exists v1, v2, v3;
# XML output
-CREATE TABLE t1(a int);
+CREATE TABLE t1(a int, key (a)) key_block_size=1024;
INSERT INTO t1 VALUES (1), (2);
--exec $MYSQL_DUMP --skip-create --skip-comments -X test t1
DROP TABLE t1;
@@ -748,7 +748,26 @@ show create table `t1`;
drop table `t1`;
+#
+# Bug #18536: wrong table order
+#
+
+create table t1(a int);
+create table t2(a int);
+create table t3(a int);
+--error 6
+--exec $MYSQL_DUMP --skip-comments --force --no-data test t3 t1 non_existing t2
+drop table t1, t2, t3;
+
--echo End of 4.1 tests
+# Bug #13318: Bad result with empty field and --hex-blob
+#
+create table t1 (a binary(1), b blob);
+insert into t1 values ('','');
+--exec $MYSQL_DUMP --skip-comments --skip-extended-insert --hex-blob test t1
+--exec $MYSQL_DUMP --skip-comments --hex-blob test t1
+drop table t1;
+
#
# dump of view
@@ -1033,12 +1052,25 @@ create view v2 as select * from v0;
select * from v2;
--exec $MYSQL_DUMP -x --skip-comments --databases test
-
drop view v2;
drop view v0;
drop view v1;
drop table t1;
+# Check new --replace option
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+CREATE TABLE t1(a int, b int);
+INSERT INTO t1 VALUES (1,1);
+INSERT INTO t1 VALUES (2,3);
+INSERT INTO t1 VALUES (3,4), (4,5);
+--exec $MYSQL_DUMP --replace --skip-comments test t1
+DROP TABLE t1;
+
+
#
# BUG#14554 - mysqldump does not separate words "ROW" and "BEGIN"
# for tables with trigger created in the IGNORE_SPACE sql mode.
@@ -1064,26 +1096,6 @@ DROP TRIGGER tr1;
DROP TABLE t1;
#
-# Bug #13318: Bad result with empty field and --hex-blob
-#
-create table t1 (a binary(1), b blob);
-insert into t1 values ('','');
---exec $MYSQL_DUMP --skip-comments --skip-extended-insert --hex-blob test t1
---exec $MYSQL_DUMP --skip-comments --hex-blob test t1
-drop table t1;
-
-#
-# Bug #18536: wrong table order
-#
-
-create table t1(a int);
-create table t2(a int);
-create table t3(a int);
---error 6
---exec $MYSQL_DUMP --skip-comments --force --no-data test t3 t1 non_existing t2
-drop table t1, t2, t3;
-
---echo End of 4.1 tests
#
# Bug 14871 Invalid view dump output
@@ -1114,6 +1126,7 @@ select * from v3 order by a;
drop table t1;
drop view v1, v2, v3, v4, v5;
+
#
# Bug #16878 dump of trigger
#
@@ -1161,3 +1174,81 @@ show create procedure p;
drop function f;
drop procedure p;
+# Added for use-thread option
+#
+create table t1 (a text , b text);
+create table t2 (a text , b text);
+insert t1 values ("Duck, Duck", "goose");
+insert t1 values ("Duck, Duck", "pidgeon");
+insert t2 values ("We the people", "in order to perform");
+insert t2 values ("a more perfect", "union");
+select * from t1;
+select * from t2;
+--exec $MYSQL_DUMP --tab=$MYSQLTEST_VARDIR/tmp/ test
+--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/t1.sql
+--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/t2.sql
+# The first load tests the pausing code
+--exec $MYSQL_IMPORT --use-threads=1 test $MYSQLTEST_VARDIR/tmp/t1.txt $MYSQLTEST_VARDIR/tmp/t2.txt
+# Now we test with multiple threads!
+--exec $MYSQL_IMPORT --silent --use-threads=5 test $MYSQLTEST_VARDIR/tmp/t1.txt $MYSQLTEST_VARDIR/tmp/t2.txt
+select * from t1;
+select * from t2;
+# Now we test with multiple threads, but less threads than files.
+create table words(a varchar(255));
+create table words2(b varchar(255));
+--exec $MYSQL_IMPORT --silent --use-threads=2 test $MYSQLTEST_VARDIR/tmp/t1.txt $MYSQLTEST_VARDIR/tmp/t2.txt $MYSQLTEST_VARDIR/std_data_ln/words.dat $MYSQLTEST_VARDIR/std_data_ln/words2.dat
+select * from t1;
+select * from t2;
+select * from words;
+select * from words2;
+
+# Drop table "words" and run with threads, should fail
+drop table words;
+--replace_regex /.*mysqlimport(\.exe)*/mysql-import/
+--error 1
+--exec $MYSQL_IMPORT --silent --use-threads=2 test $MYSQLTEST_VARDIR/tmp/t1.txt $MYSQLTEST_VARDIR/tmp/t2.txt $MYSQLTEST_VARDIR/std_data_ln/words.dat $MYSQLTEST_VARDIR/std_data_ln/words2.dat 2>&1
+
+drop table t1;
+drop table t2;
+
+drop table words2;
+
+#
+# BUG# 16853: mysqldump doesn't show events
+#
+create database first;
+use first;
+set time_zone = 'UTC';
+
+## prove one works (with spaces and tabs on the end)
+create event ee1 on schedule at '2035-12-31 20:01:23' do set @a=5;
+show events;
+show create event ee1;
+--exec $MYSQL_DUMP --events first > $MYSQLTEST_VARDIR/tmp/bug16853-1.sql
+drop database first;
+
+create database second;
+use second;
+--exec $MYSQL second < $MYSQLTEST_VARDIR/tmp/bug16853-1.sql
+show events;
+show create event ee1;
+
+## prove three works (with spaces and tabs on the end)
+# start with one from the previous restore
+create event ee2 on schedule at '2018-12-31 21:01:23' do set @a=5;
+create event ee3 on schedule at '2030-12-31 22:01:23' do set @a=5;
+show events;
+--exec $MYSQL_DUMP --events second > $MYSQLTEST_VARDIR/tmp/bug16853-2.sql
+drop database second;
+
+create database third;
+use third;
+--exec $MYSQL third < $MYSQLTEST_VARDIR/tmp/bug16853-2.sql
+show events;
+drop database third;
+
+# revert back to normal settings
+set time_zone = 'SYSTEM';
+use test;
+
+#####
diff --git a/mysql-test/t/mysqlslap.test b/mysql-test/t/mysqlslap.test
new file mode 100644
index 00000000000..01add0d7da8
--- /dev/null
+++ b/mysql-test/t/mysqlslap.test
@@ -0,0 +1,16 @@
+# Can't run test of external client with embedded server
+--source include/not_embedded.inc
+--source include/not_windows.inc
+
+--exec $MYSQL_SLAP --silent --concurrency=5 --iterations=20 --number-int-cols=2 --number-char-cols=3 --auto-generate-sql
+
+--exec $MYSQL_SLAP --silent --concurrency=5 --iterations=20 --number-int-cols=2 --number-char-cols=3 --auto-generate-sql --use-threads
+
+--exec $MYSQL_SLAP --only-print --iterations=20 --query="select * from t1" --create="CREATE TABLE t1 (id int, name varchar(64)); INSERT INTO t1 VALUES (1, 'This is a test')" --delimiter=";"
+--exec $MYSQL_SLAP --silent --concurrency=5 --iterations=20 --query="select * from t1" --create="CREATE TABLE t1 (id int, name varchar(64)); INSERT INTO t1 VALUES (1, 'This is a test')" --delimiter=";"
+
+--exec $MYSQL_SLAP --only-print --delimiter=";" --query="select * from t1;select * from t2" --create="CREATE TABLE t1 (id int, name varchar(64)); create table t2(foo1 varchar(32), foo2 varchar(32)); INSERT INTO t1 VALUES (1, 'This is a test'); insert into t2 values ('test', 'test2')" --engine="heap,myisam"
+
+--exec $MYSQL_SLAP --silent --concurrency=5 --iterations=20 --delimiter=";" --query="select * from t1;select * from t2" --create="CREATE TABLE t1 (id int, name varchar(64)); create table t2(foo1 varchar(32), foo2 varchar(32)); INSERT INTO t1 VALUES (1, 'This is a test'); insert into t2 values ('test', 'test2')"
+
+--exec $MYSQL_SLAP --silent --concurrency=5 --iterations=20 --number-int-cols=2 --number-char-cols=3 --auto-generate-sql --create-schema=test_env
diff --git a/mysql-test/t/mysqltest.test b/mysql-test/t/mysqltest.test
index 3968eb519e1..42065cfae81 100644
--- a/mysql-test/t/mysqltest.test
+++ b/mysql-test/t/mysqltest.test
@@ -521,9 +521,6 @@ echo $novar1;
--exec echo "let \$=hi;" | $MYSQL_TEST 2>&1
--error 1
---exec echo "let hi=hi;" | $MYSQL_TEST 2>&1
-
---error 1
--exec echo "let \$1 hi;" | $MYSQL_TEST 2>&1
--error 1
@@ -1125,3 +1122,40 @@ drop table t1;
drop table t1;
+# test for replace_regex
+--replace_regex /at/b/
+select "at" as col1, "c" as col2;
+
+--replace_regex /at/b/i
+select "at" as col1, "AT" as col2, "c" as col3;
+
+--replace_regex /a/b/ /ct/d/
+select "a" as col1, "ct" as col2;
+
+--replace_regex /(strawberry)/raspberry and \1/ /blueberry/blackberry/ /potato/tomato/;
+select "strawberry","blueberry","potato";
+
+--error 1
+--exec echo "--replace_regex a" | $MYSQL_TEST 2>&1
+--error 1
+--exec echo "--replace_regex a;" | $MYSQL_TEST 2>&1
+--error 1
+--exec echo "replace_regex a;" | $MYSQL_TEST 2>&1
+--error 1
+--exec echo "replace_regex a ;" | $MYSQL_TEST 2>&1
+--error 1
+--exec echo "replace_regex a b; echo OK;" | $MYSQL_TEST 2>&1
+--error 1
+--exec echo "--replace_regex /a b c" | $MYSQL_TEST 2>&1
+--error 1
+--exec echo "replace_regex /a /b c ;" | $MYSQL_TEST 2>&1
+
+# REQUIREMENT
+# replace_regex should replace substitutions from left to right in output
+
+create table t1 (a int, b int);
+insert into t1 values (1,3);
+insert into t1 values (2,4);
+--replace_regex /A/C/ /B/D/i /3/2/ /2/1/
+select * from t1;
+drop table t1;
diff --git a/mysql-test/t/ndb_alter_table.test b/mysql-test/t/ndb_alter_table.test
index 957b95c6fd9..8e3b4a6ca89 100644
--- a/mysql-test/t/ndb_alter_table.test
+++ b/mysql-test/t/ndb_alter_table.test
@@ -56,12 +56,12 @@ col3 varchar (20) not null,
col4 varchar(4) not null,
col5 enum('PENDING', 'ACTIVE', 'DISABLED') not null,
col6 int not null, to_be_deleted int) ENGINE=ndbcluster;
---replace_column 7 # 8 # 10 # 12 # 13 # 14 # 18 #
+--replace_column 6 # 7 # 8 # 10 # 12 # 13 # 14 # 18 #
show table status;
SET SQL_MODE=NO_AUTO_VALUE_ON_ZERO;
insert into t1 values
(0,4,3,5,"PENDING",1,7),(NULL,4,3,5,"PENDING",1,7),(31,4,3,5,"PENDING",1,7), (7,4,3,5,"PENDING",1,7), (NULL,4,3,5,"PENDING",1,7), (100,4,3,5,"PENDING",1,7), (99,4,3,5,"PENDING",1,7), (8,4,3,5,"PENDING",1,7), (NULL,4,3,5,"PENDING",1,7);
---replace_column 7 # 8 # 10 # 12 # 13 # 14 # 18 #
+--replace_column 6 # 7 # 8 # 10 # 12 # 13 # 14 # 18 #
show table status;
select * from t1 order by col1;
alter table t1
@@ -70,11 +70,11 @@ add column col7 varchar(30) not null after col5,
add column col8 datetime not null, drop column to_be_deleted,
change column col2 fourth varchar(30) not null after col3,
modify column col6 int not null first;
---replace_column 7 # 8 # 10 # 12 # 13 # 14 # 18 #
+--replace_column 6 # 7 # 8 # 10 # 12 # 13 # 14 # 18 #
show table status;
select * from t1 order by col1;
insert into t1 values (2, NULL,4,3,5,99,"PENDING","EXTRA",'2004-01-01 00:00:00');
---replace_column 7 # 8 # 10 # 12 # 13 # 14 # 18 #
+--replace_column 6 # 7 # 8 # 10 # 12 # 13 # 14 # 18 #
show table status;
select * from t1 order by col1;
delete from t1;
@@ -142,23 +142,19 @@ INSERT INTO t1 VALUES (1,2,0),(18,19,4),(20,21,0);
select c from t1 order by c;
drop table t1;
---disable_ps_protocol
-create table t1 ( a int primary key, b varchar(10), c varchar(10), index (b) )
-engine=ndb;
-insert into t1 values (1,'one','one'), (2,'two','two'), (3,'three','three');
-create index c on t1(c);
-connection server2;
-select * from t1 where b = 'two';
-connection server1;
-alter table t1 drop index c;
-connection server2;
-# This should fail since index information is not automatically refreshed
---error 1015
-select * from t1 where b = 'two';
-select * from t1 where b = 'two';
-connection server1;
-drop table t1;
---enable_ps_protocol
+## Test moved to ndb_alter_table_row|stmt respectively as behaviour differs
+#create table t1 ( a int primary key, b varchar(10), c varchar(10), index (b) )
+#engine=ndb;
+#insert into t1 values (1,'one','one'), (2,'two','two'), (3,'three','three');
+#create index c on t1(c);
+#connection server2;
+#select * from t1 where c = 'two';
+#connection server1;
+#alter table t1 drop index c;
+#connection server2;
+#select * from t1 where c = 'two';
+#connection server1;
+#drop table t1;
#--disable_warnings
#DROP TABLE IF EXISTS t2;
@@ -183,29 +179,32 @@ drop table t1;
#select count(*) from t2;
#drop table t2;
-connection server1;
-create table t3 (a int primary key) engine=ndbcluster;
-
-connection server2;
-begin;
-insert into t3 values (1);
-
-connection server1;
-alter table t3 rename t4;
-
-connection server2;
-# This should work as transaction is ongoing...
-delete from t3;
-insert into t3 values (1);
-commit;
-
-# This should fail as its a new transaction
---error 1015
-select * from t3;
-select * from t4;
-drop table t4;
-show tables;
-connection server1;
+## Test moved to ndb_alter_table_row|stmt respectively as behaviour differs
+#connection server1;
+#create table t3 (a int primary key) engine=ndbcluster;
+
+#connection server2;
+#begin;
+#insert into t3 values (1);
+
+#connection server1;
+#alter table t3 rename t4;
+
+#connection server2;
+## with rbr the below will not work as the "alter" event
+## explicitly invalidates the dictionary cache.
+### This should work as transaction is ongoing...
+##delete from t3;
+##insert into t3 values (1);
+#commit;
+
+## This should fail as its a new transaction
+#--error 1146
+#select * from t3;
+#select * from t4;
+#drop table t4;
+#show tables;
+#connection server1;
create table t1 (
ai bigint auto_increment,
@@ -326,6 +325,65 @@ on t1 (c010, c011, c012, c013);
drop table t1;
+# End of 4.1 tests
+
+# On-line alter table
+
+
+CREATE TABLE t1 (
+ auto int(5) unsigned NOT NULL auto_increment,
+ string char(10),
+ vstring varchar(10),
+ bin binary(2),
+ vbin varbinary(7),
+ tiny tinyint(4) DEFAULT '0' NOT NULL ,
+ short smallint(6) DEFAULT '1' NOT NULL ,
+ medium mediumint(8) DEFAULT '0' NOT NULL,
+ long_int int(11) DEFAULT '0' NOT NULL,
+ longlong bigint(13) DEFAULT '0' NOT NULL,
+ real_float float(13,1) DEFAULT 0.0 NOT NULL,
+ real_double double(16,4),
+ real_decimal decimal(16,4),
+ utiny tinyint(3) unsigned DEFAULT '0' NOT NULL,
+ ushort smallint(5) unsigned zerofill DEFAULT '00000' NOT NULL,
+ umedium mediumint(8) unsigned DEFAULT '0' NOT NULL,
+ ulong int(11) unsigned DEFAULT '0' NOT NULL,
+ ulonglong bigint(13) unsigned DEFAULT '0' NOT NULL,
+ bits bit(3),
+ options enum('zero','one','two','three','four') not null,
+ flags set('zero','one','two','three','four') not null,
+ date_field date,
+ year_field year,
+ time_field time,
+ date_time datetime,
+ time_stamp timestamp,
+ PRIMARY KEY (auto)
+) engine=ndb;
+
+CREATE TEMPORARY TABLE ndb_show_tables (id INT, type VARCHAR(20), state VARCHAR(20), logging VARCHAR(20), _database VARCHAR(255), _schema VARCHAR(20), name VARCHAR(255));
+
+--disable_warnings
+--exec $NDB_TOOLS_DIR/ndb_show_tables --p > $MYSQLTEST_VARDIR/master-data/test/tmp.dat
+LOAD DATA INFILE 'tmp.dat' INTO TABLE ndb_show_tables;
+--enable_warnings
+
+set @t1_id = (select id from ndb_show_tables where name like '%t1%');
+truncate ndb_show_tables;
+
+alter table t1 change tiny new_tiny tinyint(4) DEFAULT '0' NOT NULL;
+create index i1 on t1(medium);
+alter table t1 add index i2(long_int);
+drop index i1 on t1;
+
+--disable_warnings
+--exec $NDB_TOOLS_DIR/ndb_show_tables --p > $MYSQLTEST_VARDIR/master-data/test/tmp.dat
+LOAD DATA INFILE 'tmp.dat' INTO TABLE ndb_show_tables;
+--enable_warnings
+
+select 'no_copy' from ndb_show_tables where id = @t1_id and name like '%t1%';
+
+DROP TABLE t1, ndb_show_tables;
+
# simple test that auto incr is not lost at rename or alter
create table t1 (a int primary key auto_increment, b int) engine=ndb;
insert into t1 (b) values (101),(102),(103);
@@ -340,6 +398,3 @@ alter table t2 rename t1;
insert into t1 (b) values (401),(402),(403);
select * from t1 where a = 12;
drop table t1;
-
-# End of 4.1 tests
-
diff --git a/mysql-test/t/ndb_alter_table2.test b/mysql-test/t/ndb_alter_table2.test
index 3861fcc6c9d..afe6e44f698 100644
--- a/mysql-test/t/ndb_alter_table2.test
+++ b/mysql-test/t/ndb_alter_table2.test
@@ -72,8 +72,10 @@ CREATE TABLE t1 (
connection server1;
---error 1296
+--disable_result_log
+--error 0,1412
select * from t1;
+--enable_result_log
select * from t1;
select * from t1;
select * from t1;
diff --git a/mysql-test/t/ndb_alter_table3.test b/mysql-test/t/ndb_alter_table3.test
new file mode 100644
index 00000000000..a5fe613adcf
--- /dev/null
+++ b/mysql-test/t/ndb_alter_table3.test
@@ -0,0 +1,49 @@
+-- source include/have_ndb.inc
+-- source include/have_multi_ndb.inc
+-- source include/not_embedded.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+connection server1;
+create table t1 ( a int primary key, b varchar(10), c varchar(10), index (b) )
+engine=ndb;
+insert into t1 values (1,'one','one'), (2,'two','two'), (3,'three','three');
+create index c on t1(c);
+connection server2;
+show indexes from t1;
+select * from t1 where c = 'two';
+connection server1;
+alter table t1 drop index c;
+connection server2;
+show indexes from t1;
+select * from t1 where c = 'two';
+connection server1;
+drop table t1;
+
+connection server1;
+create table t3 (a int primary key) engine=ndbcluster;
+
+connection server2;
+begin;
+insert into t3 values (1);
+
+connection server1;
+alter table t3 rename t4;
+
+connection server2;
+# with rbr the below will not work as the "alter" event
+# explicitly invalidates the dictionary cache.
+## This should work as transaction is ongoing...
+#delete from t3;
+#insert into t3 values (1);
+commit;
+
+# This should fail as its a new transaction
+--error 1146
+select * from t3;
+select * from t4;
+drop table t4;
+show tables;
+connection server1;
diff --git a/mysql-test/t/ndb_autodiscover.test b/mysql-test/t/ndb_autodiscover.test
index 6eb039c2df2..7424687cd8a 100644
--- a/mysql-test/t/ndb_autodiscover.test
+++ b/mysql-test/t/ndb_autodiscover.test
@@ -177,7 +177,7 @@ show status like 'handler_discover%';
flush tables;
system rm $MYSQLTEST_VARDIR/master-data/test/t7.frm ;
---replace_column 7 # 8 # 9 # 12 # 13 # 15 # 18 #
+--replace_column 6 # 7 # 8 # 9 # 12 # 13 # 15 # 18 #
show table status;
show status like 'handler_discover%';
@@ -543,6 +543,6 @@ create table t10 (
insert into t10 values (1, 'kalle');
---exec $NDB_TOOLS_DIR/ndb_drop_table --no-defaults -d test `$NDB_TOOLS_DIR/ndb_show_tables --no-defaults | grep BLOB` >> $NDB_TOOLS_OUTPUT 2>&1 || true
+--exec $NDB_TOOLS_DIR/ndb_drop_table --no-defaults -d test `$NDB_TOOLS_DIR/ndb_show_tables --no-defaults | grep BLOB | while read a b c d e f g; do echo $g; done` >> $NDB_TOOLS_OUTPUT 2>&1 || true
# End of 4.1 tests
diff --git a/mysql-test/t/ndb_autodiscover3.test b/mysql-test/t/ndb_autodiscover3.test
index 73b4bf8b94f..ed75c89cdd1 100644
--- a/mysql-test/t/ndb_autodiscover3.test
+++ b/mysql-test/t/ndb_autodiscover3.test
@@ -36,23 +36,33 @@ select * from t2 order by a limit 3;
--exec $NDB_MGM --no-defaults -e "all restart -i" >> $NDB_TOOLS_OUTPUT
--exec $NDB_TOOLS_DIR/ndb_waiter --no-defaults >> $NDB_TOOLS_OUTPUT
+# to ensure mysqld has connected again, and recreated system tables
+--exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -r 30 -d cluster apply_status >> $NDB_TOOLS_OUTPUT
--connection server2
+--error ER_NO_SUCH_TABLE
+select * from t2;
+show tables like 't2';
+reset master;
create table t2 (a int key) engine=ndbcluster;
insert into t2 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
select * from t2 order by a limit 3;
# server 1 should have a stale cache, and in this case wrong frm, transaction must be retried
--connection server1
---error 1015
-select * from t2 order by a limit 3;
select * from t2 order by a limit 3;
+reset master;
--exec $NDB_MGM --no-defaults -e "all restart -i" >> $NDB_TOOLS_OUTPUT
--exec $NDB_TOOLS_DIR/ndb_waiter --no-defaults >> $NDB_TOOLS_OUTPUT
+# to ensure mysqld has connected again, and recreated system tables
+--exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -r 30 -d cluster apply_status >> $NDB_TOOLS_OUTPUT
--connection server1
-show tables;
+--error ER_NO_SUCH_TABLE
+select * from t2;
+show tables like 't2';
+reset master;
create table t2 (a int key) engine=ndbcluster;
insert into t2 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
select * from t2 order by a limit 3;
@@ -60,6 +70,7 @@ select * from t2 order by a limit 3;
# server 2 should have a stale cache, but with right frm, transaction need not be retried
--connection server2
select * from t2 order by a limit 3;
+reset master;
drop table t2;
# End of 4.1 tests
diff --git a/mysql-test/t/ndb_basic.test b/mysql-test/t/ndb_basic.test
index 5d79d5eb9f9..c7fa5aeee1e 100644
--- a/mysql-test/t/ndb_basic.test
+++ b/mysql-test/t/ndb_basic.test
@@ -6,6 +6,17 @@ DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7;
drop database if exists mysqltest;
--enable_warnings
+## workaround for bug#16445
+## remove to reproduce bug and run tests from ndb start
+## and with ndb_autodiscover disabled. Fails on Linux 50 % of the times
+#CREATE TABLE t1 (
+# pk1 INT NOT NULL PRIMARY KEY,
+# attr1 INT NOT NULL,
+# attr2 INT,
+# attr3 VARCHAR(10)
+#) ENGINE=ndbcluster;
+#drop table t1;
+
#
# Basic test to show that the NDB
# table handler is working
@@ -393,7 +404,9 @@ drop table t1;
#
# test the limit of no of attributes in one table
#
-
+# also tests bug#17179, more than 31 attributes in
+# a partitioned table
+#
create table t1 (
c1 int,
c2 int,
@@ -523,7 +536,7 @@ c125 int,
c126 int,
c127 int,
c128 int,
-primary key(c1)) engine=ndb;
+primary key using hash(c1)) engine=ndb partition by key(c1);
drop table t1;
#
@@ -700,3 +713,17 @@ select * from t1 order by f1;
select * from t1 order by f2;
select * from t1 order by f3;
drop table t1;
+
+#
+# Bug #18483 Cannot create table with FK constraint
+# ndb does not support foreign key constraint, it is silently ignored
+# in line with other storage engines
+#
+CREATE TABLE t1 (a VARCHAR(255) NOT NULL,
+ CONSTRAINT pk_a PRIMARY KEY (a))engine=ndb;
+CREATE TABLE t2(a VARCHAR(255) NOT NULL,
+ b VARCHAR(255) NOT NULL,
+ c VARCHAR(255) NOT NULL,
+ CONSTRAINT pk_b_c_id PRIMARY KEY (b,c),
+ CONSTRAINT fk_a FOREIGN KEY(a) REFERENCES t1(a))engine=ndb;
+drop table t1, t2;
diff --git a/mysql-test/t/ndb_binlog_basic.test b/mysql-test/t/ndb_binlog_basic.test
new file mode 100644
index 00000000000..3886900037d
--- /dev/null
+++ b/mysql-test/t/ndb_binlog_basic.test
@@ -0,0 +1,72 @@
+-- source include/have_ndb.inc
+-- source include/have_binlog_format_row.inc
+
+--disable_warnings
+drop table if exists t1, t2;
+drop database if exists mysqltest;
+create database mysqltest;
+use mysqltest;
+drop database mysqltest;
+use test;
+--enable_warnings
+
+#
+# basic insert, update, delete test, alter, rename, drop
+# check that binlog_index gets the right info
+#
+
+create table t1 (a int primary key) engine=ndb;
+insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+save_master_pos;
+--replace_column 1 #
+select @max_epoch:=max(epoch)-1 from cluster.binlog_index;
+
+delete from t1;
+alter table t1 add (b int);
+insert into t1 values (3,3),(4,4);
+alter table t1 rename t2;
+
+# get all in one epoch
+begin;
+insert into t2 values (1,1),(2,2);
+update t2 set b=1 where a=3;
+delete from t2 where a=4;
+commit;
+drop table t2;
+
+# check that above is ok
+# (save_master_pos waits for last gcp to complete, ensuring that we have
+# the expected data in the binlog)
+save_master_pos;
+select inserts from cluster.binlog_index where epoch > @max_epoch and inserts > 5;
+select deletes from cluster.binlog_index where epoch > @max_epoch and deletes > 5;
+select inserts,updates,deletes from
+ cluster.binlog_index where epoch > @max_epoch and updates > 0;
+
+#
+# check that purge clears the binlog_index
+#
+flush logs;
+--sleep 1
+purge master logs before now();
+select count(*) from cluster.binlog_index;
+
+#
+# several tables in different databases
+# check that same table name in different databases don't mix up
+#
+create table t1 (a int primary key, b int) engine=ndb;
+create database mysqltest;
+use mysqltest;
+create table t1 (c int, d int primary key) engine=ndb;
+use test;
+
+insert into mysqltest.t1 values (2,1),(2,2);
+save_master_pos;
+--replace_column 1 #
+select @max_epoch:=max(epoch)-1 from cluster.binlog_index;
+
+drop table t1;
+drop database mysqltest;
+select inserts,updates,deletes from
+ cluster.binlog_index where epoch > @max_epoch and inserts > 0;
diff --git a/mysql-test/t/ndb_binlog_basic2.test b/mysql-test/t/ndb_binlog_basic2.test
new file mode 100644
index 00000000000..9fa9f2f965a
--- /dev/null
+++ b/mysql-test/t/ndb_binlog_basic2.test
@@ -0,0 +1,14 @@
+-- source include/have_ndb.inc
+
+--error ER_NDB_CANT_SWITCH_BINLOG_FORMAT
+set session binlog_format=row;
+--error ER_NDB_CANT_SWITCH_BINLOG_FORMAT
+set session binlog_format=statement;
+--error ER_NDB_CANT_SWITCH_BINLOG_FORMAT
+set global binlog_format=row;
+--error ER_NDB_CANT_SWITCH_BINLOG_FORMAT
+set global binlog_format=statement;
+--error ER_NDB_CANT_SWITCH_BINLOG_FORMAT
+set session binlog_format=default;
+--error ER_NDB_CANT_SWITCH_BINLOG_FORMAT
+set global binlog_format=default;
diff --git a/mysql-test/t/ndb_binlog_ddl_multi.test b/mysql-test/t/ndb_binlog_ddl_multi.test
new file mode 100644
index 00000000000..f41e7c3a527
--- /dev/null
+++ b/mysql-test/t/ndb_binlog_ddl_multi.test
@@ -0,0 +1,191 @@
+-- source include/have_ndb.inc
+-- source include/have_multi_ndb.inc
+-- source include/have_binlog_format_row.inc
+
+--disable_warnings
+connection server2;
+drop database if exists mysqltest;
+drop table if exists t1,t2,t3;
+connection server1;
+drop database if exists mysqltest;
+drop table if exists t1,t2,t3;
+--connection server1
+reset master;
+--connection server2
+reset master;
+--enable_warnings
+
+#
+# basic test to see if ddl distribution works across
+# multiple binlogs
+#
+
+# create database
+--connection server1
+create database mysqltest;
+
+# create table
+--connection server1
+use mysqltest;
+create table t1 (a int primary key) engine=ndb;
+
+--connection server2
+create table t2 (a int primary key) engine=ndb;
+--source include/show_binlog_events.inc
+
+--connection server1
+--source include/show_binlog_events.inc
+
+# alter table
+--connection server1
+reset master;
+--connection server2
+reset master;
+
+--connection server2
+alter table t2 add column (b int);
+
+--connections server1
+--source include/show_binlog_events.inc
+
+# alter database
+--connection server1
+reset master;
+--connection server2
+reset master;
+
+--connection server2
+ALTER DATABASE mysqltest CHARACTER SET latin1;
+
+
+# having drop here instead of below sometimes triggers bug#18976
+## drop table and drop should come after data events
+#--connection server2
+#drop table mysqltest.t1;
+
+--connection server1
+--source include/show_binlog_events.inc
+# to track down bug#18976
+--real_sleep 10
+--source include/show_binlog_events.inc
+
+--connection server2
+drop table mysqltest.t1;
+
+# drop database and drop should come after data events
+--connection server1
+reset master;
+--connection server2
+reset master;
+
+--connection server1
+use test;
+insert into t2 values (1,2);
+drop database mysqltest;
+create table t1 (a int primary key) engine=ndb;
+
+--connection server2
+--source include/show_binlog_events.inc
+
+--connection server2
+drop table t2;
+
+# logfile groups and table spaces
+--connection server1
+reset master;
+--connection server2
+reset master;
+
+--connection server1
+CREATE LOGFILE GROUP lg1
+ADD UNDOFILE 'undofile.dat'
+INITIAL_SIZE 16M
+UNDO_BUFFER_SIZE = 1M
+ENGINE=NDB;
+
+ALTER LOGFILE GROUP lg1
+ADD UNDOFILE 'undofile02.dat'
+INITIAL_SIZE = 4M
+ENGINE=NDB;
+
+CREATE TABLESPACE ts1
+ADD DATAFILE 'datafile.dat'
+USE LOGFILE GROUP lg1
+INITIAL_SIZE 12M
+ENGINE NDB;
+
+ALTER TABLESPACE ts1
+ADD DATAFILE 'datafile02.dat'
+INITIAL_SIZE = 4M
+ENGINE=NDB;
+
+ALTER TABLESPACE ts1
+DROP DATAFILE 'datafile.dat'
+ENGINE = NDB;
+
+ALTER TABLESPACE ts1
+DROP DATAFILE 'datafile02.dat'
+ENGINE = NDB;
+
+DROP TABLESPACE ts1
+ENGINE = NDB;
+
+DROP LOGFILE GROUP lg1
+ENGINE =NDB;
+
+# having drop here instead of below sometimes triggers bug#18976
+#drop table t1;
+
+--connection server2
+--source include/show_binlog_events.inc
+# to track down bug#18976
+--real_sleep 10
+--source include/show_binlog_events.inc
+
+drop table t1;
+
+#
+# Bug #17827 cluster: rename of several tables in one statement,
+# gets multiply logged
+#
+--connection server1
+reset master;
+show tables;
+--connection server2
+reset master;
+show tables;
+
+--connection server1
+create table t1 (a int key) engine=ndb;
+create table t2 (a int key) engine=ndb;
+create table t3 (a int key) engine=ndb;
+rename table t3 to t4, t2 to t3, t1 to t2, t4 to t1;
+--connection server2
+--source include/show_binlog_events.inc
+
+drop table t1;
+drop table t2;
+drop table t3;
+
+#
+# Bug #17838 binlog not setup on seconday master after rename
+#
+#
+--connection server1
+reset master;
+show tables;
+--connection server2
+reset master;
+show tables;
+
+--connection server1
+create table t1 (a int key) engine=ndb;
+insert into t1 values(1);
+rename table t1 to t2;
+insert into t2 values(2);
+
+# now we should see data in table t1 _and_ t2
+# prior to bug fix, data was missing for t2
+--connection server2
+drop table t2;
+--source include/show_binlog_events.inc
diff --git a/mysql-test/t/ndb_binlog_discover.test b/mysql-test/t/ndb_binlog_discover.test
new file mode 100644
index 00000000000..e74bd3380bd
--- /dev/null
+++ b/mysql-test/t/ndb_binlog_discover.test
@@ -0,0 +1,19 @@
+-- source include/have_ndb.inc
+-- source include/have_binlog_format_row.inc
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+#
+# Bug #14516 Restart of cluster can cause NDB API replication failure
+#
+create table t1 (a int key) engine=ndb;
+reset master;
+--exec $NDB_MGM --no-defaults -e "all restart -n" > /dev/null
+--exec $NDB_TOOLS_DIR/ndb_waiter --no-defaults --not-started > /dev/null
+--exec $NDB_MGM --no-defaults -e "all start" > /dev/null
+--exec $NDB_TOOLS_DIR/ndb_waiter --no-defaults > /dev/null
+insert into t1 values(1);
+--source include/show_binlog_events.inc
+drop table t1;
diff --git a/mysql-test/t/ndb_binlog_ignore_db-master.opt b/mysql-test/t/ndb_binlog_ignore_db-master.opt
new file mode 100644
index 00000000000..e3947c0eeed
--- /dev/null
+++ b/mysql-test/t/ndb_binlog_ignore_db-master.opt
@@ -0,0 +1 @@
+--binlog-ignore-db=mysqltest
diff --git a/mysql-test/t/ndb_binlog_ignore_db.test b/mysql-test/t/ndb_binlog_ignore_db.test
new file mode 100644
index 00000000000..a4090bbb62b
--- /dev/null
+++ b/mysql-test/t/ndb_binlog_ignore_db.test
@@ -0,0 +1,15 @@
+-- source include/have_ndb.inc
+-- source include/have_binlog_format_row.inc
+
+--disable_warnings
+drop table if exists t1;
+drop database if exists mysqltest;
+--enable_warnings
+
+create database mysqltest;
+use mysqltest;
+create table t1 (a int primary key, b int) engine=ndb;
+insert into t1 values (1, 1);
+-- source include/show_binlog_events.inc
+
+drop database mysqltest;
diff --git a/mysql-test/t/ndb_binlog_multi.test b/mysql-test/t/ndb_binlog_multi.test
new file mode 100644
index 00000000000..6adacf73208
--- /dev/null
+++ b/mysql-test/t/ndb_binlog_multi.test
@@ -0,0 +1,76 @@
+-- source include/have_ndb.inc
+-- source include/have_multi_ndb.inc
+-- source include/have_binlog_format_row.inc
+
+--disable_warnings
+connection server2;
+drop table if exists t1,t2;
+connection server1;
+drop table if exists t1,t2;
+--enable_warnings
+
+# reset for test
+connection server1;
+reset master;
+connection server2;
+reset master;
+
+#
+# basic test to see if one server sees the table from the other
+# and sets up the replication correctly
+#
+
+# create table on the other server
+connection server2;
+CREATE TABLE t2 (a INT PRIMARY KEY, b int) ENGINE = NDB;
+
+# insert something on server2
+INSERT INTO t2 VALUES (1,1),(2,2);
+# verify that we get the data in the binlog
+--source include/show_binlog_events.inc
+select * from t2 order by a;
+--replace_column 1 <the_epoch>
+SELECT @the_epoch:=epoch,inserts,updates,deletes,schemaops FROM
+ cluster.binlog_index ORDER BY epoch DESC LIMIT 1;
+let $the_epoch= `SELECT @the_epoch`;
+
+# see if we got something on server1
+connection server1;
+SELECT * FROM t2 ORDER BY a;
+# doing drop table will ensure that all the events have been received
+DROP TABLE t2;
+# verify thar we have table and data in binlog
+--source include/show_binlog_events.inc
+--replace_result $the_epoch <the_epoch>
+eval SELECT inserts,updates,deletes,schemaops FROM
+ cluster.binlog_index WHERE epoch=$the_epoch;
+
+# reset for next test
+connection server1;
+reset master;
+connection server2;
+reset master;
+
+# single schema ops will not show
+connection server2;
+CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE = NDB;
+INSERT INTO t1 VALUES (1),(2);
+--source include/show_binlog_events.inc
+--replace_column 1 <the_epoch2>
+SELECT @the_epoch2:=epoch,inserts,updates,deletes,schemaops FROM
+ cluster.binlog_index ORDER BY epoch DESC LIMIT 1;
+let $the_epoch2= `SELECT @the_epoch2`;
+
+--replace_result $the_epoch <the_epoch> $the_epoch2 <the_epoch2>
+eval SELECT inserts,updates,deletes,schemaops FROM
+ cluster.binlog_index WHERE epoch > $the_epoch AND epoch <= $the_epoch2;
+
+# now see that we have the events on the other server
+connection server2;
+# doing drop table will ensure that all the events have been received
+drop table t1;
+# verify thar we have table and data in binlog
+--source include/show_binlog_events.inc
+--replace_result $the_epoch <the_epoch> $the_epoch2 <the_epoch2>
+eval SELECT inserts,updates,deletes,schemaops FROM
+ cluster.binlog_index WHERE epoch > $the_epoch AND epoch <= $the_epoch2;
diff --git a/mysql-test/t/ndb_bitfield.test b/mysql-test/t/ndb_bitfield.test
index 59d6e56577e..de0ae23bfe6 100644
--- a/mysql-test/t/ndb_bitfield.test
+++ b/mysql-test/t/ndb_bitfield.test
@@ -104,6 +104,7 @@ create table t1 (
pk1 bit(9) not null primary key,
b int
) engine=ndbcluster;
+show warnings;
--error 1005
create table t1 (
@@ -111,6 +112,7 @@ create table t1 (
b bit(9),
key(b)
) engine=ndbcluster;
+show warnings;
# bug#16125
create table t1 (
diff --git a/mysql-test/t/ndb_condition_pushdown.test b/mysql-test/t/ndb_condition_pushdown.test
index 398ca3c502c..3b53f7b3431 100644
--- a/mysql-test/t/ndb_condition_pushdown.test
+++ b/mysql-test/t/ndb_condition_pushdown.test
@@ -2,7 +2,7 @@
-- source include/not_embedded.inc
--disable_warnings
-DROP TABLE IF EXISTS t1,t2;
+DROP TABLE IF EXISTS t1,t2,t3,t4;
--enable_warnings
#
diff --git a/mysql-test/t/ndb_config.test b/mysql-test/t/ndb_config.test
index 4787abe86e2..2fe54cac048 100644
--- a/mysql-test/t/ndb_config.test
+++ b/mysql-test/t/ndb_config.test
@@ -15,4 +15,3 @@
--exec $NDB_TOOLS_DIR/ndb_config --defaults-group-suffix=.cluster0 --defaults-file=$MYSQL_TEST_DIR/std_data/ndb_config_mycnf2.cnf --query=type,nodeid,host --mycnf 2> /dev/null
--exec $NDB_TOOLS_DIR/ndb_config --defaults-group-suffix=.cluster1 --defaults-file=$MYSQL_TEST_DIR/std_data/ndb_config_mycnf2.cnf --query=type,nodeid,host --mycnf 2> /dev/null
--exec $NDB_TOOLS_DIR/ndb_config --defaults-group-suffix=.cluster2 --defaults-file=$MYSQL_TEST_DIR/std_data/ndb_config_mycnf2.cnf --query=type,nodeid,host --mycnf 2> /dev/null
---exec $NDB_TOOLS_DIR/ndb_config --defaults-group-suffix=.cluster2 --defaults-file=$MYSQL_TEST_DIR/std_data/ndb_config_mycnf2.cnf --ndb-shm --connections --query=type,nodeid1,nodeid2,group,nodeidserver --mycnf 2> /dev/null
diff --git a/mysql-test/t/ndb_config2.test b/mysql-test/t/ndb_config2.test
new file mode 100644
index 00000000000..170f1b2e5e7
--- /dev/null
+++ b/mysql-test/t/ndb_config2.test
@@ -0,0 +1,7 @@
+-- source include/have_ndb.inc
+-- source include/ndb_default_cluster.inc
+-- source include/not_embedded.inc
+
+# Following doesn't work in all configurations (if shm is not defined)
+
+--exec $NDB_TOOLS_DIR/ndb_config --defaults-group-suffix=.cluster2 --defaults-file=$MYSQL_TEST_DIR/std_data/ndb_config_mycnf2.cnf --ndb-shm --connections --query=type,nodeid1,nodeid2,group,nodeidserver --mycnf 2> /dev/null
diff --git a/mysql-test/t/ndb_database.test b/mysql-test/t/ndb_database.test
index 2e924ba2dcc..8bfdf40de88 100644
--- a/mysql-test/t/ndb_database.test
+++ b/mysql-test/t/ndb_database.test
@@ -1,13 +1,7 @@
-- source include/have_ndb.inc
--- source include/have_multi_ndb.inc
-- source include/not_embedded.inc
--disable_warnings
-connection server1;
-drop table if exists t1;
-drop database if exists mysqltest;
-connection server2;
-drop table if exists t1;
drop database if exists mysqltest;
--enable_warnings
@@ -15,38 +9,16 @@ drop database if exists mysqltest;
# Check that all tables in a database are dropped when database is dropped
#
-connection server1;
-create database mysqltest;
-
-connection server2;
create database mysqltest;
create table mysqltest.t1 (a int primary key, b int) engine=ndb;
use mysqltest;
show tables;
-connection server1;
drop database mysqltest;
-
-connection server2;
-use mysqltest;
-show tables;
-
-connection server1;
create database mysqltest;
-create table mysqltest.t1 (c int, d int primary key) engine=ndb;
use mysqltest;
show tables;
-connection server2;
drop database mysqltest;
-connection server1;
-use mysqltest;
-show tables;
-
---disable_warnings
-drop table if exists t1;
-drop database if exists mysqltest;
---enable_warnings
-
# End of 4.1 tests
diff --git a/mysql-test/t/ndb_dd_backuprestore.test b/mysql-test/t/ndb_dd_backuprestore.test
new file mode 100644
index 00000000000..1508cccb46d
--- /dev/null
+++ b/mysql-test/t/ndb_dd_backuprestore.test
@@ -0,0 +1,173 @@
+########################################
+# Author: JBM
+# Date: 2006-01-24
+# Purpose: Test CDD backup and restore
+########################################
+
+-- source include/have_ndb.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS test.t1;
+DROP TABLE IF EXISTS test.t2;
+DROP TABLE IF EXISTS test.t3;
+DROP TABLE IF EXISTS test.t4;
+DROP TABLE IF EXISTS test.t5;
+DROP TABLE IF EXISTS test.t6;
+--enable_warnings
+
+############ Test 1 Simple DD backup and restore #############
+-- echo **** Test 1 Simple DD backup and restore ****
+
+CREATE LOGFILE GROUP log_group1
+ADD UNDOFILE './log_group1/undofile.dat'
+INITIAL_SIZE 16M
+UNDO_BUFFER_SIZE = 1M
+ENGINE=NDB;
+
+CREATE TABLESPACE table_space1
+ADD DATAFILE './table_space1/datafile.dat'
+USE LOGFILE GROUP log_group1
+INITIAL_SIZE 12M
+ENGINE NDB;
+
+
+CREATE TABLE test.t1
+(pk1 MEDIUMINT NOT NULL AUTO_INCREMENT PRIMARY KEY, c2 CHAR(50) NOT NULL, c3 INT NOT NULL, c4 BIT NOT NULL) TABLESPACE table_space1 STORAGE DISK ENGINE=NDB;
+
+let $j= 500;
+--disable_query_log
+while ($j)
+{
+ eval INSERT INTO test.t1 VALUES (NULL, "Sweden", $j, b'1');
+ dec $j;
+}
+--enable_query_log
+SELECT COUNT(*) FROM test.t1;
+SELECT pk1, c2, c3, hex(c4) FROM test.t1 ORDER BY pk1 LIMIT 5;
+
+-- source include/ndb_backup.inc
+
+DROP TABLE test.t1;
+
+ALTER TABLESPACE table_space1
+DROP DATAFILE './table_space1/datafile.dat'
+ENGINE = NDB;
+
+DROP TABLESPACE table_space1
+ENGINE = NDB;
+
+DROP LOGFILE GROUP log_group1
+ENGINE =NDB;
+
+-- source include/ndb_restore_master.inc
+
+SELECT COUNT(*) FROM test.t1;
+
+SELECT pk1, c2, c3, hex(c4) FROM test.t1 ORDER BY pk1 LIMIT 5;
+
+################# Mixed Cluster Test ############################
+-- echo **** Test 2 Mixed Cluster Test backup and restore ****
+
+CREATE TABLE test.t2
+(pk1 MEDIUMINT NOT NULL AUTO_INCREMENT PRIMARY KEY, c2 VARCHAR(200) NOT NULL, c3 INT NOT NULL, c4 BIT NOT NULL)ENGINE=NDB;
+
+let $j= 500;
+--disable_query_log
+while ($j)
+{
+ eval INSERT INTO test.t2 VALUES (NULL, "Sweden, Texas", $j, b'0');
+ dec $j;
+}
+--enable_query_log
+
+CREATE TABLE test.t3 (c1 int not null auto_increment, data LONGBLOB, PRIMARY KEY(c1))TABLESPACE table_space1 STORAGE DISK ENGINE=NDB;
+
+CREATE TABLE test.t4 (c1 int not null auto_increment, data LONGBLOB, PRIMARY KEY(c1))ENGINE=NDB;
+
+let $j= 50;
+--disable_query_log
+while ($j)
+{
+ INSERT INTO test.t3 VALUES (NULL, repeat('a',1*1024));
+ INSERT INTO test.t3 VALUES (NULL, repeat('b',16*1024));
+ INSERT INTO test.t4 VALUES (NULL, repeat('a',1*1024));
+ INSERT INTO test.t4 VALUES (NULL, repeat('b',16*1024));
+ dec $j;
+}
+--enable_query_log
+
+SELECT COUNT(*) FROM test.t1;
+
+SELECT pk1, c2, c3, hex(c4) FROM test.t1 ORDER BY pk1 LIMIT 5;
+
+SELECT COUNT(*) FROM test.t2;
+
+SELECT pk1, c2, c3, hex(c4) FROM test.t2 ORDER BY pk1 LIMIT 5;
+
+SELECT COUNT(*) FROM test.t3;
+
+SELECT LENGTH(data) FROM test.t3 WHERE c1 = 1;
+
+SELECT LENGTH(data) FROM test.t3 WHERE c1 = 2;
+
+SELECT COUNT(*) FROM test.t4;
+
+SELECT LENGTH(data) FROM test.t4 WHERE c1 = 1;
+
+SELECT LENGTH(data) FROM test.t4 WHERE c1 = 2;
+
+-- source include/ndb_backup.inc
+
+DROP TABLE test.t1;
+DROP TABLE test.t2;
+DROP TABLE test.t3;
+DROP TABLE test.t4;
+
+ALTER TABLESPACE table_space1
+DROP DATAFILE './table_space1/datafile.dat'
+ENGINE = NDB;
+
+DROP TABLESPACE table_space1
+ENGINE = NDB;
+
+DROP LOGFILE GROUP log_group1
+ENGINE =NDB;
+
+-- source include/ndb_restore_master.inc
+
+SELECT COUNT(*) FROM test.t1;
+
+SELECT pk1, c2, c3, hex(c4) FROM test.t1 ORDER BY pk1 LIMIT 5;
+
+SELECT COUNT(*) FROM test.t2;
+
+SELECT pk1, c2, c3, hex(c4) FROM test.t2 ORDER BY pk1 LIMIT 5;
+
+SELECT COUNT(*) FROM test.t3;
+
+SELECT LENGTH(data) FROM test.t3 WHERE c1 = 1;
+
+SELECT LENGTH(data) FROM test.t3 WHERE c1 = 2;
+
+SELECT COUNT(*) FROM test.t4;
+
+SELECT LENGTH(data) FROM test.t4 WHERE c1 = 1;
+
+SELECT LENGTH(data) FROM test.t4 WHERE c1 = 2;
+
+DROP TABLE test.t1;
+DROP TABLE test.t2;
+DROP TABLE test.t3;
+DROP TABLE test.t4;
+
+ALTER TABLESPACE table_space1
+DROP DATAFILE './table_space1/datafile.dat'
+ENGINE = NDB;
+
+DROP TABLESPACE table_space1
+ENGINE = NDB;
+
+DROP LOGFILE GROUP log_group1
+ENGINE =NDB;
+
+#End 5.1 test case
diff --git a/mysql-test/t/ndb_dd_basic.test b/mysql-test/t/ndb_dd_basic.test
new file mode 100644
index 00000000000..9df2cfb0371
--- /dev/null
+++ b/mysql-test/t/ndb_dd_basic.test
@@ -0,0 +1,366 @@
+#################################
+# Author: JO
+# Org Date: ?
+# Purpose: To test basic Cluster Disk Data
+#################################
+# Change Author: JBM
+# Change Date: 2006-01-11
+# Change: Cleanup and test rename
+#################################
+
+-- source include/have_ndb.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+# some negative tests
+CREATE LOGFILE GROUP lg1
+ADD UNDOFILE 'undofile.dat'
+INITIAL_SIZE 16M
+UNDO_BUFFER_SIZE = 1M
+ENGINE=MYISAM;
+
+ALTER LOGFILE GROUP lg1
+ADD UNDOFILE 'undofile02.dat'
+INITIAL_SIZE = 4M
+ENGINE=XYZ;
+
+CREATE TABLESPACE ts1
+ADD DATAFILE 'datafile.dat'
+USE LOGFILE GROUP lg1
+INITIAL_SIZE 12M;
+
+##################################
+# Basic test of disk tables for NDB
+# Start by creating a logfile group
+##################################
+
+set storage_engine=ndb;
+CREATE LOGFILE GROUP lg1
+ADD UNDOFILE 'undofile.dat'
+INITIAL_SIZE 16M
+UNDO_BUFFER_SIZE = 1M;
+
+ALTER LOGFILE GROUP lg1
+ADD UNDOFILE 'undofile02.dat'
+INITIAL_SIZE = 4M
+ENGINE=NDB;
+
+###################################################
+# Create a tablespace connected to the logfile group
+###################################################
+
+set storage_engine=myisam;
+CREATE TABLESPACE ts1
+ADD DATAFILE 'datafile.dat'
+USE LOGFILE GROUP lg1
+INITIAL_SIZE 12M
+ENGINE NDB;
+
+ALTER TABLESPACE ts1
+ADD DATAFILE 'datafile02.dat'
+INITIAL_SIZE = 4M
+ENGINE=NDB;
+
+########################################
+# Create a table using this tablespace
+########################################
+
+CREATE TABLE t1
+(pk1 INT NOT NULL PRIMARY KEY, b INT NOT NULL, c INT NOT NULL)
+TABLESPACE ts1 STORAGE DISK
+ENGINE=NDB;
+
+SHOW CREATE TABLE t1;
+
+INSERT INTO t1 VALUES (0, 0, 0);
+SELECT * FROM t1;
+
+INSERT INTO t1 VALUES
+(1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5),
+(6,6,6),(7,7,7),(8,8,8),(9,9,9),(10,10,10),
+(11,11,11),(12,12,12),(13,13,13),(14,14,14),(15,15,15),
+(16,16,16),(17,17,17),(18,18,18),(19,19,19),(20,20,20),
+(21,21,21),(22,22,22),(23,23,23),(24,24,24),(25,25,25),
+(26,26,26),(27,27,27),(28,28,28),(29,29,29),(30,30,30),
+(31,31,31),(32,32,32),(33,33,33),(34,34,34),(35,35,35),
+(36,36,36),(37,37,37),(38,38,38),(39,39,39),(40,40,40),
+(41,41,41),(42,42,42),(43,43,43),(44,44,44),(45,45,45),
+(46,46,46),(47,47,47),(48,48,48),(49,49,49),(50,50,50),
+(51,51,51),(52,52,52),(53,53,53),(54,54,54),(55,55,55),
+(56,56,56),(57,57,57),(58,58,58),(59,59,59),(60,60,60),
+(61,61,61),(62,62,62),(63,63,63),(64,64,64),(65,65,65),
+(66,66,66),(67,67,67),(68,68,68),(69,69,69),(70,70,70),
+(71,71,71),(72,72,72),(73,73,73),(74,74,74),(75,75,75),
+(76,76,76),(77,77,77),(78,78,78),(79,79,79),(80,80,80),
+(81,81,81),(82,82,82),(83,83,83),(84,84,84),(85,85,85),
+(86,86,86),(87,87,87),(88,88,88),(89,89,89),(90,90,90),
+(91,91,91),(92,92,92),(93,93,93),(94,94,94),(95,95,95),
+(96,96,96),(97,97,97),(98,98,98),(99,99,99),(100,100,100),
+(101,101,101),(102,102,102),(103,103,103),(104,104,104),(105,105,105),
+(106,106,106),(107,107,107),(108,108,108),(109,109,109),(110,110,110),
+(111,111,111),(112,112,112),(113,113,113),(114,114,114),(115,115,115),
+(116,116,116),(117,117,117),(118,118,118),(119,119,119),(120,120,120),
+(121,121,121),(122,122,122),(123,123,123),(124,124,124),(125,125,125),
+(126,126,126),(127,127,127),(128,128,128),(129,129,129),(130,130,130),
+(131,131,131),(132,132,132),(133,133,133),(134,134,134),(135,135,135),
+(136,136,136),(137,137,137),(138,138,138),(139,139,139),(140,140,140),
+(141,141,141),(142,142,142),(143,143,143),(144,144,144),(145,145,145),
+(146,146,146),(147,147,147),(148,148,148),(149,149,149),(150,150,150),
+(151,151,151),(152,152,152),(153,153,153),(154,154,154),(155,155,155),
+(156,156,156),(157,157,157),(158,158,158),(159,159,159),(160,160,160),
+(161,161,161),(162,162,162),(163,163,163),(164,164,164),(165,165,165),
+(166,166,166),(167,167,167),(168,168,168),(169,169,169),(170,170,170),
+(171,171,171),(172,172,172),(173,173,173),(174,174,174),(175,175,175),
+(176,176,176),(177,177,177),(178,178,178),(179,179,179),(180,180,180),
+(181,181,181),(182,182,182),(183,183,183),(184,184,184),(185,185,185),
+(186,186,186),(187,187,187),(188,188,188),(189,189,189),(190,190,190),
+(191,191,191),(192,192,192),(193,193,193),(194,194,194),(195,195,195),
+(196,196,196),(197,197,197),(198,198,198),(199,199,199),(200,200,200),
+(201,201,201),(202,202,202),(203,203,203),(204,204,204),(205,205,205),
+(206,206,206),(207,207,207),(208,208,208),(209,209,209),(210,210,210),
+(211,211,211),(212,212,212),(213,213,213),(214,214,214),(215,215,215),
+(216,216,216),(217,217,217),(218,218,218),(219,219,219),(220,220,220),
+(221,221,221),(222,222,222),(223,223,223),(224,224,224),(225,225,225),
+(226,226,226),(227,227,227),(228,228,228),(229,229,229),(230,230,230),
+(231,231,231),(232,232,232),(233,233,233),(234,234,234),(235,235,235),
+(236,236,236),(237,237,237),(238,238,238),(239,239,239),(240,240,240),
+(241,241,241),(242,242,242),(243,243,243),(244,244,244),(245,245,245),
+(246,246,246),(247,247,247),(248,248,248),(249,249,249),(250,250,250),
+(251,251,251),(252,252,252),(253,253,253),(254,254,254),(255,255,255),
+(256,256,256),(257,257,257),(258,258,258),(259,259,259),(260,260,260),
+(261,261,261),(262,262,262),(263,263,263),(264,264,264),(265,265,265),
+(266,266,266),(267,267,267),(268,268,268),(269,269,269),(270,270,270),
+(271,271,271),(272,272,272),(273,273,273),(274,274,274),(275,275,275),
+(276,276,276),(277,277,277),(278,278,278),(279,279,279),(280,280,280),
+(281,281,281),(282,282,282),(283,283,283),(284,284,284),(285,285,285),
+(286,286,286),(287,287,287),(288,288,288),(289,289,289),(290,290,290),
+(291,291,291),(292,292,292),(293,293,293),(294,294,294),(295,295,295),
+(296,296,296),(297,297,297),(298,298,298),(299,299,299),(300,300,300),
+(301,301,301),(302,302,302),(303,303,303),(304,304,304),(305,305,305),
+(306,306,306),(307,307,307),(308,308,308),(309,309,309),(310,310,310),
+(311,311,311),(312,312,312),(313,313,313),(314,314,314),(315,315,315),
+(316,316,316),(317,317,317),(318,318,318),(319,319,319),(320,320,320),
+(321,321,321),(322,322,322),(323,323,323),(324,324,324),(325,325,325),
+(326,326,326),(327,327,327),(328,328,328),(329,329,329),(330,330,330),
+(331,331,331),(332,332,332),(333,333,333),(334,334,334),(335,335,335),
+(336,336,336),(337,337,337),(338,338,338),(339,339,339),(340,340,340),
+(341,341,341),(342,342,342),(343,343,343),(344,344,344),(345,345,345),
+(346,346,346),(347,347,347),(348,348,348),(349,349,349),(350,350,350),
+(351,351,351),(352,352,352),(353,353,353),(354,354,354),(355,355,355),
+(356,356,356),(357,357,357),(358,358,358),(359,359,359),(360,360,360),
+(361,361,361),(362,362,362),(363,363,363),(364,364,364),(365,365,365),
+(366,366,366),(367,367,367),(368,368,368),(369,369,369),(370,370,370),
+(371,371,371),(372,372,372),(373,373,373),(374,374,374),(375,375,375),
+(376,376,376),(377,377,377),(378,378,378),(379,379,379),(380,380,380),
+(381,381,381),(382,382,382),(383,383,383),(384,384,384),(385,385,385),
+(386,386,386),(387,387,387),(388,388,388),(389,389,389),(390,390,390),
+(391,391,391),(392,392,392),(393,393,393),(394,394,394),(395,395,395),
+(396,396,396),(397,397,397),(398,398,398),(399,399,399),(400,400,400),
+(401,401,401),(402,402,402),(403,403,403),(404,404,404),(405,405,405),
+(406,406,406),(407,407,407),(408,408,408),(409,409,409),(410,410,410),
+(411,411,411),(412,412,412),(413,413,413),(414,414,414),(415,415,415),
+(416,416,416),(417,417,417),(418,418,418),(419,419,419),(420,420,420),
+(421,421,421),(422,422,422),(423,423,423),(424,424,424),(425,425,425),
+(426,426,426),(427,427,427),(428,428,428),(429,429,429),(430,430,430),
+(431,431,431),(432,432,432),(433,433,433),(434,434,434),(435,435,435),
+(436,436,436),(437,437,437),(438,438,438),(439,439,439),(440,440,440),
+(441,441,441),(442,442,442),(443,443,443),(444,444,444),(445,445,445),
+(446,446,446),(447,447,447),(448,448,448),(449,449,449),(450,450,450),
+(451,451,451),(452,452,452),(453,453,453),(454,454,454),(455,455,455),
+(456,456,456),(457,457,457),(458,458,458),(459,459,459),(460,460,460),
+(461,461,461),(462,462,462),(463,463,463),(464,464,464),(465,465,465),
+(466,466,466),(467,467,467),(468,468,468),(469,469,469),(470,470,470),
+(471,471,471),(472,472,472),(473,473,473),(474,474,474),(475,475,475),
+(476,476,476),(477,477,477),(478,478,478),(479,479,479),(480,480,480),
+(481,481,481),(482,482,482),(483,483,483),(484,484,484),(485,485,485),
+(486,486,486),(487,487,487),(488,488,488),(489,489,489),(490,490,490),
+(491,491,491),(492,492,492),(493,493,493),(494,494,494),(495,495,495),
+(496,496,496),(497,497,497),(498,498,498),(499,499,499),(500, 500, 500);
+
+SELECT COUNT(*) FROM t1;
+
+####################################
+# Test error cases with size numbers
+####################################
+--error ER_WRONG_SIZE_NUMBER
+CREATE LOGFILE GROUP lg2
+ADD UNDOFILE 'x.dat'
+INITIAL_SIZE 10y
+ENGINE = NDB;
+
+--error ER_WRONG_SIZE_NUMBER
+CREATE LOGFILE GROUP lg2
+ADD UNDOFILE 'x.dat'
+INITIAL_SIZE 10MB
+ENGINE = NDB;
+
+--error 1064
+CREATE LOGFILE GROUP lg2
+ADD UNDOFILE 'x.dat'
+INITIAL_SIZE 10 MB
+ENGINE = NDB;
+
+--error 1064
+CREATE LOGFILE GROUP lg2
+ADD UNDOFILE 'x.dat'
+INITIAL_SIZE 10 M
+ENGINE = NDB;
+
+--error ER_SIZE_OVERFLOW_ERROR
+CREATE LOGFILE GROUP lg2
+ADD UNDOFILE 'x.dat'
+INITIAL_SIZE 1000000000000K
+ENGINE = NDB;
+
+DROP TABLE t1;
+
+############################
+# Test update of mm/dd part
+############################
+
+CREATE TABLE t1 (a INT PRIMARY KEY, b CHAR(4) NOT NULL, c CHAR(4) NOT NULL, KEY(b)) TABLESPACE ts1 STORAGE DISK ENGINE = NDB;
+INSERT INTO t1 VALUES (1,'1','1'), (2,'2','2'), (3,'3','3');
+BEGIN;
+UPDATE t1 SET b = '2' WHERE a = 1;
+SELECT b FROM t1 WHERE a = 1;
+SELECT * FROM t1 WHERE a = 1;
+UPDATE t1 SET c = '2' WHERE a = 1;
+SELECT b FROM t1 WHERE a = 1;
+SELECT * FROM t1 WHERE a = 1;
+UPDATE t1 SET b = '3' WHERE a = 1;
+SELECT b FROM t1 WHERE a = 1;
+SELECT * FROM t1 WHERE a = 1;
+COMMIT;
+SELECT * FROM t1 ORDER BY 1;
+BEGIN;
+UPDATE t1 SET c = '3' WHERE a = 1;
+SELECT b FROM t1 WHERE a = 1;
+SELECT * FROM t1 WHERE a = 1;
+UPDATE t1 SET b = '4' WHERE a = 1;
+SELECT b FROM t1 WHERE a = 1;
+SELECT * FROM t1 WHERE a = 1;
+UPDATE t1 SET c = '4' WHERE a = 1;
+SELECT b FROM t1 WHERE a = 1;
+SELECT * FROM t1 WHERE a = 1;
+COMMIT;
+SELECT * FROM t1 ORDER BY 1;
+UPDATE t1 SET b = '5' WHERE a = 1;
+SELECT * FROM t1 ORDER BY 1;
+UPDATE t1 SET b = '6' WHERE b = '5';
+SELECT * FROM t1 ORDER BY 1;
+UPDATE t1 SET b = '7'WHERE c = '4';
+SELECT * FROM t1 ORDER BY 1;
+UPDATE t1 SET c = '5' WHERE a = 1;
+SELECT * FROM t1 ORDER BY 1;
+UPDATE t1 SET c = '6' WHERE b = '7';
+SELECT * FROM t1 ORDER BY 1;
+UPDATE t1 SET c = '7' WHERE c = '6';
+SELECT * FROM t1 ORDER BY 1;
+DROP TABLE t1;
+
+#####
+
+CREATE TABLE t1 (a INT PRIMARY KEY, b VARCHAR(4) NOT NULL, c CHAR(4) NOT NULL, KEY(b)) TABLESPACE ts1 STORAGE DISK ENGINE NDB;
+INSERT INTO t1 VALUE (1,'1','1'), (2,'2','2'), (3,'3','3');
+BEGIN;
+UPDATE t1 SET b = '2' WHERE a = 1;
+SELECT b FROM t1 WHERE a = 1;
+SELECT * FROM t1 WHERE a = 1;
+UPDATE t1 SET c = '2' WHERE a = 1;
+SELECT b FROM t1 WHERE a = 1;
+SELECT * FROM t1 WHERE a = 1;
+UPDATE t1 SET b = '3' WHERE a = 1;
+SELECT b FROM t1 WHERE a = 1;
+SELECT * FROM t1 WHERE a = 1;
+COMMIT;
+SELECT * FROM t1 ORDER BY 1;
+BEGIN;
+UPDATE t1 SET c = '3' WHERE a = 1;
+SELECT b FROM t1 WHERE a = 1;
+SELECT * FROM t1 WHERE a = 1;
+UPDATE t1 SET b = '4' WHERE a = 1;
+SELECT b FROM t1 WHERE a = 1;
+SELECT * FROM t1 WHERE a = 1;
+UPDATE t1 SET c = '4' WHERE a = 1;
+SELECT b FROM t1 WHERE a = 1;
+SELECT * FROM t1 WHERE a = 1;
+COMMIT;
+SELECT * FROM t1 ORDER BY 1;
+UPDATE t1 SET b = '5' WHERE a = 1;
+SELECT * FROM t1 ORDER BY 1;
+UPDATE t1 SET b = '6' WHERE b = '5';
+SELECT * FROM t1 ORDER BY 1;
+UPDATE t1 SET b = '7' WHERE c = '4';
+SELECT * FROM t1 ORDER BY 1;
+UPDATE t1 SET c = '5' WHERE a = 1;
+SELECT * FROM t1 ORDER BY 1;
+UPDATE t1 SET c = '6' WHERE b = '7';
+SELECT * FROM t1 ORDER BY 1;
+UPDATE t1 SET c = '7' WHERE c = '6';
+SELECT * FROM t1 ORDER BY 1;
+DROP TABLE t1;
+
+########################
+# Test for blobs...
+########################
+
+CREATE TABLE t1 (
+ a INT NOT NULL PRIMARY KEY,
+ b TEXT NOT NULL
+) TABLESPACE ts1 STORAGE DISK ENGINE=NDBCLUSTER;
+
+# b1 length 2000+256 (blob part aligned)
+#########################################
+set @x0 = '01234567012345670123456701234567';
+set @x0 = concat(@x0,@x0,@x0,@x0,@x0,@x0,@x0,@x0);
+set @b1 = 'b1';
+set @b1 = concat(@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1);
+set @b1 = concat(@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1);
+set @b1 = concat(@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1);
+set @b1 = concat(@b1,@x0);
+# b2 length 20000
+##########################################
+set @b2 = 'b2';
+set @b2 = concat(@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2);
+set @b2 = concat(@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2);
+set @b2 = concat(@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2);
+set @b2 = concat(@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2,@b2);
+
+INSERT INTO t1 VALUES(1,@b1);
+INSERT INTO t1 VALUES(2,@b2);
+SELECT a,length(b),substr(b,1+2*900,2) FROM t1 WHERE a=1;
+SELECT a,length(b),substr(b,1+2*9000,2) FROM t1 WHERE a=2;
+UPDATE t1 SET b=@b2 WHERE a=1;
+UPDATE t1 SET b=@b1 WHERE a=2;
+SELECT a,length(b),substr(b,1+2*9000,2) FROM t1 WHERE a=1;
+SELECT a,length(b),substr(b,1+2*900,2) FROM t1 WHERE a=2;
+UPDATE t1 SET b=concat(b,b) WHERE a=1;
+UPDATE t1 SET b=concat(b,b) WHERE a=2;
+SELECT a,length(b),substr(b,1+4*9000,2) FROM t1 WHERE a=1;
+SELECT a,length(b),substr(b,1+4*900,2) FROM t1 WHERE a=2;
+DELETE FROM t1 WHERE a=1;
+DELETE FROM t1 WHERE a=2;
+SELECT COUNT(*) FROM t1;
+DROP TABLE t1;
+
+###################
+# Test Cleanup
+###################
+
+ALTER TABLESPACE ts1
+DROP DATAFILE 'datafile.dat'
+ENGINE = NDB;
+
+ALTER TABLESPACE ts1
+DROP DATAFILE 'datafile02.dat'
+ENGINE = NDB;
+
+DROP TABLESPACE ts1
+ENGINE = NDB;
+
+DROP LOGFILE GROUP lg1
+ENGINE =NDB;
+
+#End 5.1 test case
diff --git a/mysql-test/t/ndb_dd_ddl.test b/mysql-test/t/ndb_dd_ddl.test
new file mode 100644
index 00000000000..339f7bc2f22
--- /dev/null
+++ b/mysql-test/t/ndb_dd_ddl.test
@@ -0,0 +1,301 @@
+#########################################
+# Author: JBM
+# Date: 2006-01-03
+# Purpose: Test the NDB engine reaction to duplicate
+# Table spaces and log groups. Also to test
+# Statement mixed case.
+############################################
+# Change Author:JBM
+# Change Date 2006-01-19
+# Change: Adding to test cases feedback from OB
+# 1) The 'duplicate' tests.
+# a) The test is using the default (test) database and is not
+# attempting to create databases (only logs, table spaces and
+# tables). Is this intentional?
+# b) What about a duplication of table name when one exists on disk and
+# you are trying to create it again in memory?
+#
+#2) 'CaSE SensiTiVE' tests
+# a) Suggest you include a test case where the case difference is in
+# the file name. I know this is not an issue for *nix systems but
+# will be when we expand to Windows and Mac. Better put it in now.
+############################################
+#
+# Jonas 2006-03-10
+# Add verification that ndb currently is limited to 1 logfile group
+#
+
+
+-- source include/have_ndb.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+DROP DATABASE IF EXISTS mysqltest;
+CREATE DATABASE mysqltest;
+--enable_warnings
+
+############## Duplcate Statement Testing #########
+
+--echo **** Begin Duplicate Statement Testing ****
+
+CREATE LOGFILE GROUP lg1
+ADD UNDOFILE 'undofile.dat'
+INITIAL_SIZE 16M
+UNDO_BUFFER_SIZE = 1M
+ENGINE=NDB;
+
+# Verify that one currently can create only 1 logfile group
+--error ER_CREATE_FILEGROUP_FAILED
+CREATE LOGFILE GROUP lg2
+ADD UNDOFILE 'undofile2.dat'
+INITIAL_SIZE 16M
+UNDO_BUFFER_SIZE 1M
+ENGINE NDB;
+SHOW WARNINGS;
+
+--error ER_CREATE_FILEGROUP_FAILED
+CREATE LOGFILE GROUP lg1
+ADD UNDOFILE 'undofile.dat'
+INITIAL_SIZE 16M
+UNDO_BUFFER_SIZE = 1M
+ENGINE=NDB;
+
+ALTER LOGFILE GROUP lg1
+ADD UNDOFILE 'undofile02.dat'
+INITIAL_SIZE 4M ENGINE NDB;
+
+--error ER_ALTER_FILEGROUP_FAILED
+ALTER LOGFILE GROUP lg1
+ADD UNDOFILE 'undofile02.dat'
+INITIAL_SIZE 4M ENGINE=NDB;
+
+CREATE TABLESPACE ts1
+ADD DATAFILE 'datafile.dat'
+USE LOGFILE GROUP lg1
+INITIAL_SIZE 12M
+ENGINE NDB;
+
+--error ER_CREATE_FILEGROUP_FAILED
+CREATE TABLESPACE ts1
+ADD DATAFILE 'datafile.dat'
+USE LOGFILE GROUP lg1
+INITIAL_SIZE 12M
+ENGINE NDB;
+
+
+ALTER TABLESPACE ts1
+ADD DATAFILE 'datafile2.dat'
+INITIAL_SIZE 12M
+ENGINE=NDB;
+
+--error ER_ALTER_FILEGROUP_FAILED
+ALTER TABLESPACE ts1
+ADD DATAFILE 'datafile2.dat'
+INITIAL_SIZE 12M
+ENGINE=NDB;
+
+CREATE TABLE mysqltest.t1
+(pk1 INT NOT NULL PRIMARY KEY, b INT NOT NULL, c INT NOT NULL)
+TABLESPACE ts1 STORAGE DISK
+ENGINE=NDB;
+
+--error ER_TABLE_EXISTS_ERROR
+CREATE TABLE mysqltest.t1
+(pk1 INT NOT NULL PRIMARY KEY, b INT NOT NULL, c INT NOT NULL)
+TABLESPACE ts1 STORAGE DISK
+ENGINE=NDB;
+
+--error ER_TABLE_EXISTS_ERROR
+CREATE TABLE mysqltest.t1
+(pk1 INT NOT NULL PRIMARY KEY, b INT NOT NULL, c INT NOT NULL)
+ENGINE=NDB;
+
+
+DROP TABLE mysqltest.t1;
+
+ALTER TABLESPACE ts1
+DROP DATAFILE 'datafile2.dat'
+ENGINE=NDB;
+
+--error ER_ALTER_FILEGROUP_FAILED
+ALTER TABLESPACE ts1
+DROP DATAFILE 'datafile2.dat'
+ENGINE=NDB;
+
+ALTER TABLESPACE ts1
+DROP DATAFILE 'datafile.dat'
+ENGINE=NDB;
+
+--error ER_ALTER_FILEGROUP_FAILED
+ALTER TABLESPACE ts1
+DROP DATAFILE 'datafile.dat'
+ENGINE=NDB;
+
+DROP TABLESPACE ts1
+ENGINE=NDB;
+
+--error ER_DROP_FILEGROUP_FAILED
+DROP TABLESPACE ts1
+ENGINE=NDB;
+
+DROP LOGFILE GROUP lg1
+ENGINE=NDB;
+
+--error ER_DROP_FILEGROUP_FAILED
+DROP LOGFILE GROUP lg1
+ENGINE=NDB;
+
+DROP DATABASE IF EXISTS mysqltest;
+
+--echo **** End Duplicate Statement Testing ****
+############# End Duplicate Statments ############
+--echo
+############ Begin CaSe Testing ##################
+--echo **** Begin Statment CaSe Testing ****
+
+creaTE LOgfilE GrOuP lg1
+adD undoFILE 'undofile.dat'
+initiAL_siZE 16M
+UnDo_BuFfEr_SiZe = 1M
+ENGInE=NDb;
+
+altER LOgFiLE GrOUp lg1
+AdD UnDOfILe 'uNdOfiLe02.daT'
+INItIAl_SIzE 4M ENgINE nDB;
+
+CrEAtE TABLEspaCE ts1
+ADD DATAfilE 'datafile.dat'
+UsE LoGFiLE GRoUP lg1
+INITiaL_SizE 12M
+ENGiNe NDb;
+
+AlTeR tAbLeSpAcE ts1
+AdD DaTaFiLe 'dAtAfiLe2.daT'
+InItIaL_SiZe 12M
+EnGiNe=NDB;
+
+CREATE TABLE t1
+(pk1 int not null primary key, b int not null, c int not null)
+TABLEspace ts1 storAGE dISk
+ENGine nDb;
+
+DROP TABLE t1;
+
+AlteR TAblespaCE ts1
+droP DATAfile 'dAtAfiLe2.daT'
+ENGINE=NDB;
+
+ALter tablesPACE ts1
+dROp dAtAfIlE 'datafile.dat'
+ENGine=Ndb;
+
+DrOp TaBleSpAcE ts1
+engINE=ndB;
+
+DrOp lOgFiLe GrOuP lg1
+EnGiNe=nDb;
+
+--echo **** End Statment CaSe Testing ****
+############ End CaSe Testing ##################
+--echo
+############ Begin = and no = Testing ##########
+--echo **** Begin = And No = Testing ****
+
+CREATE LOGFILE GROUP lg1
+ADD UNDOFILE 'undofile.dat'
+INITIAL_SIZE=16M
+UNDO_BUFFER_SIZE=1M
+ENGINE=NDB;
+
+ALTER LOGFILE GROUP lg1
+ADD UNDOFILE 'undofile02.dat'
+INITIAL_SIZE=4M
+ENGINE=NDB;
+
+CREATE TABLESPACE ts1
+ADD DATAFILE 'datafile.dat'
+USE LOGFILE GROUP lg1
+INITIAL_SIZE=12M
+ENGINE=NDB;
+
+ALTER TABLESPACE ts1
+ADD DATAFILE 'datafile2.dat'
+INITIAL_SIZE=12M
+ENGINE=NDB;
+
+CREATE TABLE t1
+(pk1 INT NOT NULL PRIMARY KEY, b INT NOT NULL, c INT NOT NULL)
+TABLESPACE ts1 STORAGE DISK
+ENGINE=NDB;
+
+DROP TABLE t1;
+
+ALTER TABLESPACE ts1
+DROP DATAFILE 'datafile2.dat'
+ENGINE=NDB;
+
+ALTER TABLESPACE ts1
+DROP DATAFILE 'datafile.dat'
+ENGINE=NDB;
+
+DROP TABLESPACE ts1
+ENGINE=NDB;
+
+DROP LOGFILE GROUP lg1
+ENGINE=NDB;
+
+--echo
+--echo **** End of = ****
+--echo
+
+CREATE LOGFILE GROUP lg1
+ADD UNDOFILE 'undofile.dat'
+INITIAL_SIZE 16M
+UNDO_BUFFER_SIZE 1M
+ENGINE NDB;
+
+ALTER LOGFILE GROUP lg1
+ADD UNDOFILE 'undofile02.dat'
+INITIAL_SIZE 4M
+ENGINE NDB;
+
+CREATE TABLESPACE ts1
+ADD DATAFILE 'datafile.dat'
+USE LOGFILE GROUP lg1
+INITIAL_SIZE 12M
+ENGINE NDB;
+
+ALTER TABLESPACE ts1
+ADD DATAFILE 'datafile2.dat'
+INITIAL_SIZE 12M
+ENGINE NDB;
+
+CREATE TABLE t1
+(pk1 INT NOT NULL PRIMARY KEY, b INT NOT NULL, c INT NOT NULL)
+TABLESPACE ts1 STORAGE DISK
+ENGINE NDB;
+
+CREATE INDEX b_i on t1(b);
+CREATE INDEX bc_i on t1(b, c);
+
+DROP TABLE t1;
+
+ALTER TABLESPACE ts1
+DROP DATAFILE 'datafile2.dat'
+ENGINE NDB;
+
+ALTER TABLESPACE ts1
+DROP DATAFILE 'datafile.dat'
+ENGINE NDB;
+
+DROP TABLESPACE ts1
+ENGINE NDB;
+
+DROP LOGFILE GROUP lg1
+ENGINE NDB;
+
+--echo **** End = And No = ****
+############ End = And No = ##################
+
+# End 5.1 test
+
diff --git a/mysql-test/t/ndb_dd_disk2memory.test b/mysql-test/t/ndb_dd_disk2memory.test
new file mode 100644
index 00000000000..354a0c9bfb5
--- /dev/null
+++ b/mysql-test/t/ndb_dd_disk2memory.test
@@ -0,0 +1,186 @@
+########################################
+# Author: JBM
+# Date: 2006-01-12
+# Purpose: To test using ndb memory and
+# disk tables together.
+########################################
+
+-- source include/have_ndb.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS test.t1;
+DROP TABLE IF EXISTS test.t2;
+--enable_warnings
+
+############ Test Setup Section #############
+-- echo **** Test Setup Section ****
+
+CREATE LOGFILE GROUP log_group1
+ADD UNDOFILE './log_group1/undofile.dat'
+INITIAL_SIZE 16M
+UNDO_BUFFER_SIZE = 1M
+ENGINE=NDB;
+
+CREATE TABLESPACE table_space1
+ADD DATAFILE './table_space1/datafile.dat'
+USE LOGFILE GROUP log_group1
+INITIAL_SIZE 12M
+ENGINE NDB;
+
+
+CREATE TABLE test.t1
+(pk1 INT NOT NULL PRIMARY KEY, b INT NOT NULL, c INT NOT NULL)
+TABLESPACE table_space1 STORAGE DISK
+ENGINE=NDB;
+
+CREATE TABLE test.t2
+(pk2 INT NOT NULL PRIMARY KEY, b2 INT NOT NULL, c2 INT NOT NULL)
+ENGINE=NDB;
+
+--echo
+##################### Data load for first test ####################
+--echo **** Data load for first test ****
+
+INSERT INTO test.t1 VALUES
+(1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5),
+(6,6,6),(7,7,7),(8,8,8),(9,9,9),(10,10,10),
+(11,11,11),(12,12,12),(13,13,13),(14,14,14),(15,15,15),
+(16,16,16),(17,17,17),(18,18,18),(19,19,19),(20,20,20),
+(21,21,21),(22,22,22),(23,23,23),(24,24,24),(25,25,25),
+(26,26,26),(27,27,27),(28,28,28),(29,29,29),(30,30,30),
+(31,31,31),(32,32,32),(33,33,33),(34,34,34),(35,35,35),
+(36,36,36),(37,37,37),(38,38,38),(39,39,39),(40,40,40),
+(41,41,41),(42,42,42),(43,43,43),(44,44,44),(45,45,45),
+(46,46,46),(47,47,47),(48,48,48),(49,49,49),(50,50,50),
+(51,51,51),(52,52,52),(53,53,53),(54,54,54),(55,55,55),
+(56,56,56),(57,57,57),(58,58,58),(59,59,59),(60,60,60),
+(61,61,61),(62,62,62),(63,63,63),(64,64,64),(65,65,65),
+(66,66,66),(67,67,67),(68,68,68),(69,69,69),(70,70,70),
+(71,71,71),(72,72,72),(73,73,73),(74,74,74),(75,75,75);
+
+
+INSERT INTO test.t2 VALUES
+(1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5),
+(6,6,6),(7,7,7),(8,8,8),(9,9,9),(10,10,10),
+(11,11,11),(12,12,12),(13,13,13),(14,14,14),(15,15,15),
+(16,16,16),(17,17,17),(18,18,18),(19,19,19),(20,20,20),
+(21,21,21),(22,22,22),(23,23,23),(24,24,24),(25,25,25),
+(26,26,26),(27,27,27),(28,28,28),(29,29,29),(30,30,30),
+(31,31,31),(32,32,32),(33,33,33),(34,34,34),(35,35,35),
+(36,36,36),(37,37,37),(38,38,38),(39,39,39),(40,40,40),
+(41,41,41),(42,42,42),(43,43,43),(44,44,44),(45,45,45),
+(46,46,46),(47,47,47),(48,48,48),(49,49,49),(50,50,50),
+(51,51,51),(52,52,52),(53,53,53),(54,54,54),(55,55,55),
+(56,56,56),(57,57,57),(58,58,58),(59,59,59),(60,60,60),
+(61,61,61),(62,62,62),(63,63,63),(64,64,64),(65,65,65),
+(66,66,66),(67,67,67),(68,68,68),(69,69,69),(70,70,70),
+(71,71,71),(72,72,72),(73,73,73),(74,74,74),(75,75,75);
+
+--echo
+##################### Test 1 Section Begins ###############
+--echo *** Test 1 Section Begins ***
+SELECT COUNT(*) FROM test.t2 LEFT JOIN test.t1 ON pk2=pk1 WHERE b2 IN (4);
+SELECT * FROM test.t2 LEFT JOIN test.t1 ON pk2=pk1 WHERE b2 IN (4);
+SELECT COUNT(*) FROM test.t1 LEFT JOIN test.t2 ON pk1=pk2 WHERE b IN (4);
+SELECT COUNT(*) FROM test.t1 LEFT JOIN test.t2 ON b=b2 WHERE pk1 IN (75);
+SELECT b, c FROM test.t1 LEFT JOIN test.t2 ON pk1=pk2 ORDER BY b;
+--echo
+####################### Test 1 Section End ################
+
+##################### Setup for test 2 ####################
+--echo *** Setup for test 2 ****
+DELETE FROM test.t1;
+INSERT INTO test.t1 VALUES
+(1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5),
+(6,6,6),(7,7,7),(8,8,8),(9,9,9),(10,10,10),
+(11,11,11),(12,12,12),(13,13,13),(14,14,14),(15,15,15),
+(16,16,16),(17,17,17),(18,18,18),(19,19,19),(20,20,20),
+(21,21,21),(22,22,22),(23,23,23),(24,24,24),(25,25,25),
+(26,26,26),(27,27,27),(28,28,28),(29,29,29),(30,30,30),
+(31,31,31),(32,32,32),(33,33,33),(34,34,34),(35,35,35),
+(36,36,36),(37,37,37),(38,38,38),(39,39,39),(40,40,40),
+(41,41,41),(42,42,42),(43,43,43),(44,44,44),(45,45,45);
+--echo
+############################# Test Section 2 ###############
+--echo **** Test Section 2 ****
+SELECT b, c FROM test.t1 LEFT JOIN test.t2 ON pk1=pk2 ORDER BY b;
+SELECT COUNT(*) FROM test.t1 LEFT JOIN test.t2 ON b=b2;
+SELECT COUNT(*) FROM test.t1 RIGHT JOIN test.t2 ON b=b2;
+SHOW CREATE TABLE test.t2;
+SHOW CREATE TABLE test.t1;
+ALTER TABLE test.t2 TABLESPACE table_space1 STORAGE DISK
+ENGINE=NDB;
+SHOW CREATE TABLE test.t2;
+ALTER TABLE test.t1 ENGINE=NDBCLUSTER;
+SHOW CREATE TABLE test.t1;
+--echo
+######################### End Test Section 2 #################
+DROP TABLE test.t1;
+DROP TABLE test.t2;
+##################### Setup for Test Section 3 ###############
+--echo *** Setup for Test Section 3 ***
+CREATE TABLE test.t1 (
+ usr_id INT unsigned NOT NULL,
+ uniq_id INT unsigned NOT NULL AUTO_INCREMENT,
+ start_num INT unsigned NOT NULL DEFAULT 1,
+ increment INT unsigned NOT NULL DEFAULT 1,
+ PRIMARY KEY (uniq_id),
+ INDEX usr_uniq_idx (usr_id, uniq_id),
+ INDEX uniq_usr_idx (uniq_id, usr_id))
+TABLESPACE table_space1 STORAGE DISK
+ENGINE=NDB;
+
+
+CREATE TABLE test.t2 (
+ id INT unsigned NOT NULL DEFAULT 0,
+ usr2_id INT unsigned NOT NULL DEFAULT 0,
+ max INT unsigned NOT NULL DEFAULT 0,
+ c_amount INT unsigned NOT NULL DEFAULT 0,
+ d_max INT unsigned NOT NULL DEFAULT 0,
+ d_num INT unsigned NOT NULL DEFAULT 0,
+ orig_time INT unsigned NOT NULL DEFAULT 0,
+ c_time INT unsigned NOT NULL DEFAULT 0,
+ active ENUM ("no","yes") NOT NULL,
+ PRIMARY KEY (id,usr2_id),
+ INDEX id_idx (id),
+ INDEX usr2_idx (usr2_id))
+ENGINE=NDB;
+
+INSERT INTO test.t1 VALUES (3,NULL,0,50),(3,NULL,0,200),(3,NULL,0,25),(3,NULL,0,84676),(3,NULL,0,235),(3,NULL,0,10),(3,NULL,0,3098),(3,NULL,0,2947),(3,NULL,0,8987),(3,NULL,0,8347654),(3,NULL,0,20398),(3,NULL,0,8976),(3,NULL,0,500),(3,NULL,0,198);
+
+--echo
+###################### Test Section 3 ######################
+--echo **** Test Section 3 ****
+SELECT test.t1.usr_id,test.t1.uniq_id,test.t1.increment,
+test.t2.usr2_id,test.t2.c_amount,test.t2.max
+FROM test.t1
+LEFT JOIN test.t2 ON test.t2.id = test.t1.uniq_id
+WHERE test.t1.uniq_id = 4
+ORDER BY test.t2.c_amount;
+
+INSERT INTO test.t2 VALUES (2,3,3000,6000,0,0,746584,837484,'yes');
+INSERT INTO test.t2 VALUES (4,3,3000,6000,0,0,746584,837484,'yes');
+INSERT INTO test.t2 VALUES (7,3,1000,2000,0,0,746294,937484,'yes');
+
+SELECT test.t1.usr_id,test.t1.uniq_id,test.t1.increment,
+test.t2.usr2_id,test.t2.c_amount,test.t2.max
+FROM test.t1
+LEFT JOIN test.t2 ON test.t2.id = test.t1.uniq_id
+WHERE test.t1.uniq_id = 4
+ORDER BY test.t2.c_amount;
+--echo
+####################### End Section 3 #########################
+DROP TABLE test.t1;
+DROP TABLE test.t2;
+ALTER TABLESPACE table_space1
+DROP DATAFILE './table_space1/datafile.dat'
+ENGINE = NDB;
+
+DROP TABLESPACE table_space1
+ENGINE = NDB;
+
+DROP LOGFILE GROUP log_group1
+ENGINE =NDB;
+
+#End 5.1 test case
+
diff --git a/mysql-test/t/ndb_dd_dump.test b/mysql-test/t/ndb_dd_dump.test
new file mode 100644
index 00000000000..3f16f7fb28b
--- /dev/null
+++ b/mysql-test/t/ndb_dd_dump.test
@@ -0,0 +1,246 @@
+-- source include/have_ndb.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2, t3;
+--enable_warnings
+
+CREATE LOGFILE GROUP lg1
+ADD UNDOFILE 'undofile_lg1_01.dat'
+INITIAL_SIZE 2M
+UNDO_BUFFER_SIZE = 1M
+ENGINE NDB;
+
+ALTER LOGFILE GROUP lg1
+ADD UNDOFILE 'undofile_lg1_02.dat'
+INITIAL_SIZE = 4M
+ENGINE NDB;
+
+CREATE TABLESPACE ts1
+ADD DATAFILE 'datafile_ts1_01.dat'
+USE LOGFILE GROUP lg1
+EXTENT_SIZE 1M
+INITIAL_SIZE 2M
+ENGINE NDB;
+
+ALTER TABLESPACE ts1
+ADD DATAFILE 'datafile_ts1_02.dat'
+INITIAL_SIZE = 1M
+ENGINE=NDB;
+
+CREATE TABLESPACE ts2
+ADD DATAFILE 'datafile_ts2_01.dat'
+USE LOGFILE GROUP lg1
+INITIAL_SIZE 2M
+ENGINE NDB;
+
+CREATE TABLESPACE ts3
+ADD DATAFILE 'datafile_ts3_01.dat'
+USE LOGFILE GROUP lg1
+INITIAL_SIZE 4M
+ENGINE NDB;
+
+########################################
+# Create a table using this tablespace
+########################################
+
+CREATE TABLE t1
+(pk1 INT NOT NULL PRIMARY KEY, b INT NOT NULL, c INT NOT NULL)
+TABLESPACE ts1 STORAGE DISK
+ENGINE=NDB;
+
+CREATE TABLE t2
+(pk1 INT NOT NULL PRIMARY KEY, b INT NOT NULL, c INT NOT NULL)
+TABLESPACE ts2 STORAGE DISK
+ENGINE=NDB;
+
+CREATE TABLE t3
+(pk1 INT NOT NULL PRIMARY KEY, b INT NOT NULL, c INT NOT NULL)
+TABLESPACE ts3 STORAGE DISK
+ENGINE=NDB;
+
+INSERT INTO t1 VALUES
+(1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5),
+(6,6,6),(7,7,7),(8,8,8),(9,9,9),(10,10,10),
+(11,11,11),(12,12,12),(13,13,13),(14,14,14),(15,15,15),
+(16,16,16),(17,17,17),(18,18,18),(19,19,19),(20,20,20),
+(21,21,21),(22,22,22),(23,23,23),(24,24,24),(25,25,25),
+(26,26,26),(27,27,27),(28,28,28),(29,29,29),(30,30,30),
+(31,31,31),(32,32,32),(33,33,33),(34,34,34),(35,35,35),
+(36,36,36),(37,37,37),(38,38,38),(39,39,39),(40,40,40),
+(41,41,41),(42,42,42),(43,43,43),(44,44,44),(45,45,45),
+(46,46,46),(47,47,47),(48,48,48),(49,49,49),(50,50,50),
+(51,51,51),(52,52,52),(53,53,53),(54,54,54),(55,55,55),
+(56,56,56),(57,57,57),(58,58,58),(59,59,59),(60,60,60),
+(61,61,61),(62,62,62),(63,63,63),(64,64,64),(65,65,65),
+(66,66,66),(67,67,67),(68,68,68),(69,69,69),(70,70,70),
+(71,71,71),(72,72,72),(73,73,73),(74,74,74),(75,75,75),
+(76,76,76),(77,77,77),(78,78,78),(79,79,79),(80,80,80),
+(81,81,81),(82,82,82),(83,83,83),(84,84,84),(85,85,85),
+(86,86,86),(87,87,87),(88,88,88),(89,89,89),(90,90,90),
+(91,91,91),(92,92,92),(93,93,93),(94,94,94),(95,95,95),
+(96,96,96),(97,97,97),(98,98,98),(99,99,99),(100,100,100),
+(101,101,101),(102,102,102),(103,103,103),(104,104,104),(105,105,105),
+(106,106,106),(107,107,107),(108,108,108),(109,109,109),(110,110,110),
+(111,111,111),(112,112,112),(113,113,113),(114,114,114),(115,115,115),
+(116,116,116),(117,117,117),(118,118,118),(119,119,119),(120,120,120),
+(121,121,121),(122,122,122),(123,123,123),(124,124,124),(125,125,125),
+(126,126,126),(127,127,127),(128,128,128),(129,129,129),(130,130,130),
+(131,131,131),(132,132,132),(133,133,133),(134,134,134),(135,135,135),
+(136,136,136),(137,137,137),(138,138,138),(139,139,139),(140,140,140),
+(141,141,141),(142,142,142),(143,143,143),(144,144,144),(145,145,145),
+(146,146,146),(147,147,147),(148,148,148),(149,149,149),(150,150,150),
+(151,151,151),(152,152,152),(153,153,153),(154,154,154),(155,155,155),
+(156,156,156),(157,157,157),(158,158,158),(159,159,159),(160,160,160),
+(161,161,161),(162,162,162),(163,163,163),(164,164,164),(165,165,165),
+(166,166,166),(167,167,167),(168,168,168),(169,169,169),(170,170,170),
+(171,171,171),(172,172,172),(173,173,173),(174,174,174),(175,175,175),
+(176,176,176),(177,177,177),(178,178,178),(179,179,179),(180,180,180),
+(181,181,181),(182,182,182),(183,183,183),(184,184,184),(185,185,185),
+(186,186,186),(187,187,187),(188,188,188),(189,189,189),(190,190,190),
+(191,191,191),(192,192,192),(193,193,193),(194,194,194),(195,195,195),
+(196,196,196),(197,197,197),(198,198,198),(199,199,199),(200,200,200),
+(201,201,201),(202,202,202),(203,203,203),(204,204,204),(205,205,205),
+(206,206,206),(207,207,207),(208,208,208),(209,209,209),(210,210,210),
+(211,211,211),(212,212,212),(213,213,213),(214,214,214),(215,215,215),
+(216,216,216),(217,217,217),(218,218,218),(219,219,219),(220,220,220),
+(221,221,221),(222,222,222),(223,223,223),(224,224,224),(225,225,225),
+(226,226,226),(227,227,227),(228,228,228),(229,229,229),(230,230,230),
+(231,231,231),(232,232,232),(233,233,233),(234,234,234),(235,235,235),
+(236,236,236),(237,237,237),(238,238,238),(239,239,239),(240,240,240),
+(241,241,241),(242,242,242),(243,243,243),(244,244,244),(245,245,245),
+(246,246,246),(247,247,247),(248,248,248),(249,249,249),(250,250,250),
+(251,251,251),(252,252,252),(253,253,253),(254,254,254),(255,255,255),
+(256,256,256),(257,257,257),(258,258,258),(259,259,259),(260,260,260),
+(261,261,261),(262,262,262),(263,263,263),(264,264,264),(265,265,265),
+(266,266,266),(267,267,267),(268,268,268),(269,269,269),(270,270,270),
+(271,271,271),(272,272,272),(273,273,273),(274,274,274),(275,275,275),
+(276,276,276),(277,277,277),(278,278,278),(279,279,279),(280,280,280),
+(281,281,281),(282,282,282),(283,283,283),(284,284,284),(285,285,285),
+(286,286,286),(287,287,287),(288,288,288),(289,289,289),(290,290,290),
+(291,291,291),(292,292,292),(293,293,293),(294,294,294),(295,295,295),
+(296,296,296),(297,297,297),(298,298,298),(299,299,299),(300,300,300),
+(301,301,301),(302,302,302),(303,303,303),(304,304,304),(305,305,305),
+(306,306,306),(307,307,307),(308,308,308),(309,309,309),(310,310,310),
+(311,311,311),(312,312,312),(313,313,313),(314,314,314),(315,315,315),
+(316,316,316),(317,317,317),(318,318,318),(319,319,319),(320,320,320),
+(321,321,321),(322,322,322),(323,323,323),(324,324,324),(325,325,325),
+(326,326,326),(327,327,327),(328,328,328),(329,329,329),(330,330,330),
+(331,331,331),(332,332,332),(333,333,333),(334,334,334),(335,335,335),
+(336,336,336),(337,337,337),(338,338,338),(339,339,339),(340,340,340),
+(341,341,341),(342,342,342),(343,343,343),(344,344,344),(345,345,345),
+(346,346,346),(347,347,347),(348,348,348),(349,349,349),(350,350,350),
+(351,351,351),(352,352,352),(353,353,353),(354,354,354),(355,355,355),
+(356,356,356),(357,357,357),(358,358,358),(359,359,359),(360,360,360),
+(361,361,361),(362,362,362),(363,363,363),(364,364,364),(365,365,365),
+(366,366,366),(367,367,367),(368,368,368),(369,369,369),(370,370,370),
+(371,371,371),(372,372,372),(373,373,373),(374,374,374),(375,375,375),
+(376,376,376),(377,377,377),(378,378,378),(379,379,379),(380,380,380),
+(381,381,381),(382,382,382),(383,383,383),(384,384,384),(385,385,385),
+(386,386,386),(387,387,387),(388,388,388),(389,389,389),(390,390,390),
+(391,391,391),(392,392,392),(393,393,393),(394,394,394),(395,395,395),
+(396,396,396),(397,397,397),(398,398,398),(399,399,399),(400,400,400),
+(401,401,401),(402,402,402),(403,403,403),(404,404,404),(405,405,405),
+(406,406,406),(407,407,407),(408,408,408),(409,409,409),(410,410,410),
+(411,411,411),(412,412,412),(413,413,413),(414,414,414),(415,415,415),
+(416,416,416),(417,417,417),(418,418,418),(419,419,419),(420,420,420),
+(421,421,421),(422,422,422),(423,423,423),(424,424,424),(425,425,425),
+(426,426,426),(427,427,427),(428,428,428),(429,429,429),(430,430,430),
+(431,431,431),(432,432,432),(433,433,433),(434,434,434),(435,435,435),
+(436,436,436),(437,437,437),(438,438,438),(439,439,439),(440,440,440),
+(441,441,441),(442,442,442),(443,443,443),(444,444,444),(445,445,445),
+(446,446,446),(447,447,447),(448,448,448),(449,449,449),(450,450,450),
+(451,451,451),(452,452,452),(453,453,453),(454,454,454),(455,455,455),
+(456,456,456),(457,457,457),(458,458,458),(459,459,459),(460,460,460),
+(461,461,461),(462,462,462),(463,463,463),(464,464,464),(465,465,465),
+(466,466,466),(467,467,467),(468,468,468),(469,469,469),(470,470,470),
+(471,471,471),(472,472,472),(473,473,473),(474,474,474),(475,475,475),
+(476,476,476),(477,477,477),(478,478,478),(479,479,479),(480,480,480),
+(481,481,481),(482,482,482),(483,483,483),(484,484,484),(485,485,485),
+(486,486,486),(487,487,487),(488,488,488),(489,489,489),(490,490,490),
+(491,491,491),(492,492,492),(493,493,493),(494,494,494),(495,495,495),
+(496,496,496),(497,497,497),(498,498,498),(499,499,499),(500, 500, 500);
+
+INSERT INTO t2 VALUES
+(1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5);
+
+INSERT INTO t3 VALUES
+(1,1,1);
+
+--exec $MYSQL_DUMP --skip-comments --compact -Y test > $MYSQLTEST_VARDIR/tmp/ndb_dd_dump.sql
+
+DROP TABLE t1;
+DROP TABLE t2;
+DROP TABLE t3;
+
+ALTER TABLESPACE ts1
+DROP DATAFILE 'datafile_ts1_01.dat'
+ENGINE = NDB;
+
+ALTER TABLESPACE ts1
+DROP DATAFILE 'datafile_ts1_02.dat'
+ENGINE = NDB;
+
+ALTER TABLESPACE ts2
+DROP DATAFILE 'datafile_ts2_01.dat'
+ENGINE = NDB;
+
+ALTER TABLESPACE ts3
+DROP DATAFILE 'datafile_ts3_01.dat'
+ENGINE = NDB;
+
+DROP TABLESPACE ts1 ENGINE = NDB;
+DROP TABLESPACE ts2 ENGINE = NDB;
+DROP TABLESPACE ts3 ENGINE = NDB;
+
+DROP LOGFILE GROUP lg1 ENGINE = NDB;
+
+--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/ndb_dd_dump.sql
+
+SELECT DISTINCT
+ LOGFILE_GROUP_NAME,
+ FILE_NAME,
+ TOTAL_EXTENTS,
+ INITIAL_SIZE,
+ ENGINE
+FROM INFORMATION_SCHEMA.FILES WHERE FILE_TYPE="UNDO LOG" ORDER BY FILE_NAME;
+
+SELECT DISTINCT
+ TABLESPACE_NAME,
+ LOGFILE_GROUP_NAME,
+ FILE_NAME,
+ EXTENT_SIZE,
+ INITIAL_SIZE,
+ ENGINE
+FROM INFORMATION_SCHEMA.FILES WHERE FILE_TYPE="DATAFILE" ORDER BY FILE_NAME;
+
+SELECT COUNT(*) FROM t1;
+SELECT COUNT(*) FROM t2;
+SELECT COUNT(*) FROM t3;
+
+DROP TABLE t1;
+DROP TABLE t2;
+DROP TABLE t3;
+
+ALTER TABLESPACE ts1
+DROP DATAFILE 'datafile_ts1_01.dat'
+ENGINE = NDB;
+
+ALTER TABLESPACE ts1
+DROP DATAFILE 'datafile_ts1_02.dat'
+ENGINE = NDB;
+
+ALTER TABLESPACE ts2
+DROP DATAFILE 'datafile_ts2_01.dat'
+ENGINE = NDB;
+
+ALTER TABLESPACE ts3
+DROP DATAFILE 'datafile_ts3_01.dat'
+ENGINE = NDB;
+
+DROP TABLESPACE ts1 ENGINE = NDB;
+DROP TABLESPACE ts2 ENGINE = NDB;
+DROP TABLESPACE ts3 ENGINE = NDB;
+
+DROP LOGFILE GROUP lg1 ENGINE = NDB;
+
+#End 5.1 test case
diff --git a/mysql-test/t/ndb_index_ordered.test b/mysql-test/t/ndb_index_ordered.test
index e6827bdbe12..a03e0729ece 100644
--- a/mysql-test/t/ndb_index_ordered.test
+++ b/mysql-test/t/ndb_index_ordered.test
@@ -354,5 +354,79 @@ create table t1 (a int, c varchar(10),
primary key using hash (a), index(c)) engine=ndb;
insert into t1 (a, c) values (1,'aaa'),(3,'bbb');
select count(*) from t1 where c<'bbb';
+drop table t1;
+
+# -- index statistics --
+
+set autocommit=1;
+show session variables like 'ndb_index_stat_%';
+
+set ndb_index_stat_enable = off;
+show session variables like 'ndb_index_stat_%';
+
+create table t1 (a int, b int, c varchar(10) not null,
+ primary key using hash (a), index(b,c)) engine=ndb;
+insert into t1 values
+ (1,10,'aaa'),(2,10,'bbb'),(3,10,'ccc'),
+ (4,20,'aaa'),(5,20,'bbb'),(6,20,'ccc'),
+ (7,30,'aaa'),(8,30,'bbb'),(9,30,'ccc');
+select count(*) from t1 where b < 10;
+select count(*) from t1 where b >= 10 and c >= 'bbb';
+select count(*) from t1 where b > 10;
+select count(*) from t1 where b <= 20 and c < 'ccc';
+select count(*) from t1 where b = 20 and c = 'ccc';
+select count(*) from t1 where b > 20;
+select count(*) from t1 where b = 30 and c > 'aaa';
+select count(*) from t1 where b <= 20;
+select count(*) from t1 where b >= 20 and c > 'aaa';
+drop table t1;
+
+set ndb_index_stat_enable = on;
+set ndb_index_stat_cache_entries = 0;
+show session variables like 'ndb_index_stat_%';
+
+create table t1 (a int, b int, c varchar(10) not null,
+ primary key using hash (a), index(b,c)) engine=ndb;
+insert into t1 values
+ (1,10,'aaa'),(2,10,'bbb'),(3,10,'ccc'),
+ (4,20,'aaa'),(5,20,'bbb'),(6,20,'ccc'),
+ (7,30,'aaa'),(8,30,'bbb'),(9,30,'ccc');
+select count(*) from t1 where b < 10;
+select count(*) from t1 where b >= 10 and c >= 'bbb';
+select count(*) from t1 where b > 10;
+select count(*) from t1 where b <= 20 and c < 'ccc';
+select count(*) from t1 where b = 20 and c = 'ccc';
+select count(*) from t1 where b > 20;
+select count(*) from t1 where b = 30 and c > 'aaa';
+select count(*) from t1 where b <= 20;
+select count(*) from t1 where b >= 20 and c > 'aaa';
+drop table t1;
+
+set ndb_index_stat_enable = on;
+set ndb_index_stat_cache_entries = 4;
+set ndb_index_stat_update_freq = 2;
+show session variables like 'ndb_index_stat_%';
+
+create table t1 (a int, b int, c varchar(10) not null,
+ primary key using hash (a), index(b,c)) engine=ndb;
+insert into t1 values
+ (1,10,'aaa'),(2,10,'bbb'),(3,10,'ccc'),
+ (4,20,'aaa'),(5,20,'bbb'),(6,20,'ccc'),
+ (7,30,'aaa'),(8,30,'bbb'),(9,30,'ccc');
+select count(*) from t1 where b < 10;
+select count(*) from t1 where b >= 10 and c >= 'bbb';
+select count(*) from t1 where b > 10;
+select count(*) from t1 where b <= 20 and c < 'ccc';
+select count(*) from t1 where b = 20 and c = 'ccc';
+select count(*) from t1 where b > 20;
+select count(*) from t1 where b = 30 and c > 'aaa';
+select count(*) from t1 where b <= 20;
+select count(*) from t1 where b >= 20 and c > 'aaa';
+drop table t1;
+
+set ndb_index_stat_enable = @@global.ndb_index_stat_enable;
+set ndb_index_stat_cache_entries = @@global.ndb_index_stat_cache_entries;
+set ndb_index_stat_update_freq = @@global.ndb_index_stat_update_freq;
+show session variables like 'ndb_index_stat_%';
# End of 4.1 tests
diff --git a/mysql-test/t/ndb_index_unique.test b/mysql-test/t/ndb_index_unique.test
index 8561b3794c4..a40efc8a40c 100644
--- a/mysql-test/t/ndb_index_unique.test
+++ b/mysql-test/t/ndb_index_unique.test
@@ -10,10 +10,10 @@ drop table if exists t1, t2, t3, t4, t5, t6, t7, t8;
#
CREATE TABLE t1 (
- a int unsigned NOT NULL PRIMARY KEY,
- b int unsigned not null,
- c int unsigned,
- UNIQUE(b)
+ a int NOT NULL PRIMARY KEY,
+ b int not null,
+ c int,
+ UNIQUE ib(b)
) engine=ndbcluster;
insert t1 values(1, 2, 3), (2, 3, 5), (3, 4, 6), (4, 5, 8), (5,6, 2), (6,7, 2);
@@ -29,6 +29,12 @@ delete from t1 where a = 1;
insert into t1 values(8, 2, 3);
select * from t1 order by a;
+alter table t1 drop index ib;
+insert into t1 values(1, 2, 3);
+# Bug# #18129
+--error 1169
+create unique index ib on t1(b);
+
drop table t1;
#
@@ -66,7 +72,7 @@ CREATE TABLE t2 (
a int unsigned NOT NULL PRIMARY KEY,
b int unsigned not null,
c int unsigned not null,
- UNIQUE USING HASH (b, c)
+ UNIQUE (b, c) USING HASH
) engine=ndbcluster;
insert t2 values(1, 2, 3), (2, 3, 5), (3, 4, 6), (4, 5, 8), (5,6, 2), (6,7, 2);
@@ -90,7 +96,7 @@ CREATE TABLE t2 (
a int unsigned NOT NULL PRIMARY KEY,
b int unsigned not null,
c int unsigned,
- UNIQUE USING HASH (b, c)
+ UNIQUE (b, c) USING HASH
) engine=ndbcluster;
#
@@ -101,7 +107,7 @@ CREATE TABLE t3 (
a int unsigned NOT NULL,
b int unsigned not null,
c int unsigned,
- PRIMARY KEY USING HASH (a, b)
+ PRIMARY KEY (a, b) USING HASH
) engine=ndbcluster;
insert t3 values(1, 2, 3), (2, 3, 5), (3, 4, 6), (4, 5, 8), (5,6, 2), (6,7, 2);
diff --git a/mysql-test/t/ndb_lock.test b/mysql-test/t/ndb_lock.test
index 6945f91ee39..3d8597dcc45 100644
--- a/mysql-test/t/ndb_lock.test
+++ b/mysql-test/t/ndb_lock.test
@@ -70,3 +70,39 @@ insert into t1 values (1,1,1);
drop table t1;
# End of 4.1 tests
+
+#
+# Bug #17812 Previous lock table for write causes "stray" lock
+# although table is recreated
+#
+# this creating, locking, and dropping causes a subsequent hang
+# on the delete below waiting for table t2 the locking in the
+# "other" connection is relevant, as without it there is no problem
+#
+connection con1;
+create table t3 (id2 int) engine=ndb;
+
+connection con2;
+lock tables t3 write;
+unlock tables;
+
+connection con1;
+drop table t3;
+
+connection con1;
+create table t2 (id int, j int) engine=ndb;
+insert into t2 values (2, 2);
+create table t3 (id int) engine=ndb;
+
+connection con2;
+lock tables t3 read;
+
+connection con1;
+# here we get a hang before bugfix although we shouldn't
+delete t2 from t2, t3 where t2.id = t3.id;
+
+connection con2;
+unlock tables;
+
+connection con1;
+drop table t2, t3;
diff --git a/mysql-test/t/ndb_multi.test b/mysql-test/t/ndb_multi.test
index 1183f2b283f..d2dc0561955 100644
--- a/mysql-test/t/ndb_multi.test
+++ b/mysql-test/t/ndb_multi.test
@@ -1,9 +1,13 @@
-- source include/have_ndb.inc
-- source include/have_multi_ndb.inc
-- source include/not_embedded.inc
+-- source include/have_binlog_format_statement.inc
--disable_warnings
+connection server2;
+drop table if exists t1, t2, t3, t4;
+connection server1;
drop table if exists t1, t2, t3, t4;
--enable_warnings
@@ -37,10 +41,12 @@ drop table t1;
create table t1 (a int) engine=ndbcluster;
insert into t1 value (2);
connection server1;
-# Currently a retry is required remotely
---error 1296
-select * from t1;
-flush table t1;
+## Currently a retry is required remotely
+#--error 1412
+#select * from t1;
+#show warnings;
+#flush table t1;
+# Table definition change should be propagated automatically
select * from t1;
# Connect to server2 and use the tables from there
@@ -60,13 +66,9 @@ create table t4 (pk int primary key, b int) engine=ndb;
connection server1;
select * from t1;
select * from t3;
-show status like 'handler_discover%';
show tables like 't4';
-show status like 'handler_discover%';
show tables;
drop table t1, t2, t3, t4;
-connection server2;
-drop table t1, t3, t4;
# End of 4.1 tests
diff --git a/mysql-test/t/ndb_multi_row.test b/mysql-test/t/ndb_multi_row.test
new file mode 100644
index 00000000000..05a0944e99a
--- /dev/null
+++ b/mysql-test/t/ndb_multi_row.test
@@ -0,0 +1,76 @@
+-- source include/have_ndb.inc
+-- source include/have_multi_ndb.inc
+-- source include/not_embedded.inc
+-- source include/have_binlog_format_row.inc
+
+
+--disable_warnings
+connection server2;
+drop table if exists t1, t2, t3, t4;
+connection server1;
+drop table if exists t1, t2, t3, t4;
+--enable_warnings
+
+flush status;
+
+# Create test tables on server1
+create table t1 (a int) engine=ndbcluster;
+create table t2 (a int) engine=ndbcluster;
+insert into t1 value (2);
+insert into t2 value (3);
+select * from t1;
+select * from t2;
+show status like 'handler_discover%';
+
+# Check dropping and recreating table on same server
+connect (con1,localhost,,,test);
+connect (con2,localhost,,,test);
+connection con1;
+select * from t1;
+connection con2;
+drop table t1;
+create table t1 (a int) engine=ndbcluster;
+insert into t1 value (2);
+connection con1;
+select * from t1;
+
+# Check dropping and recreating table on different server
+connection server2;
+show status like 'handler_discover%';
+drop table t1;
+create table t1 (a int) engine=ndbcluster;
+insert into t1 value (2);
+connection server1;
+## Currently a retry is required remotely
+#--error 1412
+#select * from t1;
+#show warnings;
+#flush table t1;
+# Table definition change should be propagated automatically
+select * from t1;
+
+# Connect to server2 and use the tables from there
+connection server2;
+flush status;
+select * from t1;
+update t1 set a=3 where a=2;
+show status like 'handler_discover%';
+
+# Create a new table on server2
+create table t3 (a int not null primary key, b varchar(22),
+c int, last_col text) engine=ndb;
+insert into t3 values(1, 'Hi!', 89, 'Longtext column');
+create table t4 (pk int primary key, b int) engine=ndb;
+
+# Check that the tables are accessible from server1
+connection server1;
+select * from t1;
+select * from t3;
+show tables like 't4';
+show tables;
+
+drop table t1, t2, t3, t4;
+connection server2;
+drop table if exists t1, t3, t4;
+
+# End of 4.1 tests
diff --git a/mysql-test/t/ndb_rename.test b/mysql-test/t/ndb_rename.test
new file mode 100644
index 00000000000..7f9fd0e6984
--- /dev/null
+++ b/mysql-test/t/ndb_rename.test
@@ -0,0 +1,36 @@
+-- source include/have_ndb.inc
+-- source include/not_embedded.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1,t2;
+drop database if exists mysqltest;
+--enable_warnings
+
+#
+# Table rename tests
+#
+
+#
+# Create a normal table with primary key
+#
+CREATE TABLE t1 (
+ pk1 INT NOT NULL PRIMARY KEY,
+ attr1 INT NOT NULL,
+ attr2 INT,
+ attr3 VARCHAR(10),
+ INDEX i1(attr1)
+) ENGINE=ndbcluster;
+
+INSERT INTO t1 VALUES (0,0,0,"zero"),(1,1,1,"one"),(2,2,2,"two");
+SELECT * FROM t1 WHERE attr1 = 1;
+alter table t1 rename t2;
+SELECT * FROM t2 WHERE attr1 = 1;
+
+create database ndbtest;
+alter table t2 rename ndbtest.t2;
+SELECT * FROM ndbtest.t2 WHERE attr1 = 1;
+
+drop table ndbtest.t2;
+drop database ndbtest;
+
+# End of 4.1 tests
diff --git a/mysql-test/t/ndb_restore.test b/mysql-test/t/ndb_restore.test
index 049b07d5a8b..f11324492c2 100644
--- a/mysql-test/t/ndb_restore.test
+++ b/mysql-test/t/ndb_restore.test
@@ -8,15 +8,15 @@ drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
drop table if exists t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c;
--enable_warnings
-CREATE TABLE `t1` (
+CREATE TABLE `t1_c` (
`capgoaledatta` smallint(5) unsigned NOT NULL auto_increment,
`goaledatta` char(2) NOT NULL default '',
`maturegarbagefa` varchar(32) NOT NULL default '',
PRIMARY KEY (`capgoaledatta`,`goaledatta`,`maturegarbagefa`)
-) ENGINE=myisam DEFAULT CHARSET=latin1;
-INSERT INTO `t1` VALUES (2,'3','q3plus.qt'),(4,'4','q3plus.qt'),(1,'3','q3.net'),(3,'4','q3.net'),(3,'20','threetrees.qt');
+) ENGINE=ndbcluster DEFAULT CHARSET=latin1;
+INSERT INTO `t1_c` VALUES (2,'3','q3plus.qt'),(4,'4','q3plus.qt'),(1,'3','q3.net'),(3,'4','q3.net'),(3,'20','threetrees.qt');
-CREATE TABLE `t2` (
+CREATE TABLE `t2_c` (
`capgotod` smallint(5) unsigned NOT NULL auto_increment,
`gotod` smallint(5) unsigned NOT NULL default '0',
`goaledatta` char(2) default NULL,
@@ -25,17 +25,17 @@ CREATE TABLE `t2` (
`svcutonsa` varchar(64) NOT NULL default '',
PRIMARY KEY (`capgotod`),
KEY `i_quadaddsvr` (`gotod`)
-) ENGINE=myisam DEFAULT CHARSET=latin1;
-INSERT INTO `t2` VALUES (5,4,'','q3.net','addavp:MK_CASELECTOR=1','postorod rattoaa'),(2,1,'4','','addavp:MK_BRANDTAD=345','REDS Brandtad'),(3,2,'4','q3.net','execorder','fixedRatediPO REDS'),(1,1,'3','','addavp:MK_BRANDTAD=123','TEST Brandtad'),(6,5,'','told.q3.net','addavp:MK_BRANDTAD=123','Brandtad Toldzone'),(4,3,'3','q3.net','addavp:MK_POOLHINT=2','ratedi PO TEST');
+) ENGINE=ndbcluster DEFAULT CHARSET=latin1;
+INSERT INTO `t2_c` VALUES (5,4,'','q3.net','addavp:MK_CASELECTOR=1','postorod rattoaa'),(2,1,'4','','addavp:MK_BRANDTAD=345','REDS Brandtad'),(3,2,'4','q3.net','execorder','fixedRatediPO REDS'),(1,1,'3','','addavp:MK_BRANDTAD=123','TEST Brandtad'),(6,5,'','told.q3.net','addavp:MK_BRANDTAD=123','Brandtad Toldzone'),(4,3,'3','q3.net','addavp:MK_POOLHINT=2','ratedi PO TEST');
-CREATE TABLE `t3` (
+CREATE TABLE `t3_c` (
`CapGoaledatta` smallint(5) unsigned NOT NULL default '0',
`capgotod` smallint(5) unsigned NOT NULL default '0',
PRIMARY KEY (`capgotod`,`CapGoaledatta`)
-) ENGINE=myisam DEFAULT CHARSET=latin1;
-INSERT INTO `t3` VALUES (5,3),(2,4),(5,4),(1,3);
+) ENGINE=ndbcluster DEFAULT CHARSET=latin1;
+INSERT INTO `t3_c` VALUES (5,3),(2,4),(5,4),(1,3);
-CREATE TABLE `t4` (
+CREATE TABLE `t4_c` (
`capfa` bigint(20) unsigned NOT NULL auto_increment,
`realm` varchar(32) NOT NULL default '',
`authpwchap` varchar(32) default NULL,
@@ -45,26 +45,26 @@ CREATE TABLE `t4` (
PRIMARY KEY (`fa`,`realm`),
KEY `capfa` (`capfa`),
KEY `i_quadentity` (`fa`,`realm`)
-) ENGINE=myisam DEFAULT CHARSET=latin1;
-INSERT INTO `t4` VALUES (18,'john.smith','q3.net','dessjohn.smith',0,NULL),(21,'quad_katt_with_brandtad','q3.net','acne',0,NULL),(22,'quad_katt_carattoaa','q3.net','acne',0,NULL),(26,'436462612809','sqasdt.q3.net','N/A',0,'6'),(19,'john','smith.qt','dessjohn',0,NULL),(33,'436643196120','sqasdt.q3.net','N/A',1,'6'),(28,'436642900019','sqasdt.q3.net','N/A',0,'6'),(30,'436462900209','sqasdt.q3.net','N/A',0,'6'),(16,'436640006666','sqasdt.q3.net','',0,NULL),(19,'dette','el-redun.com','dessdette',0,NULL),(12,'quad_kattPP','q3.net','acne',2,NULL),(14,'436640008888','sqasdt.q3.net','',0,NULL),(29,'463624900028','sqasdt.q3.net','N/A',0,'6'),(15,'436640099099','sqasdt.q3.net','',0,NULL),(13,'pap','q3plus.qt','acne',1,NULL),(19,'436642612091','sqasdt.q3.net','N/A',0,'6'),(12,'quad_katt','q3.net','acne',0,NULL),(11,'quad_kattVK','q3.net','acne',1,NULL),(32,'463641969502','sqasdt.q3.net','N/A',1,'6'),(20,'joe','q3.net','joedesswd',0,NULL),(29,'436642900034','sqasdt.q3.net','N/A',0,'6'),(25,'contind','armerde.qt','acne',1,NULL);
+) ENGINE=ndbcluster DEFAULT CHARSET=latin1;
+INSERT INTO `t4_c` VALUES (18,'john.smith','q3.net','dessjohn.smith',0,NULL),(21,'quad_katt_with_brandtad','q3.net','acne',0,NULL),(22,'quad_katt_carattoaa','q3.net','acne',0,NULL),(26,'436462612809','sqasdt.q3.net','N/A',0,'6'),(19,'john','smith.qt','dessjohn',0,NULL),(33,'436643196120','sqasdt.q3.net','N/A',1,'6'),(28,'436642900019','sqasdt.q3.net','N/A',0,'6'),(30,'436462900209','sqasdt.q3.net','N/A',0,'6'),(16,'436640006666','sqasdt.q3.net','',0,NULL),(19,'dette','el-redun.com','dessdette',0,NULL),(12,'quad_kattPP','q3.net','acne',2,NULL),(14,'436640008888','sqasdt.q3.net','',0,NULL),(29,'463624900028','sqasdt.q3.net','N/A',0,'6'),(15,'436640099099','sqasdt.q3.net','',0,NULL),(13,'pap','q3plus.qt','acne',1,NULL),(19,'436642612091','sqasdt.q3.net','N/A',0,'6'),(12,'quad_katt','q3.net','acne',0,NULL),(11,'quad_kattVK','q3.net','acne',1,NULL),(32,'463641969502','sqasdt.q3.net','N/A',1,'6'),(20,'joe','q3.net','joedesswd',0,NULL),(29,'436642900034','sqasdt.q3.net','N/A',0,'6'),(25,'contind','armerde.qt','acne',1,NULL);
-CREATE TABLE `t5` (
+CREATE TABLE `t5_c` (
`capfa` bigint(20) unsigned NOT NULL default '0',
`gotod` smallint(5) unsigned NOT NULL default '0',
`orderutonsa` varchar(64) NOT NULL default '',
PRIMARY KEY (`capfa`,`gotod`,`orderutonsa`)
-) ENGINE=myisam DEFAULT CHARSET=latin1;
-INSERT INTO `t5` VALUES (21,2,''),(21,1,''),(22,4,'');
+) ENGINE=ndbcluster DEFAULT CHARSET=latin1;
+INSERT INTO `t5_c` VALUES (21,2,''),(21,1,''),(22,4,'');
-CREATE TABLE `t6` (
+CREATE TABLE `t6_c` (
`capfa_parent` bigint(20) unsigned NOT NULL default '0',
`capfa_child` bigint(20) unsigned NOT NULL default '0',
`relatta` smallint(5) unsigned NOT NULL default '0',
PRIMARY KEY (`capfa_child`,`capfa_parent`,`relatta`)
-) ENGINE=myisam DEFAULT CHARSET=latin1;
-INSERT INTO `t6` VALUES (15,16,0),(19,20,0),(18326932092909551615,30,0),(26,29,0),(18326932092909551615,29,0),(19,18,0),(26,28,0),(12,14,0);
+) ENGINE=ndbcluster DEFAULT CHARSET=latin1;
+INSERT INTO `t6_c` VALUES (15,16,0),(19,20,0),(18326932092909551615,30,0),(26,29,0),(18326932092909551615,29,0),(19,18,0),(26,28,0),(12,14,0);
-CREATE TABLE `t7` (
+CREATE TABLE `t7_c` (
`dardpo` char(15) NOT NULL default '',
`dardtestard` tinyint(3) unsigned NOT NULL default '0',
`FastFA` char(5) NOT NULL default '',
@@ -73,10 +73,10 @@ CREATE TABLE `t7` (
`Fastmag` char(1) NOT NULL default '',
`Beareratta` char(2) NOT NULL default '',
PRIMARY KEY (`dardpo`,`dardtestard`)
-) ENGINE=myisam DEFAULT CHARSET=latin1;
-INSERT INTO `t7` VALUES ('2.6.2.4',24,'CECHP','54545','0','0','5'),('2.2.5.4',26,'CANFA','33223','1','1','4'),('4.3.2.4',28,'ITALD','54222','1','0','5'),('129..0.0.eins',28,'G','99999','1','1','5'),('1.1.1.1',24,'AUTPT','32323','0','1','3');
+) ENGINE=ndbcluster DEFAULT CHARSET=latin1;
+INSERT INTO `t7_c` VALUES ('2.6.2.4',24,'CECHP','54545','0','0','5'),('2.2.5.4',26,'CANFA','33223','1','1','4'),('4.3.2.4',28,'ITALD','54222','1','0','5'),('129..0.0.eins',28,'G','99999','1','1','5'),('1.1.1.1',24,'AUTPT','32323','0','1','3');
-CREATE TABLE `t8` (
+CREATE TABLE `t8_c` (
`kattjame` varchar(32) NOT NULL default '',
`realm` varchar(32) NOT NULL default '',
`realm_entered` varchar(32) NOT NULL default '',
@@ -102,10 +102,10 @@ CREATE TABLE `t8` (
`acctinputoctets` bigint(20) unsigned default NULL,
PRIMARY KEY (`kattjame`,`hunderaaarbagefa`,`hassetistart`,`hassetino`),
KEY `squardporoot` (`squardporoot`)
-) ENGINE=myisam DEFAULT CHARSET=latin1;
-INSERT INTO `t8` VALUES ('4tt45345235','pap','q3plus.qt','q3plus.qt','q3.net','436643196120','436643196929','8956234534568968','5524595699','uxasmt21.net.acne.qt/481889229462692422','','1.1.1.1','2.2.4.6','4','86989','34','x','x','2012-03-12 12:55:34','2012-12-05 11:20:04',3223433,3369,9565),('4545435545','john','q3.net','q3.net','acne.li','436643196120','436643196929','45345234568968','995696699','uxasmt21.net.acne.qt/481889229462692423','','1.1.1.1','2.2.9.8','2','86989','34','x','x','2012-03-12 11:35:03','2012-12-05 08:50:04',8821923,169,3565),('versteckter_q3net_katt','joe','q3.net','elredun.com','q3.net','436643196120','436643196939','91341234568968','695595699','uxasmt21.net.acne.qt/481889229462692421','','1.1.1.1','2.5.2.5','3','86989','34','x','x','2012-03-12 18:35:04','2012-12-05 12:35:04',1923123,9569,6565);
+) ENGINE=ndbcluster DEFAULT CHARSET=latin1;
+INSERT INTO `t8_c` VALUES ('4tt45345235','pap','q3plus.qt','q3plus.qt','q3.net','436643196120','436643196929','8956234534568968','5524595699','uxasmt21.net.acne.qt/481889229462692422','','1.1.1.1','2.2.4.6','4','86989','34','x','x','2012-03-12 12:55:34','2012-12-05 11:20:04',3223433,3369,9565),('4545435545','john','q3.net','q3.net','acne.li','436643196120','436643196929','45345234568968','995696699','uxasmt21.net.acne.qt/481889229462692423','','1.1.1.1','2.2.9.8','2','86989','34','x','x','2012-03-12 11:35:03','2012-12-05 08:50:04',8821923,169,3565),('versteckter_q3net_katt','joe','q3.net','elredun.com','q3.net','436643196120','436643196939','91341234568968','695595699','uxasmt21.net.acne.qt/481889229462692421','','1.1.1.1','2.5.2.5','3','86989','34','x','x','2012-03-12 18:35:04','2012-12-05 12:35:04',1923123,9569,6565);
-CREATE TABLE `t9` (
+CREATE TABLE `t9_c` (
`kattjame` varchar(32) NOT NULL default '',
`kattjame_entered` varchar(32) NOT NULL default '',
`realm` varchar(32) NOT NULL default '',
@@ -129,27 +129,111 @@ CREATE TABLE `t9` (
`actinputocctets` bigint(20) unsigned default NULL,
`terminateraste` tinyint(3) unsigned default NULL,
PRIMARY KEY (`kattjame`,`hunderaaarbagefa`,`hassetistart`,`hassetino`)
-) ENGINE=myisam DEFAULT CHARSET=latin1;
-INSERT INTO `t9` VALUES ('3g4jh8gar2t','joe','q3.net','elredun.com','q3.net','436643316120','436643316939','91341234568968','695595699','1.1.1.1','2.2.6.2','3','86989','34','x','x','2012-03-12 18:35:04','2012-12-05 12:35:04',3123123,9569,6565,1),('4tt45345235','pap','q3plus.qt','q3plus.qt','q3.net','436643316120','436643316939','8956234534568968','5254595969','1.1.1.1','8.6.2.2','4','86989','34','x','x','2012-03-12 12:55:34','2012-12-05 11:20:04',3223433,3369,9565,2),('4545435545','john','q3.net','q3.net','acne.li','436643316120','436643316939','45345234568968','995696699','1.1.1.1','2.9.9.2','2','86998','34','x','x','2012-03-12 11:35:03','2012-12-05 08:50:04',8823123,169,3565,3);
+) ENGINE=ndbcluster DEFAULT CHARSET=latin1;
+INSERT INTO `t9_c` VALUES ('3g4jh8gar2t','joe','q3.net','elredun.com','q3.net','436643316120','436643316939','91341234568968','695595699','1.1.1.1','2.2.6.2','3','86989','34','x','x','2012-03-12 18:35:04','2012-12-05 12:35:04',3123123,9569,6565,1),('4tt45345235','pap','q3plus.qt','q3plus.qt','q3.net','436643316120','436643316939','8956234534568968','5254595969','1.1.1.1','8.6.2.2','4','86989','34','x','x','2012-03-12 12:55:34','2012-12-05 11:20:04',3223433,3369,9565,2),('4545435545','john','q3.net','q3.net','acne.li','436643316120','436643316939','45345234568968','995696699','1.1.1.1','2.9.9.2','2','86998','34','x','x','2012-03-12 11:35:03','2012-12-05 08:50:04',8823123,169,3565,3);
-create table t1_c engine=ndbcluster as select * from t1;
-create table t2_c engine=ndbcluster as select * from t2;
-create table t3_c engine=ndbcluster as select * from t3;
-create table t4_c engine=ndbcluster as select * from t4;
-create table t5_c engine=ndbcluster as select * from t5;
-create table t6_c engine=ndbcluster as select * from t6;
-create table t7_c engine=ndbcluster as select * from t7;
-create table t8_c engine=ndbcluster as select * from t8;
-create table t9_c engine=ndbcluster as select * from t9;
+create table t1 engine=myisam as select * from t1_c;
+create table t2 engine=myisam as select * from t2_c;
+create table t3 engine=myisam as select * from t3_c;
+create table t4 engine=myisam as select * from t4_c;
+create table t5 engine=myisam as select * from t5_c;
+create table t6 engine=myisam as select * from t6_c;
+create table t7 engine=myisam as select * from t7_c;
+create table t8 engine=myisam as select * from t8_c;
+create table t9 engine=myisam as select * from t9_c;
---exec $NDB_MGM --no-defaults -e "start backup" >> $NDB_TOOLS_OUTPUT
+--source include/ndb_backup.inc
drop table t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c;
---exec $NDB_TOOLS_DIR/ndb_restore --no-defaults -b 1 -n 1 -m -r --print --print_meta $NDB_BACKUP_DIR/BACKUP/BACKUP-1 >> $NDB_TOOLS_OUTPUT
---exec $NDB_TOOLS_DIR/ndb_restore --no-defaults -b 1 -n 2 -r --print --print_meta $NDB_BACKUP_DIR/BACKUP/BACKUP-1 >> $NDB_TOOLS_OUTPUT
+--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults -b $the_backup_id -n 1 -m -r --print --print_meta $NDB_BACKUP_DIR/BACKUP/BACKUP-$the_backup_id >> $NDB_TOOLS_OUTPUT
+--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults -b $the_backup_id -n 2 -r --print --print_meta $NDB_BACKUP_DIR/BACKUP/BACKUP-$the_backup_id >> $NDB_TOOLS_OUTPUT
-show tables;
+# random output order??
+#show tables;
+select count(*) from t1;
+select count(*) from t1_c;
+select count(*)
+ from (select * from t1 union
+ select * from t1_c) a;
+
+select count(*) from t2;
+select count(*) from t2_c;
+select count(*)
+ from (select * from t2 union
+ select * from t2_c) a;
+
+select count(*) from t3;
+select count(*) from t3_c;
+select count(*)
+ from (select * from t3 union
+ select * from t3_c) a;
+
+select count(*) from t4;
+select count(*) from t4_c;
+select count(*)
+ from (select * from t4 union
+ select * from t4_c) a;
+
+select count(*) from t5;
+select count(*) from t5_c;
+select count(*)
+ from (select * from t5 union
+ select * from t5_c) a;
+
+select count(*) from t6;
+select count(*) from t6_c;
+select count(*)
+ from (select * from t6 union
+ select * from t6_c) a;
+
+select count(*) from t7;
+select count(*) from t7_c;
+select count(*)
+ from (select * from t7 union
+ select * from t7_c) a;
+
+select count(*) from t8;
+select count(*) from t8_c;
+select count(*)
+ from (select * from t8 union
+ select * from t8_c) a;
+
+select count(*) from t9;
+select count(*) from t9_c;
+select count(*)
+ from (select * from t9 union
+ select * from t9_c) a;
+
+#
+# Try Partitioned tables as well
+#
+ALTER TABLE t1_c
+PARTITION BY RANGE (`capgoaledatta`)
+(PARTITION p0 VALUES LESS THAN MAXVALUE);
+
+ALTER TABLE t2_c
+PARTITION BY LIST(`capgotod`)
+(PARTITION p0 VALUES IN (0,1,2,3,4,5,6));
+
+ALTER TABLE t3_c
+PARTITION BY HASH (`CapGoaledatta`);
+
+ALTER TABLE t5_c
+PARTITION BY HASH (`capfa`)
+PARTITIONS 4;
+
+ALTER TABLE t6_c
+PARTITION BY LINEAR HASH (`relatta`)
+PARTITIONS 4;
+
+ALTER TABLE t7_c
+PARTITION BY LINEAR KEY (`dardtestard`);
+
+--source include/ndb_backup.inc
+drop table t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c;
+--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults -b $the_backup_id -n 1 -m -r --print --print_meta $NDB_BACKUP_DIR/BACKUP/BACKUP-$the_backup_id >> $NDB_TOOLS_OUTPUT
+--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults -b $the_backup_id -n 2 -r --print --print_meta $NDB_BACKUP_DIR/BACKUP/BACKUP-$the_backup_id >> $NDB_TOOLS_OUTPUT
select count(*) from t1;
select count(*) from t1_c;
@@ -205,15 +289,87 @@ select count(*)
from (select * from t9 union
select * from t9_c) a;
+drop table t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c;
+--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults -b $the_backup_id -n 1 -m -r --ndb-nodegroup_map '(0,0)' --print --print_meta $NDB_BACKUP_DIR/BACKUP/BACKUP-$the_backup_id >> $NDB_TOOLS_OUTPUT
+--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults -b $the_backup_id -n 2 -r --print --print_meta $NDB_BACKUP_DIR/BACKUP/BACKUP-$the_backup_id >> $NDB_TOOLS_OUTPUT
+
+select count(*) from t1;
+select count(*) from t1_c;
+select count(*)
+ from (select * from t1 union
+ select * from t1_c) a;
+
+select count(*) from t2;
+select count(*) from t2_c;
+select count(*)
+ from (select * from t2 union
+ select * from t2_c) a;
+
+select count(*) from t3;
+select count(*) from t3_c;
+select count(*)
+ from (select * from t3 union
+ select * from t3_c) a;
+
+select count(*) from t4;
+select count(*) from t4_c;
+select count(*)
+ from (select * from t4 union
+ select * from t4_c) a;
+
+select count(*) from t5;
+select count(*) from t5_c;
+select count(*)
+ from (select * from t5 union
+ select * from t5_c) a;
+
+select count(*) from t6;
+select count(*) from t6_c;
+select count(*)
+ from (select * from t6 union
+ select * from t6_c) a;
+
+select count(*) from t7;
+select count(*) from t7_c;
+select count(*)
+ from (select * from t7 union
+ select * from t7_c) a;
+
+select count(*) from t8;
+select count(*) from t8_c;
+select count(*)
+ from (select * from t8 union
+ select * from t8_c) a;
+
+select count(*) from t9;
+select count(*) from t9_c;
+select count(*)
+ from (select * from t9 union
+ select * from t9_c) a;
+
+#
+# Drop all table except t2_c
+# This to make sure that error returned from ndb_restore above is
+# guaranteed to be from t2_c, this since order of tables in backup
+# is none deterministic
+#
+drop table t1_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c;
+--source include/ndb_backup.inc
+--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults --core=0 -b $the_backup_id -n 1 -m -r --ndb-nodegroup_map '(0,1)' $NDB_BACKUP_DIR/BACKUP/BACKUP-$the_backup_id 2>&1 | grep Translate || true
+
+#
+# Cleanup
+#
+
--disable_warnings
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-drop table if exists t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c;
+drop table if exists t2_c;
--enable_warnings
#
# Test BUG#10287
#
---exec $NDB_TOOLS_DIR/ndb_select_all --no-defaults -d sys -D , SYSTAB_0 | grep 520093696
+--exec $NDB_TOOLS_DIR/ndb_select_all --no-defaults -d sys -D , SYSTAB_0 | grep 520093696, | sed "s/,$the_backup_id/,<the_backup_id>/"
# End of 4.1 tests
diff --git a/mysql-test/t/ndb_restore_compat.test b/mysql-test/t/ndb_restore_compat.test
new file mode 100644
index 00000000000..774011e362d
--- /dev/null
+++ b/mysql-test/t/ndb_restore_compat.test
@@ -0,0 +1,43 @@
+-- source include/have_ndb.inc
+-- source include/not_embedded.inc
+-- source include/have_case_sensitive_file_system.inc
+
+# This test currently requires case sensitive file system as the tables
+# are originally stored with uppercase
+
+#
+# Bug #18594 ndb_restore log boken in 5.1
+#
+
+--disable_warnings
+DROP DATABASE IF EXISTS BANK;
+--enable_warnings
+CREATE DATABASE BANK default charset=latin1 default collate=latin1_bin;
+USE BANK;
+--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults -b 1 -n 1 -p 1 -m -r $MYSQL_TEST_DIR/std_data/ndb_backup51 >> $NDB_TOOLS_OUTPUT
+--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults -e -b 1 -n 2 -p 1 -r $MYSQL_TEST_DIR/std_data/ndb_backup51 >> $NDB_TOOLS_OUTPUT
+SHOW TABLES;
+SELECT * FROM GL ORDER BY TIME,ACCOUNT_TYPE;
+SELECT * FROM ACCOUNT ORDER BY ACCOUNT_ID;
+SELECT COUNT(*) FROM TRANSACTION;
+SELECT * FROM SYSTEM_VALUES ORDER BY SYSTEM_VALUES_ID;
+SELECT * FROM cluster.apply_status WHERE server_id=0;
+
+#
+# verify restore of 5.0 backup
+# here we must use the already created tables as restoring the old
+# table definitions will not work
+#
+TRUNCATE GL;
+TRUNCATE ACCOUNT;
+TRUNCATE TRANSACTION;
+TRUNCATE SYSTEM_VALUES;
+TRUNCATE ACCOUNT_TYPE;
+--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults -b 1 -n 1 -p 1 -r $MYSQL_TEST_DIR/std_data/ndb_backup50 >> $NDB_TOOLS_OUTPUT
+--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults -e -b 1 -n 2 -p 1 -r $MYSQL_TEST_DIR/std_data/ndb_backup50 >> $NDB_TOOLS_OUTPUT
+SELECT * FROM GL ORDER BY TIME,ACCOUNT_TYPE;
+SELECT * FROM ACCOUNT ORDER BY ACCOUNT_ID;
+SELECT COUNT(*) FROM TRANSACTION;
+SELECT * FROM SYSTEM_VALUES ORDER BY SYSTEM_VALUES_ID;
+SELECT * FROM cluster.apply_status WHERE server_id=0;
+DROP DATABASE BANK;
diff --git a/mysql-test/t/ndb_temporary.test b/mysql-test/t/ndb_temporary.test
new file mode 100644
index 00000000000..7f6902bf745
--- /dev/null
+++ b/mysql-test/t/ndb_temporary.test
@@ -0,0 +1,38 @@
+-- source include/have_ndb.inc
+-- source include/not_embedded.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+#
+# creating a temporary table with engine=ndb should give an error
+#
+--error ER_ILLEGAL_HA_CREATE_OPTION
+create temporary table t1 (a int key) engine=ndb;
+
+
+#
+# alter temporary table to engine=ndb should give an error
+#
+create temporary table t1 (a int key) engine=myisam;
+--error ER_ILLEGAL_HA_CREATE_OPTION
+alter table t1 engine=ndb;
+drop table t1;
+
+
+#
+# if default storage engine=ndb, temporary tables
+# without explicit engine= should be created as myisam
+#
+SET SESSION storage_engine=NDBCLUSTER;
+create table t1 (a int key);
+
+# verify that we have a ndb table
+select engine from information_schema.tables where table_name = 't1';
+drop table t1;
+
+# verify that we have a myisam table
+create temporary table t1 (a int key);
+show create table t1;
+drop table t1;
diff --git a/mysql-test/t/ndb_view.test b/mysql-test/t/ndb_view.test
new file mode 100644
index 00000000000..3b8fc330b40
--- /dev/null
+++ b/mysql-test/t/ndb_view.test
@@ -0,0 +1,29 @@
+-- source include/have_ndb.inc
+-- source include/not_embedded.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1,t2,t3;
+DROP VIEW IF EXISTS v1,v2,v3;
+--enable_warnings
+
+#
+# simple operations via view
+#
+
+create table t1 (a int, b int, c int, d int) engine=ndb;
+insert into t1 values (1,2,3,4),(5,6,7,8);
+
+create view v1 as select t1.c as a, t1.a as b, t1.d as c, t1.a+t1.b+t1.c as d from t1;
+select * from v1 order by a,b,c;
+
+update v1 set a=a+100 where b=1;
+select * from v1 order by a,b,c;
+
+drop view v1;
+
+create view v1 as select t1.c as a from t1;
+insert into v1 values (200);
+select * from t1 order by a,b,c,d;
+
+drop view v1;
+drop table t1;
diff --git a/mysql-test/t/partition.test b/mysql-test/t/partition.test
new file mode 100644
index 00000000000..f7676ca471a
--- /dev/null
+++ b/mysql-test/t/partition.test
@@ -0,0 +1,1097 @@
+#--disable_abort_on_error
+#
+# Simple test for the partition storage engine
+# Taken fromm the select test
+#
+-- source include/have_partition.inc
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+create table t1 (a int)
+partition by key(a)
+(partition p0 engine = MEMORY);
+drop table t1;
+
+#
+# Partition by key no partition defined => OK
+#
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key(a,b))
+partition by key (a);
+
+#
+# Bug 13323: Select count(*) on empty table returns 2
+#
+select count(*) from t1;
+
+#
+# Test SHOW CREATE TABLE
+#
+show create table t1;
+
+drop table t1;
+#
+# Partition by key no partition, list of fields
+#
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key(a,b))
+partition by key (a, b);
+
+drop table t1;
+#
+# Partition by key specified 3 partitions and defined 3 => ok
+#
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key(a,b))
+partition by key (a)
+partitions 3
+(partition x1, partition x2, partition x3);
+
+drop table t1;
+#
+# Partition by key specifying nodegroup
+#
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key(a,b))
+partition by key (a)
+partitions 3
+(partition x1 nodegroup 0,
+ partition x2 nodegroup 1,
+ partition x3 nodegroup 2);
+
+drop table t1;
+#
+# Partition by key specifying engine
+#
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key(a,b))
+partition by key (a)
+partitions 3
+(partition x1 engine myisam,
+ partition x2 engine myisam,
+ partition x3 engine myisam);
+
+drop table t1;
+#
+# Partition by key specifying tablespace
+#
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key(a,b))
+partition by key (a)
+partitions 3
+(partition x1 tablespace ts1,
+ partition x2 tablespace ts2,
+ partition x3 tablespace ts3);
+
+CREATE TABLE t2 LIKE t1;
+
+drop table t2;
+drop table t1;
+
+#
+# Partition by key list, basic
+#
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key(a,b))
+partition by list (a)
+partitions 3
+(partition x1 values in (1,2,9,4) tablespace ts1,
+ partition x2 values in (3, 11, 5, 7) tablespace ts2,
+ partition x3 values in (16, 8, 5+19, 70-43) tablespace ts3);
+
+drop table t1;
+#
+# Partition by key list, list function
+#
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key(a,b))
+partition by list (b*a)
+partitions 3
+(partition x1 values in (1,2,9,4) tablespace ts1,
+ partition x2 values in (3, 11, 5, 7) tablespace ts2,
+ partition x3 values in (16, 8, 5+19, 70-43) tablespace ts3);
+
+drop table t1;
+
+#
+# Partition by key list, list function, no spec of #partitions
+#
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key(a,b))
+partition by list (b*a)
+(partition x1 values in (1) tablespace ts1,
+ partition x2 values in (3, 11, 5, 7) tablespace ts2,
+ partition x3 values in (16, 8, 5+19, 70-43) tablespace ts3);
+
+drop table t1;
+
+#
+# Bug 13154: Insert crashes due to bad calculation of partition id
+# for PARTITION BY KEY and SUBPARTITION BY KEY
+#
+CREATE TABLE t1 (
+a int not null)
+partition by key(a);
+
+LOCK TABLES t1 WRITE;
+insert into t1 values (1);
+insert into t1 values (2);
+insert into t1 values (3);
+insert into t1 values (4);
+UNLOCK TABLES;
+
+drop table t1;
+
+#
+# Bug #13644 DROP PARTITION NULL's DATE column
+#
+CREATE TABLE t1 (a int, name VARCHAR(50), purchased DATE)
+PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (3),
+ PARTITION p1 VALUES LESS THAN (7),
+ PARTITION p2 VALUES LESS THAN (9),
+ PARTITION p3 VALUES LESS THAN (11));
+INSERT INTO t1 VALUES
+(1, 'desk organiser', '2003-10-15'),
+(2, 'CD player', '1993-11-05'),
+(3, 'TV set', '1996-03-10'),
+(4, 'bookcase', '1982-01-10'),
+(5, 'exercise bike', '2004-05-09'),
+(6, 'sofa', '1987-06-05'),
+(7, 'popcorn maker', '2001-11-22'),
+(8, 'acquarium', '1992-08-04'),
+(9, 'study desk', '1984-09-16'),
+(10, 'lava lamp', '1998-12-25');
+
+SELECT * from t1 ORDER BY a;
+ALTER TABLE t1 DROP PARTITION p0;
+SELECT * from t1 ORDER BY a;
+
+drop table t1;
+
+#
+# Bug #13442; Truncate Partitioned table doesn't work
+#
+
+CREATE TABLE t1 (a int)
+PARTITION BY LIST (a)
+(PARTITION p0 VALUES IN (1,2,3), PARTITION p1 VALUES IN (4,5,6));
+
+insert into t1 values (1),(2),(3),(4),(5),(6);
+select * from t1;
+truncate t1;
+select * from t1;
+truncate t1;
+select * from t1;
+drop table t1;
+
+#
+# Bug #13445 Partition by KEY method crashes server
+#
+CREATE TABLE t1 (a int, b int, primary key(a,b))
+PARTITION BY KEY(b,a) PARTITIONS 4;
+
+insert into t1 values (0,0),(1,1),(2,2),(3,3),(4,4),(5,5),(6,6);
+select * from t1 where a = 4;
+
+drop table t1;
+
+#
+# Bug #13438: Engine clause in PARTITION clause causes crash
+#
+CREATE TABLE t1 (a int)
+PARTITION BY LIST (a)
+PARTITIONS 1
+(PARTITION x1 VALUES IN (1) ENGINE=MEMORY);
+
+show create table t1;
+drop table t1;
+
+#
+# Bug #13440: REPLACE causes crash in partitioned table
+#
+CREATE TABLE t1 (a int, unique(a))
+PARTITION BY LIST (a)
+(PARTITION x1 VALUES IN (10), PARTITION x2 VALUES IN (20));
+
+--error ER_NO_PARTITION_FOR_GIVEN_VALUE
+REPLACE t1 SET a = 4;
+drop table t1;
+
+#
+# Bug #14365: Crash if value too small in list partitioned table
+#
+CREATE TABLE t1 (a int)
+PARTITION BY LIST (a)
+(PARTITION x1 VALUES IN (2), PARTITION x2 VALUES IN (3));
+
+insert into t1 values (2), (3);
+--error ER_NO_PARTITION_FOR_GIVEN_VALUE
+insert into t1 values (4);
+--error ER_NO_PARTITION_FOR_GIVEN_VALUE
+insert into t1 values (1);
+drop table t1;
+
+#
+# Bug 14327: PARTITIONS clause gets lost in SHOW CREATE TABLE
+#
+CREATE TABLE t1 (a int)
+PARTITION BY HASH(a)
+PARTITIONS 5;
+
+SHOW CREATE TABLE t1;
+
+drop table t1;
+
+#
+# Bug #13446: Update to value outside of list values doesn't give error
+#
+CREATE TABLE t1 (a int)
+PARTITION BY RANGE (a)
+(PARTITION x1 VALUES LESS THAN (2));
+
+insert into t1 values (1);
+--error ER_NO_PARTITION_FOR_GIVEN_VALUE
+update t1 set a = 5;
+
+drop table t1;
+
+#
+# Bug #13441: Analyze on partitioned table didn't work
+#
+CREATE TABLE t1 (a int)
+PARTITION BY LIST (a)
+(PARTITION x1 VALUES IN (10), PARTITION x2 VALUES IN (20));
+
+analyze table t1;
+
+drop table t1;
+
+#
+# BUG 14524
+#
+CREATE TABLE `t1` (
+ `id` int(11) default NULL
+) ENGINE=BLACKHOLE DEFAULT CHARSET=latin1 PARTITION BY HASH (id) ;
+SELECT * FROM t1;
+
+drop table t1;
+
+#
+# BUG 14524
+#
+CREATE TABLE `t1` (
+ `id` int(11) default NULL
+) ENGINE=BLACKHOLE DEFAULT CHARSET=latin1 PARTITION BY HASH (id) ;
+SELECT * FROM t1;
+
+drop table t1;
+
+#
+# BUG 15221 (Cannot reorganize with the same name)
+#
+create table t1
+(a int)
+partition by range (a)
+ ( partition p0 values less than(10),
+ partition p1 values less than (20),
+ partition p2 values less than (25));
+
+alter table t1 reorganize partition p2 into (partition p2 values less than (30));
+show create table t1;
+drop table t1;
+
+CREATE TABLE t1 (a int, b int)
+PARTITION BY RANGE (a)
+(PARTITION x0 VALUES LESS THAN (2),
+ PARTITION x1 VALUES LESS THAN (4),
+ PARTITION x2 VALUES LESS THAN (6),
+ PARTITION x3 VALUES LESS THAN (8),
+ PARTITION x4 VALUES LESS THAN (10),
+ PARTITION x5 VALUES LESS THAN (12),
+ PARTITION x6 VALUES LESS THAN (14),
+ PARTITION x7 VALUES LESS THAN (16),
+ PARTITION x8 VALUES LESS THAN (18),
+ PARTITION x9 VALUES LESS THAN (20));
+
+ALTER TABLE t1 REORGANIZE PARTITION x0,x1,x2 INTO
+(PARTITION x1 VALUES LESS THAN (6));
+show create table t1;
+drop table t1;
+
+# Testcase for BUG#15819
+create table t1 (a int not null, b int not null) partition by LIST (a+b) (
+ partition p0 values in (12),
+ partition p1 values in (14)
+);
+--error ER_NO_PARTITION_FOR_GIVEN_VALUE
+insert into t1 values (10,1);
+
+drop table t1;
+
+#
+# Bug#16901 Partitions: crash, SELECT, column of part.
+# function=first column of primary key
+#
+create table t1 (f1 integer,f2 integer, f3 varchar(10), primary key(f1,f2))
+partition by range(f1) subpartition by hash(f2) subpartitions 2
+(partition p1 values less than (0),
+ partition p2 values less than (2),
+ partition p3 values less than (2147483647));
+
+insert into t1 values(10,10,'10');
+insert into t1 values(2,2,'2');
+select * from t1 where f1 = 2;
+drop table t1;
+
+#
+# Bug #16907 Partitions: crash, SELECT goes into last partition, UNIQUE INDEX
+#
+create table t1 (f1 integer,f2 integer, unique index(f1))
+partition by range(f1 div 2)
+subpartition by hash(f1) subpartitions 2
+(partition partb values less than (2),
+partition parte values less than (4),
+partition partf values less than (10000));
+insert into t1 values(10,1);
+select * from t1 where f1 = 10;
+drop table t1;
+
+#
+# Bug #16775: Wrong engine type stored for subpartition
+#
+set session storage_engine= 'memory';
+create table t1 (f_int1 int(11) default null) engine = memory
+ partition by range (f_int1) subpartition by hash (f_int1)
+ (partition part1 values less than (1000)
+ (subpartition subpart11 engine = memory));
+drop table t1;
+set session storage_engine='myisam';
+
+#
+# Bug #16782: Crash using REPLACE on table with primary key
+#
+create table t1 (f_int1 integer, f_int2 integer, primary key (f_int1))
+ partition by hash(f_int1) partitions 2;
+insert into t1 values (1,1),(2,2);
+replace into t1 values (1,1),(2,2);
+drop table t1;
+
+#
+# Bug #17169: Partitions: out of memory if add partition and unique
+#
+create table t1 (s1 int, unique (s1)) partition by list (s1) (partition x1 VALUES in (10), partition x2 values in (20));
+alter table t1 add partition (partition x3 values in (30));
+drop table t1;
+
+#
+# Bug #17754 Change to explicit removal of partitioning scheme
+# Also added a number of tests to ensure that proper engine is
+# choosen in all kinds of scenarios.
+#
+
+create table t1 (a int)
+partition by key(a)
+partitions 2
+(partition p0 engine=myisam, partition p1 engine=myisam);
+show create table t1;
+
+alter table t1;
+show create table t1;
+
+alter table t1 engine=myisam;
+show create table t1;
+
+alter table t1 engine=heap;
+show create table t1;
+
+alter table t1 remove partitioning;
+show create table t1;
+
+drop table t1;
+
+create table t1 (a int)
+engine=myisam
+partition by key(a)
+partitions 2
+(partition p0 engine=myisam, partition p1 engine=myisam);
+show create table t1;
+
+alter table t1 add column b int remove partitioning;
+show create table t1;
+
+alter table t1
+engine=myisam
+partition by key(a)
+(partition p0 engine=myisam, partition p1);
+show create table t1;
+
+alter table t1
+engine=heap
+partition by key(a)
+(partition p0, partition p1 engine=heap);
+show create table t1;
+
+alter table t1 engine=myisam, add column c int remove partitioning;
+show create table t1;
+
+alter table t1
+engine=heap
+partition by key (a)
+(partition p0, partition p1);
+show create table t1;
+
+alter table t1
+partition by key (a)
+(partition p0, partition p1);
+show create table t1;
+
+alter table t1
+engine=heap
+partition by key (a)
+(partition p0, partition p1);
+show create table t1;
+
+--error ER_MIX_HANDLER_ERROR
+alter table t1
+partition by key(a)
+(partition p0, partition p1 engine=heap);
+
+--error ER_MIX_HANDLER_ERROR
+alter table t1
+partition by key(a)
+(partition p0 engine=heap, partition p1);
+
+--error ER_MIX_HANDLER_ERROR
+alter table t1
+engine=heap
+partition by key (a)
+(partition p0 engine=heap, partition p1 engine=myisam);
+
+--error ER_MIX_HANDLER_ERROR
+alter table t1
+partition by key (a)
+(partition p0 engine=heap, partition p1 engine=myisam);
+
+drop table t1;
+
+# Bug #17432: Partition functions containing NULL values should return
+# LONGLONG_MIN
+#
+CREATE TABLE t1 (
+ f_int1 INTEGER, f_int2 INTEGER,
+ f_char1 CHAR(10), f_char2 CHAR(10), f_charbig VARCHAR(1000)
+ )
+ PARTITION BY RANGE(f_int1 DIV 2)
+ SUBPARTITION BY HASH(f_int1)
+ SUBPARTITIONS 2
+ (PARTITION parta VALUES LESS THAN (0),
+ PARTITION partb VALUES LESS THAN (5),
+ PARTITION parte VALUES LESS THAN (10),
+ PARTITION partf VALUES LESS THAN (2147483647));
+INSERT INTO t1 SET f_int1 = NULL , f_int2 = -20, f_char1 = CAST(-20 AS CHAR),
+ f_char2 = CAST(-20 AS CHAR), f_charbig = '#NULL#';
+SELECT * FROM t1 WHERE f_int1 IS NULL;
+SELECT * FROM t1;
+drop table t1;
+
+#
+# Bug 17430: Crash when SELECT * from t1 where field IS NULL
+#
+
+CREATE TABLE t1 (
+ f_int1 INTEGER, f_int2 INTEGER,
+ f_char1 CHAR(10), f_char2 CHAR(10), f_charbig VARCHAR(1000) )
+ PARTITION BY LIST(MOD(f_int1,2))
+ SUBPARTITION BY KEY(f_int1)
+ (PARTITION part1 VALUES IN (-1) (SUBPARTITION sp1, SUBPARTITION sp2),
+ PARTITION part2 VALUES IN (0) (SUBPARTITION sp3, SUBPARTITION sp5),
+ PARTITION part3 VALUES IN (1) (SUBPARTITION sp4, SUBPARTITION sp6));
+
+INSERT INTO t1 SET f_int1 = 2, f_int2 = 2, f_char1 = '2', f_char2 = '2', f_charbig = '===2===';
+INSERT INTO t1 SET f_int1 = 2, f_int2 = 2, f_char1 = '2', f_char2 = '2', f_charbig = '===2===';
+
+SELECT * FROM t1 WHERE f_int1 IS NULL;
+drop table t1;
+
+#
+# Bug#14363 Partitions: failure if create in stored procedure
+#
+delimiter //;
+
+create procedure p ()
+begin
+create table t1 (s1 mediumint,s2 mediumint)
+partition by list (s2)
+(partition p1 values in (0),
+ partition p2 values in (1));
+end//
+
+call p()//
+drop procedure p//
+drop table t1;
+
+create procedure p ()
+begin
+create table t1 (a int not null,b int not null,c int not null,primary key (a,b))
+partition by range (a)
+subpartition by hash (a+b)
+(partition x1 values less than (1)
+ (subpartition x11,
+ subpartition x12),
+ partition x2 values less than (5)
+ (subpartition x21,
+ subpartition x22));
+end//
+
+call p()//
+drop procedure p//
+drop table t1//
+delimiter ;//
+
+#
+# Bug #15447 Partitions: NULL is treated as zero
+#
+
+# NULL for RANGE partition
+create table t1 (a int,b int,c int,key(a,b))
+partition by range (a)
+partitions 3
+(partition x1 values less than (0) tablespace ts1,
+ partition x2 values less than (10) tablespace ts2,
+ partition x3 values less than maxvalue tablespace ts3);
+
+insert into t1 values (NULL, 1, 1);
+insert into t1 values (0, 1, 1);
+insert into t1 values (12, 1, 1);
+
+select partition_name, partition_description, table_rows
+from information_schema.partitions where table_schema ='test';
+drop table t1;
+
+# NULL for LIST partition
+--error ER_MULTIPLE_DEF_CONST_IN_LIST_PART_ERROR
+create table t1 (a int,b int, c int)
+partition by list(a)
+partitions 2
+(partition x123 values in (11,12),
+ partition x234 values in (1 ,NULL, NULL));
+
+--error ER_MULTIPLE_DEF_CONST_IN_LIST_PART_ERROR
+create table t1 (a int,b int, c int)
+partition by list(a)
+partitions 2
+(partition x123 values in (11, NULL),
+ partition x234 values in (1 ,NULL));
+
+create table t1 (a int,b int, c int)
+partition by list(a)
+partitions 2
+(partition x123 values in (11, 12),
+ partition x234 values in (5, 1));
+--error ER_NO_PARTITION_FOR_GIVEN_VALUE
+insert into t1 values (NULL,1,1);
+drop table t1;
+
+create table t1 (a int,b int, c int)
+partition by list(a)
+partitions 2
+(partition x123 values in (11, 12),
+ partition x234 values in (NULL, 1));
+
+insert into t1 values (11,1,6);
+insert into t1 values (NULL,1,1);
+
+select partition_name, partition_description, table_rows
+from information_schema.partitions where table_schema ='test';
+drop table t1;
+
+#
+# BUG 17947 Crash with REBUILD PARTITION
+#
+create table t1 (a int)
+partition by list (a)
+(partition p0 values in (1));
+
+--error 1064
+alter table t1 rebuild partition;
+
+drop table t1;
+
+#
+# BUG 15253 Insert that should fail doesn't
+#
+create table t1 (a int)
+partition by list (a)
+(partition p0 values in (5));
+
+--error ER_NO_PARTITION_FOR_GIVEN_VALUE
+insert into t1 values (0);
+
+drop table t1;
+
+#
+# BUG #16370 Subpartitions names not shown in SHOW CREATE TABLE output
+#
+create table t1 (a int)
+partition by range (a) subpartition by hash (a)
+(partition p0 values less than (100));
+
+show create table t1;
+alter table t1 add partition (partition p1 values less than (200)
+(subpartition subpart21));
+
+show create table t1;
+
+drop table t1;
+
+create table t1 (a int)
+partition by key (a);
+
+show create table t1;
+alter table t1 add partition (partition p1);
+show create table t1;
+
+drop table t1;
+
+#
+# BUG 15407 Crash with subpartition
+#
+--error 1064
+create table t1 (a int, b int)
+partition by range (a)
+subpartition by hash(a)
+(partition p0 values less than (0) (subpartition sp0),
+ partition p1 values less than (1));
+
+--error 1064
+create table t1 (a int, b int)
+partition by range (a)
+subpartition by hash(a)
+(partition p0 values less than (0),
+ partition p1 values less than (1) (subpartition sp0));
+
+#
+# BUG 15961 No error when subpartition defined without subpartition by clause
+#
+--error ER_SUBPARTITION_ERROR
+create table t1 (a int)
+partition by hash (a)
+(partition p0 (subpartition sp0));
+
+#
+# Bug 17127
+#
+create table t1 (a int)
+partition by range (a)
+(partition p0 values less than (1));
+
+--error ER_PARTITION_WRONG_VALUES_ERROR
+alter table t1 add partition (partition p1 values in (2));
+--error ER_PARTITION_REQUIRES_VALUES_ERROR
+alter table t1 add partition (partition p1);
+
+drop table t1;
+
+create table t1 (a int)
+partition by list (a)
+(partition p0 values in (1));
+
+--error ER_PARTITION_WRONG_VALUES_ERROR
+alter table t1 add partition (partition p1 values less than (2));
+--error ER_PARTITION_REQUIRES_VALUES_ERROR
+alter table t1 add partition (partition p1);
+
+drop table t1;
+
+create table t1 (a int)
+partition by hash (a)
+(partition p0);
+
+--error ER_PARTITION_WRONG_VALUES_ERROR
+alter table t1 add partition (partition p1 values less than (2));
+--error ER_PARTITION_WRONG_VALUES_ERROR
+alter table t1 add partition (partition p1 values in (2));
+
+drop table t1;
+
+#
+# BUG 17947 Crash with REBUILD PARTITION
+#
+create table t1 (a int)
+partition by list (a)
+(partition p0 values in (1));
+
+--error 1064
+alter table t1 rebuild partition;
+
+drop table t1;
+
+#
+# Bug #14673: Wrong InnoDB default row format
+#
+create table t1 (a int) engine=innodb partition by hash(a) ;
+show table status like 't1';
+drop table t1;
+
+#
+# Bug #14526: Partitions: indexed searches fail
+#
+create table t2 (s1 int not null auto_increment, primary key (s1)) partition by list (s1) (partition p1 values in (1),partition p2 values in (2),partition p3 values in (3),partition p4 values in (4));
+insert into t2 values (null),(null),(null);
+select * from t2;
+select * from t2 where s1 < 2;
+update t2 set s1 = s1 + 1 order by s1 desc;
+select * from t2 where s1 < 3;
+select * from t2 where s1 = 2;
+drop table t2;
+
+#
+# Bug #17497: Partitions: crash if add partition on temporary table
+#
+--error ER_PARTITION_NO_TEMPORARY
+create temporary table t1 (a int) partition by hash(a);
+
+#
+# Bug #17097: Partitions: failing ADD PRIMARY KEY leads to temporary rotten
+# metadata,crash
+#
+create table t1 (a int, b int) partition by list (a)
+ (partition p1 values in (1), partition p2 values in (2));
+--error ER_UNIQUE_KEY_NEED_ALL_FIELDS_IN_PF
+alter table t1 add primary key (b);
+show create table t1;
+drop table t1;
+
+############################################
+#
+# Author: Mikael Ronstrom
+# Date: 2006-03-01
+# Purpose
+# Bug 17772: Crash at ALTER TABLE with rename
+# and add column + comment on
+# partitioned table
+#
+############################################
+create table t1 (a int unsigned not null auto_increment primary key)
+partition by key(a);
+alter table t1 rename t2, add c char(10), comment "no comment";
+show create table t2;
+
+drop table t2;
+
+#
+# Bug#14367: Partitions: crash if utf8 column
+#
+create table t1 (s1 char(2) character set utf8)
+partition by list (case when s1 > 'cz' then 1 else 2 end)
+(partition p1 values in (1),
+ partition p2 values in (2));
+drop table t1;
+
+#
+# Bug#15336 Partitions: crash if create table as select
+#
+create table t1 (f1 int) partition by hash (f1) as select 1;
+drop table t1;
+
+#
+# bug #14350 Partitions: crash if prepared statement
+#
+prepare stmt1 from 'create table t1 (s1 int) partition by hash (s1)';
+execute stmt1;
+--error 1050
+execute stmt1;
+drop table t1;
+
+#
+# bug 17290 SP with delete, create and rollback to save point causes MySQLD core
+#
+delimiter |;
+eval CREATE PROCEDURE test.p1(IN i INT)
+BEGIN
+ DECLARE CONTINUE HANDLER FOR sqlexception BEGIN END;
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1 (num INT,PRIMARY KEY(num));
+ START TRANSACTION;
+ INSERT INTO t1 VALUES(i);
+ savepoint t1_save;
+ INSERT INTO t1 VALUES (14);
+ ROLLBACK to savepoint t1_save;
+ COMMIT;
+END|
+delimiter ;|
+CALL test.p1(12);
+CALL test.p1(13);
+drop table t1;
+
+#
+# Bug 13520: Problem with delimiters in COMMENT DATA DIRECTORY ..
+#
+CREATE TABLE t1 (a int not null)
+partition by key(a)
+(partition p0 COMMENT='first partition');
+drop table t1;
+
+#
+# Bug 13433: Problem with delimited identifiers
+#
+CREATE TABLE t1 (`a b` int not null)
+partition by key(`a b`);
+drop table t1;
+
+CREATE TABLE t1 (`a b` int not null)
+partition by hash(`a b`);
+drop table t1;
+
+#
+# Bug#18053 Partitions: crash if null
+# Bug#18070 Partitions: wrong result on WHERE ... IS NULL
+#
+create table t1 (f1 integer) partition by range(f1)
+(partition p1 values less than (0), partition p2 values less than (10));
+insert into t1 set f1 = null;
+select * from t1 where f1 is null;
+explain partitions select * from t1 where f1 is null;
+drop table t1;
+
+create table t1 (f1 integer) partition by list(f1)
+(partition p1 values in (1), partition p2 values in (null));
+insert into t1 set f1 = null;
+insert into t1 set f1 = 1;
+select * from t1 where f1 is null or f1 = 1;
+drop table t1;
+
+create table t1 (f1 smallint)
+partition by list (f1) (partition p0 values in (null));
+insert into t1 values (null);
+select * from t1 where f1 is null;
+drop table t1;
+
+create table t1 (f1 smallint)
+partition by range (f1) (partition p0 values less than (0));
+insert into t1 values (null);
+select * from t1 where f1 is null;
+drop table t1;
+
+create table t1 (f1 integer) partition by list(f1)
+(
+ partition p1 values in (1),
+ partition p2 values in (NULL),
+ partition p3 values in (2),
+ partition p4 values in (3),
+ partition p5 values in (4)
+);
+
+insert into t1 values (1),(2),(3),(4),(null);
+select * from t1 where f1 < 3;
+explain partitions select * from t1 where f1 < 3;
+select * from t1 where f1 is null;
+explain partitions select * from t1 where f1 is null;
+drop table t1;
+
+create table t1 (f1 int) partition by list(f1 div 2)
+(
+ partition p1 values in (1),
+ partition p2 values in (NULL),
+ partition p3 values in (2),
+ partition p4 values in (3),
+ partition p5 values in (4)
+);
+
+insert into t1 values (2),(4),(6),(8),(null);
+select * from t1 where f1 < 3;
+explain partitions select * from t1 where f1 < 3;
+select * from t1 where f1 is null;
+explain partitions select * from t1 where f1 is null;
+drop table t1;
+
+create table t1 (a int) partition by LIST(a) (
+ partition pn values in (NULL),
+ partition p0 values in (0),
+ partition p1 values in (1),
+ partition p2 values in (2)
+);
+insert into t1 values (NULL),(0),(1),(2);
+select * from t1 where a is null or a < 2;
+explain partitions select * from t1 where a is null or a < 2;
+select * from t1 where a is null or a < 0 or a > 1;
+explain partitions select * from t1 where a is null or a < 0 or a > 1;
+drop table t1;
+
+#
+#Bug# 17631 SHOW TABLE STATUS reports wrong engine
+#
+CREATE TABLE t1 (id INT NOT NULL PRIMARY KEY, name VARCHAR(20))
+ENGINE=MyISAM DEFAULT CHARSET=latin1
+PARTITION BY RANGE(id)
+(PARTITION p0 VALUES LESS THAN (10) ENGINE = MyISAM,
+PARTITION p1 VALUES LESS THAN (20) ENGINE = MyISAM,
+PARTITION p2 VALUES LESS THAN (30) ENGINE = MyISAM);
+--replace_column 6 0 7 0 8 0 9 0 12 NULL 13 NULL 14 NULL
+SHOW TABLE STATUS;
+DROP TABLE t1;
+
+#
+#BUG 18750 Problems with partition names
+#
+create table t1 (a int)
+partition by list (a)
+(partition `s1 s2` values in (0));
+drop table t1;
+
+create table t1 (a int)
+partition by list (a)
+(partition `7` values in (0));
+drop table t1;
+
+--error ER_WRONG_PARTITION_NAME
+create table t1 (a int)
+partition by list (a)
+(partition `s1 s2 ` values in (0));
+
+--error ER_WRONG_PARTITION_NAME
+create table t1 (a int)
+partition by list (a)
+subpartition by hash (a)
+(partition p1 values in (0) (subpartition `p1 p2 `));
+
+#
+# BUG 18752 SHOW CREATE TABLE doesn't show NULL value in SHOW CREATE TABLE
+#
+CREATE TABLE t1 (a int)
+PARTITION BY LIST (a)
+(PARTITION p0 VALUES IN (NULL));
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+--error 1064
+CREATE TABLE t1 (a int)
+PARTITION BY RANGE(a)
+(PARTITION p0 VALUES LESS THAN (NULL));
+
+#
+# Bug#18753 Partitions: auto_increment fails
+#
+create table t1 (s1 int auto_increment primary key)
+partition by list (s1)
+(partition p1 values in (1),
+ partition p2 values in (2),
+ partition p3 values in (3));
+insert into t1 values (null);
+insert into t1 values (null);
+insert into t1 values (null);
+select auto_increment from information_schema.tables where table_name='t1';
+select * from t1;
+drop table t1;
+
+#
+# BUG 19140 Partitions: Create index for partitioned table crashes
+#
+create table t1 (a int) engine=memory
+partition by key(a);
+insert into t1 values (1);
+create index inx1 on t1(a);
+drop table t1;
+
+#
+# BUG 19304 Partitions: MERGE handler not allowed in partitioned tables
+#
+--error ER_PARTITION_MERGE_ERROR
+create table t1 (a int)
+partition by key (a)
+(partition p0 engine = MERGE);
+
+#
+# BUG 19062 Partition clause ignored if CREATE TABLE ... AS SELECT ...;
+#
+create table t1 (a varchar(1))
+partition by key (a)
+as select 'a';
+
+show create table t1;
+drop table t1;
+
+#
+# BUG 19501 Partitions: SHOW TABLE STATUS shows wrong Data_free
+#
+CREATE TABLE t1 (a int) ENGINE = MYISAM PARTITION BY KEY(a);
+INSERT into t1 values (1), (2);
+--replace_column 9 0 12 NULL 13 NULL 14 NULL
+SHOW TABLE STATUS;
+DELETE from t1 where a = 1;
+--replace_column 9 0 12 NULL 13 NULL 14 NULL
+SHOW TABLE STATUS;
+ALTER TABLE t1 OPTIMIZE PARTITION p0;
+--replace_column 12 NULL 13 NULL 14 NULL
+SHOW TABLE STATUS;
+DROP TABLE t1;
+
+#
+# BUG 19502: ENABLE/DISABLE Keys don't work for partitioned tables
+#
+CREATE TABLE t1 (a int, index(a)) PARTITION BY KEY(a);
+ALTER TABLE t1 DISABLE KEYS;
+ALTER TABLE t1 ENABLE KEYS;
+DROP TABLE t1;
+
+#
+# Bug 17455 Partitions: Wrong message and error when using Repair/Optimize
+# table on partitioned table
+#
+create table t1 (a int)
+engine=MEMORY
+partition by key (a);
+
+REPAIR TABLE t1;
+OPTIMIZE TABLE t1;
+
+drop table t1;
+
+#
+# Bug 17310 Partitions: Bugs with archived partitioned tables
+#
+create database db99;
+use db99;
+create table t1 (a int not null)
+engine=archive
+partition by list (a)
+(partition p0 values in (1), partition p1 values in (2));
+insert into t1 values (1), (2);
+--error 0, 1005
+create index inx on t1 (a);
+alter table t1 add partition (partition p2 values in (3));
+alter table t1 drop partition p2;
+use test;
+drop database db99;
+
+--echo End of 5.1 tests
diff --git a/mysql-test/t/partition_02myisam.test b/mysql-test/t/partition_02myisam.test
new file mode 100644
index 00000000000..107d0b89cea
--- /dev/null
+++ b/mysql-test/t/partition_02myisam.test
@@ -0,0 +1,25 @@
+###############################################
+# #
+# Partition tests MyISAM tables #
+# #
+###############################################
+
+#
+# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE !
+# NON STORAGE SPECIFIC TESTCASES SHOULD BE ADDED IN
+# THE SOURCED FIELS ONLY.
+#
+
+# Storage engine to be tested
+let $engine= 'MYISAM';
+eval SET SESSION storage_engine=$engine;
+
+
+# Other storage engine <> storage engine to be tested
+let $engine_other= 'MEMORY';
+# number of rows for the INSERT/UPDATE/DELETE/SELECT experiments
+# on partioned tables
+# Attention: In the moment the result files fit to @max_row = 200 only
+SET @max_row = 200;
+
+-- source include/partition_1.inc
diff --git a/mysql-test/t/partition_03ndb.test b/mysql-test/t/partition_03ndb.test
new file mode 100644
index 00000000000..3190ab9dfc7
--- /dev/null
+++ b/mysql-test/t/partition_03ndb.test
@@ -0,0 +1,26 @@
+###############################################
+# #
+# Partition tests NDB tables #
+# #
+###############################################
+
+#
+# NOTE: PLEASE DO NOT ADD NOT NDB SPECIFIC TESTCASES HERE !
+# NON STORAGE SPECIFIC TESTCASES SHOULD BE ADDED IN
+# THE SOURCED FIELS ONLY.
+#
+
+# Storage engine to be tested
+let $engine= 'NDB' ;
+-- source include/have_ndb.inc
+eval SET SESSION storage_engine=$engine;
+
+
+# Other storage engine <> storage engine to be tested
+let $engine_other= 'MEMORY';
+# number of rows for the INSERT/UPDATE/DELETE/SELECT experiments
+# on partioned tables
+# Attention: In the moment the result files fit to @max_row = 200 only
+SET @max_row = 200;
+
+-- source include/partition_1.inc
diff --git a/mysql-test/t/partition_charset.test b/mysql-test/t/partition_charset.test
new file mode 100644
index 00000000000..27d0dc87b89
--- /dev/null
+++ b/mysql-test/t/partition_charset.test
@@ -0,0 +1,21 @@
+#
+# Test for character set related things in combination
+# with the partition storage engine
+#
+-- source include/have_partition.inc
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+set names utf8;
+create table t1 (s1 int)
+ partition by list (s1)
+ (partition c values in (1),
+ partition Ç values in (3));
+insert into t1 values (1),(3);
+select * from t1;
+flush tables;
+set names latin1;
+select * from t1;
+drop table t1;
diff --git a/mysql-test/t/partition_error.test b/mysql-test/t/partition_error.test
new file mode 100644
index 00000000000..659f0b8cef4
--- /dev/null
+++ b/mysql-test/t/partition_error.test
@@ -0,0 +1,777 @@
+#
+# Simple test for the erroneos create statements using the
+# partition storage engine
+#
+-- source include/have_partition.inc
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+#
+# Partition by key stand-alone error
+#
+--error 1064
+partition by list (a)
+partitions 3
+(partition x1 values in (1,2,9,4) tablespace ts1,
+ partition x2 values in (3, 11, 5, 7) tablespace ts2,
+ partition x3 values in (16, 8, 5+19, 70-43) tablespace ts3);
+
+#
+# Partition by key list, number of partitions defined, no partition defined
+#
+--error ER_PARTITIONS_MUST_BE_DEFINED_ERROR
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key(a,b))
+partition by list (a)
+partitions 2;
+
+#
+# Partition by key list, wrong result type
+#
+--error ER_PARTITION_FUNC_NOT_ALLOWED_ERROR
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key(a,b))
+partition by list (sin(a))
+partitions 3
+(partition x1 values in (1,2,9,4) tablespace ts1,
+ partition x2 values in (3, 11, 5, 7) tablespace ts2,
+ partition x3 values in (16, 8, 5+19, 70-43) tablespace ts3);
+
+#
+# Partition by key, partition function not allowed
+#
+--error 1064
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key(a,b))
+partition by key (a+2)
+partitions 3
+(partition x1 tablespace ts1,
+ partition x2 tablespace ts2,
+ partition x3 tablespace ts3);
+
+#
+# Partition by key, no partition name
+#
+--error 1064
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key(a,b))
+partition by key (a)
+partitions 3
+(partition tablespace ts1,
+ partition x2 tablespace ts2,
+ partition x3 tablespace ts3);
+
+#
+# Partition by key, invalid field in field list
+#
+--error ER_FIELD_NOT_FOUND_PART_ERROR
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key(a,b))
+partition by key (a,d)
+partitions 3
+(partition x1 tablespace ts1,
+ partition x2 tablespace ts2,
+ partition x3 tablespace ts3);
+#
+# Partition by hash, invalid field in function
+#
+--error 1054
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key(a,b))
+partition by hash (a + d)
+partitions 3
+(partition x1 tablespace ts1,
+ partition x2 tablespace ts2,
+ partition x3 tablespace ts3);
+
+#
+# Partition by hash, invalid result type
+#
+--error ER_PARTITION_FUNC_NOT_ALLOWED_ERROR
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key(a,b))
+partition by hash (sin(a))
+partitions 3
+(partition x1 tablespace ts1,
+ partition x2 tablespace ts2,
+ partition x3 tablespace ts3);
+
+#
+# Partition by key specified 3 partitions but only defined 2 => error
+#
+--error 1064
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key(a,b))
+partition by key (a)
+partitions 3
+(partition x1, partition x2);
+
+#
+# Partition by key specified 3 partitions but only defined 2 => error
+#
+--error 1064
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key(a,b))
+partition by hash (rand(a))
+partitions 2
+(partition x1, partition x2);
+
+#
+# Partition by key specified 3 partitions but only defined 2 => error
+#
+--error 1064
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key(a,b))
+partition by range (rand(a))
+partitions 2
+(partition x1 values less than (0), partition x2 values less than (2));
+
+#
+# Partition by key specified 3 partitions but only defined 2 => error
+#
+--error 1064
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key(a,b))
+partition by list (rand(a))
+partitions 2
+(partition x1 values in (1), partition x2 values in (2));
+
+#
+# Partition by hash, values less than error
+#
+--error ER_PARTITION_WRONG_VALUES_ERROR
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key(a,b))
+partition by hash (a)
+partitions 2
+(partition x1 values less than (4),
+ partition x2 values less than (5));
+
+#
+# Partition by hash, values in error
+#
+--error ER_PARTITION_WRONG_VALUES_ERROR
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key(a,b))
+partition by hash (a)
+partitions 2
+(partition x1 values in (4),
+ partition x2 values in (5));
+
+#
+# Partition by hash, values in error
+#
+--error ER_PARTITION_WRONG_VALUES_ERROR
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key(a,b))
+partition by hash (a)
+partitions 2
+(partition x1 values in (4,6),
+ partition x2 values in (5,7));
+
+#
+# Subpartition by key, no partitions defined, single field
+#
+--error ER_SUBPARTITION_ERROR
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key (a,b))
+partition by key (a)
+subpartition by key (b);
+
+#
+# Subpartition by key, no partitions defined, list of fields
+#
+--error ER_SUBPARTITION_ERROR
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key (a,b))
+partition by key (a)
+subpartition by key (a, b);
+
+#
+# Subpartition by hash, no partitions defined
+#
+--error ER_SUBPARTITION_ERROR
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key (a,b))
+partition by key (a)
+subpartition by hash (a+b);
+
+#
+# Subpartition by key, no partitions defined, single field
+#
+--error ER_SUBPARTITION_ERROR
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key (a,b))
+partition by key (a)
+subpartition by key (b);
+
+#
+# Subpartition by key, no partitions defined, list of fields
+#
+--error ER_SUBPARTITION_ERROR
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key (a,b))
+partition by key (a)
+subpartition by key (a, b);
+
+#
+# Subpartition by hash, no partitions defined
+#
+--error ER_SUBPARTITION_ERROR
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key (a,b))
+partition by key (a)
+subpartition by hash (a+b);
+
+#
+# Subpartition by hash, no partitions defined, wrong subpartition function
+#
+--error 1064
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key (a,b))
+partition by key (a)
+subpartition by hash (rand(a+b));
+
+#
+# Subpartition by hash, wrong subpartition function
+#
+--error ER_SUBPARTITION_ERROR
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key (a,b))
+partition by key (a)
+subpartition by hash (sin(a+b))
+(partition x1 (subpartition x11, subpartition x12),
+ partition x2 (subpartition x21, subpartition x22));
+
+#
+# Subpartition by hash, no partitions defined, wrong subpartition function
+#
+--error 1064
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key (a,b))
+partition by range (a)
+subpartition by key (a+b)
+(partition x1 values less than (1) (subpartition x11, subpartition x12),
+ partition x2 values less than (2) (subpartition x21, subpartition x22));
+
+#
+# Subpartition by hash, no partitions defined, wrong subpartition function
+#
+--error ER_FIELD_NOT_FOUND_PART_ERROR
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key (a,b))
+partition by range (a)
+subpartition by key (a,d)
+(partition x1 values less than (1) (subpartition x11, subpartition x12),
+ partition x2 values less than (2) (subpartition x21, subpartition x22));
+
+#
+# Subpartition by hash, no partitions defined, wrong subpartition function
+#
+--error ER_SUBPARTITION_ERROR
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key (a,b))
+partition by key (a)
+subpartition by hash (3+4);
+
+#
+# Subpartition by hash, no partitions defined, wrong subpartition function
+#
+--error 1054
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key (a,b))
+partition by range (a)
+subpartition by hash (a+d)
+(partition x1 values less than (1) (subpartition x11, subpartition x12),
+ partition x2 values less than (2) (subpartition x21, subpartition x22));
+
+#
+# Partition by range, no partition => error
+#
+--error ER_PARTITIONS_MUST_BE_DEFINED_ERROR
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key(a,b))
+partition by range (a);
+
+#
+# Partition by range, invalid field in function
+#
+--error 1054
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key(a,b))
+partition by range (a+d)
+partitions 2
+(partition x1 values less than (4) tablespace ts1,
+ partition x2 values less than (8) tablespace ts2);
+
+#
+# Partition by range, inconsistent partition function and constants
+#
+--error 1064
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key(a,b))
+partition by range (a)
+partitions 2
+(partition x1 values less than (4.0) tablespace ts1,
+ partition x2 values less than (8) tablespace ts2);
+
+#
+# Partition by range, constant partition function not allowed
+#
+--error ER_CONST_EXPR_IN_PARTITION_FUNC_ERROR
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key(a,b))
+partition by range (3+4)
+partitions 2
+(partition x1 values less than (4) tablespace ts1,
+ partition x2 values less than (8) tablespace ts2);
+
+#
+# Partition by range, no values less than definition
+#
+--error ER_PARTITION_REQUIRES_VALUES_ERROR
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key(a,b))
+partition by range (a)
+partitions 2
+(partition x1 values less than (4),
+ partition x2);
+
+#
+# Partition by range, no values in definition allowed
+#
+--error ER_PARTITION_WRONG_VALUES_ERROR
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key(a,b))
+partition by range (a)
+partitions 2
+(partition x1 values in (4),
+ partition x2);
+
+#
+# Partition by range, values in error
+#
+--error ER_PARTITION_WRONG_VALUES_ERROR
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key(a,b))
+partition by range (a)
+partitions 2
+(partition x1 values in (4),
+ partition x2 values less than (5));
+
+#
+# Partition by range, missing parenthesis
+#
+--error 1064
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key(a,b))
+partition by list (a)
+partitions 2
+(partition x1 values less than 4,
+ partition x2 values less than (5));
+
+#
+# Partition by range, maxvalue in wrong place
+#
+--error 1064
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key(a,b))
+partition by range (a)
+partitions 2
+(partition x1 values less than maxvalue,
+ partition x2 values less than (5));
+
+#
+# Partition by range, maxvalue in several places
+#
+--error 1064
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key(a,b))
+partition by range (a)
+partitions 2
+(partition x1 values less than maxvalue,
+ partition x2 values less than maxvalue);
+
+#
+# Partition by range, not increasing ranges
+#
+--error ER_RANGE_NOT_INCREASING_ERROR
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key(a,b))
+partition by range (a)
+partitions 2
+(partition x1 values less than (4),
+ partition x2 values less than (3));
+
+#
+# Partition by range, wrong result type of partition function
+#
+--error ER_PARTITION_FUNC_NOT_ALLOWED_ERROR
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key(a,b))
+partition by range (sin(a))
+partitions 2
+(partition x1 values less than (4),
+ partition x2 values less than (5));
+
+#
+# Subpartition by hash, wrong number of subpartitions
+#
+--error 1064
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key (a,b))
+partition by list (a)
+subpartition by hash (a+b)
+subpartitions 3
+( partition x1 values in (1,2,4)
+ ( subpartition x11 nodegroup 0,
+ subpartition x12 nodegroup 1),
+ partition x2 values in (3,5,6)
+ ( subpartition x21 nodegroup 0,
+ subpartition x22 nodegroup 1)
+);
+
+#
+# Subpartition by hash, wrong number of subpartitions
+#
+--error 1064
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key (a,b))
+partition by list (a)
+subpartition by hash (a+b)
+( partition x1 values in (1)
+ ( subpartition x11 nodegroup 0,
+ subpartition xextra,
+ subpartition x12 nodegroup 1),
+ partition x2 values in (2)
+ ( subpartition x21 nodegroup 0,
+ subpartition x22 nodegroup 1)
+);
+
+#
+# Subpartition by list => error
+#
+--error 1064
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key (a,b))
+partition by key (a)
+subpartition by list (a+b)
+( partition x1
+ ( subpartition x11 engine myisam,
+ subpartition x12 engine myisam),
+ partition x2
+ ( subpartition x21 engine myisam,
+ subpartition x22 engine myisam)
+);
+
+#
+# Subpartition by list => error
+#
+--error 1064
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key (a,b))
+partition by key (a)
+subpartition by list (a+b)
+( partition x1
+ ( subpartition x11 engine myisam values in (0),
+ subpartition x12 engine myisam values in (1)),
+ partition x2
+ ( subpartition x21 engine myisam values in (0),
+ subpartition x22 engine myisam values in (1))
+);
+
+#
+# Partition by list, no partition => error
+#
+--error ER_PARTITIONS_MUST_BE_DEFINED_ERROR
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key(a,b))
+partition by list (a);
+
+#
+# Partition by list, constant partition function not allowed
+#
+--error ER_CONST_EXPR_IN_PARTITION_FUNC_ERROR
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key(a,b))
+partition by list (3+4)
+partitions 2
+(partition x1 values in (4) tablespace ts1,
+ partition x2 values in (8) tablespace ts2);
+
+#
+# Partition by list, invalid field in function
+#
+--error 1054
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key(a,b))
+partition by list (a+d)
+partitions 2
+(partition x1 values in (4) tablespace ts1,
+ partition x2 values in (8) tablespace ts2);
+
+#
+# Partition by list, no values in definition
+#
+--error ER_PARTITION_REQUIRES_VALUES_ERROR
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key(a,b))
+partition by list (a)
+partitions 2
+(partition x1 values in (4),
+ partition x2);
+
+#
+# Partition by list, values less than error
+#
+--error ER_PARTITION_WRONG_VALUES_ERROR
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key(a,b))
+partition by list (a)
+partitions 2
+(partition x1 values in (4),
+ partition x2 values less than (5));
+
+#
+# Partition by list, no values in definition
+#
+--error ER_PARTITION_REQUIRES_VALUES_ERROR
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key(a,b))
+partition by list (a)
+partitions 2
+(partition x1 values in (4,6),
+ partition x2);
+
+#
+# Partition by list, duplicate values
+#
+--error ER_MULTIPLE_DEF_CONST_IN_LIST_PART_ERROR
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key(a,b))
+partition by list (a)
+partitions 2
+(partition x1 values in (4, 12+9),
+ partition x2 values in (3, 21));
+
+#
+# Partition by list, wrong constant result type (not INT)
+#
+--error 1064
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key(a,b))
+partition by list (a)
+partitions 2
+(partition x1 values in (4.0, 12+8),
+ partition x2 values in (3, 21));
+
+#
+# Partition by list, missing parenthesis
+#
+--error 1064
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key(a,b))
+partition by list (a)
+partitions 2
+(partition x1 values in 4,
+ partition x2 values in (5));
+
+#
+# Bug #13439: Crash when LESS THAN (non-literal)
+#
+--error 1054
+CREATE TABLE t1 (a int)
+PARTITION BY RANGE (a)
+(PARTITION p0 VALUES LESS THAN (x1));
+
+#
+# No partition for the given value
+#
+CREATE TABLE t1(a int)
+ PARTITION BY RANGE (a) (PARTITION p1 VALUES LESS THAN(5));
+--error ER_NO_PARTITION_FOR_GIVEN_VALUE
+insert into t1 values (10);
+drop table t1;
+
+#
+# Bug 18198 Partitions: Verify that erroneus partition functions doesn't work
+#
+create table t1 (v varchar(12))
+partition by range (ascii(v))
+(partition p0 values less than (10));
+drop table t1;
+
+-- error 1064
+create table t1 (a int)
+partition by hash (rand(a));
+-- error 1064
+create table t1 (a int)
+partition by hash(CURTIME() + a);
+-- error 1064
+create table t1 (a int)
+partition by hash (NOW()+a);
+-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED
+create table t1 (a int)
+partition by hash (extract(hour from convert_tz(a, '+00:00', '+00:00')));
+-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED
+create table t1 (a int)
+partition by range (a + (select count(*) from t1))
+(partition p1 values less than (1));
+-- error ER_PARTITION_FUNC_NOT_ALLOWED_ERROR
+create table t1 (a char(10))
+partition by hash (extractvalue(a,'a'));
diff --git a/mysql-test/t/partition_grant.test b/mysql-test/t/partition_grant.test
new file mode 100644
index 00000000000..e2e80a7ca04
--- /dev/null
+++ b/mysql-test/t/partition_grant.test
@@ -0,0 +1,51 @@
+-- source include/have_partition.inc
+# Grant tests not performed with embedded server
+-- source include/not_embedded.inc
+
+--disable_warnings
+drop schema if exists mysqltest_1;
+--enable_warnings
+
+
+#
+# Bug #17139: ALTER TABLE ... DROP PARTITION should require DROP privilege
+#
+
+create schema mysqltest_1;
+use mysqltest_1;
+
+create table t1 (a int) partition by list (a) (partition p1 values in (1), partition p2 values in (2), partition p3 values in (3));
+insert into t1 values (1),(2);
+
+grant select,alter on mysqltest_1.* to mysqltest_1@localhost;
+
+connect (conn1,localhost,mysqltest_1,,mysqltest_1);
+show grants for current_user;
+alter table t1 add b int;
+--error ER_TABLEACCESS_DENIED_ERROR
+alter table t1 drop partition p2;
+disconnect conn1;
+
+connection default;
+grant drop on mysqltest_1.* to mysqltest_1@localhost;
+
+connect (conn2,localhost,mysqltest_1,,mysqltest_1);
+alter table t1 drop partition p2;
+disconnect conn2;
+
+connection default;
+revoke alter on mysqltest_1.* from mysqltest_1@localhost;
+
+connect (conn3,localhost,mysqltest_1,,mysqltest_1);
+--error ER_TABLEACCESS_DENIED_ERROR
+alter table t1 drop partition p3;
+disconnect conn3;
+
+connection default;
+
+revoke select,alter,drop on mysqltest_1.* from mysqltest_1@localhost;
+drop user mysqltest_1@localhost;
+drop table t1;
+drop schema mysqltest_1;
+
+--echo End of 5.1 tests
diff --git a/mysql-test/t/partition_hash.test b/mysql-test/t/partition_hash.test
new file mode 100644
index 00000000000..8494de98371
--- /dev/null
+++ b/mysql-test/t/partition_hash.test
@@ -0,0 +1,111 @@
+#--disable_abort_on_error
+#
+# Simple test for the partition storage engine
+# Taken fromm the select test
+#
+-- source include/have_partition.inc
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+#
+# Partition by hash, basic
+#
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key(a,b))
+partition by hash (a + 2)
+partitions 3
+(partition x1 tablespace ts1,
+ partition x2 tablespace ts2,
+ partition x3 tablespace ts3);
+
+insert into t1 values (1,1,1);
+insert into t1 values (2,1,1);
+insert into t1 values (3,1,1);
+insert into t1 values (4,1,1);
+insert into t1 values (5,1,1);
+
+select * from t1;
+
+update t1 set c=3 where b=1;
+select * from t1;
+
+select b from t1 where a=3;
+select b,c from t1 where a=1 AND b=1;
+
+delete from t1 where a=1;
+delete from t1 where c=3;
+
+select * from t1;
+
+ALTER TABLE t1
+partition by hash (a + 3)
+partitions 3
+(partition x1 tablespace ts1,
+ partition x2 tablespace ts2,
+ partition x3 tablespace ts3);
+select * from t1;
+drop table t1;
+
+#
+# Partition by hash, only one partition
+#
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key(a,b))
+partition by hash (a)
+(partition x1);
+
+drop table t1;
+#
+# Partition by key, only one partition
+#
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key(a,b))
+partition by key (a)
+(partition x1);
+
+drop table t1;
+
+#
+# Bug# 15968 - crash when INSERT with f1 = -1 into partition by hash(f1)
+#
+CREATE TABLE t1 (f1 INTEGER, f2 char(20)) ENGINE = 'MYISAM' PARTITION BY HASH(f1) PARTITIONS 2;
+INSERT INTO t1 SET f1 = 0 - 1, f2 = '#######';
+select * from t1;
+drop table t1;
+
+#
+# BUG# 14524 Partitions: crash if blackhole
+#
+CREATE TABLE t1 (s1 int) ENGINE=BLACKHOLE PARTITION BY HASH (s1);
+INSERT INTO t1 VALUES (0);
+DROP TABLE t1;
+
+#
+# BUG 18423 Hash partitioning can lose rows in some queries
+#
+create table t1 (c1 int DEFAULT NULL,
+ c2 varchar (30) DEFAULT NULL,
+ c3 date DEFAULT NULL)
+engine = myisam
+partition by hash (to_days(c3))
+partitions 12;
+
+insert into t1 values
+(136,'abc','2002-01-05'),(142,'abc','2002-02-14'),(162,'abc','2002-06-28'),
+(182,'abc','2002-11-09'),(158,'abc','2002-06-01'),(184,'abc','2002-11-22');
+select * from t1;
+select * from t1 where c3 between '2002-01-01' and '2002-12-31';
+
+drop table t1;
+
diff --git a/mysql-test/t/partition_list.test b/mysql-test/t/partition_list.test
new file mode 100644
index 00000000000..3e0eaa45f32
--- /dev/null
+++ b/mysql-test/t/partition_list.test
@@ -0,0 +1,126 @@
+#--disable_abort_on_error
+#
+# Simple test for the partition storage engine
+# testing list partitioning
+#
+-- source include/have_partition.inc
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+#
+# Test ordinary list partitioning that it works ok
+#
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null)
+partition by list(a)
+partitions 2
+(partition x123 values in (1,5,6),
+ partition x234 values in (4,7,8));
+
+INSERT into t1 VALUES (1,1,1);
+--error ER_NO_PARTITION_FOR_GIVEN_VALUE
+INSERT into t1 VALUES (2,1,1);
+--error ER_NO_PARTITION_FOR_GIVEN_VALUE
+INSERT into t1 VALUES (3,1,1);
+INSERT into t1 VALUES (4,1,1);
+INSERT into t1 VALUES (5,1,1);
+INSERT into t1 VALUES (6,1,1);
+INSERT into t1 VALUES (7,1,1);
+INSERT into t1 VALUES (8,1,1);
+--error ER_NO_PARTITION_FOR_GIVEN_VALUE
+INSERT into t1 VALUES (9,1,1);
+INSERT into t1 VALUES (1,2,1);
+INSERT into t1 VALUES (1,3,1);
+INSERT into t1 VALUES (1,4,1);
+INSERT into t1 VALUES (7,2,1);
+INSERT into t1 VALUES (7,3,1);
+INSERT into t1 VALUES (7,4,1);
+
+SELECT * from t1;
+SELECT * from t1 WHERE a=1;
+SELECT * from t1 WHERE a=7;
+SELECT * from t1 WHERE b=2;
+
+UPDATE t1 SET a=8 WHERE a=7 AND b=3;
+SELECT * from t1;
+UPDATE t1 SET a=8 WHERE a=5 AND b=1;
+SELECT * from t1;
+
+DELETE from t1 WHERE a=8;
+SELECT * from t1;
+DELETE from t1 WHERE a=2;
+SELECT * from t1;
+DELETE from t1 WHERE a=5 OR a=6;
+SELECT * from t1;
+
+ALTER TABLE t1
+partition by list(a)
+partitions 2
+(partition x123 values in (1,5,6),
+ partition x234 values in (4,7,8));
+SELECT * from t1;
+INSERT into t1 VALUES (6,2,1);
+--error ER_NO_PARTITION_FOR_GIVEN_VALUE
+INSERT into t1 VALUES (2,2,1);
+
+drop table t1;
+#
+# Subpartition by hash, two partitions and two subpartitions
+# Defined node group
+#
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key (a,b))
+partition by list (a)
+subpartition by hash (a+b)
+( partition x1 values in (1,2,3)
+ ( subpartition x11 nodegroup 0,
+ subpartition x12 nodegroup 1),
+ partition x2 values in (4,5,6)
+ ( subpartition x21 nodegroup 0,
+ subpartition x22 nodegroup 1)
+);
+
+INSERT into t1 VALUES (1,1,1);
+INSERT into t1 VALUES (4,1,1);
+--error ER_NO_PARTITION_FOR_GIVEN_VALUE
+INSERT into t1 VALUES (7,1,1);
+UPDATE t1 SET a=5 WHERE a=1;
+SELECT * from t1;
+UPDATE t1 SET a=6 WHERE a=4;
+SELECT * from t1;
+DELETE from t1 WHERE a=6;
+SELECT * from t1;
+
+drop table t1;
+
+#
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key(a,b))
+partition by list (a)
+(partition x1 values in (1,2,9,4) tablespace ts1);
+
+drop table t1;
+
+#
+#Bug #17173 Partitions: less-than search fails
+#
+CREATE TABLE t1 (s1 int) PARTITION BY LIST (s1)
+(PARTITION p1 VALUES IN (1),
+PARTITION p2 VALUES IN (2),
+PARTITION p3 VALUES IN (3),
+PARTITION p4 VALUES IN (4),
+PARTITION p5 VALUES IN (5));
+INSERT INTO t1 VALUES (1), (2), (3), (4), (5);
+SELECT COUNT(*) FROM t1 WHERE s1 < 3;
+DROP TABLE t1;
+
diff --git a/mysql-test/t/partition_mgm_err.test b/mysql-test/t/partition_mgm_err.test
new file mode 100644
index 00000000000..8573fd59f2f
--- /dev/null
+++ b/mysql-test/t/partition_mgm_err.test
@@ -0,0 +1,213 @@
+#
+# Simple test for the erroneos create statements using the
+# partition storage engine
+#
+-- source include/have_partition.inc
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+#
+# Try faulty DROP PARTITION and COALESCE PARTITION
+#
+CREATE TABLE t1 (a int, b int)
+PARTITION BY RANGE (a)
+(PARTITION x0 VALUES LESS THAN (2),
+ PARTITION x1 VALUES LESS THAN (4),
+ PARTITION x2 VALUES LESS THAN (6),
+ PARTITION x3 VALUES LESS THAN (8),
+ PARTITION x4 VALUES LESS THAN (10),
+ PARTITION x5 VALUES LESS THAN (12),
+ PARTITION x6 VALUES LESS THAN (14),
+ PARTITION x7 VALUES LESS THAN (16),
+ PARTITION x8 VALUES LESS THAN (18),
+ PARTITION x9 VALUES LESS THAN (20));
+
+--error ER_REORG_OUTSIDE_RANGE
+ALTER TABLE t1 REORGANIZE PARTITION x0,x1 INTO
+(PARTITION x01 VALUES LESS THAN (2),
+ PARTITION x11 VALUES LESS THAN (5));
+
+--error ER_DROP_PARTITION_NON_EXISTENT
+ALTER TABLE t1 DROP PARTITION x0, x1, x2, x3, x3;
+
+--error ER_DROP_PARTITION_NON_EXISTENT
+ALTER TABLE t1 DROP PARTITION x0, x1, x2, x10;
+
+--error ER_DROP_PARTITION_NON_EXISTENT
+ALTER TABLE t1 DROP PARTITION x10, x1, x2, x1;
+
+--error ER_DROP_PARTITION_NON_EXISTENT
+ALTER TABLE t1 DROP PARTITION x10, x1, x2, x3;
+
+--error ER_REORG_PARTITION_NOT_EXIST
+ALTER TABLE t1 REORGANIZE PARTITION x0,x1,x2,x3,x4,x5,x6,x7,x8,x9,x10 INTO
+(PARTITION x11 VALUES LESS THAN (22));
+
+--error ER_SAME_NAME_PARTITION
+ALTER TABLE t1 REORGANIZE PARTITION x0,x1,x2 INTO
+(PARTITION x3 VALUES LESS THAN (6));
+
+--error ER_CONSECUTIVE_REORG_PARTITIONS
+ALTER TABLE t1 REORGANIZE PARTITION x0, x2 INTO
+(PARTITION x11 VALUES LESS THAN (2));
+
+--error ER_DROP_PARTITION_NON_EXISTENT
+ALTER TABLE t1 REORGANIZE PARTITION x0, x1, x1 INTO
+(PARTITION x11 VALUES LESS THAN (4));
+
+--error ER_REORG_OUTSIDE_RANGE
+ALTER TABLE t1 REORGANIZE PARTITION x0,x1 INTO
+(PARTITION x01 VALUES LESS THAN (5));
+
+--error ER_REORG_OUTSIDE_RANGE
+ALTER TABLE t1 REORGANIZE PARTITION x0,x1 INTO
+(PARTITION x01 VALUES LESS THAN (4),
+ PARTITION x11 VALUES LESS THAN (2));
+
+--error ER_RANGE_NOT_INCREASING_ERROR
+ALTER TABLE t1 REORGANIZE PARTITION x0,x1 INTO
+(PARTITION x01 VALUES LESS THAN (6),
+ PARTITION x11 VALUES LESS THAN (4));
+
+DROP TABLE t1;
+
+CREATE TABLE t1 (a int)
+PARTITION BY KEY (a)
+PARTITIONS 2;
+
+--error ER_SAME_NAME_PARTITION
+ALTER TABLE t1 ADD PARTITION (PARTITION p1);
+
+DROP TABLE t1;
+
+--error ER_SAME_NAME_PARTITION
+CREATE TABLE t1 (a int)
+PARTITION BY KEY (a)
+(PARTITION x0, PARTITION x1, PARTITION x2, PARTITION x3, PARTITION x3);
+
+CREATE TABLE t1 (a int)
+PARTITION BY RANGE (a)
+SUBPARTITION BY KEY (a)
+SUBPARTITIONS 2
+(PARTITION x0 VALUES LESS THAN (4),
+ PARTITION x1 VALUES LESS THAN (8));
+
+--error ER_RANGE_NOT_INCREASING_ERROR
+ALTER TABLE t1 ADD PARTITION (PARTITION x2 VALUES LESS THAN (5)
+(SUBPARTITION sp0, SUBPARTITION sp1));
+
+--error ER_ADD_PARTITION_SUBPART_ERROR
+ALTER TABLE t1 ADD PARTITION (PARTITION x2 VALUES LESS THAN (12)
+(SUBPARTITION sp0, SUBPARTITION sp1, SUBPARTITION sp2));
+
+DROP TABLE t1;
+
+CREATE TABLE t1 (a int)
+PARTITION BY LIST (a)
+(PARTITION x0 VALUES IN (1,2,3),
+ PARTITION x1 VALUES IN (4,5,6));
+
+--error ER_MULTIPLE_DEF_CONST_IN_LIST_PART_ERROR
+ALTER TABLE t1 ADD PARTITION (PARTITION x2 VALUES IN (3,4));
+
+DROP TABLE t1;
+
+CREATE TABLE t1 (a int);
+
+--error ER_PARTITION_MGMT_ON_NONPARTITIONED
+ALTER TABLE t1 ADD PARTITION PARTITIONS 1;
+
+--error ER_PARTITION_MGMT_ON_NONPARTITIONED
+ALTER TABLE t1 DROP PARTITION x1;
+
+--error ER_PARTITION_MGMT_ON_NONPARTITIONED
+ALTER TABLE t1 COALESCE PARTITION 1;
+
+DROP TABLE t1;
+
+CREATE TABLE t1 (a int)
+PARTITION BY KEY (a)
+(PARTITION x0, PARTITION x1);
+
+--error ER_ADD_PARTITION_NO_NEW_PARTITION
+ALTER TABLE t1 ADD PARTITION PARTITIONS 0;
+
+--error ER_TOO_MANY_PARTITIONS_ERROR
+ALTER TABLE t1 ADD PARTITION PARTITIONS 1024;
+
+--error ER_ONLY_ON_RANGE_LIST_PARTITION
+ALTER TABLE t1 DROP PARTITION x0;
+
+ALTER TABLE t1 COALESCE PARTITION 1;
+
+--error ER_DROP_LAST_PARTITION
+ALTER TABLE t1 COALESCE PARTITION 1;
+
+DROP TABLE t1;
+
+CREATE TABLE t1 (a int)
+PARTITION BY RANGE (a)
+(PARTITION x0 VALUES LESS THAN (4),
+ PARTITION x1 VALUES LESS THAN (8));
+
+--error ER_PARTITIONS_MUST_BE_DEFINED_ERROR
+ALTER TABLE t1 ADD PARTITION PARTITIONS 1;
+
+--error ER_DROP_PARTITION_NON_EXISTENT
+ALTER TABLE t1 DROP PARTITION x2;
+
+--error ER_COALESCE_ONLY_ON_HASH_PARTITION
+ALTER TABLE t1 COALESCE PARTITION 1;
+
+ALTER TABLE t1 DROP PARTITION x1;
+
+--error ER_DROP_LAST_PARTITION
+ALTER TABLE t1 DROP PARTITION x0;
+
+DROP TABLE t1;
+
+#
+# Bug# 16534 - Trying to add multiple partitions crashes server
+#
+CREATE TABLE t1 ( id INT NOT NULL,
+ fname VARCHAR(50) NOT NULL,
+ lname VARCHAR(50) NOT NULL,
+ hired DATE NOT NULL )
+PARTITION BY RANGE(YEAR(hired)) (
+ PARTITION p1 VALUES LESS THAN (1991),
+ PARTITION p2 VALUES LESS THAN (1996),
+ PARTITION p3 VALUES LESS THAN (2001),
+ PARTITION p4 VALUES LESS THAN (2005));
+ALTER TABLE t1 ADD PARTITION (
+ PARTITION p5 VALUES LESS THAN (2010),
+ PARTITION p6 VALUES LESS THAN MAXVALUE);
+DROP TABLE t1;
+
+#
+#BUG 15523 ALTER TABLE ... PARTITION BY does not work
+#
+CREATE TABLE t1 (a INT);
+SHOW CREATE TABLE t1;
+ALTER TABLE t1 PARTITION BY KEY(a) PARTITIONS 2;
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+#
+#BUG 15820 create table with 1 partition, doing ALTER TABLE ADD PARTITION fails
+#
+CREATE TABLE t1 (a INT) PARTITION BY HASH(a);
+ALTER TABLE t1 ADD PARTITION PARTITIONS 4;
+DROP TABLE t1;
+
+#
+#BUG 15408: Partitions: subpartition names are not unique
+#
+--error ER_SAME_NAME_PARTITION
+CREATE TABLE t1 (s1 int, s2 int)
+PARTITION BY LIST (s1)
+SUBPARTITION BY KEY (s2) (
+PARTITION p1 VALUES IN (0) (SUBPARTITION p1b),
+PARTITION p2 VALUES IN (2) (SUBPARTITION p1b)
+);
diff --git a/mysql-test/t/partition_mgm_err2.test b/mysql-test/t/partition_mgm_err2.test
new file mode 100644
index 00000000000..7d15bd7b19f
--- /dev/null
+++ b/mysql-test/t/partition_mgm_err2.test
@@ -0,0 +1,26 @@
+#
+# Test of partitions that require symlinks
+#
+-- source include/have_partition.inc
+
+-- require r/have_symlink.require
+disable_query_log;
+show variables like "have_symlink";
+enable_query_log;
+
+#
+# BUG: 14354 Partitions: data directory clause fails
+#
+--system rm -rf $MYSQLTEST_VARDIR/tmp/bug14354
+--system mkdir $MYSQLTEST_VARDIR/tmp/bug14354
+disable_query_log;
+eval CREATE TABLE t1 (id int) PARTITION BY RANGE(id) (
+PARTITION p1 VALUES LESS THAN (20) ENGINE=myisam
+DATA DIRECTORY="$MYSQLTEST_VARDIR/tmp/bug14354"
+INDEX DIRECTORY="$MYSQLTEST_VARDIR/tmp/bug14354");
+enable_query_log;
+INSERT INTO t1 VALUES (15);
+--system test -f $MYSQLTEST_VARDIR/tmp/bug14354/t1#P#p1.MYD
+--system test -f $MYSQLTEST_VARDIR/tmp/bug14354/t1#P#p1.MYI
+DROP TABLE t1;
+--system rm -rf $MYSQLTEST_VARDIR/tmp/bug14354
diff --git a/mysql-test/t/partition_order.test b/mysql-test/t/partition_order.test
new file mode 100644
index 00000000000..1e1b3339d64
--- /dev/null
+++ b/mysql-test/t/partition_order.test
@@ -0,0 +1,828 @@
+#--disable_abort_on_error
+#
+# Simple test for the partition storage engine
+# Focuses on tests of ordered index read
+#
+-- source include/have_partition.inc
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+#
+# Ordered index read, int type
+#
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+primary key(a),
+index (b))
+partition by range (a)
+partitions 2
+(partition x1 values less than (25),
+ partition x2 values less than (100));
+
+# Insert a couple of tuples
+INSERT into t1 values (1, 1);
+INSERT into t1 values (2, 5);
+INSERT into t1 values (30, 4);
+INSERT into t1 values (35, 2);
+
+select * from t1 order by b;
+
+select * from t1 force index (b) where b > 0 order by b;
+
+drop table t1;
+
+#
+# Ordered index read, unsigned int type
+#
+CREATE TABLE t1 (
+a int not null,
+b int unsigned not null,
+primary key(a),
+index (b))
+partition by range (a)
+partitions 2
+(partition x1 values less than (25),
+ partition x2 values less than (100));
+
+# Insert a couple of tuples
+INSERT into t1 values (1, 1);
+INSERT into t1 values (2, 5);
+INSERT into t1 values (30, 4);
+INSERT into t1 values (35, 2);
+
+select * from t1 force index (b) where b > 0 order by b;
+
+drop table t1;
+
+#
+# Ordered index read, tiny int type
+#
+CREATE TABLE t1 (
+a int not null,
+b tinyint not null,
+primary key(a),
+index (b))
+partition by range (a)
+partitions 2
+(partition x1 values less than (25),
+ partition x2 values less than (100));
+
+# Insert a couple of tuples
+INSERT into t1 values (1, 1);
+INSERT into t1 values (2, 5);
+INSERT into t1 values (30, 4);
+INSERT into t1 values (35, 2);
+
+select * from t1 force index (b) where b > 0 order by b;
+
+drop table t1;
+
+#
+# Ordered index read, unsigned tinyint type
+#
+CREATE TABLE t1 (
+a int not null,
+b tinyint unsigned not null,
+primary key(a),
+index (b))
+partition by range (a)
+partitions 2
+(partition x1 values less than (25),
+ partition x2 values less than (100));
+
+# Insert a couple of tuples
+INSERT into t1 values (1, 1);
+INSERT into t1 values (2, 5);
+INSERT into t1 values (30, 4);
+INSERT into t1 values (35, 2);
+
+select * from t1 force index (b) where b > 0 order by b;
+
+drop table t1;
+
+#
+# Ordered index read, smallint type
+#
+CREATE TABLE t1 (
+a int not null,
+b smallint not null,
+primary key(a),
+index (b))
+partition by range (a)
+partitions 2
+(partition x1 values less than (25),
+ partition x2 values less than (100));
+
+# Insert a couple of tuples
+INSERT into t1 values (1, 1);
+INSERT into t1 values (2, 5);
+INSERT into t1 values (30, 4);
+INSERT into t1 values (35, 2);
+
+select * from t1 force index (b) where b > 0 order by b;
+
+drop table t1;
+
+#
+# Ordered index read, unsigned smallint type
+#
+CREATE TABLE t1 (
+a int not null,
+b smallint unsigned not null,
+primary key(a),
+index (b))
+partition by range (a)
+partitions 2
+(partition x1 values less than (25),
+ partition x2 values less than (100));
+
+# Insert a couple of tuples
+INSERT into t1 values (1, 1);
+INSERT into t1 values (2, 5);
+INSERT into t1 values (30, 4);
+INSERT into t1 values (35, 2);
+
+select * from t1 force index (b) where b > 0 order by b;
+
+drop table t1;
+#
+# Ordered index read, mediumint type
+#
+CREATE TABLE t1 (
+a int not null,
+b mediumint not null,
+primary key(a),
+index (b))
+partition by range (a)
+partitions 2
+(partition x1 values less than (25),
+ partition x2 values less than (100));
+
+# Insert a couple of tuples
+INSERT into t1 values (1, 1);
+INSERT into t1 values (2, 5);
+INSERT into t1 values (30, 4);
+INSERT into t1 values (35, 2);
+
+select * from t1 force index (b) where b > 0 order by b;
+
+drop table t1;
+
+#
+# Ordered index read, unsigned int type
+#
+CREATE TABLE t1 (
+a int not null,
+b mediumint unsigned not null,
+primary key(a),
+index (b))
+partition by range (a)
+partitions 2
+(partition x1 values less than (25),
+ partition x2 values less than (100));
+
+# Insert a couple of tuples
+INSERT into t1 values (1, 1);
+INSERT into t1 values (2, 5);
+INSERT into t1 values (30, 4);
+INSERT into t1 values (35, 2);
+
+select * from t1 force index (b) where b > 0 order by b;
+
+drop table t1;
+
+#
+# Ordered index read, unsigned bigint type
+#
+CREATE TABLE t1 (
+a int not null,
+b bigint unsigned not null,
+primary key(a),
+index (b))
+partition by range (a)
+partitions 2
+(partition x1 values less than (25),
+ partition x2 values less than (100));
+
+# Insert a couple of tuples
+INSERT into t1 values (1, 1);
+INSERT into t1 values (2, 5);
+INSERT into t1 values (30, 4);
+INSERT into t1 values (35, 2);
+
+select * from t1 force index (b) where b > 0 order by b;
+
+drop table t1;
+
+#
+# Ordered index read, bigint type
+#
+CREATE TABLE t1 (
+a int not null,
+b bigint not null,
+primary key(a),
+index (b))
+partition by range (a)
+partitions 2
+(partition x1 values less than (25),
+ partition x2 values less than (100));
+
+# Insert a couple of tuples
+INSERT into t1 values (1, 1);
+INSERT into t1 values (2, 5);
+INSERT into t1 values (30, 4);
+INSERT into t1 values (35, 2);
+
+select * from t1 force index (b) where b > 0 order by b;
+
+drop table t1;
+#
+# Ordered index read, bigint type
+#
+CREATE TABLE t1 (
+a int not null,
+b bigint not null,
+primary key(a),
+index (b))
+partition by range (a)
+partitions 2
+(partition x1 values less than (25),
+ partition x2 values less than (100));
+
+# Insert a couple of tuples
+INSERT into t1 values (1, 1);
+INSERT into t1 values (2, 5);
+INSERT into t1 values (30, 4);
+INSERT into t1 values (35, 2);
+
+select * from t1 force index (b) where b > 0 order by b;
+
+drop table t1;
+
+#
+# Ordered index read, float type
+#
+CREATE TABLE t1 (
+a int not null,
+b float not null,
+primary key(a),
+index (b))
+partition by range (a)
+partitions 2
+(partition x1 values less than (25),
+ partition x2 values less than (100));
+
+# Insert a couple of tuples
+INSERT into t1 values (1, 1);
+INSERT into t1 values (2, 5);
+INSERT into t1 values (30, 4);
+INSERT into t1 values (35, 2);
+
+select * from t1 force index (b) where b > 0 order by b;
+
+drop table t1;
+
+#
+# Ordered index read, double type
+#
+CREATE TABLE t1 (
+a int not null,
+b double not null,
+primary key(a),
+index (b))
+partition by range (a)
+partitions 2
+(partition x1 values less than (25),
+ partition x2 values less than (100));
+
+# Insert a couple of tuples
+INSERT into t1 values (1, 1);
+INSERT into t1 values (2, 5);
+INSERT into t1 values (30, 4);
+INSERT into t1 values (35, 2);
+
+select * from t1 force index (b) where b > 0 order by b;
+
+drop table t1;
+
+#
+# Ordered index read, unsigned double type
+#
+CREATE TABLE t1 (
+a int not null,
+b double unsigned not null,
+primary key(a),
+index (b))
+partition by range (a)
+partitions 2
+(partition x1 values less than (25),
+ partition x2 values less than (100));
+
+# Insert a couple of tuples
+INSERT into t1 values (1, 1);
+INSERT into t1 values (2, 5);
+INSERT into t1 values (30, 4);
+INSERT into t1 values (35, 2);
+
+select * from t1 force index (b) where b > 0 order by b;
+
+drop table t1;
+
+#
+# Ordered index read, unsigned float type
+#
+CREATE TABLE t1 (
+a int not null,
+b float unsigned not null,
+primary key(a),
+index (b))
+partition by range (a)
+partitions 2
+(partition x1 values less than (25),
+ partition x2 values less than (100));
+
+# Insert a couple of tuples
+INSERT into t1 values (1, 1);
+INSERT into t1 values (2, 5);
+INSERT into t1 values (30, 4);
+INSERT into t1 values (35, 2);
+
+select * from t1 force index (b) where b > 0 order by b;
+
+drop table t1;
+
+#
+# Ordered index read, double precision type
+#
+CREATE TABLE t1 (
+a int not null,
+b double precision not null,
+primary key(a),
+index (b))
+partition by range (a)
+partitions 2
+(partition x1 values less than (25),
+ partition x2 values less than (100));
+
+# Insert a couple of tuples
+INSERT into t1 values (1, 1);
+INSERT into t1 values (2, 5);
+INSERT into t1 values (30, 4);
+INSERT into t1 values (35, 2);
+
+select * from t1 force index (b) where b > 0 order by b;
+
+drop table t1;
+#
+# Ordered index read, unsigned double precision type
+#
+CREATE TABLE t1 (
+a int not null,
+b double precision unsigned not null,
+primary key(a),
+index (b))
+partition by range (a)
+partitions 2
+(partition x1 values less than (25),
+ partition x2 values less than (100));
+
+# Insert a couple of tuples
+INSERT into t1 values (1, 1);
+INSERT into t1 values (2, 5);
+INSERT into t1 values (30, 4);
+INSERT into t1 values (35, 2);
+
+select * from t1 force index (b) where b > 0 order by b;
+
+drop table t1;
+
+#
+# Ordered index read, decimal type
+#
+CREATE TABLE t1 (
+a int not null,
+b decimal not null,
+primary key(a),
+index (b))
+partition by range (a)
+partitions 2
+(partition x1 values less than (25),
+ partition x2 values less than (100));
+
+# Insert a couple of tuples
+INSERT into t1 values (1, 1);
+INSERT into t1 values (2, 5);
+INSERT into t1 values (30, 4);
+INSERT into t1 values (35, 2);
+
+select * from t1 force index (b) where b > 0 order by b;
+
+drop table t1;
+#
+# Ordered index read, char type
+#
+CREATE TABLE t1 (
+a int not null,
+b char(10) not null,
+primary key(a),
+index (b))
+partition by range (a)
+partitions 2
+(partition x1 values less than (25),
+ partition x2 values less than (100));
+
+# Insert a couple of tuples
+INSERT into t1 values (1, '1');
+INSERT into t1 values (2, '5');
+INSERT into t1 values (30, '4');
+INSERT into t1 values (35, '2');
+
+select * from t1 force index (b) where b > 0 order by b;
+
+drop table t1;
+
+#
+# Ordered index read, varchar type
+#
+CREATE TABLE t1 (
+a int not null,
+b varchar(10) not null,
+primary key(a),
+index (b))
+partition by range (a)
+partitions 2
+(partition x1 values less than (25),
+ partition x2 values less than (100));
+
+# Insert a couple of tuples
+INSERT into t1 values (1, '1');
+INSERT into t1 values (2, '5');
+INSERT into t1 values (30, '4');
+INSERT into t1 values (35, '2');
+
+select * from t1 force index (b) where b > '0' order by b;
+
+drop table t1;
+#
+# Ordered index read, varchar type limited index size
+#
+CREATE TABLE t1 (
+a int not null,
+b varchar(10) not null,
+primary key(a),
+index (b(5)))
+partition by range (a)
+partitions 2
+(partition x1 values less than (25),
+ partition x2 values less than (100));
+
+# Insert a couple of tuples
+INSERT into t1 values (1, '1');
+INSERT into t1 values (2, '5');
+INSERT into t1 values (30, '4');
+INSERT into t1 values (35, '2');
+
+select * from t1 force index (b) where b > '0' order by b;
+
+drop table t1;
+
+#
+# Ordered index read, varchar binary type
+#
+CREATE TABLE t1 (
+a int not null,
+b varchar(10) binary not null,
+primary key(a),
+index (b))
+partition by range (a)
+partitions 2
+(partition x1 values less than (25),
+ partition x2 values less than (100));
+
+# Insert a couple of tuples
+INSERT into t1 values (1, '1');
+INSERT into t1 values (2, '5');
+INSERT into t1 values (30, '4');
+INSERT into t1 values (35, '2');
+
+select * from t1 force index (b) where b > '0' order by b;
+
+drop table t1;
+
+#
+# Ordered index read, tinytext type
+#
+CREATE TABLE t1 (
+a int not null,
+b tinytext not null,
+primary key(a),
+index (b(10)))
+partition by range (a)
+partitions 2
+(partition x1 values less than (25),
+ partition x2 values less than (100));
+
+# Insert a couple of tuples
+INSERT into t1 values (1, '1');
+INSERT into t1 values (2, '5');
+INSERT into t1 values (30, '4');
+INSERT into t1 values (35, '2');
+
+select * from t1 force index (b) where b > '0' order by b;
+
+drop table t1;
+#
+# Ordered index read, text type
+#
+CREATE TABLE t1 (
+a int not null,
+b text not null,
+primary key(a),
+index (b(10)))
+partition by range (a)
+partitions 2
+(partition x1 values less than (25),
+ partition x2 values less than (100));
+
+# Insert a couple of tuples
+INSERT into t1 values (1, '1');
+INSERT into t1 values (2, '5');
+INSERT into t1 values (30, '4');
+INSERT into t1 values (35, '2');
+
+select * from t1 force index (b) where b > '0' order by b;
+
+drop table t1;
+
+#
+# Ordered index read, mediumtext type
+#
+CREATE TABLE t1 (
+a int not null,
+b mediumtext not null,
+primary key(a),
+index (b(10)))
+partition by range (a)
+partitions 2
+(partition x1 values less than (25),
+ partition x2 values less than (100));
+
+# Insert a couple of tuples
+INSERT into t1 values (1, '1');
+INSERT into t1 values (2, '5');
+INSERT into t1 values (30, '4');
+INSERT into t1 values (35, '2');
+
+select * from t1 force index (b) where b > '0' order by b;
+
+drop table t1;
+#
+# Ordered index read, longtext type
+#
+CREATE TABLE t1 (
+a int not null,
+b longtext not null,
+primary key(a),
+index (b(10)))
+partition by range (a)
+partitions 2
+(partition x1 values less than (25),
+ partition x2 values less than (100));
+
+# Insert a couple of tuples
+INSERT into t1 values (1, '1');
+INSERT into t1 values (2, '5');
+INSERT into t1 values (30, '4');
+INSERT into t1 values (35, '2');
+
+select * from t1 force index (b) where b > '0' order by b;
+
+drop table t1;
+#
+# Ordered index read, enum type
+#
+CREATE TABLE t1 (
+a int not null,
+b enum('1','2', '4', '5') not null,
+primary key(a),
+index (b))
+partition by range (a)
+partitions 2
+(partition x1 values less than (25),
+ partition x2 values less than (100));
+
+# Insert a couple of tuples
+INSERT into t1 values (1, '1');
+INSERT into t1 values (2, '5');
+INSERT into t1 values (30, '4');
+INSERT into t1 values (35, '2');
+
+select * from t1 force index (b) where b >= '1' order by b;
+
+drop table t1;
+#
+# Ordered index read, set type
+#
+CREATE TABLE t1 (
+a int not null,
+b set('1','2', '4', '5') not null,
+primary key(a),
+index (b))
+partition by range (a)
+partitions 2
+(partition x1 values less than (25),
+ partition x2 values less than (100));
+
+# Insert a couple of tuples
+INSERT into t1 values (1, '1');
+INSERT into t1 values (2, '5');
+INSERT into t1 values (30, '4');
+INSERT into t1 values (35, '2');
+
+select * from t1 force index (b) where b >= '1' order by b;
+
+drop table t1;
+#
+# Ordered index read, date type
+#
+CREATE TABLE t1 (
+a int not null,
+b date not null,
+primary key(a),
+index (b))
+partition by range (a)
+partitions 2
+(partition x1 values less than (25),
+ partition x2 values less than (100));
+
+# Insert a couple of tuples
+INSERT into t1 values (1, '2001-01-01');
+INSERT into t1 values (2, '2005-01-01');
+INSERT into t1 values (30, '2004-01-01');
+INSERT into t1 values (35, '2002-01-01');
+
+select * from t1 force index (b) where b > '2000-01-01' order by b;
+
+drop table t1;
+#
+# Ordered index read, datetime type
+#
+CREATE TABLE t1 (
+a int not null,
+b datetime not null,
+primary key(a),
+index (b))
+partition by range (a)
+partitions 2
+(partition x1 values less than (25),
+ partition x2 values less than (100));
+
+# Insert a couple of tuples
+INSERT into t1 values (1, '2001-01-01 00:00:00');
+INSERT into t1 values (2, '2005-01-01 00:00:00');
+INSERT into t1 values (30, '2004-01-01 00:00:00');
+INSERT into t1 values (35, '2002-01-01 00:00:00');
+
+select * from t1 force index (b) where b > '2000-01-01 00:00:00' order by b;
+
+drop table t1;
+#
+# Ordered index read, timestamp type
+#
+CREATE TABLE t1 (
+a int not null,
+b timestamp not null,
+primary key(a),
+index (b))
+partition by range (a)
+partitions 2
+(partition x1 values less than (25),
+ partition x2 values less than (100));
+
+# Insert a couple of tuples
+INSERT into t1 values (1, '2001-01-01 00:00:00');
+INSERT into t1 values (2, '2005-01-01 00:00:00');
+INSERT into t1 values (30, '2004-01-01 00:00:00');
+INSERT into t1 values (35, '2002-01-01 00:00:00');
+
+select * from t1 force index (b) where b > '2000-01-01 00:00:00' order by b;
+
+drop table t1;
+#
+# Ordered index read, time type
+#
+CREATE TABLE t1 (
+a int not null,
+b time not null,
+primary key(a),
+index (b))
+partition by range (a)
+partitions 2
+(partition x1 values less than (25),
+ partition x2 values less than (100));
+
+# Insert a couple of tuples
+INSERT into t1 values (1, '01:00:00');
+INSERT into t1 values (2, '05:00:00');
+INSERT into t1 values (30, '04:00:00');
+INSERT into t1 values (35, '02:00:00');
+
+select * from t1 force index (b) where b > '00:00:00' order by b;
+
+drop table t1;
+#
+# Ordered index read, year type
+#
+CREATE TABLE t1 (
+a int not null,
+b year not null,
+primary key(a),
+index (b))
+partition by range (a)
+partitions 2
+(partition x1 values less than (25),
+ partition x2 values less than (100));
+
+# Insert a couple of tuples
+INSERT into t1 values (1, 2001);
+INSERT into t1 values (2, 2005);
+INSERT into t1 values (30, 2004);
+INSERT into t1 values (35, 2002);
+
+select * from t1 force index (b) where b > 2000 order by b;
+
+drop table t1;
+#
+# Ordered index read, bit(5) type
+#
+CREATE TABLE t1 (
+a int not null,
+b bit(5) not null,
+c int,
+primary key(a),
+index (b))
+partition by range (a)
+partitions 2
+(partition x1 values less than (25),
+ partition x2 values less than (100));
+
+# Insert a couple of tuples
+INSERT into t1 values (1, b'00001', NULL);
+INSERT into t1 values (2, b'00101', 2);
+INSERT into t1 values (30, b'00100', 2);
+INSERT into t1 values (35, b'00010', NULL);
+
+select a from t1 force index (b) where b > b'00000' order by b;
+
+drop table t1;
+#
+# Ordered index read, bit(15) type
+#
+CREATE TABLE t1 (
+a int not null,
+b bit(15) not null,
+c int,
+primary key(a),
+index (b))
+partition by range (a)
+partitions 2
+(partition x1 values less than (25),
+ partition x2 values less than (100));
+
+# Insert a couple of tuples
+INSERT into t1 values (1, b'000000000000001', NULL);
+INSERT into t1 values (2, b'001010000000101', 2);
+INSERT into t1 values (30, b'001000000000100', 2);
+INSERT into t1 values (35, b'000100000000010', NULL);
+
+select a from t1 force index (b) where b > b'000000000000000' order by b;
+
+drop table t1;
+
+#
+# Ordered index read, NULL values
+#
+CREATE TABLE t1 (
+a int not null,
+b int,
+primary key(a),
+index (b))
+partition by range (a)
+partitions 2
+(partition x1 values less than (25),
+ partition x2 values less than (100));
+
+# Insert a couple of tuples
+INSERT into t1 values (1, 1);
+INSERT into t1 values (5, NULL);
+INSERT into t1 values (2, 5);
+INSERT into t1 values (30, 4);
+INSERT into t1 values (35, 2);
+INSERT into t1 values (40, NULL);
+
+select * from t1 force index (b) where b < 10 OR b IS NULL order by b;
+
+drop table t1;
diff --git a/mysql-test/t/partition_pruning.test b/mysql-test/t/partition_pruning.test
new file mode 100644
index 00000000000..0c922392d32
--- /dev/null
+++ b/mysql-test/t/partition_pruning.test
@@ -0,0 +1,568 @@
+#
+# Partition pruning tests. Currently we only detect which partitions to
+# prune, so the test is EXPLAINs.
+#
+-- source include/have_partition.inc
+
+--disable_warnings
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+--enable_warnings
+
+
+# Check if we can infer from condition on partition fields that
+# no records will match.
+create table t1 ( a int not null) partition by hash(a) partitions 2;
+insert into t1 values (1),(2),(3);
+explain select * from t1 where a=5 and a=6;
+drop table t1;
+
+# Simple HASH partitioning
+create table t1 (
+ a int(11) not null
+) partition by hash (a) partitions 2;
+insert into t1 values (1),(2),(3);
+
+explain partitions select * from t1 where a=1;
+explain partitions select * from t1 where a=2;
+explain partitions select * from t1 where a=1 or a=2;
+
+# Partitioning over several fields
+create table t2 (
+ a int not null,
+ b int not null
+) partition by key(a,b) partitions 2;
+insert into t2 values (1,1),(2,2),(3,3);
+
+explain partitions select * from t2 where a=1;
+explain partitions select * from t2 where b=1;
+
+explain partitions select * from t2 where a=1 and b=1;
+
+# RANGE(expr) partitioning
+create table t3 (
+ a int
+)
+partition by range (a*1) (
+ partition p0 values less than (10),
+ partition p1 values less than (20)
+);
+insert into t3 values (5),(15);
+
+explain partitions select * from t3 where a=11;
+explain partitions select * from t3 where a=10;
+explain partitions select * from t3 where a=20;
+
+explain partitions select * from t3 where a=30;
+
+# LIST(expr) partitioning
+create table t4 (a int not null, b int not null) partition by LIST (a+b) (
+ partition p0 values in (12),
+ partition p1 values in (14)
+);
+insert into t4 values (10,2), (10,4);
+
+# empty OR one
+explain partitions select * from t4 where (a=10 and b=1) or (a=10 and b=2);
+
+# empty OR one OR empty
+explain partitions select * from t4
+ where (a=10 and b=1) or (a=10 and b=2) or (a=10 and b = 3);
+
+# one OR empty OR one
+explain partitions select * from t4 where (a=10 and b=2) or (a=10 and b=3)
+ or (a=10 and b = 4);
+
+# empty OR full
+explain partitions select * from t4 where (a=10 and b=1) or a=11;
+
+# one OR full
+explain partitions select * from t4 where (a=10 and b=2) or a=11;
+
+drop table t1, t2, t3, t4;
+
+# LIST(expr)/HASH subpartitioning.
+create table t5 (a int not null, b int not null,
+ c int not null, d int not null)
+partition by LIST(a+b) subpartition by HASH (c+d) subpartitions 2
+(
+ partition p0 values in (12),
+ partition p1 values in (14)
+);
+
+insert into t5 values (10,2,0,0), (10,4,0,0), (10,2,0,1), (10,4,0,1);
+explain partitions select * from t5;
+
+# empty OR one OR empty
+explain partitions select * from t5
+ where (a=10 and b=1) or (a=10 and b=2) or (a=10 and b = 3);
+
+# one OR empty OR one
+explain partitions select * from t5 where (a=10 and b=2) or (a=10 and b=3)
+ or (a=10 and b = 4);
+
+# conditions on subpartitions only
+explain partitions select * from t5 where (c=1 and d=1);
+explain partitions select * from t5 where (c=2 and d=1);
+
+# mixed partition/subpartitions.
+explain partitions select * from t5 where (a=10 and b=2 and c=1 and d=1) or
+(c=2 and d=1);
+
+# same as above
+explain partitions select * from t5 where (a=10 and b=2 and c=1 and d=1) or
+(b=2 and c=2 and d=1);
+
+# LIST(field) partitioning, interval analysis.
+create table t6 (a int not null) partition by LIST(a) (
+ partition p1 values in (1),
+ partition p3 values in (3),
+ partition p5 values in (5),
+ partition p7 values in (7),
+ partition p9 values in (9)
+);
+insert into t6 values (1),(3),(5);
+
+explain partitions select * from t6 where a < 1;
+explain partitions select * from t6 where a <= 1;
+explain partitions select * from t6 where a > 9;
+explain partitions select * from t6 where a >= 9;
+
+explain partitions select * from t6 where a > 0 and a < 5;
+explain partitions select * from t6 where a > 5 and a < 12;
+explain partitions select * from t6 where a > 3 and a < 8 ;
+
+explain partitions select * from t6 where a >= 0 and a <= 5;
+explain partitions select * from t6 where a >= 5 and a <= 12;
+explain partitions select * from t6 where a >= 3 and a <= 8;
+
+explain partitions select * from t6 where a > 3 and a < 5;
+
+# RANGE(field) partitioning, interval analysis.
+create table t7 (a int not null) partition by RANGE(a) (
+ partition p10 values less than (10),
+ partition p30 values less than (30),
+ partition p50 values less than (50),
+ partition p70 values less than (70),
+ partition p90 values less than (90)
+);
+insert into t7 values (10),(30),(50);
+
+# leftmost intervals
+explain partitions select * from t7 where a < 5;
+explain partitions select * from t7 where a < 10;
+explain partitions select * from t7 where a <= 10;
+explain partitions select * from t7 where a = 10;
+
+#rightmost intervals
+explain partitions select * from t7 where a < 90;
+explain partitions select * from t7 where a = 90;
+explain partitions select * from t7 where a > 90;
+explain partitions select * from t7 where a >= 90;
+
+# misc intervals
+explain partitions select * from t7 where a > 11 and a < 29;
+
+# LIST(monontonic_func) partitioning
+create table t8 (a date not null) partition by RANGE(YEAR(a)) (
+ partition p0 values less than (1980),
+ partition p1 values less than (1990),
+ partition p2 values less than (2000)
+);
+insert into t8 values ('1985-05-05'),('1995-05-05');
+
+explain partitions select * from t8 where a < '1980-02-02';
+
+# LIST(strict_monotonic_func) partitioning
+create table t9 (a date not null) partition by RANGE(TO_DAYS(a)) (
+ partition p0 values less than (732299), -- 2004-12-19
+ partition p1 values less than (732468), -- 2005-06-06
+ partition p2 values less than (732664) -- 2005-12-19
+);
+insert into t9 values ('2005-05-05'), ('2005-04-04');
+
+explain partitions select * from t9 where a < '2004-12-19';
+explain partitions select * from t9 where a <= '2004-12-19';
+
+drop table t5,t6,t7,t8,t9;
+
+# Test the case where we can't create partitioning 'index'
+create table t1 (a enum('a','b','c','d') default 'a')
+ partition by hash (ascii(a)) partitions 2;
+insert into t1 values ('a'),('b'),('c');
+explain partitions select * from t1 where a='b';
+drop table t1;
+
+#
+# Test cases for bugs found in code review:
+#
+create table t1 (
+ a1 int not null
+)
+partition by range (a1) (
+ partition p0 values less than (3),
+ partition p1 values less than (6),
+ partition p2 values less than (9)
+);
+insert into t1 values (1),(2),(3);
+explain partitions select * from t1 where a1 > 3;
+explain partitions select * from t1 where a1 >= 3;
+
+explain partitions select * from t1 where a1 < 3 and a1 > 3;
+drop table t1;
+
+#
+create table t3 (a int, b int)
+ partition by list(a) subpartition by hash(b) subpartitions 4 (
+ partition p0 values in (1),
+ partition p1 values in (2),
+ partition p2 values in (3),
+ partition p3 values in (4)
+ );
+insert into t3 values (1,1),(2,2),(3,3);
+
+explain partitions select * from t3 where a=2 or b=1;
+explain partitions select * from t3 where a=4 or b=2;
+explain partitions select * from t3 where (a=2 or b=1) and (a=4 or b=2) ;
+drop table t3;
+
+# Test for NULLs
+create table t1 (a int) partition by hash(a) partitions 2;
+insert into t1 values (1),(2);
+explain partitions select * from t1 where a is null;
+
+# this uses both partitions
+explain partitions select * from t1 where a is not null;
+drop table t1;
+
+# Join tests
+create table t1 (a int not null, b int not null, key(a), key(b))
+ partition by hash(a) partitions 4;
+insert into t1 values (1,1),(2,2),(3,3),(4,4);
+
+explain partitions
+select * from t1 X, t1 Y
+where X.b = Y.b and (X.a=1 or X.a=2) and (Y.a=2 or Y.a=3);
+
+explain partitions
+select * from t1 X, t1 Y where X.a = Y.a and (X.a=1 or X.a=2);
+
+drop table t1;
+
+# Tests for "short ranges"
+create table t1 (a int) partition by hash(a) partitions 20;
+insert into t1 values (1),(2),(3);
+explain partitions select * from t1 where a > 1 and a < 3;
+explain partitions select * from t1 where a >= 1 and a < 3;
+explain partitions select * from t1 where a > 1 and a <= 3;
+explain partitions select * from t1 where a >= 1 and a <= 3;
+drop table t1;
+
+create table t1 (a int, b int)
+ partition by list(a) subpartition by hash(b) subpartitions 20
+(
+ partition p0 values in (0),
+ partition p1 values in (1),
+ partition p2 values in (2),
+ partition p3 values in (3)
+);
+insert into t1 values (1,1),(2,2),(3,3);
+
+explain partitions select * from t1 where b > 1 and b < 3;
+explain partitions select * from t1 where b > 1 and b < 3 and (a =1 or a =2);
+drop table t1;
+
+# Test partition pruning for single-table UPDATE/DELETE.
+# TODO: Currently we test only "all partitions pruned away" case. Add more
+# tests when the patch that makes use of partition pruning results at
+# execution phase is pushed.
+
+create table t1 (a int) partition by list(a) (
+ partition p0 values in (1,2),
+ partition p1 values in (3,4)
+);
+insert into t1 values (1),(1),(2),(2),(3),(4),(3),(4);
+
+# This won't do any table access
+flush status;
+update t1 set a=100 where a=5;
+show status like 'Handler_read_rnd_next';
+
+# ... as compared to this, which will scan both partitions
+flush status;
+update t1 set a=100 where a+1=5+1;
+show status like 'Handler_read_rnd_next';
+
+# Same as above for DELETE:
+flush status;
+delete from t1 where a=5;
+show status like 'Handler_read_rnd_next';
+
+flush status;
+delete from t1 where a+1=5+1;
+show status like 'Handler_read_rnd_next';
+
+# Same as above multi-table UPDATE/DELETE
+create table t2 like t1;
+insert into t2 select * from t2;
+
+flush status;
+update t1,t2 set t1.a=1000, t2.a=1000 where t1.a=5 and t2.a=5;
+show status like 'Handler_read_rnd_next';
+# ^ This shows 3 accesses, these are caused by const table reads.
+# They should vanish when partition pruning results are used.
+
+flush status;
+delete t1,t2 from t1, t2 where t1.a=5 and t2.a=5;
+show status like 'Handler_read_rnd_next';
+drop table t1,t2;
+
+#
+# WL#2986 Tests (Checking if partition pruning results are used at query
+# execution phase)
+#
+CREATE TABLE `t1` (
+ `a` int(11) default NULL
+);
+INSERT INTO t1 VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+
+CREATE TABLE `t2` (
+ `a` int(11) default NULL,
+ KEY `a` (`a`)
+) ;
+
+insert into t2 select A.a + 10*(B.a + 10* C.a) from t1 A, t1 B, t1 C ;
+insert into t1 select a from t2;
+
+drop table t2;
+CREATE TABLE `t2` (
+ `a` int(11) default NULL,
+ `b` int(11) default NULL
+)
+PARTITION BY RANGE (a) (
+PARTITION p0 VALUES LESS THAN (200),
+PARTITION p1 VALUES LESS THAN (400),
+PARTITION p2 VALUES LESS THAN (600),
+PARTITION p3 VALUES LESS THAN (800),
+PARTITION p4 VALUES LESS THAN (1001));
+
+insert into t2 select a,1 from t1 where a < 200;
+insert into t2 select a,2 from t1 where a >= 200 and a < 400;
+insert into t2 select a,3 from t1 where a >= 400 and a < 600;
+insert into t2 select a,4 from t1 where a >= 600 and a < 800;
+insert into t2 select a,5 from t1 where a >= 800 and a < 1001;
+
+explain partitions select * from t2;
+explain partitions select * from t2 where a < 801 and a > 200;
+explain partitions select * from t2 where a < 801 and a > 800;
+explain partitions select * from t2 where a > 600;
+explain partitions select * from t2 where a > 600 and b = 1;
+explain partitions select * from t2 where a > 600 and b = 4;
+explain partitions select * from t2 where a > 600 and b = 5;
+explain partitions select * from t2 where b = 5;
+
+flush status;
+update t2 set b = 100 where b = 6;
+show status like 'Handler_read_rnd_next';
+flush status;
+update t2 set a = 1002 where a = 1001;
+show status like 'Handler_read_rnd_next';
+flush status;
+update t2 set b = 6 where a = 600;
+show status like 'Handler_read_rnd_next';
+flush status;
+update t2 set b = 6 where a > 600 and a < 800;
+show status like 'Handler_read_rnd_next';
+flush status;
+delete from t2 where a > 600;
+show status like 'Handler_read_rnd_next';
+
+drop table t2;
+CREATE TABLE `t2` (
+ `a` int(11) default NULL,
+ `b` int(11) default NULL,
+ index (b)
+)
+PARTITION BY RANGE (a) (
+PARTITION p0 VALUES LESS THAN (200),
+PARTITION p1 VALUES LESS THAN (400),
+PARTITION p2 VALUES LESS THAN (600),
+PARTITION p3 VALUES LESS THAN (800),
+PARTITION p4 VALUES LESS THAN (1001));
+
+insert into t2 select a,1 from t1 where a < 100;
+insert into t2 select a,2 from t1 where a >= 200 and a < 300;
+insert into t2 select a,3 from t1 where a >= 300 and a < 400;
+insert into t2 select a,4 from t1 where a >= 400 and a < 500;
+insert into t2 select a,5 from t1 where a >= 500 and a < 600;
+insert into t2 select a,6 from t1 where a >= 600 and a < 700;
+insert into t2 select a,7 from t1 where a >= 700 and a < 800;
+insert into t2 select a,8 from t1 where a >= 800 and a < 900;
+insert into t2 select a,9 from t1 where a >= 900 and a < 1001;
+
+explain partitions select * from t2;
+# not using indexes
+explain partitions select * from t2 where a = 101;
+explain partitions select * from t2 where a = 550;
+explain partitions select * from t2 where a = 833;
+explain partitions select * from t2 where (a = 100 OR a = 900);
+explain partitions select * from t2 where (a > 100 AND a < 600);
+explain partitions select * from t2 where b = 4;
+explain partitions select * from t2 where b = 6;
+explain partitions select * from t2 where b in (1,3,5);
+explain partitions select * from t2 where b in (2,4,6);
+explain partitions select * from t2 where b in (7,8,9);
+explain partitions select * from t2 where b > 5;
+explain partitions select * from t2 where b > 5 and b < 8;
+explain partitions select * from t2 where b > 5 and b < 7;
+explain partitions select * from t2 where b > 0 and b < 5;
+
+flush status;
+update t2 set a = 111 where b = 10;
+show status like 'Handler_read_rnd_next';
+show status like 'Handler_read_key';
+flush status;
+update t2 set a = 111 where b in (5,6);
+show status like 'Handler_read_rnd_next';
+show status like 'Handler_read_key';
+flush status;
+update t2 set a = 222 where b = 7;
+show status like 'Handler_read_rnd_next';
+show status like 'Handler_read_key';
+flush status;
+delete from t2 where b = 7;
+show status like 'Handler_read_rnd_next';
+show status like 'Handler_read_key';
+flush status;
+delete from t2 where b > 5;
+show status like 'Handler_read_rnd_next';
+show status like 'Handler_read_key';
+show status like 'Handler_read_prev';
+show status like 'Handler_read_next';
+flush status;
+delete from t2 where b < 5 or b > 3;
+show status like 'Handler_read_rnd_next';
+show status like 'Handler_read_key';
+show status like 'Handler_read_prev';
+show status like 'Handler_read_next';
+
+drop table t1, t2;
+
+# BUG#18025
+# part1: mediumint columns
+create table t1 ( f_int1 mediumint, f_int2 integer)
+partition by list(mod(f_int1,4)) (
+ partition p_3 values in (-3),
+ partition p_2 values in (-2),
+ partition p_1 values in (-1),
+ partition p0 values in (0),
+ partition p1 values in (1),
+ partition p2 values in (2),
+ partition p3 values in (3)
+);
+
+insert into t1 values (9, 9), (8, 8), (7, 7), (6, 6), (5, 5),
+ (4, 4), (3, 3), (2, 2), (1, 1);
+select * from t1 where f_int1 between 5 and 15 order by f_int1;
+
+drop table t1;
+
+# part2: bug in pruning code
+create table t1 (a char(10)) partition by list(length(a)) (
+ partition p1 values in (1),
+ partition p2 values in (2),
+ partition p3 values in (3),
+ partition p4 values in (4),
+ partition p5 values in (5)
+);
+insert into t1 values ('a'),('bb'),('ccc'),('dddd'),('eeEee');
+select * from t1 where a>='a' and a <= 'dddd';
+explain partitions select * from t1 where a>='a' and a <= 'dddd';
+drop table t1;
+
+# BUG#18659: Assertion failure when subpartitioning is used and partition is
+# "IS NULL"
+create table t1 (f_int1 integer) partition by list(abs(mod(f_int1,2)))
+ subpartition by hash(f_int1) subpartitions 2
+(
+ partition part1 values in (0),
+ partition part2 values in (1),
+ partition part4 values in (null)
+);
+insert into t1 set f_int1 = null;
+
+select * from t1 where f_int1 is null;
+explain partitions select * from t1 where f_int1 is null;
+drop table t1;
+
+#
+# BUG#18558
+#
+create table t1 (a int not null, b int not null)
+partition by list(a)
+ subpartition by hash(b) subpartitions 4
+(
+ partition p0 values in (1),
+ partition p1 values in (2),
+ partition p2 values in (3)
+);
+insert into t1 values (1,1),(1,2),(1,3),(1,4),
+ (2,1),(2,2),(2,3),(2,4);
+explain partitions select * from t1 where a=1 AND (b=1 OR b=2);
+drop table t1;
+
+create table t1 (a int, b int not null)
+partition by list(a)
+ subpartition by hash(b) subpartitions 2
+(
+ partition p0 values in (1),
+ partition p1 values in (2),
+ partition p2 values in (3),
+ partition pn values in (NULL)
+);
+insert into t1 values (1,1),(1,2),(1,3),(1,4),
+ (2,1),(2,2),(2,3),(2,4), (NULL,1);
+
+explain partitions select * from t1 where a IS NULL AND (b=1 OR b=2);
+
+explain partitions select * from t1 where (a IS NULL or a < 1) AND (b=1 OR b=2);
+explain partitions select * from t1 where (a IS NULL or a < 2) AND (b=1 OR b=2);
+explain partitions select * from t1 where (a IS NULL or a <= 1) AND (b=1 OR b=2);
+
+drop table t1;
+
+create table t1 ( a int) partition by list (MOD(a, 10))
+( partition p0 values in (0), partition p1 values in (1),
+ partition p2 values in (2), partition p3 values in (3),
+ partition p4 values in (4), partition p5 values in (5),
+ partition p6 values in (6), partition pn values in (NULL)
+);
+insert into t1 values (NULL), (0),(1),(2),(3),(4),(5),(6);
+explain partitions select * from t1 where a is null or a < 2;
+drop table t1;
+
+# Testcase from BUG#18751
+create table t1 (s1 int) partition by list (s1)
+ (partition p1 values in (0),
+ partition p2 values in (1),
+ partition p3 values in (null));
+
+insert into t1 values (0),(1),(null);
+
+select count(*) from t1 where s1 < 0 or s1 is null;
+explain partitions select count(*) from t1 where s1 < 0 or s1 is null;
+drop table t1;
+
+# No tests for NULLs in RANGE(monotonic_expr()) - they depend on BUG#15447
+# being fixed.
+
+#
+#BUG 17946 Like searches fail with partitioning
+#
+create table t1 (a char(32) primary key)
+partition by key()
+partitions 100;
+insert into t1 values ('na');
+select * from t1;
+select * from t1 where a like 'n%';
+drop table t1;
+
diff --git a/mysql-test/t/partition_range.test b/mysql-test/t/partition_range.test
new file mode 100644
index 00000000000..ef539e2001f
--- /dev/null
+++ b/mysql-test/t/partition_range.test
@@ -0,0 +1,418 @@
+#--disable_abort_on_error
+#
+# Simple test for the partition storage engine
+# Focuses on range partitioning tests
+#
+-- source include/have_partition.inc
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+#
+# Partition by range, basic
+#
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key(a,b))
+partition by range (a)
+partitions 3
+(partition x1 values less than (5) tablespace ts1,
+ partition x2 values less than (10) tablespace ts2,
+ partition x3 values less than maxvalue tablespace ts3);
+
+# Simple insert and verify test
+INSERT into t1 values (1, 1, 1);
+INSERT into t1 values (6, 1, 1);
+INSERT into t1 values (10, 1, 1);
+INSERT into t1 values (15, 1, 1);
+
+select * from t1;
+show create table t1;
+
+ALTER TABLE t1
+partition by range (a)
+partitions 3
+(partition x1 values less than (5) tablespace ts1,
+ partition x2 values less than (10) tablespace ts2,
+ partition x3 values less than maxvalue tablespace ts3);
+
+select * from t1;
+show create table t1;
+
+drop table if exists t1;
+
+#
+# Partition by range, basic
+# No primary key
+#
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null)
+partition by range (a)
+partitions 3
+(partition x1 values less than (5) tablespace ts1,
+ partition x2 values less than (10) tablespace ts2,
+ partition x3 values less than maxvalue tablespace ts3);
+
+# Simple insert and verify test
+INSERT into t1 values (1, 1, 1);
+INSERT into t1 values (6, 1, 1);
+INSERT into t1 values (10, 1, 1);
+INSERT into t1 values (15, 1, 1);
+
+select * from t1;
+
+ALTER TABLE t1
+partition by range (a)
+partitions 3
+(partition x1 values less than (5) tablespace ts1,
+ partition x2 values less than (10) tablespace ts2,
+ partition x3 values less than maxvalue tablespace ts3);
+
+select * from t1;
+
+drop table if exists t1;
+
+#
+# Partition by range, basic
+# No max value used
+#
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key(a,b))
+partition by range (a)
+partitions 3
+(partition x1 values less than (5) tablespace ts1,
+ partition x2 values less than (10) tablespace ts2,
+ partition x3 values less than (15) tablespace ts3);
+
+
+# Simple insert and verify test
+INSERT into t1 values (1, 1, 1);
+INSERT into t1 values (6, 1, 1);
+INSERT into t1 values (10, 1, 1);
+--error ER_NO_PARTITION_FOR_GIVEN_VALUE
+INSERT into t1 values (15, 1, 1);
+
+select * from t1;
+
+ALTER TABLE t1
+partition by range (a)
+partitions 3
+(partition x1 values less than (5) tablespace ts1,
+ partition x2 values less than (10) tablespace ts2,
+ partition x3 values less than (15) tablespace ts3);
+
+select * from t1;
+
+drop table t1;
+
+#
+# Partition by range, only one partition
+#
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key(a,b))
+partition by range (a)
+(partition x1 values less than (1));
+
+drop table t1;
+
+#
+# Subpartition by hash, two partitions and two subpartitions
+#
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key (a,b))
+partition by range (a)
+subpartition by hash (a+b)
+( partition x1 values less than (1)
+ ( subpartition x11,
+ subpartition x12),
+ partition x2 values less than (5)
+ ( subpartition x21,
+ subpartition x22)
+);
+
+SELECT * from t1;
+show create table t1;
+
+ALTER TABLE t1 ADD COLUMN d int;
+show create table t1;
+
+drop table t1;
+
+#
+# Subpartition by hash, two partitions and two subpartitions
+# Defined tablespace, engine and node group
+#
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key (a,b))
+partition by range (a)
+subpartition by hash (a+b)
+( partition x1 values less than (1)
+ ( subpartition x11 tablespace t1 engine myisam nodegroup 0,
+ subpartition x12 tablespace t2 engine myisam nodegroup 1),
+ partition x2 values less than (5)
+ ( subpartition x21 tablespace t1 engine myisam nodegroup 0,
+ subpartition x22 tablespace t2 engine myisam nodegroup 1)
+);
+
+SELECT * from t1;
+
+drop table t1;
+
+#
+# Subpartition by hash, two partitions and two subpartitions
+# Defined tablespace, node group
+#
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key (a,b))
+partition by range (a)
+subpartition by hash (a+b)
+( partition x1 values less than (1)
+ ( subpartition x11 tablespace t1 nodegroup 0,
+ subpartition x12 tablespace t2 nodegroup 1),
+ partition x2 values less than (5)
+ ( subpartition x21 tablespace t1 nodegroup 0,
+ subpartition x22 tablespace t2 nodegroup 1)
+);
+
+SELECT * from t1;
+
+drop table t1;
+
+#
+# Subpartition by hash, two partitions and two subpartitions
+# Defined engine and node group
+#
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key (a,b))
+partition by range (a)
+subpartition by hash (a+b)
+( partition x1 values less than (1)
+ ( subpartition x11 engine myisam nodegroup 0,
+ subpartition x12 engine myisam nodegroup 1),
+ partition x2 values less than (5)
+ ( subpartition x21 engine myisam nodegroup 0,
+ subpartition x22 engine myisam nodegroup 1)
+);
+
+INSERT into t1 VALUES (1,1,1);
+INSERT into t1 VALUES (4,1,1);
+--error ER_NO_PARTITION_FOR_GIVEN_VALUE
+INSERT into t1 VALUES (5,1,1);
+
+SELECT * from t1;
+
+ALTER TABLE t1
+partition by range (a)
+subpartition by hash (a+b)
+( partition x1 values less than (1)
+ ( subpartition x11 engine myisam nodegroup 0,
+ subpartition x12 engine myisam nodegroup 1),
+ partition x2 values less than (5)
+ ( subpartition x21 engine myisam nodegroup 0,
+ subpartition x22 engine myisam nodegroup 1)
+);
+
+SELECT * from t1;
+
+drop table t1;
+
+#
+# Subpartition by hash, two partitions and two subpartitions
+# Defined tablespace, engine
+#
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key (a,b))
+partition by range (a)
+subpartition by hash (a+b)
+( partition x1 values less than (1)
+ ( subpartition x11 tablespace t1 engine myisam,
+ subpartition x12 tablespace t2 engine myisam),
+ partition x2 values less than (5)
+ ( subpartition x21 tablespace t1 engine myisam,
+ subpartition x22 tablespace t2 engine myisam)
+);
+
+INSERT into t1 VALUES (1,1,1);
+INSERT into t1 VALUES (4,1,1);
+--error ER_NO_PARTITION_FOR_GIVEN_VALUE
+INSERT into t1 VALUES (5,1,1);
+
+SELECT * from t1;
+
+ALTER TABLE t1
+partition by range (a)
+subpartition by hash (a+b)
+( partition x1 values less than (1)
+ ( subpartition x11 tablespace t1 engine myisam,
+ subpartition x12 tablespace t2 engine myisam),
+ partition x2 values less than (5)
+ ( subpartition x21 tablespace t1 engine myisam,
+ subpartition x22 tablespace t2 engine myisam)
+);
+
+SELECT * from t1;
+
+drop table t1;
+
+#
+# Subpartition by hash, two partitions and two subpartitions
+# Defined tablespace
+#
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key (a,b))
+partition by range (a)
+subpartition by hash (a+b)
+( partition x1 values less than (1)
+ ( subpartition x11 tablespace t1,
+ subpartition x12 tablespace t2),
+ partition x2 values less than (5)
+ ( subpartition x21 tablespace t1,
+ subpartition x22 tablespace t2)
+);
+
+INSERT into t1 VALUES (1,1,1);
+INSERT into t1 VALUES (4,1,1);
+--error ER_NO_PARTITION_FOR_GIVEN_VALUE
+INSERT into t1 VALUES (5,1,1);
+
+SELECT * from t1;
+
+ALTER TABLE t1
+partition by range (a)
+subpartition by hash (a+b)
+( partition x1 values less than (1)
+ ( subpartition x11 tablespace t1 engine myisam,
+ subpartition x12 tablespace t2 engine myisam),
+ partition x2 values less than (5)
+ ( subpartition x21 tablespace t1 engine myisam,
+ subpartition x22 tablespace t2 engine myisam)
+);
+
+SELECT * from t1;
+
+drop table t1;
+
+#
+# Subpartition by hash, two partitions and two subpartitions
+# Defined engine
+#
+CREATE TABLE t1 (
+a int not null,
+b int not null,
+c int not null,
+primary key (a,b))
+partition by range (a)
+subpartition by hash (a+b)
+( partition x1 values less than (1)
+ ( subpartition x11 engine myisam,
+ subpartition x12 engine myisam),
+ partition x2 values less than (5)
+ ( subpartition x21 engine myisam,
+ subpartition x22 engine myisam)
+);
+
+INSERT into t1 VALUES (1,1,1);
+INSERT into t1 VALUES (4,1,1);
+--error ER_NO_PARTITION_FOR_GIVEN_VALUE
+INSERT into t1 VALUES (5,1,1);
+
+SELECT * from t1;
+
+ALTER TABLE t1
+partition by range (a)
+subpartition by hash (a+b)
+( partition x1 values less than (1)
+ ( subpartition x11 engine myisam,
+ subpartition x12 engine myisam),
+ partition x2 values less than (5)
+ ( subpartition x21 engine myisam,
+ subpartition x22 engine myisam)
+);
+
+SELECT * from t1;
+
+drop table t1;
+
+#
+# Bug #17894 Comparison with "less than" operator fails with Range partition
+#
+CREATE TABLE t1 (c1 int default NULL, c2 varchar(30) default NULL,
+c3 date default NULL) engine=myisam
+PARTITION BY RANGE (year(c3)) (PARTITION p0 VALUES LESS THAN (1995),
+PARTITION p1 VALUES LESS THAN (1996) , PARTITION p2 VALUES LESS THAN (1997) ,
+PARTITION p3 VALUES LESS THAN (1998) , PARTITION p4 VALUES LESS THAN (1999) ,
+PARTITION p5 VALUES LESS THAN (2000) , PARTITION p6 VALUES LESS THAN (2001) ,
+PARTITION p7 VALUES LESS THAN (2002) , PARTITION p8 VALUES LESS THAN (2003) ,
+PARTITION p9 VALUES LESS THAN (2004) , PARTITION p10 VALUES LESS THAN (2010),
+PARTITION p11 VALUES LESS THAN MAXVALUE );
+INSERT INTO t1 VALUES (1, 'testing partitions', '1995-07-17'),
+(3, 'testing partitions','1995-07-31'),
+(5, 'testing partitions','1995-08-13'),
+(7, 'testing partitions','1995-08-26'),
+(9, 'testing partitions','1995-09-09'),
+(0, 'testing partitions','2000-07-10'),
+(2, 'testing partitions','2000-07-23'),
+(4, 'testing partitions','2000-08-05'),
+(6, 'testing partitions','2000-08-19'),
+(8, 'testing partitions','2000-09-01');
+SELECT COUNT(*) FROM t1 WHERE c3 BETWEEN '1996-12-31' AND '2000-12-31';
+SELECT COUNT(*) FROM t1 WHERE c3 < '2000-12-31';
+DROP TABLE t1;
+
+#
+# BUG 18962 Errors in DROP PARTITION
+#
+create table t1 (a int)
+partition by range (MOD(a,3))
+subpartition by hash(a)
+subpartitions 2
+(partition p0 values less than (1),
+ partition p1 values less than (2),
+ partition p2 values less than (3),
+ partition p3 values less than (4));
+ALTER TABLE t1 DROP PARTITION p3;
+ALTER TABLE t1 DROP PARTITION p1;
+ALTER TABLE t1 DROP PARTITION p2;
+drop table t1;
+
+create table t1 (a int)
+partition by range (MOD(a,3))
+subpartition by hash(a)
+subpartitions 2
+(partition p0 values less than (1),
+ partition p1 values less than (2),
+ partition p2 values less than (3),
+ partition p3 values less than (4));
+ALTER TABLE t1 DROP PARTITION p0;
+ALTER TABLE t1 DROP PARTITION p1;
+ALTER TABLE t1 DROP PARTITION p2;
+drop table t1;
diff --git a/mysql-test/t/ps.test b/mysql-test/t/ps.test
index cc7d7ef2d82..639a576fb35 100644
--- a/mysql-test/t/ps.test
+++ b/mysql-test/t/ps.test
@@ -2,7 +2,7 @@
# SQL Syntax for Prepared Statements test
#
--disable_warnings
-drop table if exists t1,t2;
+drop table if exists t1,t2,t3,t4;
# Avoid wrong warnings if mysql_client_test fails
drop database if exists client_test_db;
diff --git a/mysql-test/t/ps_1general.test b/mysql-test/t/ps_1general.test
index 72b69fc8d9f..f61a7820afe 100644
--- a/mysql-test/t/ps_1general.test
+++ b/mysql-test/t/ps_1general.test
@@ -342,8 +342,11 @@ prepare stmt4 from ' show warnings limit 20 ';
--error 1295
prepare stmt4 from ' show errors limit 20 ';
prepare stmt4 from ' show storage engines ';
---replace_column 2 YES/NO
+# The output depends upon the precise order in which
+# storage engines are registered, so we switch off the output.
+--disable_result_log
execute stmt4;
+--enable_result_log
################ MISC STUFF ################
## get a warning and an error
diff --git a/mysql-test/t/query_cache.test b/mysql-test/t/query_cache.test
index d416f34ce45..e2ff20e6ecc 100644
--- a/mysql-test/t/query_cache.test
+++ b/mysql-test/t/query_cache.test
@@ -12,8 +12,12 @@ flush query cache; # This crashed in some versions
reset query cache;
flush status;
--disable_warnings
-drop table if exists t1,t2,t3,t4,t11,t21;
+drop table if exists t1,t2,t3,t4,t11,t21,t1_1,t1_2,t9,t9_1,t9_2;
drop database if exists mysqltest;
+
+# Fix possible left overs from other tests
+drop table if exists ```a`;
+drop view if exists v1;
--enable_warnings
#
@@ -203,7 +207,7 @@ show status like "Qcache_queries_in_cache";
drop table t1;
#
-# Charset convertion (cp1251_koi8 always present)
+# Charset conversion (cp1251_koi8 always present)
#
create table t1 (a char(1) not null collate koi8r_general_ci);
insert into t1 values(_koi8r"");
diff --git a/mysql-test/t/raid.test b/mysql-test/t/raid.test
deleted file mode 100644
index 3ca5adaaaea..00000000000
--- a/mysql-test/t/raid.test
+++ /dev/null
@@ -1,224 +0,0 @@
--- require r/have_raid.require
-disable_query_log;
-show variables like "have_raid";
-enable_query_log;
-
-#
-# Test of raided tables
-#
-
---disable_warnings
-DROP TABLE IF EXISTS t1,t2;
-DROP DATABASE IF EXISTS test_$1;
---enable_warnings
-
-#
-# Test dropping database with raid tables
-#
-
-create database test_$1;
-create table test_$1.r1 (i int) raid_type=1;
-create table test_$1.r2 (i int) raid_type=1 raid_chunks=32;
-drop database test_$1;
-
-#
-# Bug #3182: Test using more than 257 raid chunks
-#
-create database test_$1;
-create table test_$1.r2 (i int) raid_type=1 raid_chunks=257;
-show create table test_$1.r2;
-drop database test_$1;
-
-#
-# Test that data is spread over different raid directories
-#
-
-CREATE TABLE t1 (
-id int unsigned not null auto_increment primary key,
-c char(255) not null
-) RAID_TYPE=STRIPED RAID_CHUNKS=2 RAID_CHUNKSIZE=123;
-INSERT INTO t1 VALUES
-(NULL,'1'),(NULL,'a'),(NULL,'a'),(NULL,'a'),(NULL,'p'),(NULL,'a'),
-(NULL,'2'),(NULL,'b'),(NULL,'a'),(NULL,'a'),(NULL,'q'),(NULL,'a'),
-(NULL,'3'),(NULL,'c'),(NULL,'a'),(NULL,'a'),(NULL,'r'),(NULL,'a'),
-(NULL,'4'),(NULL,'d'),(NULL,'a'),(NULL,'a'),(NULL,'s'),(NULL,'a'),
-(NULL,'5'),(NULL,'e'),(NULL,'a'),(NULL,'a'),(NULL,'t'),(NULL,'a'),
-(NULL,'6'),(NULL,'f'),(NULL,'a'),(NULL,'a'),(NULL,'u'),(NULL,'a'),
-(NULL,'7'),(NULL,'g'),(NULL,'a'),(NULL,'a'),(NULL,'v'),(NULL,'a'),
-(NULL,'8'),(NULL,'h'),(NULL,'a'),(NULL,'a'),(NULL,'w'),(NULL,'a'),
-(NULL,'9'),(NULL,'i'),(NULL,'a'),(NULL,'a'),(NULL,'x'),(NULL,'a'),
-(NULL,'0'),(NULL,'j'),(NULL,'a'),(NULL,'a'),(NULL,'y'),(NULL,'a'),
-(NULL,'1'),(NULL,'k'),(NULL,'a'),(NULL,'a'),(NULL,'z'),(NULL,'a'),
-(NULL,'2'),(NULL,'l'),(NULL,'a'),(NULL,'a'),(NULL,'/'),(NULL,'a'),
-(NULL,'3'),(NULL,'m'),(NULL,'a'),(NULL,'a'),(NULL,'*'),(NULL,'a'),
-(NULL,'4'),(NULL,'n'),(NULL,'a'),(NULL,'a'),(NULL,'+'),(NULL,'a'),
-(NULL,'5'),(NULL,'o'),(NULL,'a'),(NULL,'a'),(NULL,'?'),(NULL,'a');
-INSERT INTO t1 VALUES
-(NULL,'1'),(NULL,'a'),(NULL,'a'),(NULL,'a'),(NULL,'p'),(NULL,'a'),
-(NULL,'2'),(NULL,'b'),(NULL,'a'),(NULL,'a'),(NULL,'q'),(NULL,'a'),
-(NULL,'3'),(NULL,'c'),(NULL,'a'),(NULL,'a'),(NULL,'r'),(NULL,'a'),
-(NULL,'4'),(NULL,'d'),(NULL,'a'),(NULL,'a'),(NULL,'s'),(NULL,'a'),
-(NULL,'5'),(NULL,'e'),(NULL,'a'),(NULL,'a'),(NULL,'t'),(NULL,'a'),
-(NULL,'6'),(NULL,'f'),(NULL,'a'),(NULL,'a'),(NULL,'u'),(NULL,'a'),
-(NULL,'7'),(NULL,'g'),(NULL,'a'),(NULL,'a'),(NULL,'v'),(NULL,'a'),
-(NULL,'8'),(NULL,'h'),(NULL,'a'),(NULL,'a'),(NULL,'w'),(NULL,'a'),
-(NULL,'9'),(NULL,'i'),(NULL,'a'),(NULL,'a'),(NULL,'x'),(NULL,'a'),
-(NULL,'0'),(NULL,'j'),(NULL,'a'),(NULL,'a'),(NULL,'y'),(NULL,'a'),
-(NULL,'1'),(NULL,'k'),(NULL,'a'),(NULL,'a'),(NULL,'z'),(NULL,'a'),
-(NULL,'2'),(NULL,'l'),(NULL,'a'),(NULL,'a'),(NULL,'/'),(NULL,'a'),
-(NULL,'3'),(NULL,'m'),(NULL,'a'),(NULL,'a'),(NULL,'*'),(NULL,'a'),
-(NULL,'4'),(NULL,'n'),(NULL,'a'),(NULL,'a'),(NULL,'+'),(NULL,'a'),
-(NULL,'5'),(NULL,'o'),(NULL,'a'),(NULL,'a'),(NULL,'?'),(NULL,'a');
-INSERT INTO t1 VALUES
-(NULL,'1'),(NULL,'a'),(NULL,'a'),(NULL,'a'),(NULL,'p'),(NULL,'a'),
-(NULL,'2'),(NULL,'b'),(NULL,'a'),(NULL,'a'),(NULL,'q'),(NULL,'a'),
-(NULL,'3'),(NULL,'c'),(NULL,'a'),(NULL,'a'),(NULL,'r'),(NULL,'a'),
-(NULL,'4'),(NULL,'d'),(NULL,'a'),(NULL,'a'),(NULL,'s'),(NULL,'a'),
-(NULL,'5'),(NULL,'e'),(NULL,'a'),(NULL,'a'),(NULL,'t'),(NULL,'a'),
-(NULL,'6'),(NULL,'f'),(NULL,'a'),(NULL,'a'),(NULL,'u'),(NULL,'a'),
-(NULL,'7'),(NULL,'g'),(NULL,'a'),(NULL,'a'),(NULL,'v'),(NULL,'a'),
-(NULL,'8'),(NULL,'h'),(NULL,'a'),(NULL,'a'),(NULL,'w'),(NULL,'a'),
-(NULL,'9'),(NULL,'i'),(NULL,'a'),(NULL,'a'),(NULL,'x'),(NULL,'a'),
-(NULL,'0'),(NULL,'j'),(NULL,'a'),(NULL,'a'),(NULL,'y'),(NULL,'a'),
-(NULL,'1'),(NULL,'k'),(NULL,'a'),(NULL,'a'),(NULL,'z'),(NULL,'a'),
-(NULL,'2'),(NULL,'l'),(NULL,'a'),(NULL,'a'),(NULL,'/'),(NULL,'a'),
-(NULL,'3'),(NULL,'m'),(NULL,'a'),(NULL,'a'),(NULL,'*'),(NULL,'a'),
-(NULL,'4'),(NULL,'n'),(NULL,'a'),(NULL,'a'),(NULL,'+'),(NULL,'a'),
-(NULL,'5'),(NULL,'o'),(NULL,'a'),(NULL,'a'),(NULL,'?'),(NULL,'a');
-INSERT INTO t1 VALUES
-(NULL,'1'),(NULL,'a'),(NULL,'a'),(NULL,'a'),(NULL,'p'),(NULL,'a'),
-(NULL,'2'),(NULL,'b'),(NULL,'a'),(NULL,'a'),(NULL,'q'),(NULL,'a'),
-(NULL,'3'),(NULL,'c'),(NULL,'a'),(NULL,'a'),(NULL,'r'),(NULL,'a'),
-(NULL,'4'),(NULL,'d'),(NULL,'a'),(NULL,'a'),(NULL,'s'),(NULL,'a'),
-(NULL,'5'),(NULL,'e'),(NULL,'a'),(NULL,'a'),(NULL,'t'),(NULL,'a'),
-(NULL,'6'),(NULL,'f'),(NULL,'a'),(NULL,'a'),(NULL,'u'),(NULL,'a'),
-(NULL,'7'),(NULL,'g'),(NULL,'a'),(NULL,'a'),(NULL,'v'),(NULL,'a'),
-(NULL,'8'),(NULL,'h'),(NULL,'a'),(NULL,'a'),(NULL,'w'),(NULL,'a'),
-(NULL,'9'),(NULL,'i'),(NULL,'a'),(NULL,'a'),(NULL,'x'),(NULL,'a'),
-(NULL,'0'),(NULL,'j'),(NULL,'a'),(NULL,'a'),(NULL,'y'),(NULL,'a'),
-(NULL,'1'),(NULL,'k'),(NULL,'a'),(NULL,'a'),(NULL,'z'),(NULL,'a'),
-(NULL,'2'),(NULL,'l'),(NULL,'a'),(NULL,'a'),(NULL,'/'),(NULL,'a'),
-(NULL,'3'),(NULL,'m'),(NULL,'a'),(NULL,'a'),(NULL,'*'),(NULL,'a'),
-(NULL,'4'),(NULL,'n'),(NULL,'a'),(NULL,'a'),(NULL,'+'),(NULL,'a'),
-(NULL,'5'),(NULL,'o'),(NULL,'a'),(NULL,'a'),(NULL,'?'),(NULL,'a');
-INSERT INTO t1 VALUES
-(NULL,'1'),(NULL,'a'),(NULL,'a'),(NULL,'a'),(NULL,'p'),(NULL,'a'),
-(NULL,'2'),(NULL,'b'),(NULL,'a'),(NULL,'a'),(NULL,'q'),(NULL,'a'),
-(NULL,'3'),(NULL,'c'),(NULL,'a'),(NULL,'a'),(NULL,'r'),(NULL,'a'),
-(NULL,'4'),(NULL,'d'),(NULL,'a'),(NULL,'a'),(NULL,'s'),(NULL,'a'),
-(NULL,'5'),(NULL,'e'),(NULL,'a'),(NULL,'a'),(NULL,'t'),(NULL,'a'),
-(NULL,'6'),(NULL,'f'),(NULL,'a'),(NULL,'a'),(NULL,'u'),(NULL,'a'),
-(NULL,'7'),(NULL,'g'),(NULL,'a'),(NULL,'a'),(NULL,'v'),(NULL,'a'),
-(NULL,'8'),(NULL,'h'),(NULL,'a'),(NULL,'a'),(NULL,'w'),(NULL,'a'),
-(NULL,'9'),(NULL,'i'),(NULL,'a'),(NULL,'a'),(NULL,'x'),(NULL,'a'),
-(NULL,'0'),(NULL,'j'),(NULL,'a'),(NULL,'a'),(NULL,'y'),(NULL,'a'),
-(NULL,'1'),(NULL,'k'),(NULL,'a'),(NULL,'a'),(NULL,'z'),(NULL,'a'),
-(NULL,'2'),(NULL,'l'),(NULL,'a'),(NULL,'a'),(NULL,'/'),(NULL,'a'),
-(NULL,'3'),(NULL,'m'),(NULL,'a'),(NULL,'a'),(NULL,'*'),(NULL,'a'),
-(NULL,'4'),(NULL,'n'),(NULL,'a'),(NULL,'a'),(NULL,'+'),(NULL,'a'),
-(NULL,'5'),(NULL,'o'),(NULL,'a'),(NULL,'a'),(NULL,'?'),(NULL,'a');
-select count(*) from t1;
-ALTER TABLE t1 ADD COLUMN x INT UNSIGNED NOT NULL;
-ALTER TABLE t1 ADD KEY c (c);
-ALTER TABLE t1 DROP KEY c;
-ALTER TABLE t1 DROP COLUMN x;
-ALTER TABLE t1 RENAME t2;
-select count(*) from t2;
-DROP TABLE t2;
-
-/* variable rows */
-CREATE TABLE t1 (
-id int unsigned not null auto_increment primary key,
-c varchar(255) not null
-) RAID_TYPE=STRIPED RAID_CHUNKS=5 RAID_CHUNKSIZE=121;
-INSERT INTO t1 VALUES
-(NULL,'1'),(NULL,'a'),(NULL,'a'),(NULL,'a'),(NULL,'p'),(NULL,'a'),
-(NULL,'2'),(NULL,'b'),(NULL,'a'),(NULL,'a'),(NULL,'q'),(NULL,'a'),
-(NULL,'3'),(NULL,'c'),(NULL,'a'),(NULL,'a'),(NULL,'r'),(NULL,'a'),
-(NULL,'4'),(NULL,'d'),(NULL,'a'),(NULL,'a'),(NULL,'s'),(NULL,'a'),
-(NULL,'5'),(NULL,'e'),(NULL,'a'),(NULL,'a'),(NULL,'t'),(NULL,'a'),
-(NULL,'6'),(NULL,'f'),(NULL,'a'),(NULL,'a'),(NULL,'u'),(NULL,'a'),
-(NULL,'7'),(NULL,'g'),(NULL,'a'),(NULL,'a'),(NULL,'v'),(NULL,'a'),
-(NULL,'8'),(NULL,'h'),(NULL,'a'),(NULL,'a'),(NULL,'w'),(NULL,'a'),
-(NULL,'9'),(NULL,'i'),(NULL,'a'),(NULL,'a'),(NULL,'x'),(NULL,'a'),
-(NULL,'0'),(NULL,'j'),(NULL,'a'),(NULL,'a'),(NULL,'y'),(NULL,'a'),
-(NULL,'1'),(NULL,'k'),(NULL,'a'),(NULL,'a'),(NULL,'z'),(NULL,'a'),
-(NULL,'2'),(NULL,'l'),(NULL,'a'),(NULL,'a'),(NULL,'/'),(NULL,'a'),
-(NULL,'3'),(NULL,'m'),(NULL,'a'),(NULL,'a'),(NULL,'*'),(NULL,'a'),
-(NULL,'4'),(NULL,'n'),(NULL,'a'),(NULL,'a'),(NULL,'+'),(NULL,'a'),
-(NULL,'5'),(NULL,'o'),(NULL,'a'),(NULL,'a'),(NULL,'?'),(NULL,'a');
-INSERT INTO t1 VALUES
-(NULL,'1'),(NULL,'a'),(NULL,'a'),(NULL,'a'),(NULL,'p'),(NULL,'a'),
-(NULL,'2'),(NULL,'b'),(NULL,'a'),(NULL,'a'),(NULL,'q'),(NULL,'a'),
-(NULL,'3'),(NULL,'c'),(NULL,'a'),(NULL,'a'),(NULL,'r'),(NULL,'a'),
-(NULL,'4'),(NULL,'d'),(NULL,'a'),(NULL,'a'),(NULL,'s'),(NULL,'a'),
-(NULL,'5'),(NULL,'e'),(NULL,'a'),(NULL,'a'),(NULL,'t'),(NULL,'a'),
-(NULL,'6'),(NULL,'f'),(NULL,'a'),(NULL,'a'),(NULL,'u'),(NULL,'a'),
-(NULL,'7'),(NULL,'g'),(NULL,'a'),(NULL,'a'),(NULL,'v'),(NULL,'a'),
-(NULL,'8'),(NULL,'h'),(NULL,'a'),(NULL,'a'),(NULL,'w'),(NULL,'a'),
-(NULL,'9'),(NULL,'i'),(NULL,'a'),(NULL,'a'),(NULL,'x'),(NULL,'a'),
-(NULL,'0'),(NULL,'j'),(NULL,'a'),(NULL,'a'),(NULL,'y'),(NULL,'a'),
-(NULL,'1'),(NULL,'k'),(NULL,'a'),(NULL,'a'),(NULL,'z'),(NULL,'a'),
-(NULL,'2'),(NULL,'l'),(NULL,'a'),(NULL,'a'),(NULL,'/'),(NULL,'a'),
-(NULL,'3'),(NULL,'m'),(NULL,'a'),(NULL,'a'),(NULL,'*'),(NULL,'a'),
-(NULL,'4'),(NULL,'n'),(NULL,'a'),(NULL,'a'),(NULL,'+'),(NULL,'a'),
-(NULL,'5'),(NULL,'o'),(NULL,'a'),(NULL,'a'),(NULL,'?'),(NULL,'a');
-INSERT INTO t1 VALUES
-(NULL,'1'),(NULL,'a'),(NULL,'a'),(NULL,'a'),(NULL,'p'),(NULL,'a'),
-(NULL,'2'),(NULL,'b'),(NULL,'a'),(NULL,'a'),(NULL,'q'),(NULL,'a'),
-(NULL,'3'),(NULL,'c'),(NULL,'a'),(NULL,'a'),(NULL,'r'),(NULL,'a'),
-(NULL,'4'),(NULL,'d'),(NULL,'a'),(NULL,'a'),(NULL,'s'),(NULL,'a'),
-(NULL,'5'),(NULL,'e'),(NULL,'a'),(NULL,'a'),(NULL,'t'),(NULL,'a'),
-(NULL,'6'),(NULL,'f'),(NULL,'a'),(NULL,'a'),(NULL,'u'),(NULL,'a'),
-(NULL,'7'),(NULL,'g'),(NULL,'a'),(NULL,'a'),(NULL,'v'),(NULL,'a'),
-(NULL,'8'),(NULL,'h'),(NULL,'a'),(NULL,'a'),(NULL,'w'),(NULL,'a'),
-(NULL,'9'),(NULL,'i'),(NULL,'a'),(NULL,'a'),(NULL,'x'),(NULL,'a'),
-(NULL,'0'),(NULL,'j'),(NULL,'a'),(NULL,'a'),(NULL,'y'),(NULL,'a'),
-(NULL,'1'),(NULL,'k'),(NULL,'a'),(NULL,'a'),(NULL,'z'),(NULL,'a'),
-(NULL,'2'),(NULL,'l'),(NULL,'a'),(NULL,'a'),(NULL,'/'),(NULL,'a'),
-(NULL,'3'),(NULL,'m'),(NULL,'a'),(NULL,'a'),(NULL,'*'),(NULL,'a'),
-(NULL,'4'),(NULL,'n'),(NULL,'a'),(NULL,'a'),(NULL,'+'),(NULL,'a'),
-(NULL,'5'),(NULL,'o'),(NULL,'a'),(NULL,'a'),(NULL,'?'),(NULL,'a');
-INSERT INTO t1 VALUES
-(NULL,'1'),(NULL,'a'),(NULL,'a'),(NULL,'a'),(NULL,'p'),(NULL,'a'),
-(NULL,'2'),(NULL,'b'),(NULL,'a'),(NULL,'a'),(NULL,'q'),(NULL,'a'),
-(NULL,'3'),(NULL,'c'),(NULL,'a'),(NULL,'a'),(NULL,'r'),(NULL,'a'),
-(NULL,'4'),(NULL,'d'),(NULL,'a'),(NULL,'a'),(NULL,'s'),(NULL,'a'),
-(NULL,'5'),(NULL,'e'),(NULL,'a'),(NULL,'a'),(NULL,'t'),(NULL,'a'),
-(NULL,'6'),(NULL,'f'),(NULL,'a'),(NULL,'a'),(NULL,'u'),(NULL,'a'),
-(NULL,'7'),(NULL,'g'),(NULL,'a'),(NULL,'a'),(NULL,'v'),(NULL,'a'),
-(NULL,'8'),(NULL,'h'),(NULL,'a'),(NULL,'a'),(NULL,'w'),(NULL,'a'),
-(NULL,'9'),(NULL,'i'),(NULL,'a'),(NULL,'a'),(NULL,'x'),(NULL,'a'),
-(NULL,'0'),(NULL,'j'),(NULL,'a'),(NULL,'a'),(NULL,'y'),(NULL,'a'),
-(NULL,'1'),(NULL,'k'),(NULL,'a'),(NULL,'a'),(NULL,'z'),(NULL,'a'),
-(NULL,'2'),(NULL,'l'),(NULL,'a'),(NULL,'a'),(NULL,'/'),(NULL,'a'),
-(NULL,'3'),(NULL,'m'),(NULL,'a'),(NULL,'a'),(NULL,'*'),(NULL,'a'),
-(NULL,'4'),(NULL,'n'),(NULL,'a'),(NULL,'a'),(NULL,'+'),(NULL,'a'),
-(NULL,'5'),(NULL,'o'),(NULL,'a'),(NULL,'a'),(NULL,'?'),(NULL,'a');
-INSERT INTO t1 VALUES
-(NULL,'1'),(NULL,'a'),(NULL,'a'),(NULL,'a'),(NULL,'p'),(NULL,'a'),
-(NULL,'2'),(NULL,'b'),(NULL,'a'),(NULL,'a'),(NULL,'q'),(NULL,'a'),
-(NULL,'3'),(NULL,'c'),(NULL,'a'),(NULL,'a'),(NULL,'r'),(NULL,'a'),
-(NULL,'4'),(NULL,'d'),(NULL,'a'),(NULL,'a'),(NULL,'s'),(NULL,'a'),
-(NULL,'5'),(NULL,'e'),(NULL,'a'),(NULL,'a'),(NULL,'t'),(NULL,'a'),
-(NULL,'6'),(NULL,'f'),(NULL,'a'),(NULL,'a'),(NULL,'u'),(NULL,'a'),
-(NULL,'7'),(NULL,'g'),(NULL,'a'),(NULL,'a'),(NULL,'v'),(NULL,'a'),
-(NULL,'8'),(NULL,'h'),(NULL,'a'),(NULL,'a'),(NULL,'w'),(NULL,'a'),
-(NULL,'9'),(NULL,'i'),(NULL,'a'),(NULL,'a'),(NULL,'x'),(NULL,'a'),
-(NULL,'0'),(NULL,'j'),(NULL,'a'),(NULL,'a'),(NULL,'y'),(NULL,'a'),
-(NULL,'1'),(NULL,'k'),(NULL,'a'),(NULL,'a'),(NULL,'z'),(NULL,'a'),
-(NULL,'2'),(NULL,'l'),(NULL,'a'),(NULL,'a'),(NULL,'/'),(NULL,'a'),
-(NULL,'3'),(NULL,'m'),(NULL,'a'),(NULL,'a'),(NULL,'*'),(NULL,'a'),
-(NULL,'4'),(NULL,'n'),(NULL,'a'),(NULL,'a'),(NULL,'+'),(NULL,'a'),
-(NULL,'5'),(NULL,'o'),(NULL,'a'),(NULL,'a'),(NULL,'?'),(NULL,'a');
-select count(*) from t1;
-ALTER TABLE t1 ADD COLUMN x INT UNSIGNED NOT NULL;
-ALTER TABLE t1 ADD KEY c (c);
-ALTER TABLE t1 DROP KEY c;
-ALTER TABLE t1 DROP COLUMN x;
-ALTER TABLE t1 RENAME t2;
-ALTER TABLE t2 CHANGE COLUMN c c VARCHAR(251) NOT NULL;
-select count(*) from t2;
-DROP TABLE t2;
-
-# End of 4.1 tests
diff --git a/mysql-test/t/renamedb.test b/mysql-test/t/renamedb.test
new file mode 100644
index 00000000000..5cfb2ce0c12
--- /dev/null
+++ b/mysql-test/t/renamedb.test
@@ -0,0 +1,18 @@
+--disable_warnings
+drop database if exists testdb1;
+--enable_warnings
+
+create database testdb1 default character set latin2;
+use testdb1;
+create table t1 (a int);
+insert into t1 values (1),(2),(3);
+show create database testdb1;
+show tables;
+rename database testdb1 to testdb2;
+--error 1049
+show create database testdb1;
+show create database testdb2;
+select database();
+show tables;
+select a from t1 order by a;
+drop database testdb2;
diff --git a/mysql-test/t/rpl000001.test b/mysql-test/t/rpl000001.test
deleted file mode 100644
index 5b4b29addc4..00000000000
--- a/mysql-test/t/rpl000001.test
+++ /dev/null
@@ -1,131 +0,0 @@
-source include/master-slave.inc;
-
-create table t1 (word char(20) not null);
-load data infile '../std_data_ln/words.dat' into table t1;
---replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
-eval load data local infile '$MYSQL_TEST_DIR/std_data/words.dat' into table t1;
-select * from t1 limit 10;
-
-#
-# Test slave with wrong password
-#
-save_master_pos;
-connection slave;
-sync_with_master;
-stop slave;
-connection master;
-set password for root@"localhost" = password('foo');
-connection slave;
-start slave;
-connection master;
-#
-# Give slave time to do at last one failed connect retry
-# This one must be short so that the slave will not stop retrying
-real_sleep 2;
-set password for root@"localhost" = password('');
-# Give slave time to connect (will retry every second)
-sleep 2;
-
-create table t3(n int);
-insert into t3 values(1),(2);
-save_master_pos;
-connection slave;
-sync_with_master;
-select * from t3;
-select sum(length(word)) from t1;
-connection master;
-drop table t1,t3;
-save_master_pos;
-connection slave;
-sync_with_master;
-
-# Test if the slave SQL thread can be more than 16K behind the slave
-# I/O thread (> IO_SIZE)
-
-connection master;
-# we'll use table-level locking to delay slave SQL thread
-create table t1 (n int) engine=myisam;
-sync_slave_with_master;
-connection master;
-reset master;
-connection slave;
-stop slave;
-reset slave;
-
-connection master;
-let $1=5000;
-# Generate 16K of relay log
-disable_query_log;
-while ($1)
-{
- eval insert into t1 values($1);
- dec $1;
-}
-enable_query_log;
-
-# Try to cause a large relay log lag on the slave by locking t1
-connection slave;
-lock tables t1 read;
-start slave;
-#hope this is long enough for I/O thread to fetch over 16K relay log data
-sleep 3;
-unlock tables;
-
-#test handling of aborted connection in the middle of update
-
-connection master;
-create table t2(id int);
-insert into t2 values(connection_id());
-save_master_pos;
-
-connection master1;
-# Avoid generating result
-create temporary table t3(n int);
-insert into t3 select get_lock('crash_lock%20C', 1) from t2;
-
-connection master;
-send update t1 set n = n + get_lock('crash_lock%20C', 2);
-connection master1;
-sleep 3;
-select (@id := id) - id from t2;
-kill @id;
-# We don't drop t3 as this is a temporary table
-drop table t2;
-connection master;
---error 1053,2013
-reap;
-connection slave;
-# The SQL slave thread should now have stopped because the query was killed on
-# the master (so it has a non-zero error code in the binlog).
-wait_for_slave_to_stop;
-
-# The following test can't be done because the result of Pos will differ
-# on different computers
-# --replace_result $MASTER_MYPORT MASTER_PORT
-# show slave status;
-
-set global sql_slave_skip_counter=1;
-start slave;
-select count(*) from t1;
-connection master1;
-drop table t1;
-create table t1 (n int);
-insert into t1 values(3456);
-insert into mysql.user (Host, User, Password)
- VALUES ("10.10.10.%", "blafasel2", password("blafasel2"));
-select select_priv,user from mysql.user where user = _binary'blafasel2';
-update mysql.user set Select_priv = "Y" where User= _binary"blafasel2";
-select select_priv,user from mysql.user where user = _binary'blafasel2';
-save_master_pos;
-connection slave;
-sync_with_master;
-select n from t1;
-select select_priv,user from mysql.user where user = _binary'blafasel2';
-connection master1;
-drop table t1;
-delete from mysql.user where user="blafasel2";
-save_master_pos;
-connection slave;
-sync_with_master;
-
-# End of 4.1 tests
diff --git a/mysql-test/t/rpl000004.test b/mysql-test/t/rpl000004.test
deleted file mode 100644
index 9c8c535c67d..00000000000
--- a/mysql-test/t/rpl000004.test
+++ /dev/null
@@ -1,25 +0,0 @@
-source include/master-slave.inc;
-
-set SQL_LOG_BIN=0;
-create table t1 (word char(20) not null, index(word));
-load data infile '../std_data_ln/words.dat' into table t1;
-create table t2 (word char(20) not null);
-load data infile '../std_data_ln/words.dat' into table t2;
-create table t3 (word char(20) not null primary key);
-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/t/rpl000005.test b/mysql-test/t/rpl000005.test
deleted file mode 100644
index e81ad739402..00000000000
--- a/mysql-test/t/rpl000005.test
+++ /dev/null
@@ -1,24 +0,0 @@
-source include/master-slave.inc;
-
-#
-# Bug#7100 relay_log_space_max missing from SHOW VARIABLES
-#
-SHOW VARIABLES LIKE 'relay_log_space_limit';
-
-CREATE TABLE t1 (name varchar(64), age smallint(3));
-INSERT INTO t1 SET name='Andy', age=31;
-INSERT t1 SET name='Jacob', age=2;
-INSERT into t1 SET name='Caleb', age=1;
-ALTER TABLE t1 ADD id int(8) ZEROFILL AUTO_INCREMENT PRIMARY KEY;
-select * from t1;
-save_master_pos;
-connection 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/t/rpl000006.test b/mysql-test/t/rpl000006.test
deleted file mode 100644
index 334ed575835..00000000000
--- a/mysql-test/t/rpl000006.test
+++ /dev/null
@@ -1,47 +0,0 @@
-#
-# Test forced timestamp
-#
-source include/master-slave.inc;
-
-# Don't log table creating to the slave as we want to test LOAD TABLE
-set SQL_LOG_BIN=0,timestamp=200006;
-create table t1(t timestamp not null,a char(1));
-insert into t1 ( a) values ('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;
-
-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;
-
-# End of 4.1 tests
diff --git a/mysql-test/t/rpl000013-slave.opt b/mysql-test/t/rpl000013-slave.opt
deleted file mode 100644
index 2662c695b41..00000000000
--- a/mysql-test/t/rpl000013-slave.opt
+++ /dev/null
@@ -1 +0,0 @@
---abort-slave-event-count=1
diff --git a/mysql-test/t/rpl000013.test b/mysql-test/t/rpl000013.test
index eca4803c6bc..c681e76cf51 100644
--- a/mysql-test/t/rpl000013.test
+++ b/mysql-test/t/rpl000013.test
@@ -1,3 +1,13 @@
+# 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_statement.inc
source include/master-slave.inc;
save_master_pos;
connection slave;
diff --git a/mysql-test/t/rpl000017.test b/mysql-test/t/rpl000017.test
index 866b7fd1c25..2ba321cd8c3 100644
--- a/mysql-test/t/rpl000017.test
+++ b/mysql-test/t/rpl000017.test
@@ -1,7 +1,7 @@
-connect (master,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK);
-connect (slave,localhost,root,,test,$SLAVE_MYPORT,slave.sock);
+source include/master-slave.inc;
+connection slave;
+stop slave;
connection master;
-reset 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;
diff --git a/mysql-test/t/rpl000015-slave.sh b/mysql-test/t/rpl_000015-slave.sh
index 7deeca3d2d6..7deeca3d2d6 100755
--- a/mysql-test/t/rpl000015-slave.sh
+++ b/mysql-test/t/rpl_000015-slave.sh
diff --git a/mysql-test/t/rpl000015.slave-mi b/mysql-test/t/rpl_000015.slave-mi
index 28bc753dd56..28bc753dd56 100644
--- a/mysql-test/t/rpl000015.slave-mi
+++ b/mysql-test/t/rpl_000015.slave-mi
diff --git a/mysql-test/t/rpl000015.test b/mysql-test/t/rpl_000015.test
index df4bf6f977b..cf93beb2bfe 100644
--- a/mysql-test/t/rpl000015.test
+++ b/mysql-test/t/rpl_000015.test
@@ -1,3 +1,9 @@
+#####################
+# 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.sock);
connection master;
@@ -30,12 +36,12 @@ connection master;
--disable_warnings
drop table if exists t1;
--enable_warnings
-create table t1 (n int);
+create table t1 (n int, PRIMARY KEY(n));
insert into t1 values (10),(45),(90);
sync_slave_with_master;
-select * from t1;
+connection slave;
+SELECT * FROM t1 ORDER BY n;
connection master;
+SELECT * FROM t1 ORDER BY n;
drop table t1;
sync_slave_with_master;
-
-# End of 4.1 tests
diff --git a/mysql-test/t/rpl_EE_err.test b/mysql-test/t/rpl_EE_err.test
new file mode 100644
index 00000000000..6d064ae3197
--- /dev/null
+++ b/mysql-test/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/t/rpl_EE_error.test b/mysql-test/t/rpl_EE_error.test
deleted file mode 100644
index 640a2b1a88c..00000000000
--- a/mysql-test/t/rpl_EE_error.test
+++ /dev/null
@@ -1,32 +0,0 @@
-# See if an EE_ error in one event of the master's binlog stops replication
-# (it should not: in this configuration the EE_ error is probably not
-# critical). Example: you do a DROP TABLE on a table which has no MYI file
-# check if START SLAVE, RESET SLAVE, CHANGE MASTER reset Last_slave_error and
-# Last_slave_errno in SHOW SLAVE STATUS (1st and 3rd commands did not: bug 986).
-
-source include/master-slave.inc;
-
-create table t1 (a int) engine=myisam;
-flush tables;
-system rm $MYSQLTEST_VARDIR/master-data/test/t1.MYI ;
-drop table if exists t1;
-save_master_pos;
-connection slave;
-sync_with_master;
-
-# Now a real error.
-
-connection master;
-create table t1 (a int, unique(a)) engine=myisam;
-set sql_log_bin=0;
-insert into t1 values(2);
-set sql_log_bin=1;
-save_master_pos;
---error 1062
-insert into t1 values(1),(2);
-drop table t1;
-save_master_pos;
-connection slave;
-wait_for_slave_to_stop;
-
-# End of 4.1 tests
diff --git a/mysql-test/t/rpl_LD_INFILE.test b/mysql-test/t/rpl_LD_INFILE.test
new file mode 100644
index 00000000000..bace5d4c1f5
--- /dev/null
+++ b/mysql-test/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/t/rpl_alter_db.test b/mysql-test/t/rpl_alter_db.test
new file mode 100644
index 00000000000..5ac8a2f4018
--- /dev/null
+++ b/mysql-test/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/t/rpl000001-slave.opt b/mysql-test/t/rpl_auto_increment-slave.opt
index 627becdbfb5..627becdbfb5 100644
--- a/mysql-test/t/rpl000001-slave.opt
+++ b/mysql-test/t/rpl_auto_increment-slave.opt
diff --git a/mysql-test/t/rpl_auto_increment.test b/mysql-test/t/rpl_auto_increment.test
index 71032404307..19770ffbdc0 100644
--- a/mysql-test/t/rpl_auto_increment.test
+++ b/mysql-test/t/rpl_auto_increment.test
@@ -1,104 +1,12 @@
-#
-# Test of auto_increment with offset
-#
-source include/have_innodb.inc;
-source include/master-slave.inc;
-
-create table t1 (a int not null auto_increment,b int, primary key (a)) engine=myisam auto_increment=3;
-insert into t1 values (NULL,1),(NULL,2),(NULL,3);
-select * from t1;
-
-sync_slave_with_master;
-select * from t1;
-connection master;
-drop table t1;
-
-create table t1 (a int not null auto_increment,b int, primary key (a)) engine=myisam;
-insert into t1 values (1,1),(NULL,2),(3,3),(NULL,4);
-delete from t1 where b=4;
-insert into t1 values (NULL,5),(NULL,6);
-select * from t1;
-
-sync_slave_with_master;
-select * from t1;
-connection master;
-
-drop table t1;
-
-set @@session.auto_increment_increment=100, @@session.auto_increment_offset=10;
-show variables like "%auto_inc%";
-
-create table t1 (a int not null auto_increment, primary key (a)) engine=myisam;
-# Insert with 2 insert statements to get better testing of logging
-insert into t1 values (NULL),(5),(NULL);
-insert into t1 values (250),(NULL);
-select * from t1;
-insert into t1 values (1000);
-set @@insert_id=400;
-insert into t1 values(NULL),(NULL);
-select * from t1;
-
-sync_slave_with_master;
-select * from t1;
-connection master;
-drop table t1;
-
-#
-# Same test with innodb (as the innodb code is a bit different)
-#
-create table t1 (a int not null auto_increment, primary key (a)) engine=innodb;
-# Insert with 2 insert statements to get better testing of logging
-insert into t1 values (NULL),(5),(NULL);
-insert into t1 values (250),(NULL);
-select * from t1;
-insert into t1 values (1000);
-set @@insert_id=400;
-insert into t1 values(NULL),(NULL);
-select * from t1;
-
-sync_slave_with_master;
-select * from t1;
-connection master;
-drop table t1;
-
-set @@session.auto_increment_increment=1, @@session.auto_increment_offset=1;
-create table t1 (a int not null auto_increment, primary key (a)) engine=myisam;
-# Insert with 2 insert statements to get better testing of logging
-insert into t1 values (NULL),(5),(NULL),(NULL);
-insert into t1 values (500),(NULL),(502),(NULL),(NULL);
-select * from t1;
-set @@insert_id=600;
---error 1062
-insert into t1 values(600),(NULL),(NULL);
-set @@insert_id=600;
-insert ignore into t1 values(600),(NULL),(NULL),(610),(NULL);
-select * from t1;
-
-sync_slave_with_master;
-select * from t1;
-connection master;
-drop table t1;
-
-#
-# Test that auto-increment works when slave has rows in the table
-#
-set @@session.auto_increment_increment=10, @@session.auto_increment_offset=1;
-
-create table t1 (a int not null auto_increment, primary key (a)) engine=myisam;
-
-sync_slave_with_master;
-insert into t1 values(2),(12),(22),(32),(42);
-connection master;
-
-insert into t1 values (NULL),(NULL);
-insert into t1 values (3),(NULL),(NULL);
-select * from t1;
-
-sync_slave_with_master;
-select * from t1;
-connection master;
-
-drop table t1;
-
-# End cleanup
-sync_slave_with_master;
+#####################################
+# 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/t/rpl_bit.test b/mysql-test/t/rpl_bit.test
new file mode 100644
index 00000000000..07b0778296c
--- /dev/null
+++ b/mysql-test/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/t/rpl_bit_npk.test b/mysql-test/t/rpl_bit_npk.test
new file mode 100644
index 00000000000..12b587919f9
--- /dev/null
+++ b/mysql-test/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/t/rpl_change_master.test b/mysql-test/t/rpl_change_master.test
index 6c055a81ceb..c031464c95e 100644
--- a/mysql-test/t/rpl_change_master.test
+++ b/mysql-test/t/rpl_change_master.test
@@ -19,11 +19,11 @@ connection slave;
--real_sleep 3 # wait for I/O thread to have read updates
stop slave;
--replace_result $MASTER_MYPORT MASTER_MYPORT
---replace_column 1 # 8 # 9 # 23 # 33 #
+--replace_column 1 # 7 # 8 # 9 # 23 # 33 #
show slave status;
change master to master_user='root';
--replace_result $MASTER_MYPORT MASTER_MYPORT
---replace_column 1 # 8 # 9 # 23 # 33 #
+--replace_column 1 # 7 # 8 # 9 # 23 # 33 #
show slave status;
start slave;
sync_with_master;
diff --git a/mysql-test/t/rpl_charset.test b/mysql-test/t/rpl_charset.test
deleted file mode 100644
index e916ae9ad6c..00000000000
--- a/mysql-test/t/rpl_charset.test
+++ /dev/null
@@ -1,173 +0,0 @@
-# Replication of character sets.
-# This test will fail if the server/client does not support enough charsets.
-
-source include/master-slave.inc;
---disable_warnings
-set timestamp=1000000000;
-drop database if exists mysqltest2;
-drop database if exists mysqltest3;
---enable_warnings
-
-create database mysqltest2 character set latin2;
-set @@character_set_server=latin5;
-create database mysqltest3;
---disable_query_log
-select "--- --master--" as "";
---enable_query_log
-show create database mysqltest2;
-show create database mysqltest3;
-sync_slave_with_master;
---disable_query_log
-select "--- --slave--" as "";
---enable_query_log
-show create database mysqltest2;
-show create database mysqltest3;
-
-connection master;
-set @@collation_server=armscii8_bin;
-drop database mysqltest3;
-create database mysqltest3;
---disable_query_log
-select "--- --master--" as "";
---enable_query_log
-show create database mysqltest3;
-sync_slave_with_master;
---disable_query_log
-select "--- --slave--" as "";
---enable_query_log
-show create database mysqltest3;
-
-connection master;
-use mysqltest2;
-create table t1 (a int auto_increment primary key, b varchar(100));
-set character_set_client=cp850, collation_connection=latin2_croatian_ci;
-insert into t1 (b) values(@@character_set_server);
-insert into t1 (b) values(@@collation_server);
-# character_set_database and collation_database are not tested as they
-# needn't be replicated (Bar said in Jan 2005).
-insert into t1 (b) values(@@character_set_client);
-# collation_client does not exist
-insert into t1 (b) values(@@character_set_connection);
-insert into t1 (b) values(@@collation_connection);
---disable_query_log
-select "--- --master--" as "";
---enable_query_log
-select * from t1 order by a;
-sync_slave_with_master;
---disable_query_log
-select "--- --slave--" as "";
---enable_query_log
-select * from mysqltest2.t1 order by a;
-
-connection master;
-set character_set_client=latin1, collation_connection=latin1_german1_ci;
-truncate table t1;
-insert into t1 (b) values(@@collation_connection);
-insert into t1 (b) values(LEAST("Mller","Muffler"));
-set collation_connection=latin1_german2_ci;
-insert into t1 (b) values(@@collation_connection);
-insert into t1 (b) values(LEAST("Mller","Muffler"));
---disable_query_log
-select "--- --master--" as "";
---enable_query_log
-select * from t1 order by a;
-sync_slave_with_master;
---disable_query_log
-select "--- --slave--" as "";
---enable_query_log
-select * from mysqltest2.t1 order by a;
-
-# Presently charset info is not logged with LOAD DATA but it will
-# change in Jan 2005 when Dmitri pushes his new LOAD DATA,
-# before 5.0.3 goes out. When done, LOAD DATA INFILE should be tested
-# here.
-
-# See if user var is prefixed with collation in binlog and replicated well.
-# Note: replication of user variables is broken as far as derivation is
-# concerned. That's because when we store a user variable in the binlog,
-# we lose its derivation. So later on the slave, it's impossible to
-# know if the collation was explicit or not, so we use DERIVATION_NONE,
-# which provokes error messages (like 'Illegal mix of collation') when
-# we replay the master's INSERT/etc statements.
-connection master;
-set @a= _cp850 'Mller' collate cp850_general_ci;
-truncate table t1;
-insert into t1 (b) values(collation(@a));
---disable_query_log
-select "--- --master--" as "";
---enable_query_log
-select * from t1 order by a;
-sync_slave_with_master;
---disable_query_log
-select "--- --slave--" as "";
---enable_query_log
-select * from mysqltest2.t1 order by a;
-
-connection master;
-drop database mysqltest2;
-drop database mysqltest3;
---replace_column 2 # 5 #
-show binlog events from 98;
-sync_slave_with_master;
-
-# Check that we can change global.collation_server (since 5.0.3)
-
-set global character_set_server=latin2;
-set global character_set_server=latin1; # back
-connection master;
-set global character_set_server=latin2;
-set global character_set_server=latin1; # back
-
-# Check that SET ONE_SHOT is really one shot
-
-set one_shot @@character_set_server=latin5;
-set @@max_join_size=1000;
-select @@character_set_server;
-select @@character_set_server;
-set @@character_set_server=latin5;
-select @@character_set_server;
-select @@character_set_server;
-
-# ONE_SHOT on not charset/collation stuff is not allowed
--- error 1382
-set one_shot max_join_size=10;
-
-# Test of wrong character set numbers;
-error 1115;
-set character_set_client=9999999;
-error 1273;
-set collation_server=9999998;
-
-# This one was contributed by Sergey Petrunia (BUG#3943)
-
-use test;
-CREATE TABLE t1 (c1 VARBINARY(255), c2 VARBINARY(255));
-SET CHARACTER_SET_CLIENT=koi8r,
- CHARACTER_SET_CONNECTION=cp1251,
- CHARACTER_SET_RESULTS=koi8r;
-INSERT INTO t1 (c1, c2) VALUES (', ',', ');
-select hex(c1), hex(c2) from t1;
-sync_slave_with_master;
-select hex(c1), hex(c2) from t1;
-
-connection master;
-# Let's have a look at generated SETs.
---replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
---exec $MYSQL_BINLOG --short-form $MYSQLTEST_VARDIR/log/master-bin.000001
-drop table t1;
-sync_slave_with_master;
-
-#
-# BUG#6676: Derivation of variables must be correct on slave
-#
-connection master;
-create table `t1` (
- `pk` varchar(10) not null default '',
- primary key (`pk`)
-) engine=myisam default charset=latin1;
-set @p=_latin1 'test';
-update t1 set pk='test' where pk=@p;
-drop table t1;
-sync_slave_with_master;
-
-# End of 4.1 tests
diff --git a/mysql-test/t/rpl_commit_after_flush.test b/mysql-test/t/rpl_commit_after_flush.test
index 6129e5485a6..7a924ddb11e 100644
--- a/mysql-test/t/rpl_commit_after_flush.test
+++ b/mysql-test/t/rpl_commit_after_flush.test
@@ -1,19 +1,11 @@
-source include/master-slave.inc;
-source include/have_innodb.inc;
-create table t1 (a int) engine=innodb;
-begin;
-insert into t1 values(1);
-flush tables with read lock;
-commit;
-save_master_pos;
-connection slave;
-sync_with_master;
-# cleanup
-connection master;
-unlock tables;
-drop table t1;
-save_master_pos;
-connection slave;
-sync_with_master;
-
-# End of 4.1 tests
+#####################################
+# 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
+let $engine_type=innodb;
+-- source extra/rpl_tests/rpl_commit_after_flush.test
diff --git a/mysql-test/t/rpl_create_database.test b/mysql-test/t/rpl_create_database.test
index cfccc4567b5..70cff8daca2 100644
--- a/mysql-test/t/rpl_create_database.test
+++ b/mysql-test/t/rpl_create_database.test
@@ -55,14 +55,13 @@ CREATE DATABASE mysqltest_sisyfos;
USE mysqltest_sisyfos;
CREATE TABLE t2 (a INT);
let $VERSION=`select version()`;
---replace_result $VERSION VERSION
---replace_column 2 # 5 #
-SHOW BINLOG EVENTS;
SHOW DATABASES;
sync_slave_with_master;
SHOW DATABASES;
-SHOW CREATE TABLE mysqltest_prometheus.t1;
-SHOW CREATE TABLE mysqltest_sisyfos.t2;
+USE mysqltest_prometheus;
+SHOW TABLES;
+USE mysqltest_sisyfos;
+SHOW TABLES;
connection master;
DROP DATABASE IF EXISTS mysqltest_prometheus;
diff --git a/mysql-test/t/rpl_ddl.test b/mysql-test/t/rpl_ddl.test
index d2a41a305b6..ca1c25c5f09 100644
--- a/mysql-test/t/rpl_ddl.test
+++ b/mysql-test/t/rpl_ddl.test
@@ -24,487 +24,11 @@
#
# 3. The assignment of the DDL command to be tested to $my_stmt can
# be a bit difficult. "'" must be avoided, because the test
-# routine "include/rpl_stmt_seq.inc" performs a
+# routine "include/rpl_stmt_seq.inc" performs a
# eval SELECT CONCAT('######## ','$my_stmt',' ########') as "";
#
-
+--source include/not_ndb_default.inc
--source include/have_innodb.inc
--source include/master-slave.inc
-
-###############################################################
-# Some preparations
-###############################################################
-# The sync_slave_with_master is needed to make the xids deterministic.
-sync_slave_with_master;
-connection master;
-
-SET AUTOCOMMIT = 1;
-#
-# 1. DROP all objects, which probably already exist, but must be created here
-#
---disable_warnings
-DROP DATABASE IF EXISTS mysqltest1;
-DROP DATABASE IF EXISTS mysqltest2;
-DROP DATABASE IF EXISTS mysqltest3;
---enable_warnings
-#
-# 2. CREATE all objects needed
-# working database is mysqltest1
-# working (transactional!) is mysqltest1.t1
-#
-CREATE DATABASE mysqltest1;
-CREATE DATABASE mysqltest2;
-CREATE TABLE mysqltest1.t1 (f1 BIGINT) ENGINE= "InnoDB";
-INSERT INTO mysqltest1.t1 SET f1= 0;
-CREATE TABLE mysqltest1.t2 (f1 BIGINT) ENGINE= "InnoDB";
-CREATE TABLE mysqltest1.t3 (f1 BIGINT) ENGINE= "InnoDB";
-CREATE TABLE mysqltest1.t4 (f1 BIGINT) ENGINE= "InnoDB";
-CREATE TABLE mysqltest1.t5 (f1 BIGINT) ENGINE= "InnoDB";
-CREATE TABLE mysqltest1.t6 (f1 BIGINT) ENGINE= "InnoDB";
-CREATE INDEX my_idx6 ON mysqltest1.t6(f1);
-CREATE TABLE mysqltest1.t7 (f1 BIGINT) ENGINE= "InnoDB";
-INSERT INTO mysqltest1.t7 SET f1= 0;
-CREATE TABLE mysqltest1.t8 (f1 BIGINT) ENGINE= "InnoDB";
-CREATE TABLE mysqltest1.t9 (f1 BIGINT) ENGINE= "InnoDB";
-CREATE TABLE mysqltest1.t10 (f1 BIGINT) ENGINE= "InnoDB";
-CREATE TABLE mysqltest1.t11 (f1 BIGINT) ENGINE= "InnoDB";
-CREATE TABLE mysqltest1.t12 (f1 BIGINT) ENGINE= "InnoDB";
-CREATE TABLE mysqltest1.t13 (f1 BIGINT) ENGINE= "InnoDB";
-CREATE TABLE mysqltest1.t14 (f1 BIGINT) ENGINE= "InnoDB";
-CREATE TABLE mysqltest1.t15 (f1 BIGINT) ENGINE= "InnoDB";
-CREATE TABLE mysqltest1.t16 (f1 BIGINT) ENGINE= "InnoDB";
-CREATE TABLE mysqltest1.t17 (f1 BIGINT) ENGINE= "InnoDB";
-CREATE TABLE mysqltest1.t18 (f1 BIGINT) ENGINE= "InnoDB";
-CREATE TABLE mysqltest1.t19 (f1 BIGINT) ENGINE= "InnoDB";
-CREATE TEMPORARY TABLE mysqltest1.t23 (f1 BIGINT);
-
-#
-# 3. master sessions: never do AUTOCOMMIT
-# slave sessions: never do AUTOCOMMIT
-#
-SET AUTOCOMMIT = 0;
-use mysqltest1;
-sync_slave_with_master;
-connection slave;
---disable_query_log
-SELECT '-------- switch to slave --------' as "";
---enable_query_log
-SET AUTOCOMMIT = 0;
-use mysqltest1;
-connection master;
---disable_query_log
-SELECT '-------- switch to master -------' as "";
---enable_query_log
-
-
-# We don't want to abort the whole test if one statement sent
-# to the server gets an error, because the following test
-# sequences are nearly independend of the previous statements.
---disable_abort_on_error
-
-###############################################################
-# Banal case: (explicit) COMMIT and ROLLBACK
-# Just for checking if the test sequence is usable
-###############################################################
-
-let $my_stmt= COMMIT;
-let $my_master_commit= true;
-let $my_slave_commit= true;
---source include/rpl_stmt_seq.inc
-
-let $my_stmt= ROLLBACK;
-let $my_master_commit= false;
-let $my_slave_commit= false;
---source include/rpl_stmt_seq.inc
-
-###############################################################
-# Cases with commands very similar to COMMIT
-###############################################################
-
-let $my_stmt= SET AUTOCOMMIT=1;
-let $my_master_commit= true;
-let $my_slave_commit= true;
---source include/rpl_stmt_seq.inc
-SET AUTOCOMMIT=0;
-
-let $my_stmt= START TRANSACTION;
-let $my_master_commit= true;
-let $my_slave_commit= true;
---source include/rpl_stmt_seq.inc
-
-let $my_stmt= BEGIN;
-let $my_master_commit= true;
-let $my_slave_commit= true;
---source include/rpl_stmt_seq.inc
-
-###############################################################
-# Cases with (BASE) TABLES and (UPDATABLE) VIEWs
-###############################################################
-
-let $my_stmt= DROP TABLE mysqltest1.t2;
-let $my_master_commit= true;
-let $my_slave_commit= true;
---source include/rpl_stmt_seq.inc
-SHOW TABLES LIKE 't2';
-connection slave;
---disable_query_log
-SELECT '-------- switch to slave --------' as "";
---enable_query_log
-SHOW TABLES LIKE 't2';
-connection master;
---disable_query_log
-SELECT '-------- switch to master -------' as "";
---enable_query_log
-
-# Note: Since this test is executed with a skip-innodb slave, the
-# slave incorrectly commits the insert. One can *not* have InnoDB on
-# master and MyISAM on slave and expect that a transactional rollback
-# after a CREATE TEMPORARY TABLE should work correctly on the slave.
-# For this to work properly the handler on the slave must be able to
-# handle transactions (e.g. InnoDB or NDB).
-let $my_stmt= DROP TEMPORARY TABLE mysqltest1.t23;
-let $my_master_commit= false;
-let $my_slave_commit= true;
---source include/rpl_stmt_seq.inc
-SHOW TABLES LIKE 't23';
-connection slave;
---disable_query_log
-SELECT '-------- switch to slave --------' as "";
---enable_query_log
-SHOW TABLES LIKE 't23';
-connection master;
---disable_query_log
-SELECT '-------- switch to master -------' as "";
---enable_query_log
-
-let $my_stmt= RENAME TABLE mysqltest1.t3 to mysqltest1.t20;
-let $my_master_commit= true;
-let $my_slave_commit= true;
---source include/rpl_stmt_seq.inc
-SHOW TABLES LIKE 't20';
-connection slave;
---disable_query_log
-SELECT '-------- switch to slave --------' as "";
---enable_query_log
-SHOW TABLES LIKE 't20';
-connection master;
---disable_query_log
-SELECT '-------- switch to master -------' as "";
---enable_query_log
-
-let $my_stmt= ALTER TABLE mysqltest1.t4 ADD column f2 BIGINT;
-let $my_master_commit= true;
-let $my_slave_commit= true;
---source include/rpl_stmt_seq.inc
-describe mysqltest1.t4;
-connection slave;
---disable_query_log
-SELECT '-------- switch to slave --------' as "";
---enable_query_log
-describe mysqltest1.t4;
-connection master;
---disable_query_log
-SELECT '-------- switch to master -------' as "";
---enable_query_log
-
-let $my_stmt= CREATE TABLE mysqltest1.t21 (f1 BIGINT) ENGINE= "InnoDB";
-let $my_master_commit= true;
-let $my_slave_commit= true;
---source include/rpl_stmt_seq.inc
-
-# Note: Since this test is executed with a skip-innodb slave, the
-# slave incorrectly commits the insert. One can *not* have InnoDB on
-# master and MyISAM on slave and expect that a transactional rollback
-# after a CREATE TEMPORARY TABLE should work correctly on the slave.
-# For this to work properly the handler on the slave must be able to
-# handle transactions (e.g. InnoDB or NDB).
-let $my_stmt= CREATE TEMPORARY TABLE mysqltest1.t22 (f1 BIGINT);
-let $my_master_commit= false;
-let $my_slave_commit= true;
---source include/rpl_stmt_seq.inc
-
-let $my_stmt= TRUNCATE TABLE mysqltest1.t7;
-let $my_master_commit= true;
-let $my_slave_commit= true;
---source include/rpl_stmt_seq.inc
-SELECT * FROM mysqltest1.t7;
-connection slave;
---disable_query_log
-SELECT '-------- switch to slave --------' as "";
---enable_query_log
-SELECT * FROM mysqltest1.t7;
-connection master;
---disable_query_log
-SELECT '-------- switch to master -------' as "";
---enable_query_log
-
-###############################################################
-# Cases with LOCK/UNLOCK
-###############################################################
-
-# MySQL insists in locking mysqltest1.t1, because rpl_stmt_seq performs an
-# INSERT into this table.
-let $my_stmt= LOCK TABLES mysqltest1.t1 WRITE, mysqltest1.t8 READ;
-let $my_master_commit= true;
-let $my_slave_commit= true;
---source include/rpl_stmt_seq.inc
-UNLOCK TABLES;
-
-# No prior locking
-let $my_stmt= UNLOCK TABLES;
-let $my_master_commit= false;
-let $my_slave_commit= false;
---source include/rpl_stmt_seq.inc
-
-# With prior read locking
-# Note that this test generate an error since the rpl_stmt_seq.inc
-# tries to insert into t1.
-LOCK TABLES mysqltest1.t1 READ;
-let $my_stmt= UNLOCK TABLES;
-let $my_master_commit= false;
-let $my_slave_commit= false;
---source include/rpl_stmt_seq.inc
-
-# With prior write locking
-LOCK TABLES mysqltest1.t1 WRITE, mysqltest1.t8 READ;
-let $my_stmt= UNLOCK TABLES;
-let $my_master_commit= true;
-let $my_slave_commit= true;
---source include/rpl_stmt_seq.inc
-
-###############################################################
-# Cases with INDEXES
-###############################################################
-
-let $my_stmt= DROP INDEX my_idx6 ON mysqltest1.t6;
-let $my_master_commit= true;
-let $my_slave_commit= true;
---source include/rpl_stmt_seq.inc
-SHOW INDEX FROM mysqltest1.t6;
-connection slave;
---disable_query_log
-SELECT '-------- switch to slave --------' as "";
---enable_query_log
-SHOW INDEX FROM mysqltest1.t6;
-connection master;
---disable_query_log
-SELECT '-------- switch to master -------' as "";
---enable_query_log
-
-let $my_stmt= CREATE INDEX my_idx5 ON mysqltest1.t5(f1);
-let $my_master_commit= true;
-let $my_slave_commit= true;
---source include/rpl_stmt_seq.inc
-SHOW INDEX FROM mysqltest1.t5;
-connection slave;
---disable_query_log
-SELECT '-------- switch to slave --------' as "";
---enable_query_log
-SHOW INDEX FROM mysqltest1.t5;
-connection master;
---disable_query_log
-SELECT '-------- switch to master -------' as "";
---enable_query_log
-
-###############################################################
-# Cases with DATABASE
-###############################################################
-
-let $my_stmt= DROP DATABASE mysqltest2;
-let $my_master_commit= true;
-let $my_slave_commit= true;
---source include/rpl_stmt_seq.inc
-SHOW DATABASES LIKE "mysqltest2";
-connection slave;
---disable_query_log
-SELECT '-------- switch to slave --------' as "";
---enable_query_log
-SHOW DATABASES LIKE "mysqltest2";
-connection master;
---disable_query_log
-SELECT '-------- switch to master -------' as "";
---enable_query_log
-
-let $my_stmt= CREATE DATABASE mysqltest3;
-let $my_master_commit= true;
-let $my_slave_commit= true;
---source include/rpl_stmt_seq.inc
-SHOW DATABASES LIKE "mysqltest3";
-connection slave;
---disable_query_log
-SELECT '-------- switch to slave --------' as "";
---enable_query_log
-SHOW DATABASES LIKE "mysqltest3";
-connection master;
---disable_query_log
-SELECT '-------- switch to master -------' as "";
---enable_query_log
-
-# End of 4.1 tests
-
-###############################################################
-# Cases with stored procedures
-###############################################################
-let $my_stmt= CREATE PROCEDURE p1() READS SQL DATA SELECT "this is p1";
-let $my_master_commit= true;
-let $my_slave_commit= true;
---source include/rpl_stmt_seq.inc
---vertical_results
---replace_column 5 # 6 #
-SHOW PROCEDURE STATUS LIKE 'p1';
---disable_query_log
-SELECT '-------- switch to slave -------' as "";
---enable_query_log
-connection slave;
---replace_column 5 # 6 #
-SHOW PROCEDURE STATUS LIKE 'p1';
-connection master;
---horizontal_results
-
-let $my_stmt= ALTER PROCEDURE p1 COMMENT "I have been altered";
-let $my_master_commit= true;
-let $my_slave_commit= true;
---source include/rpl_stmt_seq.inc
---vertical_results
---replace_column 5 # 6 #
-SHOW PROCEDURE STATUS LIKE 'p1';
---disable_query_log
-SELECT '-------- switch to slave -------' as "";
---enable_query_log
-connection slave;
---replace_column 5 # 6 #
-SHOW PROCEDURE STATUS LIKE 'p1';
-connection master;
---horizontal_results
-
-let $my_stmt= DROP PROCEDURE p1;
-let $my_master_commit= true;
-let $my_slave_commit= true;
---source include/rpl_stmt_seq.inc
---vertical_results
-SHOW PROCEDURE STATUS LIKE 'p1';
---disable_query_log
-SELECT '-------- switch to slave -------' as "";
---enable_query_log
-connection slave;
-SHOW PROCEDURE STATUS LIKE 'p1';
-connection master;
---horizontal_results
-
-###############################################################
-# Cases with VIEWs
-###############################################################
-let $my_stmt= CREATE OR REPLACE VIEW v1 as select * from t1;
-let $my_master_commit= true;
-let $my_slave_commit= true;
---source include/rpl_stmt_seq.inc
-SHOW CREATE VIEW v1;
---disable_query_log
-SELECT '-------- switch to slave -------' as "";
---enable_query_log
-connection slave;
-SHOW CREATE VIEW v1;
-connection master;
-
-let $my_stmt= ALTER VIEW v1 AS select f1 from t1;
-let $my_master_commit= true;
-let $my_slave_commit= true;
---source include/rpl_stmt_seq.inc
-SHOW CREATE VIEW v1;
---disable_query_log
-SELECT '-------- switch to slave -------' as "";
---enable_query_log
-connection slave;
-SHOW CREATE VIEW v1;
-connection master;
-
-let $my_stmt= DROP VIEW IF EXISTS v1;
-let $my_master_commit= true;
-let $my_slave_commit= true;
---source include/rpl_stmt_seq.inc
---error 1146
-SHOW CREATE VIEW v1;
---disable_query_log
-SELECT '-------- switch to slave -------' as "";
---enable_query_log
-connection slave;
---error 1146
-SHOW CREATE VIEW v1;
-connection master;
-
-###############################################################
-# Cases with TRIGGERs
-###############################################################
-let $my_stmt= CREATE TRIGGER trg1 BEFORE INSERT ON t1 FOR EACH ROW SET @a:=1;
-let $my_master_commit= true;
-let $my_slave_commit= true;
---source include/rpl_stmt_seq.inc
-SHOW TRIGGERS;
---disable_query_log
-SELECT '-------- switch to slave -------' as "";
---enable_query_log
-connection slave;
-SHOW TRIGGERS;
-connection master;
-
-let $my_stmt= DROP TRIGGER trg1;
-let $my_master_commit= true;
-let $my_slave_commit= true;
---source include/rpl_stmt_seq.inc
-SHOW TRIGGERS;
---disable_query_log
-SELECT '-------- switch to slave -------' as "";
---enable_query_log
-connection slave;
-SHOW TRIGGERS;
-connection master;
-
-###############################################################
-# Cases with USERs
-###############################################################
-let $my_stmt= CREATE USER user1@localhost;
-let $my_master_commit= true;
-let $my_slave_commit= true;
---source include/rpl_stmt_seq.inc
-SELECT user FROM mysql.user WHERE user = 'user1';
---disable_query_log
-SELECT '-------- switch to slave -------' as "";
---enable_query_log
-connection slave;
-SELECT user FROM mysql.user WHERE user = 'user1';
-connection master;
-
-let $my_stmt= RENAME USER user1@localhost TO rename1@localhost;
-let $my_master_commit= true;
-let $my_slave_commit= true;
---source include/rpl_stmt_seq.inc
-SELECT user FROM mysql.user WHERE user = 'rename1';
---disable_query_log
-SELECT '-------- switch to slave -------' as "";
---enable_query_log
-connection slave;
-SELECT user FROM mysql.user WHERE user = 'rename1';
-connection master;
-
-let $my_stmt= DROP USER rename1@localhost;
-let $my_master_commit= true;
-let $my_slave_commit= true;
---source include/rpl_stmt_seq.inc
-SELECT user FROM mysql.user WHERE user = 'rename1';
---disable_query_log
-SELECT '-------- switch to slave -------' as "";
---enable_query_log
-connection slave;
-SELECT user FROM mysql.user WHERE user = 'rename1';
-connection master;
-
-###############################################################
-# Cleanup
-###############################################################
---disable_warnings
-DROP DATABASE IF EXISTS mysqltest1;
-DROP DATABASE IF EXISTS mysqltest2;
-DROP DATABASE IF EXISTS mysqltest3;
---enable_warnings
-
-
+let $engine_type= "InnoDB";
+-- source extra/rpl_tests/rpl_ddl.test
diff --git a/mysql-test/t/rpl_deadlock.test b/mysql-test/t/rpl_deadlock.test
deleted file mode 100644
index 684cb54611c..00000000000
--- a/mysql-test/t/rpl_deadlock.test
+++ /dev/null
@@ -1,119 +0,0 @@
-# See if slave restarts the transaction after failing on an InnoDB deadlock error.
-
-# Note: testing what happens when too many retries is possible, but
-# needs large waits when running with --debug, so we don't do it.
-# The same way, this test may not test what is expected when run
-# under Valgrind, timings are too short then (with --valgrind I
-# (Guilhem) have seen the test manage to provoke lock wait timeout
-# error but not deadlock error; that is ok as code deals with the two
-# errors in exactly the same way.
-# We don't 'show status like 'slave_retried_transactions'' because this
-# is not repeatable (depends on sleeps).
-
-source include/have_innodb.inc;
-source include/master-slave.inc;
-
-connection master;
-create table t1 (a int not null, key(a)) engine=innodb;
-create table t2 (a int not null, key(a)) engine=innodb;
-create table t3 (a int) engine=innodb;
-create table t4 (a int) engine=innodb;
-show variables like 'slave_transaction_retries';
-sync_slave_with_master;
-
-show create table t1;
-show create table t2;
-show variables like 'slave_transaction_retries';
-stop slave;
-
-# 1) Test deadlock
-
-connection master;
-begin;
-# Let's keep BEGIN and the locked statement in two different relay logs.
-let $1=200;
-disable_query_log;
-while ($1)
-{
- eval insert into t3 values( $1 );
- dec $1;
-}
-enable_query_log;
-insert into t3 select * from t2 for update;
-insert into t1 values(1);
-commit;
-save_master_pos;
-
-connection slave;
-begin;
-# Let's make our transaction large so that it's slave who is chosen as
-# victim
-let $1=1000;
-disable_query_log;
-while ($1)
-{
- eval insert into t4 values( $1 );
- dec $1;
-}
-enable_query_log;
-select * from t1 for update;
-start slave;
---real_sleep 3 # hope that slave is blocked now
-insert into t2 values(22); # provoke deadlock, slave should be victim
-commit;
-sync_with_master;
-select * from t1; # check that slave succeeded finally
-select * from t2;
-# check that no error is reported
---replace_column 1 # 8 # 9 # 23 # 33 #
---replace_result $MASTER_MYPORT MASTER_MYPORT
---vertical_results
-show slave status;
---horizontal_results
-
-# 2) Test lock wait timeout
-
-stop slave;
-change master to master_log_pos=532; # the BEGIN log event
-begin;
-select * from t2 for update; # hold lock
-start slave;
---real_sleep 10 # slave should have blocked, and be retrying
-commit;
-sync_with_master;
-select * from t1; # check that slave succeeded finally
-select * from t2;
-# check that no error is reported
---replace_column 1 # 8 # 9 # 11 # 23 # 33 #
---replace_result $MASTER_MYPORT MASTER_MYPORT
---vertical_results
-show slave status;
---horizontal_results
-
-# Now we repeat 2), but with BEGIN in the same relay log as
-# COMMIT (to see if seeking into hot log is ok).
-
-set global max_relay_log_size=0;
-
-# This is really copy-paste of 2) of above
-stop slave;
-change master to master_log_pos=532;
-begin;
-select * from t2 for update;
-start slave;
---real_sleep 10
-commit;
-sync_with_master;
-select * from t1;
-select * from t2;
---replace_column 1 # 8 # 9 # 11 # 23 # 33 #
---replace_result $MASTER_MYPORT MASTER_MYPORT
---vertical_results
-show slave status;
---horizontal_results
-
-connection master;
-drop table t1,t2,t3,t4;
-sync_slave_with_master;
-
-# End of 4.1 tests
diff --git a/mysql-test/t/rpl_deadlock-slave.opt b/mysql-test/t/rpl_deadlock_innodb-slave.opt
index f4a8c640458..f4a8c640458 100644
--- a/mysql-test/t/rpl_deadlock-slave.opt
+++ b/mysql-test/t/rpl_deadlock_innodb-slave.opt
diff --git a/mysql-test/t/rpl_deadlock_innodb.test b/mysql-test/t/rpl_deadlock_innodb.test
new file mode 100644
index 00000000000..ee907f81b22
--- /dev/null
+++ b/mysql-test/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/t/rpl_delete_all.test b/mysql-test/t/rpl_delete_all.test
deleted file mode 100644
index e0c0757bbc2..00000000000
--- a/mysql-test/t/rpl_delete_all.test
+++ /dev/null
@@ -1,43 +0,0 @@
-source include/master-slave.inc;
-
-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;
-
-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;
-
-connection master;
-create table t1 (a int);
-sync_slave_with_master;
-insert into t1 values(1);
-connection master;
-delete from t1;
-sync_slave_with_master;
-select * from t1;
-
-insert into t1 values(1);
-connection master;
-insert into t1 values(2);
-update t1 set a=2;
-sync_slave_with_master;
-select * from t1;
-
-# cleanup
-connection master;
-drop table t1;
-sync_slave_with_master;
-
-# End of 4.1 tests
diff --git a/mysql-test/t/rpl_delete_no_where.test b/mysql-test/t/rpl_delete_no_where.test
new file mode 100644
index 00000000000..11adb2e6dd5
--- /dev/null
+++ b/mysql-test/t/rpl_delete_no_where.test
@@ -0,0 +1,6 @@
+###################################################
+# By JBM 2006-02-14 added to skip test when NDB #
+##################################################
+-- source include/not_ndb_default.inc
+let $engine_type=myisam;
+-- source extra/rpl_tests/rpl_delete_no_where.test
diff --git a/mysql-test/t/rpl_do_grant.test b/mysql-test/t/rpl_do_grant.test
index 54287a67657..8d6f99e4bf1 100644
--- a/mysql-test/t/rpl_do_grant.test
+++ b/mysql-test/t/rpl_do_grant.test
@@ -1,6 +1,7 @@
-# Test that GRANT and SET PASSWORD are replicated to the slave
+# 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;
+-- source include/master-slave.inc
# do not be influenced by other tests.
connection master;
@@ -46,3 +47,52 @@ sync_with_master;
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/t/rpl_drop.test b/mysql-test/t/rpl_drop.test
index ebb33c92a20..b38007a755f 100644
--- a/mysql-test/t/rpl_drop.test
+++ b/mysql-test/t/rpl_drop.test
@@ -12,3 +12,5 @@ connection slave;
sync_with_master;
# End of 4.1 tests
+
+
diff --git a/mysql-test/t/rpl_drop_db.test b/mysql-test/t/rpl_drop_db.test
index 3ac0d593fee..38ad07f72f1 100644
--- a/mysql-test/t/rpl_drop_db.test
+++ b/mysql-test/t/rpl_drop_db.test
@@ -46,12 +46,13 @@ show tables;
use test;
select * from t1;
+system rm $MYSQLTEST_VARDIR/master-data/mysqltest1/f1.txt;
connection master;
-drop table t1;
+DROP DATABASE mysqltest1;
sync_slave_with_master;
#cleanup
connection slave;
stop slave;
-system rm -rf $MYSQLTEST_VARDIR/master-data/mysqltest1;
+#system rm -rf $MYSQLTEST_VARDIR/master-data/mysqltest1;
diff --git a/mysql-test/t/rpl_drop_temp.test b/mysql-test/t/rpl_drop_temp.test
index 55a4e741d7c..305c78d3f06 100644
--- a/mysql-test/t/rpl_drop_temp.test
+++ b/mysql-test/t/rpl_drop_temp.test
@@ -1,17 +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);
-create temporary table mysqltest.t2 (n int);
+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/t/rpl_empty_master_crash.test b/mysql-test/t/rpl_empty_master_crash.test
index 5f26bedc9fe..707d1eca8c2 100644
--- a/mysql-test/t/rpl_empty_master_crash.test
+++ b/mysql-test/t/rpl_empty_master_crash.test
@@ -1,6 +1,6 @@
source include/master-slave.inc;
---replace_column 1 # 8 # 9 # 23 # 33 #
+--replace_column 1 # 8 # 9 # 16 # 23 # 33 #
show slave status;
#
diff --git a/mysql-test/t/rpl_error_ignored_table-slave.opt b/mysql-test/t/rpl_err_ignoredtable-slave.opt
index cb49119bfcb..cb49119bfcb 100644
--- a/mysql-test/t/rpl_error_ignored_table-slave.opt
+++ b/mysql-test/t/rpl_err_ignoredtable-slave.opt
diff --git a/mysql-test/t/rpl_error_ignored_table.test b/mysql-test/t/rpl_err_ignoredtable.test
index 339d966dbb3..42ca8cf2e8b 100644
--- a/mysql-test/t/rpl_error_ignored_table.test
+++ b/mysql-test/t/rpl_err_ignoredtable.test
@@ -1,24 +1,27 @@
# 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
-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 1062
+--error 1022, 1062
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;
-# The port number is different when doing the release build with
-# Do-compile, hence we have to replace the port number here accordingly
---replace_result $MASTER_MYPORT MASTER_PORT
---replace_column 1 # 8 # 9 # 23 # 33 #
-show slave status;
# 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;
@@ -44,17 +47,20 @@ 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;
---replace_column 2 # 5 #
-show binlog events from 98;
save_master_pos;
connection slave;
-# SQL slave thread should not have stopped (because table of the killed
-# query is in the ignore list).
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/t/rpl_failed_optimize.test b/mysql-test/t/rpl_failed_optimize.test
index 8c4698c0d9b..81e8342b5c0 100644
--- a/mysql-test/t/rpl_failed_optimize.test
+++ b/mysql-test/t/rpl_failed_optimize.test
@@ -1,23 +1,11 @@
-source include/have_innodb.inc;
-source include/master-slave.inc;
-
-#
-# BUG#5551 "Failed OPTIMIZE TABLE is logged to binary log"
-# Replication should work when OPTIMIZE TABLE timeouts, and
-# when OPTIMIZE TABLE is executed on a non-existing table
-#
-
-CREATE TABLE t1 ( a int ) ENGINE=InnoDB;
-BEGIN;
-INSERT INTO t1 VALUES (1);
-
-connection master1;
-OPTIMIZE TABLE t1;
-
-OPTIMIZE TABLE non_existing;
-sync_slave_with_master;
-
-connection master;
-drop table t1;
-sync_slave_with_master;
-# End of 4.1 tests
+#######################################
+# 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/t/rpl_flush_tables.test b/mysql-test/t/rpl_flush_tables.test
deleted file mode 100644
index bbc5c33770c..00000000000
--- a/mysql-test/t/rpl_flush_tables.test
+++ /dev/null
@@ -1,56 +0,0 @@
-#
-# Test of replicating FLUSH TABLES to make
-# RENAME TABLE work with MERGE tables on the slave.
-# Test of FLUSH NO_WRITE_TO_BINLOG by the way.
-#
---source include/master-slave.inc
-# Skipped on Windows because it can't handle a table underlying an open
-# merge table getting renamed.
---source include/not_windows.inc
-
-create table t1 (a int);
-insert into t1 values (10);
-create table t2 (a int);
-create table t3 (a int) engine=merge union(t1);
-create table t4 (a int);
-# We force the slave to open t3 (because we want to try confusing him) with this :
-insert into t4 select * from t3;
-rename table t1 to t5, t2 to t1;
-# RENAME may have confused the master (this is a known bug): so FLUSH tables,
-# first don't write it to the binlog, to test the NO_WRITE_TO_BINLOG keyword.
-flush no_write_to_binlog tables;
-# Check that it's not in the binlog.
---replace_result $SERVER_VERSION SERVER_VERSION
---replace_column 2 # 5 #
-show binlog events;
-# Check that the master is not confused.
-select * from t3;
-# This FLUSH should go into the binlog to not confuse the slave.
-flush tables;
-# Check that it's in the binlog.
---replace_result $SERVER_VERSION SERVER_VERSION
---replace_column 2 # 5 #
-show binlog events;
-save_master_pos;
-connection slave;
-sync_with_master;
-# Check that the slave is not confused.
-select * from t3;
-# Note that all this confusion may cause warnings 'table xx is open on rename'
-# in the .err files; these are not fatal and are not reported by mysql-test-run.
-
-stop slave;
-connection master;
-drop table t1;
-connection slave;
-flush tables with read lock;
-start slave;
-sleep 1;
---error 1192
-stop slave;
-
-connection master;
-drop table t3, t4, t5;
-
-# End of 4.1 tests
-# Adding comment for force manual merge 5.0 -> wl1012. Delete me if needed.
diff --git a/mysql-test/t/rpl_flush_log_loop-master.opt b/mysql-test/t/rpl_flushlog_loop-master.opt
index a4d1d403dc9..a4d1d403dc9 100644
--- a/mysql-test/t/rpl_flush_log_loop-master.opt
+++ b/mysql-test/t/rpl_flushlog_loop-master.opt
diff --git a/mysql-test/t/rpl_flush_log_loop-master.sh b/mysql-test/t/rpl_flushlog_loop-master.sh
index a321dd690cd..a321dd690cd 100755
--- a/mysql-test/t/rpl_flush_log_loop-master.sh
+++ b/mysql-test/t/rpl_flushlog_loop-master.sh
diff --git a/mysql-test/t/rpl_flush_log_loop-slave.opt b/mysql-test/t/rpl_flushlog_loop-slave.opt
index 95839c831c9..95839c831c9 100644
--- a/mysql-test/t/rpl_flush_log_loop-slave.opt
+++ b/mysql-test/t/rpl_flushlog_loop-slave.opt
diff --git a/mysql-test/t/rpl_flush_log_loop-slave.sh b/mysql-test/t/rpl_flushlog_loop-slave.sh
index e46ea6d400b..e46ea6d400b 100755
--- a/mysql-test/t/rpl_flush_log_loop-slave.sh
+++ b/mysql-test/t/rpl_flushlog_loop-slave.sh
diff --git a/mysql-test/t/rpl_flush_log_loop.test b/mysql-test/t/rpl_flushlog_loop.test
index 6e45047bd30..ded111d769f 100644
--- a/mysql-test/t/rpl_flush_log_loop.test
+++ b/mysql-test/t/rpl_flushlog_loop.test
@@ -1,24 +1,47 @@
# Testing if "flush logs" command bouncing resulting in logs created in a loop
# in case of bi-directional replication
+-- source include/master-slave.inc
-source include/master-slave.inc;
-
+#
+# Start replication master -> slave
+#
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;
-sleep 5;
+
+#
+# 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;
---replace_result $SLAVE_MYPORT SLAVE_PORT
---replace_column 1 # 8 # 9 # 23 # 33 #
-show slave status;
-# End of 4.1 tests
+#
+# Show status of slave
+#
+--replace_result $SLAVE_MYPORT SLAVE_PORT
+--replace_column 1 # 8 # 9 # 16 # 23 # 33 #
+--vertical_results
+SHOW SLAVE STATUS;
diff --git a/mysql-test/t/rpl_foreign_key_innodb-slave.opt b/mysql-test/t/rpl_foreign_key_innodb-slave.opt
new file mode 100644
index 00000000000..627becdbfb5
--- /dev/null
+++ b/mysql-test/t/rpl_foreign_key_innodb-slave.opt
@@ -0,0 +1 @@
+--innodb
diff --git a/mysql-test/t/rpl_foreign_key_innodb.test b/mysql-test/t/rpl_foreign_key_innodb.test
new file mode 100644
index 00000000000..d085bff2012
--- /dev/null
+++ b/mysql-test/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/t/rpl_heap.test b/mysql-test/t/rpl_heap.test
index 3ee335fe58d..b35983ad4d7 100644
--- a/mysql-test/t/rpl_heap.test
+++ b/mysql-test/t/rpl_heap.test
@@ -1,3 +1,6 @@
+# Requires statement logging
+-- source include/have_binlog_format_statement.inc
+
# You must run this test with --manager.
require_manager;
@@ -15,9 +18,11 @@ reset master;
drop table if exists t1;
# we use CREATE SELECT to verify that DELETE does not get into binlog
# before CREATE SELECT
-create table t1 type=HEAP select 10 as a;
+create table t1 engine=HEAP select 10 as a;
insert into t1 values(11);
save_master_pos;
+--replace_column 2 # 5 #
+--replace_regex /table_id: [0-9]+/table_id: #/
show binlog events from 79;
connection slave;
reset slave;
@@ -35,6 +40,8 @@ select * from t1;
# (the LIMIT is to not use the query cache)
select * from t1 limit 10;
save_master_pos;
+--replace_column 2 # 5 #
+--replace_regex /table_id: [0-9]+/table_id: #/
show binlog events in 'master-bin.002' from 79;
connection slave;
diff --git a/mysql-test/t/rpl_ignore_table.test b/mysql-test/t/rpl_ignore_table.test
index bc651779208..84b0a4cde38 100644
--- a/mysql-test/t/rpl_ignore_table.test
+++ b/mysql-test/t/rpl_ignore_table.test
@@ -23,6 +23,8 @@ UPDATE test.t4 NATURAL JOIN test.t1 SET t1.a=5;
sync_slave_with_master;
SELECT * FROM t4;
+# Cleanup
connection master;
DROP TABLE t1;
DROP TABLE t4;
+sync_slave_with_master;
diff --git a/mysql-test/t/rpl000008-slave.opt b/mysql-test/t/rpl_ignore_table_update-slave.opt
index 177f89e0910..177f89e0910 100644
--- a/mysql-test/t/rpl000008-slave.opt
+++ b/mysql-test/t/rpl_ignore_table_update-slave.opt
diff --git a/mysql-test/t/rpl000008.test b/mysql-test/t/rpl_ignore_table_update.test
index fe030f90411..fe030f90411 100644
--- a/mysql-test/t/rpl000008.test
+++ b/mysql-test/t/rpl_ignore_table_update.test
diff --git a/mysql-test/t/rpl_insert_id.test b/mysql-test/t/rpl_insert_id.test
index e038829760d..bfd66431d3c 100644
--- a/mysql-test/t/rpl_insert_id.test
+++ b/mysql-test/t/rpl_insert_id.test
@@ -1,152 +1,11 @@
-# See if queries that use both auto_increment and LAST_INSERT_ID()
-# are replicated well
-
-# We also check how the foreign_key_check variable is replicated
-
-source include/master-slave.inc;
-source include/have_innodb.inc;
-connection master;
-create table t1(a int auto_increment, key(a));
-create table t2(b int auto_increment, c int, key(b));
-insert into t1 values (1),(2),(3);
-insert into t1 values (null);
-insert into t2 values (null,last_insert_id());
-save_master_pos;
-connection slave;
-sync_with_master;
-select * from t1;
-select * from t2;
-connection master;
-#check if multi-line inserts,
-#which set last_insert_id to the first id inserted,
-#are replicated the same way
-drop table t1;
-drop table t2;
---disable_warnings
-create table t1(a int auto_increment, key(a)) engine=innodb;
-create table t2(b int auto_increment, c int, key(b), foreign key(b) references t1(a)) engine=innodb;
---enable_warnings
-SET FOREIGN_KEY_CHECKS=0;
-insert into t1 values (10);
-insert into t1 values (null),(null),(null);
-insert into t2 values (5,0);
-insert into t2 values (null,last_insert_id());
-SET FOREIGN_KEY_CHECKS=1;
-save_master_pos;
-connection slave;
-sync_with_master;
-select * from t1;
-select * from t2;
-connection master;
-
-# check if INSERT SELECT in auto_increment is well replicated (bug #490)
-
-drop table t2;
-drop table t1;
-create table t1(a int auto_increment, key(a));
-create table t2(b int auto_increment, c int, key(b));
-insert into t1 values (10);
-insert into t1 values (null),(null),(null);
-insert into t2 values (5,0);
-insert into t2 (c) select * from t1;
-select * from t2;
-save_master_pos;
-connection slave;
-sync_with_master;
-select * from t1;
-select * from t2;
-connection master;
-drop table t1;
-drop table t2;
-save_master_pos;
-connection slave;
-sync_with_master;
-
-#
-# Bug#8412: Error codes reported in binary log for CHARACTER SET,
-# FOREIGN_KEY_CHECKS
-#
-connection master;
-SET TIMESTAMP=1000000000;
-CREATE TABLE t1 ( a INT UNIQUE );
-SET FOREIGN_KEY_CHECKS=0;
---error 1062
-INSERT INTO t1 VALUES (1),(1);
-sync_slave_with_master;
-
-connection master;
-drop table t1;
-sync_slave_with_master;
-# End of 4.1 tests
-
-
-#
-# BUG#15728: LAST_INSERT_ID function inside a stored function returns 0
-#
-# The solution is not to reset last_insert_id on enter to sub-statement.
-#
-connection master;
---disable_warnings
-drop function if exists bug15728;
-drop function if exists bug15728_insert;
-drop table if exists t1, t2;
---enable_warnings
-
-create table t1 (
- id int not null auto_increment,
- last_id int,
- primary key (id)
-);
-create function bug15728() returns int(11)
- return last_insert_id();
-
-insert into t1 (last_id) values (0);
-insert into t1 (last_id) values (last_insert_id());
-insert into t1 (last_id) values (bug15728());
-
-# Check that nested call replicates too.
-create table t2 (
- id int not null auto_increment,
- last_id int,
- primary key (id)
-);
-delimiter |;
-create function bug15728_insert() returns int(11) modifies sql data
-begin
- insert into t2 (last_id) values (bug15728());
- return bug15728();
-end|
-create trigger t1_bi before insert on t1 for each row
-begin
- declare res int;
- select bug15728_insert() into res;
- set NEW.last_id = res;
-end|
-delimiter ;|
-
-insert into t1 (last_id) values (0);
-
-drop trigger t1_bi;
-
-# Check that nested call doesn't affect outer context.
-select last_insert_id();
-select bug15728_insert();
-select last_insert_id();
-insert into t1 (last_id) values (bug15728());
-# This should be exactly one greater than in the previous call.
-select last_insert_id();
-
-save_master_pos;
-connection slave;
-sync_with_master;
-select * from t1;
-select * from t2;
-connection master;
-
-drop function bug15728;
-drop function bug15728_insert;
-drop table t1, t2;
-
-# End of 5.0 tests
-
-sync_slave_with_master;
+#################################
+# 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/t/rpl_insert_id_pk-slave.opt b/mysql-test/t/rpl_insert_id_pk-slave.opt
new file mode 100644
index 00000000000..627becdbfb5
--- /dev/null
+++ b/mysql-test/t/rpl_insert_id_pk-slave.opt
@@ -0,0 +1 @@
+--innodb
diff --git a/mysql-test/t/rpl_insert_id_pk.test b/mysql-test/t/rpl_insert_id_pk.test
new file mode 100644
index 00000000000..01f30b78ac5
--- /dev/null
+++ b/mysql-test/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/t/rpl_insert_ignore.test b/mysql-test/t/rpl_insert_ignore.test
index a6cc69b1df8..dc8994b82f3 100644
--- a/mysql-test/t/rpl_insert_ignore.test
+++ b/mysql-test/t/rpl_insert_ignore.test
@@ -1,73 +1,8 @@
-# Testcase for BUG#6287 "Slave skips auto_increment values in Replication with InnoDB"
-# The bug was that if on master, INSERT IGNORE ignored some
-# rows, and the table was InnoDB with auto_inc column, then on slave
-# some rows received an auto_inc bigger than on master.
-# Slave needs to be started with --innodb to store table in InnoDB.
-# Same test for MyISAM (which had no bug).
-
+#####################################
+# Wrapper for rpl_insert_ignore.test#
+#####################################
+-- source include/not_ndb_default.inc
-- source include/have_innodb.inc
-
--- source include/master-slave.inc
-
-CREATE TABLE t1 (
- a int unsigned not null auto_increment primary key,
- b int unsigned,
- unique (b)
-) ENGINE=innodb;
-
-CREATE TABLE t2 (
- a int unsigned, # to force INSERT SELECT to have a certain order
- b int unsigned
-) ENGINE=innodb;
-
-
-INSERT INTO t1 VALUES (NULL, 1);
-INSERT INTO t1 VALUES (NULL, 2);
-INSERT INTO t1 VALUES (NULL, 3);
-INSERT INTO t1 VALUES (NULL, 4);
-
-# An alternation of values which will conflict in t1 and will not.
-
-INSERT INTO t2 VALUES (1, 1);
-INSERT INTO t2 VALUES (2, 2);
-INSERT INTO t2 VALUES (3, 5);
-INSERT INTO t2 VALUES (4, 3);
-INSERT INTO t2 VALUES (5, 4);
-INSERT INTO t2 VALUES (6, 6);
-
-INSERT IGNORE INTO t1 SELECT NULL, t2.b FROM t2 ORDER BY t2.a;
-
-# Compare results
-
-SELECT * FROM t1 ORDER BY a;
-
-sync_slave_with_master;
-SELECT * FROM t1 ORDER BY a;
-
-# Now do the same for MyISAM
-
-connection master;
-drop table t1;
-CREATE TABLE t1 (
- a int unsigned not null auto_increment primary key,
- b int unsigned,
- unique (b)
-) ENGINE=myisam;
-
-INSERT INTO t1 VALUES (1, 1);
-INSERT INTO t1 VALUES (2, 2);
-INSERT INTO t1 VALUES (3, 3);
-INSERT INTO t1 VALUES (4, 4);
-
-INSERT IGNORE INTO t1 SELECT NULL, t2.b FROM t2 ORDER BY t2.a;
-
-SELECT * FROM t1 ORDER BY a;
-
-sync_slave_with_master;
-SELECT * FROM t1 ORDER BY a;
-
-connection master;
-drop table t1, t2;
-sync_slave_with_master;
-
-# End of 4.1 tests
+let $engine_type=innodb;
+let $engine_type2=myisam;
+-- source extra/rpl_tests/rpl_insert_ignore.test
diff --git a/mysql-test/t/rpl000009-slave.opt b/mysql-test/t/rpl_load_from_master-slave.opt
index c015c02ba78..c015c02ba78 100644
--- a/mysql-test/t/rpl000009-slave.opt
+++ b/mysql-test/t/rpl_load_from_master-slave.opt
diff --git a/mysql-test/t/rpl000009.test b/mysql-test/t/rpl_load_from_master.test
index 161e01ad293..9bab7d5696e 100644
--- a/mysql-test/t/rpl000009.test
+++ b/mysql-test/t/rpl_load_from_master.test
@@ -1,5 +1,11 @@
# 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
@@ -19,12 +25,12 @@ save_master_pos;
connection slave;
sync_with_master;
create database mysqltest2;
-create table mysqltest2.foo (n int);
+create table mysqltest2.foo (n int)ENGINE=MyISAM;
insert into mysqltest2.foo values(4);
connection master;
-create table mysqltest2.foo (n int);
+create table mysqltest2.foo (n int)ENGINE=MyISAM;
insert into mysqltest2.foo values(5);
-create table mysqltest.bar (m int);
+create table mysqltest.bar (m int)ENGINE=MyISAM;
insert into mysqltest.bar values(15);
save_master_pos;
connection slave;
@@ -49,13 +55,13 @@ set sql_log_bin = 0;
create database mysqltest2;
create database mysqltest;
show databases;
-create table mysqltest2.t1(n int, s char(20));
-create table mysqltest2.t2(n int, s text);
+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));
-create table mysqltest.t2(n int, s text);
+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');
@@ -69,21 +75,21 @@ 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));
+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));
+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));
+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));
+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));
+create table mysqltest.t3(n int, s char(20))ENGINE=MyISAM;
insert into mysqltest.t3 values (1, 'original bar.t3');
load data from master;
diff --git a/mysql-test/t/rpl_load_table_from_master.test b/mysql-test/t/rpl_load_table_from_master.test
new file mode 100644
index 00000000000..b9cec3858a9
--- /dev/null
+++ b/mysql-test/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/t/rpl_loaddata.test b/mysql-test/t/rpl_loaddata.test
index 5ebdec6f761..6f9ee4ef80a 100644
--- a/mysql-test/t/rpl_loaddata.test
+++ b/mysql-test/t/rpl_loaddata.test
@@ -1,154 +1,7 @@
-# See if replication of a "LOAD DATA in an autoincrement column"
-# Honours autoincrement values
-# i.e. if the master and slave have the same sequence
-#
-# check replication of load data for temporary tables with additional
-# parameters
-#
-# check if duplicate entries trigger an error (they should unless IGNORE or
-# REPLACE was used on the master) (bug 571).
-#
-# check if START SLAVE, RESET SLAVE, CHANGE MASTER reset Last_slave_error and
-# Last_slave_errno in SHOW SLAVE STATUS (1st and 3rd commands did not: bug 986)
-
-source include/master-slave.inc;
-
-connection slave;
-reset master;
-connection master;
-
-create table t1(a int not null auto_increment, b int, primary key(a) );
-load data infile '../std_data_ln/rpl_loaddata.dat' into table t1;
-
-create temporary table t2 (day date,id int(9),category enum('a','b','c'),name varchar(60));
-load data infile '../std_data_ln/rpl_loaddata2.dat' into table t2 fields terminated by ',' optionally enclosed by '%' escaped by '@' lines terminated by '\n##\n' starting by '>' ignore 1 lines;
-
-create table t3 (day date,id int(9),category enum('a','b','c'),name varchar(60));
-insert into t3 select * from t2;
-
-save_master_pos;
-connection slave;
-sync_with_master;
-
-select * from t1;
-select * from t3;
-# We want to be sure that LOAD DATA is in the slave's binlog.
-# But we can't simply read this binlog, because as the slave has not been
-# restarted for this test, the file_id is uncertain (would cause test
-# failures). So instead, we test if the binlog looks long enough to
-# contain LOAD DATA. Since 5.0.3 we assume that binlog of 1292 is ok.
-# If LOAD DATA was not logged, the binlog would be shorter.
-show master status;
-
-connection master;
-
-drop table t1;
-drop table t2;
-drop table t3;
-create table t1(a int, b int, unique(b));
-
-save_master_pos;
-connection slave;
-sync_with_master;
-
-# See if slave stops when there's a duplicate entry for key error in LOAD DATA
-
-insert into t1 values(1,10);
-
-connection master;
-load data infile '../std_data_ln/rpl_loaddata.dat' into table t1;
-
-save_master_pos;
-connection slave;
-# The SQL slave thread should be stopped now.
-wait_for_slave_to_stop;
-
-# Skip the bad event and see if error is cleared in SHOW SLAVE STATUS by START
-# SLAVE, even though we are not executing any event (as sql_slave_skip_counter
-# takes us directly to the end of the relay log).
-
-set global sql_slave_skip_counter=1;
-start slave;
-sync_with_master;
---replace_result $MASTER_MYPORT MASTER_PORT
---replace_column 1 # 8 # 9 # 23 # 33 #
-show slave status;
-
-# Trigger error again to test CHANGE MASTER
-
-connection master;
-set sql_log_bin=0;
-delete from t1;
-set sql_log_bin=1;
-load data infile '../std_data_ln/rpl_loaddata.dat' into table t1;
-save_master_pos;
-connection slave;
-# The SQL slave thread should be stopped now.
-# Exec_Master_Log_Pos should point to the start of Execute event
-# for last load data.
-wait_for_slave_to_stop;
-
-# CHANGE MASTER and see if error is cleared in SHOW SLAVE STATUS.
-stop slave;
-change master to master_user='test';
-change master to master_user='root';
---replace_result $MASTER_MYPORT MASTER_PORT
---replace_column 1 # 8 # 9 # 23 # 33 #
-show slave status;
-
-# Trigger error again to test RESET SLAVE
-
-set global sql_slave_skip_counter=1;
-start slave;
-sync_with_master;
-connection master;
-set sql_log_bin=0;
-delete from t1;
-set sql_log_bin=1;
-load data infile '../std_data_ln/rpl_loaddata.dat' into table t1;
-save_master_pos;
-connection slave;
-# The SQL slave thread should be stopped now.
-wait_for_slave_to_stop;
-
-# RESET SLAVE and see if error is cleared in SHOW SLAVE STATUS.
-stop slave;
-reset slave;
---replace_result $MASTER_MYPORT MASTER_PORT
---replace_column 1 # 8 # 9 # 23 # 33 #
-show slave status;
-
-# Finally, see if logging is done ok on master for a failing LOAD DATA INFILE
-
-connection master;
-reset master;
-create table t2 (day date,id int(9),category enum('a','b','c'),name varchar(60),
-unique(day)) engine=MyISAM; # no transactions
---error 1062
-load data infile '../std_data_ln/rpl_loaddata2.dat' into table t2 fields
-terminated by ',' optionally enclosed by '%' escaped by '@' lines terminated by
-'\n##\n' starting by '>' ignore 1 lines;
-select * from t2;
-save_master_pos;
-connection slave;
-start slave;
-sync_with_master;
-select * from t2;
-
-# verify that if no error on slave, this is an error
-
-alter table t2 drop key day;
-connection master;
-delete from t2;
---error 1062
-load data infile '../std_data_ln/rpl_loaddata2.dat' into table t2 fields
-terminated by ',' optionally enclosed by '%' escaped by '@' lines terminated by
-'\n##\n' starting by '>' ignore 1 lines;
-connection slave;
-wait_for_slave_to_stop;
-drop table t2;
-connection master;
-drop table t2;
-drop table t1;
-sync_with_master;
-# End of 4.1 tests
+########################################################
+# 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/t/rpl_loaddata2.test b/mysql-test/t/rpl_loaddata2.test
new file mode 100644
index 00000000000..9e908cac677
--- /dev/null
+++ b/mysql-test/t/rpl_loaddata2.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/t/rpl_loaddata_rule_m-master.opt b/mysql-test/t/rpl_loaddata_m-master.opt
index 9d4a8f0b95e..9d4a8f0b95e 100644
--- a/mysql-test/t/rpl_loaddata_rule_m-master.opt
+++ b/mysql-test/t/rpl_loaddata_m-master.opt
diff --git a/mysql-test/t/rpl_loaddata_m.test b/mysql-test/t/rpl_loaddata_m.test
new file mode 100644
index 00000000000..537d4c163ef
--- /dev/null
+++ b/mysql-test/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/t/rpl_loaddata_rule_m.test b/mysql-test/t/rpl_loaddata_rule_m.test
deleted file mode 100644
index 4b8e5326c98..00000000000
--- a/mysql-test/t/rpl_loaddata_rule_m.test
+++ /dev/null
@@ -1,33 +0,0 @@
-# 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).
-
-source include/master-slave.inc;
-
---disable_warnings
-drop database if exists mysqltest;
---enable_warnings
-
-connection slave;
-stop slave; # don't need slave for this test
-
-# Test logging on master
-
-connection master;
-# 'test' is the current database
-create database mysqltest;
-create table t1(a int, b int, unique(b));
-use mysqltest;
-load data infile '../std_data_ln/rpl_loaddata.dat' into table test.t1;
-# Starting from 5.0.3 LOAD DATA is replicated much in the same way as ordinary
-# query so "show binlog ..." should show two events (before 5.0.3 no events
-# were returned).
---replace_column 2 # 5 #
-show binlog events from 98;
-
-drop database mysqltest;
-use test;
-drop table t1;
-
-# End of 4.1 tests
-# Adding comment for force manual merge 5.0 -> wl1012: Delete me
diff --git a/mysql-test/t/rpl_loaddata_rule_s.test b/mysql-test/t/rpl_loaddata_rule_s.test
deleted file mode 100644
index 2061e898811..00000000000
--- a/mysql-test/t/rpl_loaddata_rule_s.test
+++ /dev/null
@@ -1,25 +0,0 @@
-# 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/master-slave.inc;
-connection slave;
-reset master;
-
-connection master;
-# 'test' is the current database
-create table 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 t1; # check that LOAD was replicated
-show binlog events from 98; # should be nothing
-
-connection master;
-drop table t1;
-
-# End of 4.1 tests
diff --git a/mysql-test/t/rpl_loaddata_rule_s-slave.opt b/mysql-test/t/rpl_loaddata_s-slave.opt
index 9d4a8f0b95e..9d4a8f0b95e 100644
--- a/mysql-test/t/rpl_loaddata_rule_s-slave.opt
+++ b/mysql-test/t/rpl_loaddata_s-slave.opt
diff --git a/mysql-test/t/rpl_loaddata_s.test b/mysql-test/t/rpl_loaddata_s.test
new file mode 100644
index 00000000000..72a5d1a8ec1
--- /dev/null
+++ b/mysql-test/t/rpl_loaddata_s.test
@@ -0,0 +1,30 @@
+# 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_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
+--replace_column 2 # 5 #
+--replace_regex /table_id: [0-9]+/table_id: #/
+show binlog events from 102; # should be nothing
+
+# Cleanup
+connection master;
+drop table test.t1;
+sync_slave_with_master;
diff --git a/mysql-test/t/rpl_loaddatalocal.test b/mysql-test/t/rpl_loaddatalocal.test
index af4fd0106bd..758ac94af24 100644
--- a/mysql-test/t/rpl_loaddatalocal.test
+++ b/mysql-test/t/rpl_loaddatalocal.test
@@ -53,11 +53,11 @@ 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;
system rm $MYSQLTEST_VARDIR/master-data/rpl_loaddatalocal.select_outfile ;
-select * from t1;
+SELECT * FROM t1 ORDER BY a;
save_master_pos;
connection slave;
sync_with_master;
-select * from t1;
+SELECT * FROM t1 ORDER BY a;
connection master;
drop table t1;
save_master_pos;
diff --git a/mysql-test/t/rpl_loadfile.test b/mysql-test/t/rpl_loadfile.test
new file mode 100644
index 00000000000..a671bab15bb
--- /dev/null
+++ b/mysql-test/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/t/rpl_log.test b/mysql-test/t/rpl_log.test
deleted file mode 100644
index 6e614991d36..00000000000
--- a/mysql-test/t/rpl_log.test
+++ /dev/null
@@ -1,113 +0,0 @@
-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, 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;
-stop slave;
-reset master;
-reset slave;
-# We are going to read the slave's binlog which contains file_id (for some LOAD
-# DATA INFILE); to make it repeatable (not influenced by other tests), we need
-# to stop and start the slave, to be sure file_id will start from 1.
-# This can be done with 'server_stop slave', but
-# this would require the manager, so most of the time the test will be skipped
-# :(
-# To workaround this, I (Guilhem) add a (empty) rpl_log-slave.opt (because when
-# mysql-test-run finds such a file it restarts the slave before doing the
-# test). That's not very elegant but I could find no better way, sorry.
-
-let $VERSION=`select version()`;
-
-connection master;
-reset master;
-create table t1(n int not null auto_increment primary key);
-insert into t1 values (NULL);
-drop table t1;
-create table t1 (word char(20) not null);
-load data infile '../std_data_ln/words.dat' into table t1 ignore 1 lines;
-select count(*) from t1;
-drop table t1;
---replace_result $VERSION VERSION
-show binlog events;
-show binlog events from 98 limit 1;
-show binlog events from 98 limit 2;
-show binlog events from 98 limit 2,1;
-flush logs;
-
-# We need an extra update before doing save_master_pos.
-# Otherwise, an unlikely scenario may occur:
-# * When the master's binlog_dump thread reads the end of master-bin.001,
-# it send the rotate event which is at this end, plus a fake rotate event
-# because it's starting to read a new binlog.
-# save_master_pos will record the position of the first of the two rotate
-# (because the fake one is not in the master's binlog anyway).
-# * Later the slave waits for the position of the first rotate event,
-# and it may quickly stop (in 'slave stop') without having received the fake
-# one.
-# So, depending on a few milliseconds, we end up with 2 rotate events in the
-# relay log or one, which influences the output of SHOW SLAVE STATUS, making
-# it not predictable and causing random test failures.
-# To make it predictable, we do a useless update now, but which has the
-# interest of making the slave catch both rotate events.
-
-create table t5 (a int);
-drop table t5;
-
-# Sync slave and force it to start on another binary log
-
-save_master_pos;
-connection slave;
-# Note that the above 'slave start' will cause a 3rd rotate event (a fake one)
-# to go into the relay log (the master always sends a fake one when replication
-# starts).
-start slave;
-sync_with_master;
-flush logs;
-stop slave;
-connection master;
-
-# Create some entries for second log
-
-create table t1 (n int);
-insert into t1 values (1);
-drop table t1;
---replace_result $VERSION VERSION
-show binlog events;
---replace_result $VERSION VERSION
-show binlog events in 'master-bin.000002';
-show binary logs;
-save_master_pos;
-connection slave;
-start slave;
-sync_with_master;
-show binary logs;
---replace_result $MASTER_MYPORT MASTER_PORT $VERSION VERSION
-show binlog events in 'slave-bin.000001' from 4;
---replace_result $MASTER_MYPORT MASTER_PORT $VERSION VERSION
-show binlog events in 'slave-bin.000002' from 4;
---replace_result $MASTER_MYPORT MASTER_PORT
---replace_column 1 # 8 # 9 # 23 # 33 #
-show slave status;
-
-# Need to recode the following
-
-#show new master for slave with master_log_file='master-bin.000001' and master_log_pos=4 and master_server_id=1;
-#show new master for slave with master_log_file='master-bin.000001' and master_log_pos=79 and master_server_id=1;
-#show new master for slave with master_log_file='master-bin.000001' and master_log_pos=311 and master_server_id=1;
-#show new master for slave with master_log_file='master-bin.000002' and master_log_pos=4 and master_server_id=1;
-#show new master for slave with master_log_file='master-bin.000002' and master_log_pos=122 and master_server_id=1;
-
---error 1220
-show binlog events in 'slave-bin.000005' from 4;
-
-# End of 4.1 tests
-# Adding comment for force manual merge 5.0 -> wl1012: Delete me
diff --git a/mysql-test/t/rpl_log_pos.test b/mysql-test/t/rpl_log_pos.test
index 979b146bb22..61c24da514e 100644
--- a/mysql-test/t/rpl_log_pos.test
+++ b/mysql-test/t/rpl_log_pos.test
@@ -1,19 +1,29 @@
+##########
+# 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;
--replace_result $MASTER_MYPORT MASTER_PORT
--replace_column 1 # 8 # 9 # 23 # 33 #
show slave status;
stop slave;
-change master to master_log_pos=73;
+change master to master_log_pos=74;
start slave;
sleep 5;
stop slave;
-change master to master_log_pos=73;
+change master to master_log_pos=74;
--replace_result $MASTER_MYPORT MASTER_PORT
--replace_column 1 # 8 # 9 # 23 # 33 #
show slave status;
@@ -23,13 +33,14 @@ sleep 5;
--replace_column 1 # 8 # 9 # 23 # 33 #
show slave status;
stop slave;
-change master to master_log_pos=173;
+change master to master_log_pos=177;
start slave;
sleep 2;
--replace_result $MASTER_MYPORT MASTER_PORT
--replace_column 1 # 8 # 9 # 23 # 33 #
show slave status;
connection master;
+--replace_column 3 <Binlog_Ignore_DB>
show master status;
create table if not exists t1 (n int);
drop table if exists t1;
@@ -38,10 +49,10 @@ insert into t1 values (1),(2),(3);
save_master_pos;
connection slave;
stop slave;
-change master to master_log_pos=98;
+change master to master_log_pos=102;
start slave;
sync_with_master;
-select * from t1;
+select * from t1 ORDER BY n;
connection master;
drop table t1;
sync_slave_with_master;
diff --git a/mysql-test/t/rpl_max_relay_size.test b/mysql-test/t/rpl_max_relay_size.test
deleted file mode 100644
index 9b6b06e0b14..00000000000
--- a/mysql-test/t/rpl_max_relay_size.test
+++ /dev/null
@@ -1,96 +0,0 @@
-# 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.
-
-source include/master-slave.inc;
-connection slave;
-stop slave;
-connection master;
-# Generate a big enough master's binlog to cause relay log rotations
-create table t1 (a int);
-let $1=800;
-disable_query_log;
-begin;
-while ($1)
-{
-# eval means expand $ expressions
- eval insert into t1 values( $1 );
- dec $1;
-}
-enable_query_log;
-drop table t1;
-save_master_pos;
-connection slave;
-reset slave;
-set global max_binlog_size=8192;
-set global max_relay_log_size=8192-1; # mapped to 4096
-select @@global.max_relay_log_size;
-start slave;
-sync_with_master;
---replace_result $MASTER_MYPORT MASTER_PORT
---replace_column 1 # 8 # 9 # 23 # 33 #
-show slave status;
-stop slave;
-reset slave;
-set global max_relay_log_size=(5*4096);
-select @@global.max_relay_log_size;
-start slave;
-sync_with_master;
---replace_result $MASTER_MYPORT MASTER_PORT
---replace_column 1 # 8 # 9 # 23 # 33 #
-show slave status;
-stop slave;
-reset slave;
-set global max_relay_log_size=0;
-select @@global.max_relay_log_size;
-start slave;
-sync_with_master;
---replace_result $MASTER_MYPORT MASTER_PORT
---replace_column 1 # 8 # 9 # 23 # 33 #
-show slave status;
-
-# Tests below are mainly to ensure that we have not coded with wrong assumptions
-
-stop slave;
-reset slave;
-# test of relay log rotation when the slave is stopped
-# (to make sure it does not crash).
-flush logs;
---replace_result $MASTER_MYPORT MASTER_PORT
---replace_column 1 # 8 # 9 # 23 # 33 #
-show slave status;
-
-reset slave;
-start slave;
-sync_with_master;
-# test of relay log rotation when the slave is started
-flush logs;
-# We have now easy way to be sure that the SQL thread has now deleted the
-# log we just closed. But a trick to achieve this is do an update on the master.
-connection master;
-create table t1 (a int);
-save_master_pos;
-connection slave;
-sync_with_master;
---replace_result $MASTER_MYPORT MASTER_PORT
---replace_column 1 # 8 # 9 # 23 # 33 #
-show slave status;
-# one more rotation, to be sure Relay_Log_Space is correctly updated
-flush logs;
-connection master;
-drop table t1;
-save_master_pos;
-connection slave;
-sync_with_master;
---replace_result $MASTER_MYPORT MASTER_PORT
---replace_column 1 # 8 # 9 # 23 # 33 #
-show slave status;
-
-connection master;
-# test that the absence of relay logs does not make a master crash
-flush logs;
-show master status;
-
-# End of 4.1 tests
-#
diff --git a/mysql-test/t/rpl000002.test b/mysql-test/t/rpl_mixed_ddl_dml.test
index bafd8a30159..5b9ed6898b8 100644
--- a/mysql-test/t/rpl000002.test
+++ b/mysql-test/t/rpl_mixed_ddl_dml.test
@@ -1,3 +1,8 @@
+# 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_statement.inc
+
source include/master-slave.inc;
# Test replication of auto_increment
diff --git a/mysql-test/t/rpl_multi_delete.test b/mysql-test/t/rpl_multi_delete.test
index 4a8c0ab6912..a251cbf8833 100644
--- a/mysql-test/t/rpl_multi_delete.test
+++ b/mysql-test/t/rpl_multi_delete.test
@@ -1,10 +1,11 @@
source include/master-slave.inc;
-create table t1 (a int);
+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;
@@ -16,26 +17,10 @@ sync_with_master;
select * from t1;
select * from t2;
-# End of 4.1 tests
-
-# Check if deleting 0 rows is binlogged (BUG#13348)
-
-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);
-insert into t2 values(1);
-
-connection master;
-DELETE t1.*, t2.* from t1, t2;
-
-sync_slave_with_master;
-select * from t1;
-select * from t2;
-
connection master;
drop table t1,t2;
-sync_slave_with_master;
+save_master_pos;
+connection slave;
+sync_with_master;
+
+# End of 4.1 tests
diff --git a/mysql-test/t/rpl_multi_delete2.test b/mysql-test/t/rpl_multi_delete2.test
index c50311de363..81379d4056b 100644
--- a/mysql-test/t/rpl_multi_delete2.test
+++ b/mysql-test/t/rpl_multi_delete2.test
@@ -36,7 +36,7 @@ select * from a;
# BUG#3461
connection master;
-create table t1 (a int);
+create table t1 (a int primary key);
create table t2 (a int);
insert into t1 values (1);
diff --git a/mysql-test/t/rpl_multi_engine-slave.opt b/mysql-test/t/rpl_multi_engine-slave.opt
new file mode 100644
index 00000000000..627becdbfb5
--- /dev/null
+++ b/mysql-test/t/rpl_multi_engine-slave.opt
@@ -0,0 +1 @@
+--innodb
diff --git a/mysql-test/t/rpl_multi_engine.test b/mysql-test/t/rpl_multi_engine.test
new file mode 100644
index 00000000000..10780c765f7
--- /dev/null
+++ b/mysql-test/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/t/rpl_multi_query.test b/mysql-test/t/rpl_multi_query.test
deleted file mode 100644
index b4cd88f756e..00000000000
--- a/mysql-test/t/rpl_multi_query.test
+++ /dev/null
@@ -1,32 +0,0 @@
-# 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)
-
-# PS doesn't support multi-statements
---disable_ps_protocol
-
-source include/master-slave.inc;
---disable_warnings
-drop database if exists mysqltest;
---enable_warnings
-create database mysqltest;
-
-delimiter /;
-create table mysqltest.t1 ( n int);
-insert into mysqltest.t1 values(1)/
-insert into mysqltest.t1 values(2);
-insert into mysqltest.t1 values(3);
-insert into mysqltest.t1 values(4);
-insert into mysqltest.t1 values(5)/
-delimiter ;/
-sync_slave_with_master;
-select * from mysqltest.t1;
-connection master;
---replace_column 2 # 5 #
-show binlog events from 98;
-drop database mysqltest;
-sync_slave_with_master;
-
-# End of 4.1 tests
-#
diff --git a/mysql-test/t/rpl_multi_update.test b/mysql-test/t/rpl_multi_update.test
index f6a960434ad..a6111455d16 100644
--- a/mysql-test/t/rpl_multi_update.test
+++ b/mysql-test/t/rpl_multi_update.test
@@ -1,49 +1,7 @@
-source include/master-slave.inc;
-
-CREATE TABLE t1 (
- a int unsigned not null auto_increment primary key,
- b int unsigned
-) ENGINE=MyISAM;
-
-CREATE TABLE t2 (
- a int unsigned not null auto_increment primary key,
- b int unsigned
-) ENGINE=MyISAM;
-
-INSERT INTO t1 VALUES (NULL, 0);
-INSERT INTO t1 SELECT NULL, 0 FROM t1;
-
-INSERT INTO t2 VALUES (NULL, 0), (NULL,1);
-
-SELECT * FROM t1 ORDER BY a;
-SELECT * FROM t2 ORDER BY a;
-
-UPDATE t1, t2 SET t1.b = t2.b WHERE t1.a = t2.a;
-save_master_pos;
-connection slave;
-sync_with_master;
-
-# End of 4.1 tests
-
-# Check if updating 0 rows is binlogged (BUG#13348)
-
-connection master;
-delete from t1;
-delete from t2;
-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;
-
-connection master;
-drop table t1, t2;
-sync_slave_with_master;
+########################################################
+# 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/t/rpl_multi_update2.test b/mysql-test/t/rpl_multi_update2.test
index a78b1901f51..7401786501e 100644
--- a/mysql-test/t/rpl_multi_update2.test
+++ b/mysql-test/t/rpl_multi_update2.test
@@ -1,62 +1,9 @@
-# Let's verify that multi-update is not always skipped by slave if
-# some replicate-* rules exist.
-# (BUG#7011)
-
-source include/master-slave.inc;
-
---disable_warnings
-drop table if exists t1,t2;
---enable_warnings
-
-CREATE TABLE t1 (
- a int unsigned not null auto_increment primary key,
- b int unsigned
-) ENGINE=MyISAM;
-
-CREATE TABLE t2 (
- a int unsigned not null auto_increment primary key,
- b int unsigned
-) ENGINE=MyISAM;
-
-INSERT INTO t1 VALUES (NULL, 0);
-INSERT INTO t1 SELECT NULL, 0 FROM t1;
-
-INSERT INTO t2 VALUES (NULL, 0), (NULL,1);
-
-SELECT * FROM t1 ORDER BY a;
-SELECT * FROM t2 ORDER BY a;
-
-UPDATE t1, t2 SET t1.b = (t2.b+4) WHERE t1.a = t2.a;
-SELECT * FROM t1 ORDER BY a;
-SELECT * FROM t2 ORDER BY a;
-
-save_master_pos;
-connection slave;
-sync_with_master;
-SELECT * FROM t1 ORDER BY a;
-SELECT * FROM t2 ORDER BY a;
-
-connection master;
-drop table t1,t2;
-sync_slave_with_master;
-
-#
-# BUG#13236 multi-update with subquery & --replicate-ignore-table
-#
-reset master;
-
-connection master;
-CREATE TABLE t1 ( a INT );
-INSERT INTO t1 VALUES (0);
-UPDATE t1, (SELECT 3 as b) AS x SET t1.a = x.b;
-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
+#######################################################
+# 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
+let $engine_type=MyISAM;
+--source extra/rpl_tests/rpl_multi_update2.test
diff --git a/mysql-test/t/rpl_multi_update3.test b/mysql-test/t/rpl_multi_update3.test
index 8d566764ad9..438a644729c 100644
--- a/mysql-test/t/rpl_multi_update3.test
+++ b/mysql-test/t/rpl_multi_update3.test
@@ -1,223 +1,9 @@
-source include/master-slave.inc;
-
-##############################################################################
-#
-# Let's verify that multi-update with a subselect does not cause the slave to crash
-# (BUG#10442)
-#
---disable_query_log
-SELECT '-------- Test for BUG#9361 --------' as "";
---enable_query_log
-
-CREATE TABLE t1 (
- a int unsigned not null auto_increment primary key,
- b int unsigned
-) ENGINE=MyISAM;
-
-CREATE TABLE t2 (
- a int unsigned not null auto_increment primary key,
- b int unsigned
-) ENGINE=MyISAM;
-
-INSERT INTO t1 VALUES (NULL, 0);
-INSERT INTO t1 SELECT NULL, 0 FROM t1;
-
-INSERT INTO t2 VALUES (NULL, 0), (NULL,1);
-
-SELECT * FROM t1 ORDER BY a;
-SELECT * FROM t2 ORDER BY a;
-
-UPDATE t2, (SELECT a FROM t1) AS t SET t2.b = t.a+5 ;
-SELECT * FROM t1 ORDER BY a;
-SELECT * FROM t2 ORDER BY a;
-
-sync_slave_with_master;
-connection slave;
-SELECT * FROM t1 ORDER BY a;
-SELECT * FROM t2 ORDER BY a;
-
-connection master;
-drop table t1,t2;
-
-##############################################################################
-#
-# Test for BUG#9361:
-# Subselects should work inside multi-updates
-#
---disable_query_log
-SELECT '-------- Test 1 for BUG#9361 --------' as "";
---enable_query_log
-
-connection master;
-
---disable_warnings
-DROP TABLE IF EXISTS t1;
-DROP TABLE IF EXISTS t2;
---enable_warnings
-
-CREATE TABLE t1 (
- a1 char(30),
- a2 int,
- a3 int,
- a4 char(30),
- a5 char(30)
-);
-
-CREATE TABLE t2 (
- b1 int,
- b2 char(30)
-);
-
-# Insert one row per table
-INSERT INTO t1 VALUES ('Yes', 1, NULL, 'foo', 'bar');
-INSERT INTO t2 VALUES (1, 'baz');
-
-# This should update the row in t1
-UPDATE t1 a, t2
- SET a.a1 = 'No'
- WHERE a.a2 =
- (SELECT b1
- FROM t2
- WHERE b2 = 'baz')
- AND a.a3 IS NULL
- AND a.a4 = 'foo'
- AND a.a5 = 'bar';
-
-sync_slave_with_master;
-connection slave;
-SELECT * FROM t1;
-SELECT * FROM t2;
-
-connection master;
-DROP TABLE t1, t2;
-
-##############################################################################
-#
-# Second test for BUG#9361
-#
-
---disable_query_log
-SELECT '-------- Test 2 for BUG#9361 --------' as "";
---enable_query_log
-
-connection master;
-
---disable_warnings
-DROP TABLE IF EXISTS t1;
-DROP TABLE IF EXISTS t2;
-DROP TABLE IF EXISTS t3;
---enable_warnings
-
-CREATE TABLE t1 (
- i INT,
- j INT,
- x INT,
- y INT,
- z INT
-);
-
-CREATE TABLE t2 (
- i INT,
- k INT,
- x INT,
- y INT,
- z INT
-);
-
-CREATE TABLE t3 (
- j INT,
- k INT,
- x INT,
- y INT,
- z INT
-);
-
-INSERT INTO t1 VALUES ( 1, 2,13,14,15);
-INSERT INTO t2 VALUES ( 1, 3,23,24,25);
-INSERT INTO t3 VALUES ( 2, 3, 1,34,35), ( 2, 3, 1,34,36);
-
-UPDATE t1 AS a
-INNER JOIN t2 AS b
- ON a.i = b.i
-INNER JOIN t3 AS c
- ON a.j = c.j AND b.k = c.k
-SET a.x = b.x,
- a.y = b.y,
- a.z = (
- SELECT sum(z)
- FROM t3
- WHERE y = 34
- )
-WHERE b.x = 23;
-
-sync_slave_with_master;
-connection slave;
-
-SELECT * FROM t1;
-
-connection master;
-DROP TABLE t1, t2, t3;
-
-##############################################################################
-#
-# BUG#12618
-#
-# TEST: Replication of a statement containing a join in a multi-update.
-
-DROP TABLE IF EXISTS t1;
-DROP TABLE IF EXISTS t2;
-
-CREATE TABLE t1 (
- idp int(11) NOT NULL default '0',
- idpro int(11) default NULL,
- price decimal(19,4) default NULL,
- PRIMARY KEY (idp)
-);
-
-CREATE TABLE t2 (
- idpro int(11) NOT NULL default '0',
- price decimal(19,4) default NULL,
- nbprice int(11) default NULL,
- PRIMARY KEY (idpro)
-);
-
-INSERT INTO t1 VALUES
- (1,1,'3.0000'),
- (2,2,'1.0000'),
- (3,1,'1.0000'),
- (4,1,'4.0000'),
- (5,3,'2.0000'),
- (6,2,'4.0000');
-
-INSERT INTO t2 VALUES
- (1,'0.0000',0),
- (2,'0.0000',0),
- (3,'0.0000',0);
-
-# This update sets t2 to the minimal prices for each product
-update
- t2
- join
- ( select idpro, min(price) as min_price, count(*) as nbr_price
- from t1
- where idpro>0 and price>0
- group by idpro
- ) as table_price
-on t2.idpro = table_price.idpro
-set t2.price = table_price.min_price,
- t2.nbprice = table_price.nbr_price;
-
-select "-- MASTER AFTER JOIN --" as "";
-select * from t1;
-select * from t2;
-
-sync_slave_with_master;
-
-select "-- SLAVE AFTER JOIN --" as "";
-select * from t1;
-select * from t2;
-
-connection master;
-drop table t1, t2;
-sync_slave_with_master;
-# End of 4.1 tests
+#######################################################
+# 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
+let $engine_type=MyISAM;
+-- source extra/rpl_tests/rpl_multi_update3.test
diff --git a/mysql-test/t/rpl_multi_update4.test b/mysql-test/t/rpl_multi_update4.test
index 3d909b8e5cd..4991a385f6f 100644
--- a/mysql-test/t/rpl_multi_update4.test
+++ b/mysql-test/t/rpl_multi_update4.test
@@ -15,7 +15,7 @@ connection slave;
drop database if exists d2;
--enable_warnings
-### Test
+### Do on master
connection master;
create database d1; # accepted by slave
@@ -30,15 +30,16 @@ insert into t2 select id + 3 from t1;
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;
-#connection slave;
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/t/rpl_mystery22.test b/mysql-test/t/rpl_mystery22.test
deleted file mode 100644
index f190968a03c..00000000000
--- a/mysql-test/t/rpl_mystery22.test
+++ /dev/null
@@ -1,40 +0,0 @@
-# test case to make slave thread get ahead by 22 bytes
-
-source include/master-slave.inc;
-
-# first, cause a duplicate key problem on the slave
-create table t1(n int auto_increment primary key);
-sync_slave_with_master;
-insert into t1 values (2);
-connection master;
-insert into t1 values(NULL);
-insert into t1 values(NULL);
-save_master_pos;
-connection slave;
-sleep 3; # there is no way around this sleep - we have to wait until
-# the slave tries to run the query, fails and aborts slave thread
-delete from t1 where n = 2;
-start slave;
-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);
-save_master_pos;
-connection slave;
-start slave;
-#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;
-#clean up
-connection master;
-drop table t1;
-sync_slave_with_master;
-
-# End of 4.1 tests
diff --git a/mysql-test/t/rpl_ndb_2innodb-master.opt b/mysql-test/t/rpl_ndb_2innodb-master.opt
new file mode 100644
index 00000000000..f31d53c3cb1
--- /dev/null
+++ b/mysql-test/t/rpl_ndb_2innodb-master.opt
@@ -0,0 +1 @@
+--default-storage-engine=ndb --binlog-format=row
diff --git a/mysql-test/t/rpl_ndb_2innodb-slave.opt b/mysql-test/t/rpl_ndb_2innodb-slave.opt
new file mode 100644
index 00000000000..ee81186c513
--- /dev/null
+++ b/mysql-test/t/rpl_ndb_2innodb-slave.opt
@@ -0,0 +1 @@
+--innodb --default-storage-engine=innodb --binlog-format=row
diff --git a/mysql-test/t/rpl_ndb_2innodb.test b/mysql-test/t/rpl_ndb_2innodb.test
new file mode 100644
index 00000000000..e09d8b6685b
--- /dev/null
+++ b/mysql-test/t/rpl_ndb_2innodb.test
@@ -0,0 +1,16 @@
+#############################################################
+# Author: JBM
+# Date: 2006-02-24
+# Purpose: Trying to test ability to replicate from cluster
+# to innodb, or myisam, or replicate from innodb/myisam to
+# cluster slave. Due to limitations I have created wrappers
+# to be able to use the same code for all these different
+# test and to have control over the tests.
+##############################################################
+-- source include/have_ndb.inc
+-- source include/master-slave.inc
+connection slave;
+-- source include/have_innodb.inc
+connection master;
+SET storage_engine=ndb;
+--source extra/rpl_tests/rpl_ndb_2multi_eng.test
diff --git a/mysql-test/t/rpl_ndb_2myisam-master.opt b/mysql-test/t/rpl_ndb_2myisam-master.opt
new file mode 100644
index 00000000000..f31d53c3cb1
--- /dev/null
+++ b/mysql-test/t/rpl_ndb_2myisam-master.opt
@@ -0,0 +1 @@
+--default-storage-engine=ndb --binlog-format=row
diff --git a/mysql-test/t/rpl_ndb_2myisam-slave.opt b/mysql-test/t/rpl_ndb_2myisam-slave.opt
new file mode 100644
index 00000000000..59de63c0da2
--- /dev/null
+++ b/mysql-test/t/rpl_ndb_2myisam-slave.opt
@@ -0,0 +1 @@
+--default-storage-engine=myisam --binlog-format=row
diff --git a/mysql-test/t/rpl_ndb_2myisam.test b/mysql-test/t/rpl_ndb_2myisam.test
new file mode 100644
index 00000000000..abbe419bc02
--- /dev/null
+++ b/mysql-test/t/rpl_ndb_2myisam.test
@@ -0,0 +1,13 @@
+#############################################################
+# Author: JBM
+# Date: 2006-02-24
+# Purpose: Trying to test ability to replicate from cluster
+# to innodb, or myisam, or replicate from innodb/myisam to
+# cluster slave. Due to limitations I have created wrappers
+# to be able to use the same code for all these different
+# test and to have control over the tests.
+##############################################################
+-- source include/have_ndb.inc
+-- source include/master-slave.inc
+SET storage_engine=ndb;
+--source extra/rpl_tests/rpl_ndb_2multi_eng.test
diff --git a/mysql-test/t/rpl_ndb_UUID.test b/mysql-test/t/rpl_ndb_UUID.test
new file mode 100644
index 00000000000..c6fc218beed
--- /dev/null
+++ b/mysql-test/t/rpl_ndb_UUID.test
@@ -0,0 +1,6 @@
+########################################################
+# By JBM 2005-02-15 Wrapped to allow reuse of test code#
+########################################################
+--source include/have_ndb.inc
+let $engine_type=NDB;
+--source extra/rpl_tests/rpl_row_UUID.test
diff --git a/mysql-test/t/rpl_ndb_auto_inc.test b/mysql-test/t/rpl_ndb_auto_inc.test
new file mode 100644
index 00000000000..a9cc9563d88
--- /dev/null
+++ b/mysql-test/t/rpl_ndb_auto_inc.test
@@ -0,0 +1,116 @@
+#
+# Test of auto_increment in CRBR
+#
+#####################################
+# By: JBM
+# Date: 2006-02-10
+# Change: Augmented test to use with cluster
+#####################################
+-- source include/master-slave.inc
+
+--echo ***************** Test 1 ************************
+--echo
+CREATE TABLE t1 (a INT NOT NULL auto_increment,b INT, PRIMARY KEY (a)) ENGINE=NDB auto_increment=3;
+insert into t1 values (NULL,1),(NULL,2),(NULL,3);
+--echo ******* Select from Master *************
+--echo
+select * from t1 ORDER BY a;
+
+
+sync_slave_with_master;
+--echo ******* Select from Slave *************
+--echo
+select * from t1 ORDER BY a;
+connection master;
+drop table t1;
+
+create table t1 (a int not null auto_increment,b int, primary key (a)) engine=NDB;
+insert into t1 values (1,1),(NULL,2),(3,3),(NULL,4);
+delete from t1 where b=4;
+insert into t1 values (NULL,5),(NULL,6);
+--echo ******* Select from Master *************
+--echo
+select * from t1 ORDER BY a;
+
+sync_slave_with_master;
+--echo ******* Select from Slave *************
+--echo
+select * from t1 ORDER BY a;
+connection master;
+
+drop table t1;
+
+create table t1 (a int not null auto_increment, primary key (a)) engine=NDB;
+# Insert with 2 insert statements to get better testing of logging
+insert into t1 values (NULL),(5),(NULL);
+insert into t1 values (250),(NULL);
+--echo ******* Select from Master *************
+--echo
+select * from t1 ORDER BY a;
+insert into t1 values (1000);
+set @@insert_id=400;
+insert into t1 values(NULL),(NULL);
+--echo ******* Select from Master *************
+--echo
+select * from t1 ORDER BY a;
+
+sync_slave_with_master;
+--echo ******* Select from Slave *************
+--echo
+select * from t1 ORDER BY a;
+connection master;
+drop table t1;
+
+create table t1 (a int not null auto_increment, primary key (a)) engine=NDB;
+# Insert with 2 insert statements to get better testing of logging
+insert into t1 values (NULL),(5),(NULL),(NULL);
+insert into t1 values (500),(NULL),(502),(NULL),(600);
+--echo ******* Select from Master *************
+--echo
+select * from t1 ORDER BY a;
+set @@insert_id=600;
+# We expect a duplicate key error that we will ignore below
+--error 1022
+insert into t1 values(600),(NULL),(NULL);
+set @@insert_id=600;
+insert ignore into t1 values(600),(NULL),(NULL),(610),(NULL);
+--echo ******* Select from Master *************
+--echo
+select * from t1 ORDER BY a;
+
+sync_slave_with_master;
+--echo ******* Select from Slave *************
+--echo
+select * from t1 ORDER BY a;
+connection master;
+drop table t1;
+
+#
+# Test that auto-increment works when slave has rows in the table
+#
+
+create table t1 (a int not null auto_increment, primary key (a)) engine=NDB;
+
+sync_slave_with_master;
+insert into t1 values(2),(12),(22),(32),(42);
+connection master;
+
+insert into t1 values (NULL),(NULL);
+insert into t1 values (3),(NULL),(NULL);
+--echo ******* Select from Master *************
+--echo
+select * from t1 ORDER BY a;
+
+sync_slave_with_master;
+--echo ******* Select from Slave *************
+--echo
+--echo ** Slave should have 2, 12, 22, 32, 42 **
+--echo ** Master will have 2 but not 12, 22, 32, 42 **
+--echo
+select * from t1 ORDER BY a;
+connection master;
+
+drop table t1;
+
+# End cleanup
+sync_slave_with_master;
diff --git a/mysql-test/t/rpl_ndb_bank.test b/mysql-test/t/rpl_ndb_bank.test
new file mode 100644
index 00000000000..3601c841c54
--- /dev/null
+++ b/mysql-test/t/rpl_ndb_bank.test
@@ -0,0 +1,180 @@
+#
+# Currently this test only runs in the source tree with the
+# ndb/test programs compiled.
+# invoke with: ./mysql-test-run --ndb-extra-test --do-test=rpl_ndb_bank
+#
+# 1. start a "bank" application running on the master cluster
+# 2. perform online sync of slave
+# 3. periodically check consistency of slave
+# 4. stop the bank application
+# 5. check that the slave and master BANK databases are the same
+#
+
+--source include/have_ndb.inc
+--source include/have_ndb_extra.inc
+--source include/have_binlog_format_row.inc
+--source include/master-slave.inc
+
+# kill any trailing processes
+--system killall lt-bankTransactionMaker lt-bankTimer lt-bankMakeGL || true
+
+--disable_warnings
+# initialize master
+--connection master
+CREATE DATABASE IF NOT EXISTS BANK;
+DROP DATABASE BANK;
+CREATE DATABASE BANK default charset=latin1 default collate=latin1_bin;
+--enable_warnings
+
+#
+# These tables should correspond to the table definitions in
+# storage/ndb/test/src/NDBT_Tables.cpp
+#
+--connection master
+USE BANK;
+CREATE TABLE GL ( TIME BIGINT UNSIGNED NOT NULL,
+ ACCOUNT_TYPE INT UNSIGNED NOT NULL,
+ BALANCE INT UNSIGNED NOT NULL,
+ DEPOSIT_COUNT INT UNSIGNED NOT NULL,
+ DEPOSIT_SUM INT UNSIGNED NOT NULL,
+ WITHDRAWAL_COUNT INT UNSIGNED NOT NULL,
+ WITHDRAWAL_SUM INT UNSIGNED NOT NULL,
+ PURGED INT UNSIGNED NOT NULL,
+ PRIMARY KEY USING HASH (TIME,ACCOUNT_TYPE))
+ ENGINE = NDB;
+
+CREATE TABLE ACCOUNT ( ACCOUNT_ID INT UNSIGNED NOT NULL,
+ OWNER INT UNSIGNED NOT NULL,
+ BALANCE INT UNSIGNED NOT NULL,
+ ACCOUNT_TYPE INT UNSIGNED NOT NULL,
+ PRIMARY KEY USING HASH (ACCOUNT_ID))
+ ENGINE = NDB;
+
+CREATE TABLE TRANSACTION ( TRANSACTION_ID BIGINT UNSIGNED NOT NULL,
+ ACCOUNT INT UNSIGNED NOT NULL,
+ ACCOUNT_TYPE INT UNSIGNED NOT NULL,
+ OTHER_ACCOUNT INT UNSIGNED NOT NULL,
+ TRANSACTION_TYPE INT UNSIGNED NOT NULL,
+ TIME BIGINT UNSIGNED NOT NULL,
+ AMOUNT INT UNSIGNED NOT NULL,
+ PRIMARY KEY USING HASH (TRANSACTION_ID,ACCOUNT))
+ ENGINE = NDB;
+
+CREATE TABLE SYSTEM_VALUES ( SYSTEM_VALUES_ID INT UNSIGNED NOT NULL,
+ VALUE BIGINT UNSIGNED NOT NULL,
+ PRIMARY KEY USING HASH (SYSTEM_VALUES_ID))
+ ENGINE = NDB;
+
+CREATE TABLE ACCOUNT_TYPE ( ACCOUNT_TYPE_ID INT UNSIGNED NOT NULL,
+ DESCRIPTION CHAR(64) NOT NULL,
+ PRIMARY KEY USING HASH (ACCOUNT_TYPE_ID))
+ ENGINE = NDB;
+
+#
+# create "BANK" application
+#
+--exec NDB_CONNECTSTRING=localhost:$NDBCLUSTER_PORT ../storage/ndb/test/ndbapi/bank/bankCreator >> $NDB_TOOLS_OUTPUT
+
+#
+# start main loop
+# repeat backup-restore-check
+#
+
+# set this high if testing to run many syncs in loop
+--let $2=1
+while ($2)
+{
+
+#
+# start "BANK" application
+#
+--exec NDB_CONNECTSTRING=localhost:$NDBCLUSTER_PORT ../storage/ndb/test/ndbapi/bank/bankTimer -w 5 >> $NDB_TOOLS_OUTPUT &
+--exec NDB_CONNECTSTRING=localhost:$NDBCLUSTER_PORT ../storage/ndb/test/ndbapi/bank/bankMakeGL >> $NDB_TOOLS_OUTPUT &
+--exec NDB_CONNECTSTRING=localhost:$NDBCLUSTER_PORT ../storage/ndb/test/ndbapi/bank/bankTransactionMaker >> $NDB_TOOLS_OUTPUT &
+
+#
+# let the "BANK" run for a while
+#
+--sleep 5
+
+--disable_warnings
+# initialize slave for sync
+--connection slave
+STOP SLAVE;
+RESET SLAVE;
+# to make sure we drop any ndbcluster tables
+CREATE DATABASE IF NOT EXISTS BANK;
+DROP DATABASE BANK;
+# create database
+CREATE DATABASE BANK;
+--enable_warnings
+
+#
+# Time to sync the slave:
+# start by taking a backup on master
+--connection master
+RESET MASTER;
+--exec $NDB_MGM --no-defaults --ndb-connectstring="localhost:$NDBCLUSTER_PORT" -e "start backup" >> $NDB_TOOLS_OUTPUT
+
+# there is no neat way to find the backupid, this is a hack to find it...
+--exec $NDB_TOOLS_DIR/ndb_select_all --ndb-connectstring="localhost:$NDBCLUSTER_PORT" -d sys --delimiter=',' SYSTAB_0 | grep 520093696 > $MYSQLTEST_VARDIR/tmp.dat
+CREATE TABLE IF NOT EXISTS cluster.backup_info (id INT, backup_id INT) ENGINE = HEAP;
+DELETE FROM cluster.backup_info;
+LOAD DATA INFILE '../tmp.dat' INTO TABLE cluster.backup_info FIELDS TERMINATED BY ',';
+--replace_column 1 <the_backup_id>
+SELECT @the_backup_id:=backup_id FROM cluster.backup_info;
+let the_backup_id=`select @the_backup_id`;
+
+# restore on slave, first check that nothing is there
+--connection slave
+--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults --ndb-connectstring="localhost:$NDBCLUSTER_PORT_SLAVE" -p 8 -b $the_backup_id -n 1 -m -r --print --print_meta $NDB_BACKUP_DIR/BACKUP/BACKUP-$the_backup_id >> $NDB_TOOLS_OUTPUT
+--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults --ndb-connectstring="localhost:$NDBCLUSTER_PORT_SLAVE" -p 8 -b $the_backup_id -n 2 -r -e --print --print_meta $NDB_BACKUP_DIR/BACKUP/BACKUP-$the_backup_id >> $NDB_TOOLS_OUTPUT
+
+#
+# now setup replication to continue from last epoch
+--source include/ndb_setup_slave.inc
+--connection slave
+START SLAVE;
+
+
+#
+# Now loop and check consistency every 2 seconds on slave
+#
+--connection slave
+--let $1=10
+while ($1)
+{
+ --sleep 2
+ --replace_result $MASTER_MYPORT MASTER_PORT
+ --replace_column 1 <Slave_IO_State> 7 <Read_Master_Log_Pos> 8 <Relay_Log_File> 9 <Relay_Log_Pos> 16 <Replicate_Ignore_Table> 22 <Exec_Master_Log_Pos> 23 <Relay_Log_Space> 33 <Seconds_Behind_Master>
+ SHOW SLAVE STATUS;
+ STOP SLAVE;
+ --exec NDB_CONNECTSTRING=localhost:$NDBCLUSTER_PORT_SLAVE ../storage/ndb/test/ndbapi/bank/bankValidateAllGLs >> $NDB_TOOLS_OUTPUT
+ START SLAVE;
+ --dec $1
+}
+
+#
+# Stop transactions
+#
+--exec killall lt-bankTransactionMaker lt-bankTimer lt-bankMakeGL
+
+#
+# Check that the databases are the same on slave and master
+# 1. dump database BANK on both master and slave
+# 2. compare, there should be no difference
+#
+--exec $MYSQL_DUMP --compact --order-by-primary --skip-extended-insert --no-create-info BANK ACCOUNT_TYPE ACCOUNT GL TRANSACTION > $MYSQLTEST_VARDIR/tmp/master_BANK.sql
+--connection master
+use test;
+create table t1 (a int primary key) engine=ndb;
+insert into t1 values (1);
+--sync_slave_with_master
+--exec $MYSQL_DUMP_SLAVE --compact --order-by-primary --skip-extended-insert --no-create-info BANK ACCOUNT_TYPE ACCOUNT GL TRANSACTION > $MYSQLTEST_VARDIR/tmp/slave_BANK.sql
+--connection master
+drop table t1;
+
+--exec diff $MYSQLTEST_VARDIR/tmp/master_BANK.sql $MYSQLTEST_VARDIR/tmp/slave_BANK.sql
+
+ --dec $2
+}
diff --git a/mysql-test/t/rpl_ndb_basic.test b/mysql-test/t/rpl_ndb_basic.test
new file mode 100644
index 00000000000..c702908ed68
--- /dev/null
+++ b/mysql-test/t/rpl_ndb_basic.test
@@ -0,0 +1,180 @@
+--source include/have_ndb.inc
+--source include/have_binlog_format_row.inc
+--source include/master-slave.inc
+
+
+
+#
+# Bug #11087
+#
+# connect to the master and create tabe t1 in gotoslave database
+--connection master
+CREATE TABLE `t1` ( `nid` int(11) NOT NULL default '0',
+ `nom` char(4) default NULL,
+ `prenom` char(4) default NULL,
+ PRIMARY KEY (`nid`))
+ ENGINE=ndbcluster DEFAULT CHARSET=latin1;
+
+INSERT INTO t1 VALUES(1,"XYZ1","ABC1");
+select * from t1 order by nid;
+
+--sync_slave_with_master
+# connect to slave and ensure data it there.
+--connection slave
+select * from t1 order by nid;
+
+--connection master
+delete from t1;
+INSERT INTO t1 VALUES(1,"XYZ2","ABC2");
+# Make sure all rows are on the master
+select * from t1 order by nid;
+
+# make sure all rows are on the slave.
+--sync_slave_with_master
+--connection slave
+# Bug #11087 would have row with nid 2 missing
+select * from t1 order by nid;
+
+--connection master
+DROP table t1;
+
+#
+# Test replication of table with no primary key
+#
+--connection master
+CREATE TABLE `t1` ( `nid` int(11) NOT NULL default '0',
+ `nom` char(4) default NULL,
+ `prenom` char(4) default NULL)
+ ENGINE=ndbcluster DEFAULT CHARSET=latin1;
+
+INSERT INTO t1 VALUES(1,"XYZ1","ABC1"),(2,"AAA","BBB"),(3,"CCC","DDD");
+select * from t1 order by nid;
+
+--sync_slave_with_master
+# connect to slave and ensure data it there.
+--connection slave
+select * from t1 order by nid;
+
+--connection master
+delete from t1 where nid = 2;
+INSERT INTO t1 VALUES(4,"EEE","FFF");
+# Make sure all rows are on the master
+select * from t1 order by nid;
+
+# make sure all rows are on the slave.
+--sync_slave_with_master
+--connection slave
+select * from t1 order by nid;
+
+--connection master
+UPDATE t1 set nid=nid+1;
+UPDATE t1 set nom="CCP" where nid = 4;
+select * from t1 order by nid;
+
+# make sure all rows are on the slave.
+--sync_slave_with_master
+--connection slave
+select * from t1 order by nid;
+
+--connection master
+DROP table t1;
+
+##################################################################
+#
+# Check that retries are made on the slave on some temporary errors
+#
+
+#
+# 1. Deadlock
+#
+--connection master
+CREATE TABLE `t1` ( `nid` int(11) NOT NULL default '0',
+ `nom` char(4) default NULL,
+ `prenom` char(4) default NULL,
+ PRIMARY KEY USING HASH (`nid`))
+ ENGINE=ndbcluster DEFAULT CHARSET=latin1;
+INSERT INTO t1 VALUES(1,"XYZ1","ABC1");
+
+# cause a lock on that row on the slave
+--sync_slave_with_master
+--connection slave
+--echo **** On Slave ****
+BEGIN;
+UPDATE t1 SET `nom`="LOCK" WHERE `nid`=1;
+
+# set number of retries low so we fail the retries
+set GLOBAL slave_transaction_retries=1;
+
+# now do a change to this row on the master
+# will deadlock on the slave because of lock above
+--connection master
+--echo **** On Master ****
+UPDATE t1 SET `nom`="DEAD" WHERE `nid`=1;
+
+# wait for deadlock to be detected
+# sleep longer than dead lock detection timeout in config
+# we do this 2 times, once with few retries to verify that we
+# get a failure with the set sleep, and once with the _same_
+# sleep, but with more retries to get it to succeed
+--sleep 5
+
+# replication should have stopped, since max retries where not enough
+# verify with show slave status
+--connection slave
+--echo **** On Slave ****
+--replace_result $MASTER_MYPORT MASTER_PORT
+--replace_column 1 <Slave_IO_State> 7 <Read_Master_Log_Pos> 8 <Relay_Log_File> 9 <Relay_Log_Pos> 16 <Replicate_Ignore_Table> 22 <Exec_Master_Log_Pos> 23 <Relay_Log_Space> 33 <Seconds_Behind_Master>
+--query_vertical SHOW SLAVE STATUS;
+
+# now set max retries high enough to succeed, and start slave again
+set GLOBAL slave_transaction_retries=10;
+START SLAVE;
+# wait for deadlock to be detected and retried
+# should be the same sleep as above for test to be valid
+--sleep 5
+
+# commit transaction to release lock on row and let replication succeed
+select * from t1 order by nid;
+COMMIT;
+
+# verify that the row succeded to be applied on the slave
+--connection master
+--sync_slave_with_master
+--connection slave
+select * from t1 order by nid;
+
+# cleanup
+--connection master
+DROP TABLE t1;
+
+
+#
+# BUG#18094
+# Slave caches invalid table definition after atlters causes select failure
+#
+--connection master
+CREATE TABLE t1 (c1 INT KEY) ENGINE=NDB;
+
+INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
+
+ALTER TABLE t1 ADD c2 INT;
+
+--sync_slave_with_master
+connection slave;
+SELECT * FROM t1 ORDER BY c1;
+
+connection master;
+ALTER TABLE t1 CHANGE c2 c2 TEXT CHARACTER SET utf8;
+ALTER TABLE t1 CHANGE c2 c2 BLOB;
+
+--sync_slave_with_master
+connection slave;
+# here we would get error 1412 prior to bug
+SELECT * FROM t1 ORDER BY c1 LIMIT 5;
+
+
+
+# cleanup
+--connection master
+DROP TABLE t1;
+-- source include/master-slave-end.inc
diff --git a/mysql-test/t/rpl_ndb_blob.test b/mysql-test/t/rpl_ndb_blob.test
new file mode 100644
index 00000000000..94af986b222
--- /dev/null
+++ b/mysql-test/t/rpl_ndb_blob.test
@@ -0,0 +1,142 @@
+--source include/have_ndb.inc
+--source include/have_binlog_format_row.inc
+--source include/master-slave.inc
+
+#
+# basic test of blob replication for NDB
+#
+
+# easy test
+
+--connection master
+create table t1 (
+ a int not null primary key,
+ b text not null
+) engine=ndb;
+
+insert into t1 values(1, repeat('abc',10));
+insert into t1 values(2, repeat('def',200));
+insert into t1 values(3, repeat('ghi',3000));
+
+select 'M', a, sha1(b) from t1
+order by a;
+
+--sync_slave_with_master
+--sleep 5
+--connection slave
+select 'S', a, sha1(b) from t1
+order by a;
+
+--connection master
+drop table t1;
+--sync_slave_with_master
+
+# hard test
+
+--connection master
+create table t1 (
+ a int not null primary key,
+ b text not null,
+ c int,
+ d longblob,
+ e tinyblob
+) engine=ndbcluster;
+
+--disable_query_log
+# length 61
+set @s0 = 'rggurloniukyehuxdbfkkyzlceixzrehqhvxvxbpwizzvjzpucqmzrhzxzfau';
+set @s1 = 'ykyymbzqgqlcjhlhmyqelfoaaohvtbekvifukdtnvcrrjveevfakxarxexomz';
+set @s2 = 'dbnfqyzgtqxalcrwtfsqabknvtfcbpoonxsjiqvmhnfikxxhcgoexlkoezvah';
+--enable_query_log
+
+insert into t1 values (
+ 0, repeat(@s2,454), 100, repeat(@s2,345), NULL);
+insert into t1 values (
+ 1, repeat(@s0,504), NULL, repeat(@s1,732), repeat(@s1,1));
+insert into t1 values (
+ 2, '', 102, '', repeat(@s2,1));
+insert into t1 values (
+ 3, repeat(@s0,545), 103, repeat(@s2,788), repeat(@s0,1));
+insert into t1 values (
+ 4, repeat(@s1,38), 104, repeat(@s0,260), repeat(@s0,1));
+insert into t1 values (
+ 5, repeat(@s2,12), 105, repeat(@s2,40), repeat(@s1,1));
+insert into t1 values (
+ 6, repeat(@s1,242), 106, NULL, repeat(@s1,1));
+insert into t1 values (
+ 7, repeat(@s1,30), 107, repeat(@s0,161), '');
+insert into t1 values (
+ 8, repeat(@s1,719), 108, repeat(@s2,104), NULL);
+insert into t1 values (
+ 9, repeat(@s2,427), NULL, NULL, NULL);
+
+select 'M', a, sha1(b), c, sha1(d), sha1(e)
+from t1 order by a;
+
+--sync_slave_with_master
+--sleep 5
+--connection slave
+select 'S', a, sha1(b), c, sha1(d), sha1(e)
+from t1 order by a;
+
+--connection master
+drop table t1;
+--sync_slave_with_master
+
+# table with varsize key (future cluster/schema)
+
+# sql/ha_ndbcluster_binlog.cc
+--connection master
+CREATE TABLE IF NOT EXISTS t1 (
+ db VARBINARY(63) NOT NULL,
+ name VARBINARY(63) NOT NULL,
+ slock BINARY(32) NOT NULL,
+ query BLOB NOT NULL,
+ node_id INT UNSIGNED NOT NULL,
+ epoch BIGINT UNSIGNED NOT NULL,
+ id INT UNSIGNED NOT NULL,
+ version INT UNSIGNED NOT NULL,
+ type INT UNSIGNED NOT NULL,
+ PRIMARY KEY USING HASH (db,name))
+ENGINE=NDB;
+
+insert into t1 values ('test','t1',
+ 'abc',repeat(@s0,10), 11,12,13,14,15);
+insert into t1 values ('test','t2',
+ 'def',repeat(@s1,100), 21,22,23,24,25);
+insert into t1 values ('test','t3',
+ 'ghi',repeat(@s2,1000),31,32,33,34,35);
+insert into t1 values ('testtttttttttt','t1',
+ 'abc',repeat(@s0,10), 11,12,13,14,15);
+insert into t1 values ('testttttttttttt','t1',
+ 'def',repeat(@s1,100), 21,22,23,24,25);
+insert into t1 values ('testtttttttttttt','t1',
+ 'ghi',repeat(@s2,1000),31,32,33,34,35);
+insert into t1 values ('t','t11111111111',
+ 'abc',repeat(@s0,10), 11,12,13,14,15);
+insert into t1 values ('t','t111111111111',
+ 'def',repeat(@s1,100), 21,22,23,24,25);
+insert into t1 values ('t','t1111111111111',
+ 'ghi',repeat(@s2,1000),31,32,33,34,35);
+
+select 'M', db, name, sha1(query), node_id, epoch, id, version, type
+from t1 order by db, name;
+
+--sync_slave_with_master
+--sleep 5
+--connection slave
+select 'S', db, name, sha1(query), node_id, epoch, id, version, type
+from t1 order by db, name;
+
+--connection master
+drop table t1;
+--sync_slave_with_master
+
+#
+# view the binlog - not deterministic (mats)
+#
+
+#--connection master
+#let $VERSION=`select version()`;
+#--replace_result $VERSION VERSION
+#show binlog events;
diff --git a/mysql-test/t/rpl_ndb_blob2.test b/mysql-test/t/rpl_ndb_blob2.test
new file mode 100644
index 00000000000..2e8f02eaf75
--- /dev/null
+++ b/mysql-test/t/rpl_ndb_blob2.test
@@ -0,0 +1,9 @@
+#################################
+# Wrapper for rpl_row_blob.test #
+# Using wrapper to share test #
+# code between engine tests #
+#################################
+-- source include/have_ndb.inc
+let $engine_type=NDBCLUSTER;
+-- source extra/rpl_tests/rpl_row_blob.test
+
diff --git a/mysql-test/t/rpl_ndb_charset.test b/mysql-test/t/rpl_ndb_charset.test
new file mode 100644
index 00000000000..eb412a0349a
--- /dev/null
+++ b/mysql-test/t/rpl_ndb_charset.test
@@ -0,0 +1,6 @@
+########################################################
+# By JBM 2005-02-15 Wrapped to allow reuse of test code#
+########################################################
+--source include/have_ndb.inc
+let $engine_type=NDB;
+-- source extra/rpl_tests/rpl_row_charset.test
diff --git a/mysql-test/t/rpl_ndb_commit_afterflush.test b/mysql-test/t/rpl_ndb_commit_afterflush.test
new file mode 100644
index 00000000000..ce2a4d9506c
--- /dev/null
+++ b/mysql-test/t/rpl_ndb_commit_afterflush.test
@@ -0,0 +1,9 @@
+#####################################
+# Wrapper for rpl_commit_after_flush#
+# Wrapped to reuse test code on #
+# Different engines #
+# By JBM 2004-02-15 #
+#####################################
+-- source include/have_ndb.inc
+let $engine_type=NDB;
+-- source extra/rpl_tests/rpl_commit_after_flush.test
diff --git a/mysql-test/t/rpl_ndb_dd_advance.test b/mysql-test/t/rpl_ndb_dd_advance.test
new file mode 100644
index 00000000000..80ff533ec5b
--- /dev/null
+++ b/mysql-test/t/rpl_ndb_dd_advance.test
@@ -0,0 +1,578 @@
+###############################################
+# Author: JBM #
+# Date: 2006-03-07 #
+# Purpose: To test advance DD and replication #
+###############################################
+
+#### Include Section ####
+--source include/have_ndb.inc
+--source include/have_binlog_format_row.inc
+#--source include/have_ndb_extra.inc
+--source include/master-slave.inc
+
+#### Test start cleanup section #####
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2, t3;
+--enable_warnings
+
+######################################################
+# Requirment: Cluster DD and replication must be able#
+# to handle ALTER tables and indexes and must rpl #
+# to the slave correctly #
+######################################################
+
+## Test #1 replication of CDD and Alter Tables #####
+--echo ***** Test 1 RPL of CDD and Alter *****
+--echo ***** Test 1 setup *****
+
+CREATE LOGFILE GROUP lg1
+ADD UNDOFILE 'undofile.dat'
+INITIAL_SIZE 16M
+UNDO_BUFFER_SIZE = 1M
+ENGINE=NDB;
+
+ALTER LOGFILE GROUP lg1
+ADD UNDOFILE 'undofile02.dat'
+INITIAL_SIZE 4M
+ENGINE=NDB;
+
+CREATE TABLESPACE ts1
+ADD DATAFILE 'datafile.dat'
+USE LOGFILE GROUP lg1
+INITIAL_SIZE 12M
+ENGINE=NDB;
+
+ALTER TABLESPACE ts1
+ADD DATAFILE 'datafile02.dat'
+INITIAL_SIZE 4M
+ENGINE=NDB;
+
+CREATE TABLE t1
+ (c1 INT NOT NULL PRIMARY KEY,
+ c2 INT NOT NULL,
+ c3 INT NOT NULL)
+ TABLESPACE ts1 STORAGE DISK
+ ENGINE=NDB;
+
+--echo ***** insert some data *****
+
+let $j= 900;
+--disable_query_log
+while ($j)
+{
+ eval INSERT INTO t1 VALUES($j,$j*2,$j+3);
+ dec $j;
+}
+--enable_query_log
+
+--echo ***** Select from Master *****
+
+SELECT * FROM t1 ORDER BY c1 LIMIT 5;
+
+--echo ***** Select from Slave *****
+--sync_slave_with_master
+connection slave;
+SELECT * FROM t1 ORDER BY c1 LIMIT 5;
+
+###################################
+# Just to some File Schema check #
+###################################
+
+--disable_query_log
+SELECT DISTINCT FILE_NAME, FILE_TYPE, TABLESPACE_NAME, LOGFILE_GROUP_NAME
+ FROM INFORMATION_SCHEMA.FILES
+ WHERE ENGINE="ndbcluster" ORDER BY FILE_NAME;
+--enable_query_log
+
+--echo **** Do First Set of ALTERs in the master table ****
+###################################################
+# On this first set of alters I expect:
+# 1. To be able to create and index on 2 columns
+# 2. To be able to create a unique index
+# 3. To be able to add two columns and have
+# it all replicated correctly to the slave cluster.
+###################################################
+connection master;
+CREATE INDEX t1_i ON t1(c2, c3);
+#Bug 18039
+#CREATE UNIQUE INDEX t1_i2 ON t1(c2);
+ALTER TABLE t1 ADD c4 TIMESTAMP;
+ALTER TABLE t1 ADD c5 DOUBLE;
+ALTER TABLE t1 ADD INDEX (c5);
+SHOW CREATE TABLE t1;
+
+--echo **** Show first set of ALTERs on SLAVE ****
+--sync_slave_with_master
+connection slave;
+SHOW CREATE TABLE t1;
+
+--echo **** Second set of alters test 1 ****
+############################################
+# With this next set of alters we have had
+# Some issues with renames of tables. So this
+# test renames our main table, drop and index off
+# of it, creates another table with then name
+# of the orginal table, inserts a row, drops
+# the table and renames the orginal table back.
+# I want to make sure that 1) the cluster does
+# okay with this and 2) that it is replicated
+# correctly.
+#############################################
+connection master;
+ALTER TABLE t1 RENAME t2;
+ALTER TABLE t2 DROP INDEX c5;
+CREATE TABLE t1(c1 INT)ENGINE=NDB;
+INSERT INTO t1 VALUES(1);
+DROP TABLE t1;
+ALTER TABLE t2 RENAME t1;
+
+--echo **** Show second set of ALTERs on MASTER ****
+
+SHOW CREATE TABLE t1;
+
+--echo **** Show second set of ALTERs on SLAVE ****
+--sync_slave_with_master
+connection slave;
+SHOW CREATE TABLE t1;
+
+--echo **** Third and last set of alters for test1 ****
+#########################################################
+# In this last set of alters, we are messing with the
+# cluster ability to rebuild indexes, drop a column that make up
+# an index with another column and change types several times in
+# a row. I have choosen the BLOB as it seems to have had many
+# issues in this release. I want to make sure that the cluster
+# deals with these radical changes and that the replication to
+# the slave cluster is dones correctly.
+###########################################################
+connection master;
+ALTER TABLE t1 CHANGE c1 c1 DOUBLE;
+ALTER TABLE t1 CHANGE c2 c2 DECIMAL(10,2);
+ALTER TABLE t1 DROP COLUMN c3;
+ALTER TABLE t1 CHANGE c4 c4 TEXT CHARACTER SET utf8;
+ALTER TABLE t1 CHANGE c4 c4 BLOB;
+ALTER TABLE t1 CHANGE c4 c3 BLOB;
+set @b1 = 'b1';
+set @b1 = concat(@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1,@b1);
+UPDATE t1 SET c3=@b1 where c1 = 1;
+UPDATE t1 SET c3=@b1 where c1 = 2;
+
+--echo **** Show last set of ALTERs on MASTER ****
+
+SHOW CREATE TABLE t1;
+SELECT * FROM t1 ORDER BY c1 LIMIT 5;
+
+--echo **** Show last set of ALTERs on SLAVE ****
+--sync_slave_with_master
+connection slave;
+SHOW CREATE TABLE t1;
+# Bug 18094
+#SELECT * FROM t1 ORDER BY c1 LIMIT 5;
+SELECT * FROM t1 where c1 = 1;
+
+connection master;
+DROP TABLE t1;
+--sync_slave_with_master
+connection slave;
+STOP SLAVE;
+RESET SLAVE;
+connection master;
+RESET MASTER;
+connection slave;
+START SLAVE;
+
+################### TEST 2 TPCB for disk data ###########################
+# Requirement: To have Stored Procedures and Functions that are used to #
+# populate and post transactions to the data base using CDD that span #
+# 2 tables spaces and also use a memory only cluster tables. In addition#
+# The slave is to be stopped, cleaned and restored and synced with the #
+# Master cluster #
+#########################################################################
+
+--echo ******** Create additional TABLESPACE test 2 **************
+
+connection master;
+CREATE TABLESPACE ts2
+ADD DATAFILE 'datafile03.dat'
+USE LOGFILE GROUP lg1
+INITIAL_SIZE 12M
+ENGINE=NDB;
+
+ALTER TABLESPACE ts2
+ADD DATAFILE 'datafile04.dat'
+INITIAL_SIZE 12M
+ENGINE=NDB;
+
+###### CLEAN UP SECTION ##############
+DROP DATABASE IF EXISTS tpcb;
+CREATE DATABASE tpcb;
+######## Creat Table Section #########
+--echo *********** Create TPCB Tables *****************
+CREATE TABLE tpcb.account
+ (id INT, bid INT, balance DECIMAL(10,2),
+ filler CHAR(255), PRIMARY KEY(id))
+ TABLESPACE ts1 STORAGE DISK
+ ENGINE=NDB;
+
+CREATE TABLE tpcb.branch
+ (bid INT, balance DECIMAL(10,2), filler VARCHAR(255),
+ PRIMARY KEY(bid))
+ ENGINE=NDB;
+
+CREATE TABLE tpcb.teller
+ (tid INT, balance DECIMAL(10,2), filler VARCHAR(255),
+ PRIMARY KEY(tid))
+ TABLESPACE ts2 STORAGE DISK
+ ENGINE=NDB;
+
+CREATE TABLE tpcb.history
+ (id MEDIUMINT NOT NULL AUTO_INCREMENT,aid INT,
+ tid INT, bid INT, amount DECIMAL(10,2),
+ tdate DATETIME, teller CHAR(20), uuidf LONGBLOB,
+ filler CHAR(80),PRIMARY KEY (id))
+ TABLESPACE ts2 STORAGE DISK
+ ENGINE=NDB;
+
+--echo ********* Create Procedures and Functions ************
+delimiter |;
+CREATE PROCEDURE tpcb.load()
+BEGIN
+ DECLARE acct INT DEFAULT 1000;
+ DECLARE brch INT DEFAULT 100;
+ DECLARE tell INT DEFAULT 1000;
+ DECLARE tmp INT DEFAULT 100;
+ WHILE brch > 0 DO
+ SET tmp = 100;
+ WHILE tmp > 0 DO
+ INSERT INTO tpcb.account VALUES (acct, brch, 0.0, "FRESH ACCOUNT");
+ SET acct = acct - 1;
+ SET tmp = tmp -1;
+ END WHILE;
+ INSERT INTO tpcb.branch VALUES (brch, 0.0, "FRESH BRANCH");
+ SET brch = brch - 1;
+ END WHILE;
+ WHILE tell > 0 DO
+ INSERT INTO tpcb.teller VALUES (tell, 0.0, "FRESH TELLER");
+ SET tell = tell - 1;
+ END WHILE;
+END|
+
+CREATE FUNCTION tpcb.account_id () RETURNS INT
+BEGIN
+ DECLARE num INT;
+ DECLARE ran INT;
+ SELECT RAND() * 10 INTO ran;
+ IF (ran < 2)
+ THEN
+ SELECT RAND() * 10 INTO num;
+ ELSEIF (ran < 4)
+ THEN
+ SELECT RAND() * 100 INTO num;
+ ELSE
+ SELECT RAND() * 1000 INTO num;
+ END IF;
+ IF (num < 1)
+ THEN
+ RETURN 1;
+ END IF;
+ RETURN num;
+END|
+
+CREATE FUNCTION tpcb.teller_id () RETURNS INT
+BEGIN
+ DECLARE num INT;
+ DECLARE ran INT;
+ SELECT RAND() * 10 INTO ran;
+ IF (ran < 2)
+ THEN
+ SELECT RAND() * 10 INTO num;
+ ELSEIF (ran < 5)
+ THEN
+ SELECT RAND() * 100 INTO num;
+ ELSE
+ SELECT RAND() * 1000 INTO num;
+ END IF;
+ IF (num < 1)
+ THEN
+ RETURN 1;
+ END IF;
+ RETURN num;
+END|
+
+CREATE PROCEDURE tpcb.trans()
+BEGIN
+ DECLARE acct INT DEFAULT 0;
+ DECLARE brch INT DEFAULT 0;
+ DECLARE tell INT DEFAULT 0;
+ DECLARE bal DECIMAL(10,2) DEFAULT 0.0;
+ DECLARE amount DECIMAL(10,2) DEFAULT 1.00;
+ DECLARE test INT DEFAULT 0;
+ DECLARE bbal DECIMAL(10,2) DEFAULT 0.0;
+ DECLARE tbal DECIMAL(10,2) DEFAULT 0.0;
+ DECLARE local_uuid VARCHAR(255);
+ DECLARE local_user VARCHAR(255);
+ DECLARE local_time TIMESTAMP;
+
+ SELECT RAND() * 10 INTO test;
+ SELECT tpcb.account_id() INTO acct;
+ SELECT tpcb.teller_id() INTO tell;
+
+ SELECT account.balance INTO bal FROM tpcb.account WHERE id = acct;
+ SELECT account.bid INTO brch FROM tpcb.account WHERE id = acct;
+ SELECT teller.balance INTO tbal FROM tpcb.teller WHERE tid = tell;
+ SELECT branch.balance INTO bbal FROM tpcb.branch WHERE bid = brch;
+
+ IF (test < 5)
+ THEN
+ SET bal = bal + amount;
+ SET bbal = bbal + amount;
+ SET tbal = tbal + amount;
+ UPDATE tpcb.account SET balance = bal, filler = 'account updated'
+ WHERE id = acct;
+ UPDATE tpcb.branch SET balance = bbal, filler = 'branch updated'
+ WHERE bid = brch;
+ UPDATE tpcb.teller SET balance = tbal, filler = 'teller updated'
+ WHERE tid = tell;
+ ELSE
+ SET bal = bal - amount;
+ SET bbal = bbal - amount;
+ SET tbal = tbal - amount;
+ UPDATE tpcb.account SET balance = bal, filler = 'account updated'
+ WHERE id = acct;
+ UPDATE tpcb.branch SET balance = bbal, filler = 'branch updated'
+ WHERE bid = brch;
+ UPDATE tpcb.teller SET balance = tbal, filler = 'teller updated'
+ WHERE tid = tell;
+ END IF;
+
+ SET local_uuid=UUID();
+ SET local_user=USER();
+ SET local_time= NOW();
+ INSERT INTO tpcb.history VALUES(NULL,acct,tell,brch,amount, local_time,local_user,
+ local_uuid,'completed trans');
+END|
+delimiter ;|
+
+--echo ****** TEST 2 test time *********************************
+USE tpcb;
+
+--echo *********** Load up the database ******************
+CALL tpcb.load();
+
+--echo ********** Check load master and slave **************
+SELECT COUNT(*) FROM account;
+--sync_slave_with_master
+connection slave;
+USE tpcb;
+SELECT COUNT(*) FROM account;
+
+--echo ******** Run in some transactions ***************
+
+connection master;
+let $j= 1000;
+--disable_query_log
+while ($j)
+{
+ CALL tpcb.trans();
+ dec $j;
+}
+--enable_query_log
+
+--echo ***** Time to try slave sync ***********
+--echo **** Must make sure slave is clean *****
+--connection slave
+STOP SLAVE;
+RESET SLAVE;
+DROP PROCEDURE tpcb.load;
+DROP PROCEDURE tpcb.trans;
+DROP TABLE tpcb.account;
+DROP TABLE tpcb.teller;
+DROP TABLE tpcb.branch;
+DROP TABLE tpcb.history;
+DROP DATABASE tpcb;
+
+ALTER TABLESPACE ts1
+DROP DATAFILE 'datafile.dat'
+ENGINE=NDB;
+
+ALTER TABLESPACE ts1
+DROP DATAFILE 'datafile02.dat'
+ENGINE=NDB;
+
+DROP TABLESPACE ts1 ENGINE=NDB;
+
+ALTER TABLESPACE ts2
+DROP DATAFILE 'datafile03.dat'
+ENGINE=NDB;
+
+ALTER TABLESPACE ts2
+DROP DATAFILE 'datafile04.dat'
+ENGINE=NDB;
+
+DROP TABLESPACE ts2 ENGINE=NDB;
+
+DROP LOGFILE GROUP lg1 ENGINE=NDB;
+
+--echo ********** Take a backup of the Master *************
+connection master;
+
+SELECT COUNT(*) FROM history;
+
+let $j= 1000;
+--disable_query_log
+while ($j)
+{
+ CALL tpcb.trans();
+ dec $j;
+}
+--enable_query_log
+
+SELECT COUNT(*) FROM history;
+
+#RESET MASTER;
+--exec $NDB_MGM --no-defaults --ndb-connectstring="localhost:$NDBCLUSTER_PORT" -e "start backup" >> $NDB_TOOLS_OUTPUT
+
+--exec $NDB_TOOLS_DIR/ndb_select_all --ndb-connectstring="localhost:$NDBCLUSTER_PORT" -d sys --delimiter=',' SYSTAB_0 | grep 520093696 > $MYSQLTEST_VARDIR/tmp.dat
+
+CREATE TEMPORARY TABLE IF NOT EXISTS cluster.backup_info (id INT, backup_id INT) ENGINE = HEAP;
+
+DELETE FROM cluster.backup_info;
+
+LOAD DATA INFILE '../tmp.dat' INTO TABLE cluster.backup_info FIELDS TERMINATED BY ',';
+
+--replace_column 1 <the_backup_id>
+
+SELECT @the_backup_id:=backup_id FROM cluster.backup_info;
+
+let the_backup_id=`select @the_backup_id`;
+
+DROP TABLE IF EXISTS cluster.backup_info;
+#RESET MASTER;
+
+--echo ************ Restore the slave ************************
+connection slave;
+CREATE DATABASE tpcb;
+--source include/ndb_restore_slave_eoption.inc
+
+--echo ***** Check a few slave restore values ***************
+connection slave;
+USE tpcb;
+SELECT COUNT(*) FROM account;
+
+--echo ***** Add some more records to master *********
+connection master;
+let $j= 1000;
+--disable_query_log
+while ($j)
+{
+ CALL tpcb.trans();
+ dec $j;
+}
+--enable_query_log
+
+#
+# now setup replication to continue from last epoch
+# 1. get apply_status epoch from slave
+# 2. get corresponding _next_ binlog postition from master
+# 3. change master on slave
+# 4. add some transaction for slave to process
+# 5. start the replication
+
+--echo ***** Finsh the slave sync process *******
+--disable_query_log
+# 1. 2. 3.
+--source include/ndb_setup_slave.inc
+--enable_query_log
+
+# 4.
+--echo * 4. *
+connection master;
+let $j= 1000;
+--disable_query_log
+while ($j)
+{
+ CALL tpcb.trans();
+ dec $j;
+}
+--enable_query_log
+
+# 5.
+--echo * 5. *
+connection slave;
+START SLAVE;
+
+--echo **** We should be ready to continue on *************
+
+connection master;
+let $j= 50;
+--disable_query_log
+while ($j)
+{
+ CALL tpcb.trans();
+ dec $j;
+}
+--enable_query_log
+
+--echo ****** Let's make sure we match *******
+--echo ***** MASTER *******
+USE tpcb;
+SELECT COUNT(*) FROM history;
+
+--echo ****** SLAVE ********
+--sync_slave_with_master
+connection slave;
+USE tpcb;
+SELECT COUNT(*) FROM history;
+
+--echo *** DUMP MASTER & SLAVE FOR COMPARE ********
+
+--exec $MYSQL_DUMP --compact --order-by-primary --skip-extended-insert tpcb account teller branch history > $MYSQLTEST_VARDIR/tmp/RPL_DD_ADV_M.sql
+
+--exec $MYSQL_DUMP_SLAVE --compact --order-by-primary --skip-extended-insert tpcb account teller branch history > $MYSQLTEST_VARDIR/tmp/RPL_DD_ADV_S.sql
+
+--echo *************** TEST 2 CLEANUP SECTION ********************
+connection master;
+DROP PROCEDURE tpcb.load;
+DROP PROCEDURE tpcb.trans;
+DROP TABLE tpcb.account;
+DROP TABLE tpcb.teller;
+DROP TABLE tpcb.branch;
+DROP TABLE tpcb.history;
+DROP DATABASE tpcb;
+
+ALTER TABLESPACE ts1
+DROP DATAFILE 'datafile.dat'
+ENGINE=NDB;
+
+ALTER TABLESPACE ts1
+DROP DATAFILE 'datafile02.dat'
+ENGINE=NDB;
+
+DROP TABLESPACE ts1 ENGINE=NDB;
+
+ALTER TABLESPACE ts2
+DROP DATAFILE 'datafile03.dat'
+ENGINE=NDB;
+
+ALTER TABLESPACE ts2
+DROP DATAFILE 'datafile04.dat'
+ENGINE=NDB;
+
+DROP TABLESPACE ts2 ENGINE=NDB;
+
+DROP LOGFILE GROUP lg1 ENGINE=NDB;
+
+--sync_slave_with_master
+
+connection master;
+
+--echo ****** Do dumps compare ************
+
+--exec diff $MYSQLTEST_VARDIR/tmp/RPL_DD_ADV_M.sql $MYSQLTEST_VARDIR/tmp/RPL_DD_ADV_S.sql
+
+## Note: Ths files should only get removed, if the above diff succeeds.
+
+--exec rm $MYSQLTEST_VARDIR/tmp/RPL_DD_ADV_M.sql
+--exec rm $MYSQLTEST_VARDIR/tmp/RPL_DD_ADV_S.sql
+
+# End 5.1 test case
diff --git a/mysql-test/t/rpl_ndb_dd_basic.test b/mysql-test/t/rpl_ndb_dd_basic.test
new file mode 100644
index 00000000000..104be91e6e4
--- /dev/null
+++ b/mysql-test/t/rpl_ndb_dd_basic.test
@@ -0,0 +1,85 @@
+--source include/have_ndb.inc
+--source include/have_binlog_format_row.inc
+--source include/master-slave.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+#
+# Basic test of disk tables for NDB
+#
+
+#
+# Start by creating a logfile group
+#
+
+CREATE LOGFILE GROUP lg1
+ADD UNDOFILE 'undofile.dat'
+INITIAL_SIZE 16M
+UNDO_BUFFER_SIZE = 1M
+ENGINE=NDB;
+
+alter logfile group lg1
+add undofile 'undofile02.dat'
+initial_size 4M engine=ndb;
+
+#
+# Create a tablespace connected to the logfile group
+#
+
+CREATE TABLESPACE ts1
+ADD DATAFILE 'datafile.dat'
+USE LOGFILE GROUP lg1
+INITIAL_SIZE 12M
+ENGINE NDB;
+
+alter tablespace ts1
+add datafile 'datafile02.dat'
+initial_size 4M engine=ndb;
+
+#
+# Create a table using this tablespace
+#
+
+CREATE TABLE t1
+(pk1 int not null primary key, b int not null, c int not null)
+tablespace ts1 storage disk
+engine ndb;
+
+#
+# insert some data
+#
+
+insert into t1 values (1,2,3);
+select * from t1 order by pk1;
+
+#
+# check that the data is also on the slave
+#
+
+--sync_slave_with_master
+--connection slave
+select * from t1 order by pk1;
+
+#
+# view the binlog
+#
+
+--connection master
+-- source include/show_binlog_events.inc
+
+#
+# cleanup
+#
+
+drop table t1;
+alter tablespace ts1
+drop datafile 'datafile.dat'
+engine=ndb;
+alter tablespace ts1
+drop datafile 'datafile02.dat'
+engine=ndb;
+DROP TABLESPACE ts1 ENGINE=NDB;
+DROP LOGFILE GROUP lg1 ENGINE=NDB;
+-- source include/master-slave-end.inc
diff --git a/mysql-test/t/rpl_ndb_ddl.test b/mysql-test/t/rpl_ndb_ddl.test
new file mode 100644
index 00000000000..b3d32232518
--- /dev/null
+++ b/mysql-test/t/rpl_ndb_ddl.test
@@ -0,0 +1,34 @@
+######################## 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..
+#
+# 3. The assignment of the DDL command to be tested to $my_stmt can
+# be a bit difficult. "'" must be avoided, because the test
+# routine "include/rpl_stmt_seq.inc" performs a
+# eval SELECT CONCAT('######## ','$my_stmt',' ########') as "";
+#
+
+--source include/have_ndb.inc
+--source include/master-slave.inc
+let $engine_type= "NDB";
+-- source extra/rpl_tests/rpl_ddl.test
diff --git a/mysql-test/t/rpl_ndb_delete_nowhere.test b/mysql-test/t/rpl_ndb_delete_nowhere.test
new file mode 100644
index 00000000000..92ceddf7f5c
--- /dev/null
+++ b/mysql-test/t/rpl_ndb_delete_nowhere.test
@@ -0,0 +1,8 @@
+#########################################
+# By JBM 2006-02-14 Test wrapping to #
+# Share test code between engine tests #
+#########################################
+--source include/have_ndb.inc
+-- source include/have_binlog_format_row.inc
+let $engine_type=NDB;
+-- source extra/rpl_tests/rpl_delete_no_where.test
diff --git a/mysql-test/t/rpl_ndb_func003.test b/mysql-test/t/rpl_ndb_func003.test
new file mode 100644
index 00000000000..2d240385555
--- /dev/null
+++ b/mysql-test/t/rpl_ndb_func003.test
@@ -0,0 +1,11 @@
+###################################
+# Wrapper for rpl_row_func003.test#
+# This test was orginally designed#
+# To test InnoDB using RBR, but #
+# It can also be used to test NDB #
+# So this wrapper is being used to#
+# reduce test case code #
+###################################
+-- source include/have_ndb.inc
+let $engine_type=NDB;
+-- source extra/rpl_tests/rpl_row_func003.test
diff --git a/mysql-test/t/rpl_ndb_idempotent.test b/mysql-test/t/rpl_ndb_idempotent.test
new file mode 100644
index 00000000000..1a2c29079b1
--- /dev/null
+++ b/mysql-test/t/rpl_ndb_idempotent.test
@@ -0,0 +1,116 @@
+--source include/have_ndb.inc
+--source include/have_binlog_format_row.inc
+--source include/master-slave.inc
+
+#
+# Currently test only works with ndb since it retrieves "old"
+# binlog positions with cluster.binlog_index and apply_status;
+#
+
+# create a table with one row
+CREATE TABLE t1 (c1 CHAR(15), c2 CHAR(15), c3 INT, PRIMARY KEY (c3)) ENGINE = NDB ;
+INSERT INTO t1 VALUES ("row1","will go away",1);
+SELECT * FROM t1 ORDER BY c3;
+
+# sync slave and retrieve epoch
+sync_slave_with_master;
+--replace_column 1 <the_epoch>
+SELECT @the_epoch:=MAX(epoch) FROM cluster.apply_status;
+let $the_epoch= `select @the_epoch` ;
+SELECT * FROM t1 ORDER BY c3;
+
+# get the master binlog pos from the epoch
+connection master;
+--replace_result $the_epoch <the_epoch>
+--replace_column 1 <the_pos>
+eval SELECT @the_pos:=Position,@the_file:=SUBSTRING_INDEX(FILE, '/', -1)
+ FROM cluster.binlog_index WHERE epoch = $the_epoch ;
+let $the_pos= `SELECT @the_pos` ;
+let $the_file= `SELECT @the_file` ;
+
+# insert some more values
+INSERT INTO t1 VALUES ("row2","will go away",2),("row3","will change",3),("row4","D",4);
+DELETE FROM t1 WHERE c3 = 1;
+UPDATE t1 SET c2="should go away" WHERE c3 = 2;
+UPDATE t1 SET c2="C" WHERE c3 = 3;
+DELETE FROM t1 WHERE c3 = 2;
+
+SELECT * FROM t1 ORDER BY c3;
+
+# check that we have it on the slave
+--sync_slave_with_master
+--connection slave
+SELECT * FROM t1 ORDER BY c3;
+
+--replace_result $MASTER_MYPORT MASTER_PORT
+--replace_column 1 <Slave_IO_State> 7 <Read_Master_Log_Pos> 8 <Relay_Log_File> 9 <Relay_Log_Pos> 16 <Replicate_Ignore_Table> 22 <Exec_Master_Log_Pos> 23 <Relay_Log_Space> 33 <Seconds_Behind_Master>
+SHOW SLAVE STATUS;
+
+# stop slave and reset position to before the last changes
+STOP SLAVE;
+--replace_result $the_pos <the_pos>
+eval CHANGE MASTER TO
+ master_log_file = '$the_file',
+ master_log_pos = $the_pos ;
+
+--replace_result $MASTER_MYPORT MASTER_PORT
+--replace_column 1 <Slave_IO_State> 7 <Read_Master_Log_Pos> 8 <Relay_Log_File> 9 <Relay_Log_Pos> 16 <Replicate_Ignore_Table> 22 <Exec_Master_Log_Pos> 23 <Relay_Log_Space> 33 <Seconds_Behind_Master>
+SHOW SLAVE STATUS;
+
+# start the slave again
+# -> same events should have been applied again
+# e.g. inserting rows that already there
+# deleting a row which is not there
+# updating a row which is not there
+START SLAVE;
+
+--connection master
+SELECT * FROM t1 ORDER BY c3;
+--sync_slave_with_master
+--connection slave
+SELECT * FROM t1 ORDER BY c3;
+
+STOP SLAVE;
+
+#
+# cleanup
+#
+--connection master
+DROP TABLE t1;
+RESET master;
+--connection slave
+DROP TABLE t1;
+RESET slave;
+
+START SLAVE;
+
+#
+# Test that we can handle update of a row that does not exist on the slave
+# will trigger usage of AO_IgnoreError on slave side so that the INSERT
+# still succeeds even if the replication of the UPDATE generates an error.
+#
+--connection master
+CREATE TABLE t1 (c1 CHAR(15) NOT NULL, c2 CHAR(15) NOT NULL, c3 INT NOT NULL, PRIMARY KEY (c3)) ENGINE = NDB ;
+INSERT INTO t1 VALUES ("row1","remove on slave",1);
+
+--sync_slave_with_master
+--connection slave
+DELETE FROM t1;
+
+--connection master
+BEGIN;
+UPDATE t1 SET c2="does not exist" WHERE c3=1;
+INSERT INTO t1 VALUES ("row2","new on slave",2);
+COMMIT;
+
+--sync_slave_with_master
+--connection slave
+SELECT * FROM t1;
+--replace_result $MASTER_MYPORT MASTER_PORT
+--replace_column 1 <Slave_IO_State> 7 <Read_Master_Log_Pos> 8 <Relay_Log_File> 9 <Relay_Log_Pos> 16 <Replicate_Ignore_Table> 22 <Exec_Master_Log_Pos> 23 <Relay_Log_Space> 33 <Seconds_Behind_Master>
+SHOW SLAVE STATUS;
+
+connection master;
+DROP TABLE IF EXISTS t1;
+
+# End of 5.1 Test
diff --git a/mysql-test/t/rpl_ndb_innodb2ndb-master.opt b/mysql-test/t/rpl_ndb_innodb2ndb-master.opt
new file mode 100644
index 00000000000..248f9e60566
--- /dev/null
+++ b/mysql-test/t/rpl_ndb_innodb2ndb-master.opt
@@ -0,0 +1 @@
+--innodb --binlog-format=row
diff --git a/mysql-test/t/rpl_ndb_innodb2ndb-slave.opt b/mysql-test/t/rpl_ndb_innodb2ndb-slave.opt
new file mode 100644
index 00000000000..d6f11dcd7bc
--- /dev/null
+++ b/mysql-test/t/rpl_ndb_innodb2ndb-slave.opt
@@ -0,0 +1 @@
+--binlog-format=row --default-storage-engine=ndbcluster
diff --git a/mysql-test/t/rpl_ndb_innodb2ndb.test b/mysql-test/t/rpl_ndb_innodb2ndb.test
new file mode 100644
index 00000000000..229ee11353b
--- /dev/null
+++ b/mysql-test/t/rpl_ndb_innodb2ndb.test
@@ -0,0 +1,16 @@
+#############################################################
+# Author: JBM
+# Date: 2006-02-24
+# Purpose: Trying to test ability to replicate from cluster
+# to innodb, or myisam, or replicate from innodb/myisam to
+# cluster slave. Due to limitations I have created wrappers
+# to be able to use the same code for all these different
+# test and to have control over the tests.
+##############################################################
+-- source include/have_innodb.inc
+-- source include/master-slave.inc
+connection slave;
+-- source include/have_ndb.inc
+connection master;
+SET storage_engine=innodb;
+--source extra/rpl_tests/rpl_ndb_2multi_eng.test
diff --git a/mysql-test/t/rpl_ndb_insert_ignore.test b/mysql-test/t/rpl_ndb_insert_ignore.test
new file mode 100644
index 00000000000..17acb5983f4
--- /dev/null
+++ b/mysql-test/t/rpl_ndb_insert_ignore.test
@@ -0,0 +1,8 @@
+#####################################
+# Wrapper for rpl_insert_ignore.test#
+#####################################
+-- source include/have_ndb.inc
+-- source include/have_binlog_format_row.inc
+let $engine_type=NDB;
+let $engine_type2=myisam;
+-- source extra/rpl_tests/rpl_insert_ignore.test
diff --git a/mysql-test/t/rpl_ndb_load.test b/mysql-test/t/rpl_ndb_load.test
new file mode 100644
index 00000000000..2ee540afd18
--- /dev/null
+++ b/mysql-test/t/rpl_ndb_load.test
@@ -0,0 +1,66 @@
+#
+# Currently this test only runs in the source tree with the
+# ndb/test programs compiled.
+# invoke with: ./mysql-test-run --ndb-extra-test --do-test=rpl_ndb_load
+#
+
+--source include/have_ndb.inc
+--source include/have_ndb_extra.inc
+--source include/have_binlog_format_row.inc
+--source include/master-slave.inc
+
+--disable_warnings
+# reset master
+connection master;
+DROP DATABASE IF EXISTS TEST_DB;
+CREATE DATABASE TEST_DB;
+--enable_warnings
+
+#
+# These tables should correspond to the table definitions in
+# storage/ndb/test/ndbapi/bench/
+#
+connection master;
+USE TEST_DB;
+CREATE TABLE SUBSCRIBER
+ ( NUMBER CHAR(12) BINARY NOT NULL,
+ NAME CHAR(32) BINARY NOT NULL,
+ GROUP_ID INT UNSIGNED NOT NULL,
+ LOCATION INT UNSIGNED NOT NULL,
+ SESSIONS INT UNSIGNED NOT NULL,
+ CHANGED_BY CHAR(32) BINARY NOT NULL,
+ CHANGED_TIME CHAR(32) BINARY NOT NULL,
+ PRIMARY KEY USING HASH (NUMBER))
+ ENGINE = NDB;
+
+CREATE TABLE GROUP_T
+ ( GROUP_ID INT UNSIGNED NOT NULL,
+ GROUP_NAME CHAR(32) BINARY NOT NULL,
+ ALLOW_READ CHAR(1) BINARY NOT NULL,
+ ALLOW_INSERT INT UNSIGNED NOT NULL,
+ ALLOW_DELETE INT UNSIGNED NOT NULL,
+ PRIMARY KEY USING HASH (GROUP_ID))
+ ENGINE = NDB;
+
+CREATE TABLE SESSION
+ ( NUMBER CHAR(12) BINARY NOT NULL,
+ SERVER_ID INT UNSIGNED NOT NULL,
+ DATA VARBINARY(1998) NOT NULL,
+ PRIMARY KEY USING HASH (NUMBER,SERVER_ID))
+ ENGINE = NDB;
+
+CREATE TABLE SERVER
+ ( SUFFIX CHAR(2) BINARY NOT NULL,
+ SERVER_ID INT UNSIGNED NOT NULL,
+ NAME CHAR(32) BINARY NOT NULL,
+ NO_OF_READ INT UNSIGNED NOT NULL,
+ NO_OF_INSERT INT UNSIGNED NOT NULL,
+ NO_OF_DELETE INT UNSIGNED NOT NULL,
+ PRIMARY KEY USING HASH (SUFFIX, SERVER_ID))
+ ENGINE = NDB;
+
+#
+# start "load" application
+#
+--exec NDB_CONNECTSTRING=localhost:$NDBCLUSTER_PORT ../storage/ndb/test/ndbapi/DbCreate >> $NDB_TOOLS_OUTPUT
+--exec NDB_CONNECTSTRING=localhost:$NDBCLUSTER_PORT ../storage/ndb/test/ndbapi/DbAsyncGenerator >> $NDB_TOOLS_OUTPUT
diff --git a/mysql-test/t/rpl_log-master.opt b/mysql-test/t/rpl_ndb_log-master.opt
index e0d075c3fbd..e0d075c3fbd 100644
--- a/mysql-test/t/rpl_log-master.opt
+++ b/mysql-test/t/rpl_ndb_log-master.opt
diff --git a/mysql-test/t/rpl_ndb_log.test b/mysql-test/t/rpl_ndb_log.test
new file mode 100644
index 00000000000..e883d24b977
--- /dev/null
+++ b/mysql-test/t/rpl_ndb_log.test
@@ -0,0 +1,12 @@
+###################################
+# 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/have_binlog_format_row.inc
+-- source include/have_ndb.inc
+let $engine_type=NDB;
+-- source extra/rpl_tests/rpl_log.test
+
diff --git a/mysql-test/t/rpl_ndb_multi.test b/mysql-test/t/rpl_ndb_multi.test
new file mode 100644
index 00000000000..fc7ecab00ac
--- /dev/null
+++ b/mysql-test/t/rpl_ndb_multi.test
@@ -0,0 +1,71 @@
+--source include/have_ndb.inc
+--source include/have_multi_ndb.inc
+--source include/have_binlog_format_row.inc
+--source include/master-slave.inc
+
+# note: server2 is another "master" connected to the master cluster
+
+#
+# Currently test only works with ndb since it retrieves "old"
+# binlog positions with cluster.binlog_index and apply_status;
+#
+
+# create a table with one row, and make sure the other "master" gets it
+CREATE TABLE t1 (c1 CHAR(15), c2 CHAR(15), c3 INT, PRIMARY KEY (c3)) ENGINE = NDB ;
+connection server2;
+reset master;
+SHOW TABLES;
+connection master;
+INSERT INTO t1 VALUES ("row1","will go away",1);
+SELECT * FROM t1 ORDER BY c3;
+connection server2;
+SELECT * FROM t1 ORDER BY c3;
+
+# sync slave and retrieve epoch and stop the slave
+connection master;
+sync_slave_with_master;
+--replace_column 1 <the_epoch>
+SELECT @the_epoch:=MAX(epoch) FROM cluster.apply_status;
+let $the_epoch= `select @the_epoch` ;
+SELECT * FROM t1 ORDER BY c3;
+stop slave;
+
+# get the master binlog pos from the epoch, from the _other_ "master", server2
+connection server2;
+--replace_result $the_epoch <the_epoch>
+eval SELECT @the_pos:=Position,@the_file:=SUBSTRING_INDEX(FILE, '/', -1)
+ FROM cluster.binlog_index WHERE epoch = $the_epoch ;
+let $the_pos= `SELECT @the_pos` ;
+let $the_file= `SELECT @the_file` ;
+
+# now connect the slave to the _other_ "master"
+connection slave;
+--replace_result $MASTER_MYPORT1 <MASTER_PORT1>
+eval CHANGE MASTER TO
+ master_port=$MASTER_MYPORT1,
+ master_log_file = '$the_file',
+ master_log_pos = $the_pos ;
+start slave;
+
+# insert some more values on the first master
+connection master;
+INSERT INTO t1 VALUES ("row2","will go away",2),("row3","will change",3),("row4","D",4);
+DELETE FROM t1 WHERE c3 = 1;
+UPDATE t1 SET c2="should go away" WHERE c3 = 2;
+UPDATE t1 SET c2="C" WHERE c3 = 3;
+DELETE FROM t1 WHERE c3 = 2;
+
+SELECT * FROM t1 ORDER BY c3;
+
+save_master_pos;
+
+# insert another row, and check that we have it on the slave
+connection server2;
+INSERT INTO t1 VALUES ("row5","E",5);
+SELECT * FROM t1 ORDER BY c3;
+#sync_slave_with_master;
+connection slave;
+--sleep 2
+SELECT * FROM t1 ORDER BY c3;
+
+STOP SLAVE;
diff --git a/mysql-test/t/rpl_ndb_multi_update2-slave.opt b/mysql-test/t/rpl_ndb_multi_update2-slave.opt
new file mode 100644
index 00000000000..17d4171af0e
--- /dev/null
+++ b/mysql-test/t/rpl_ndb_multi_update2-slave.opt
@@ -0,0 +1 @@
+--replicate-ignore-table=nothing.sensible
diff --git a/mysql-test/t/rpl_ndb_multi_update2.test b/mysql-test/t/rpl_ndb_multi_update2.test
new file mode 100644
index 00000000000..df4f0eec39d
--- /dev/null
+++ b/mysql-test/t/rpl_ndb_multi_update2.test
@@ -0,0 +1,12 @@
+############################################################
+# By JBM 2006-02-15 Wrapper for rpl_multi_update2.test #
+# to reuse test code between engine runs #
+############################################################
+-- source include/have_ndb.inc
+
+# Run this only for row based replication, as replication of
+# auto_increment values are not supported with NDB as storage engine
+-- source include/have_binlog_format_row.inc
+
+let $engine_type=NDB;
+--source extra/rpl_tests/rpl_multi_update2.test
diff --git a/mysql-test/t/rpl_ndb_multi_update3.test b/mysql-test/t/rpl_ndb_multi_update3.test
new file mode 100644
index 00000000000..008e2143987
--- /dev/null
+++ b/mysql-test/t/rpl_ndb_multi_update3.test
@@ -0,0 +1,8 @@
+############################################################
+# By JBM 2006-02-15 Wrapper for rpl_multi_update3.test #
+# to reuse test code between engine runs #
+############################################################
+-- source include/have_ndb.inc
+-- source include/have_binlog_format_row.inc
+let $engine_type=NDB;
+-- source extra/rpl_tests/rpl_multi_update3.test
diff --git a/mysql-test/t/rpl_ndb_myisam2ndb-master.opt b/mysql-test/t/rpl_ndb_myisam2ndb-master.opt
new file mode 100644
index 00000000000..83ed8522e72
--- /dev/null
+++ b/mysql-test/t/rpl_ndb_myisam2ndb-master.opt
@@ -0,0 +1 @@
+--binlog-format=row
diff --git a/mysql-test/t/rpl_ndb_myisam2ndb-slave.opt b/mysql-test/t/rpl_ndb_myisam2ndb-slave.opt
new file mode 100644
index 00000000000..b7990823676
--- /dev/null
+++ b/mysql-test/t/rpl_ndb_myisam2ndb-slave.opt
@@ -0,0 +1 @@
+--default-storage-engine=ndbcluster --binlog-format=row
diff --git a/mysql-test/t/rpl_ndb_myisam2ndb.test b/mysql-test/t/rpl_ndb_myisam2ndb.test
new file mode 100644
index 00000000000..0c2df6441cb
--- /dev/null
+++ b/mysql-test/t/rpl_ndb_myisam2ndb.test
@@ -0,0 +1,15 @@
+#############################################################
+# Author: JBM
+# Date: 2006-02-24
+# Purpose: Trying to test ability to replicate from cluster
+# to innodb, or myisam, or replicate from innodb/myisam to
+# cluster slave. Due to limitations I have created wrappers
+# to be able to use the same code for all these different
+# test and to have control over the tests.
+##############################################################
+-- source include/master-slave.inc
+connection slave;
+--source include/have_ndb.inc
+connection master;
+SET storage_engine=myisam;
+--source extra/rpl_tests/rpl_ndb_2multi_eng.test
diff --git a/mysql-test/t/rpl_ndb_relayrotate-slave.opt b/mysql-test/t/rpl_ndb_relayrotate-slave.opt
new file mode 100644
index 00000000000..3a4abbf091e
--- /dev/null
+++ b/mysql-test/t/rpl_ndb_relayrotate-slave.opt
@@ -0,0 +1,3 @@
+-O max_relay_log_size=16384
+--innodb
+--log-warnings
diff --git a/mysql-test/t/rpl_ndb_relayrotate.test b/mysql-test/t/rpl_ndb_relayrotate.test
new file mode 100644
index 00000000000..c5ec0e1d21b
--- /dev/null
+++ b/mysql-test/t/rpl_ndb_relayrotate.test
@@ -0,0 +1,8 @@
+############################################################
+# By JBM 2006-02-15 Wrapper for rpl_relayrotate.test #
+# to reuse test code between engine runs #
+############################################################
+-- source include/have_ndb.inc
+-- source include/have_ndb_extra.inc
+let $engine_type=NDB;
+-- source extra/rpl_tests/rpl_relayrotate.test
diff --git a/mysql-test/t/rpl_ndb_row_001.test b/mysql-test/t/rpl_ndb_row_001.test
new file mode 100644
index 00000000000..1e2a4ec02df
--- /dev/null
+++ b/mysql-test/t/rpl_ndb_row_001.test
@@ -0,0 +1,6 @@
+########################################################
+# By JBM 2005-02-15 Wrapped to allow reuse of test code#
+########################################################
+--source include/have_ndb.inc
+let $engine_type=NDB;
+-- source extra/rpl_tests/rpl_row_001.test
diff --git a/mysql-test/t/rpl_ndb_sp003.test b/mysql-test/t/rpl_ndb_sp003.test
new file mode 100644
index 00000000000..75ad9f0a488
--- /dev/null
+++ b/mysql-test/t/rpl_ndb_sp003.test
@@ -0,0 +1,9 @@
+#################################
+# Wrapper for rpl_row_sp003.test#
+# These tests have been wrapped #
+# so the same code can be used #
+# For different engines #
+#################################
+-- source include/have_ndb.inc
+let $engine_type=NDBCLUSTER;
+-- source extra/rpl_tests/rpl_row_sp003.test
diff --git a/mysql-test/t/rpl_ndb_sp006.test b/mysql-test/t/rpl_ndb_sp006.test
new file mode 100644
index 00000000000..590facc3648
--- /dev/null
+++ b/mysql-test/t/rpl_ndb_sp006.test
@@ -0,0 +1,9 @@
+#################################
+# Wrapper for rpl_row_sp006.test#
+# These tests have been wrapped #
+# so the same code can be used #
+# For different engines #
+#################################
+-- source include/have_ndb.inc
+let $engine_type=NDBCLUSTER;
+-- source extra/rpl_tests/rpl_row_sp006.test
diff --git a/mysql-test/t/rpl_ndb_sync.test b/mysql-test/t/rpl_ndb_sync.test
new file mode 100644
index 00000000000..95f56609ed7
--- /dev/null
+++ b/mysql-test/t/rpl_ndb_sync.test
@@ -0,0 +1,102 @@
+--source include/have_ndb.inc
+--source include/have_binlog_format_row.inc
+--source include/master-slave.inc
+
+#
+# Currently test only works with ndb since it retrieves "old"
+# binlog positions with cluster.binlog_index and apply_status;
+#
+
+# stop the save
+--connection slave
+STOP SLAVE;
+CREATE DATABASE ndbsynctest;
+USE ndbsynctest;
+
+# get some data on the master
+--connection master
+CREATE DATABASE ndbsynctest;
+USE ndbsynctest;
+CREATE TABLE t1 (c1 BIT(1) NOT NULL, c2 BIT(1) NOT NULL, c3 CHAR(15), PRIMARY KEY(c3)) ENGINE = NDB ;
+INSERT INTO t1 VALUES (1,1,"row1"),(0,1,"row2"),(1,0,"row3"),(0,0,"row4");
+CREATE TABLE t2 (c1 CHAR(15), c2 BIT(1) NOT NULL, c3 BIT(1) NOT NULL, PRIMARY KEY(c1)) ENGINE = NDB ;
+INSERT INTO t2 VALUES ("ABC",1,1),("BCDEF",0,1),("CD",1,0),("DEFGHIJKL",0,0);
+SELECT hex(c1),hex(c2),c3 FROM t1 ORDER BY c3;
+SELECT hex(c2),hex(c3),c1 FROM t2 ORDER BY c1;
+
+# take a backup on master
+--source include/ndb_backup.inc
+
+# update a row
+UPDATE t1 SET c2=0 WHERE c3="row2";
+SELECT hex(c1),hex(c2),c3 FROM t1 ORDER BY c3;
+
+# restore on slave, first check that nothing is there
+--connection slave
+
+# we should have no tables
+SHOW TABLES;
+
+--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults --ndb-connectstring="localhost:$NDBCLUSTER_PORT_SLAVE" -b $the_backup_id -n 1 -m -r --print --print_meta $NDB_BACKUP_DIR/BACKUP/BACKUP-$the_backup_id >> $NDB_TOOLS_OUTPUT
+--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults --ndb-connectstring="localhost:$NDBCLUSTER_PORT_SLAVE" -b $the_backup_id -n 2 -r -e --print --print_meta $NDB_BACKUP_DIR/BACKUP/BACKUP-$the_backup_id >> $NDB_TOOLS_OUTPUT
+
+#
+# BUG#11960
+# prior to bugfix "DROP DATABASE" would give a warning since
+# the events were not created by ndb_restore
+#
+DROP DATABASE ndbsynctest;
+CREATE DATABASE ndbsynctest;
+USE ndbsynctest;
+--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults --ndb-connectstring="localhost:$NDBCLUSTER_PORT_SLAVE" -b $the_backup_id -n 1 -m -r --print --print_meta $NDB_BACKUP_DIR/BACKUP/BACKUP-$the_backup_id >> $NDB_TOOLS_OUTPUT
+--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults --ndb-connectstring="localhost:$NDBCLUSTER_PORT_SLAVE" -b $the_backup_id -n 2 -r -e --print --print_meta $NDB_BACKUP_DIR/BACKUP/BACKUP-$the_backup_id >> $NDB_TOOLS_OUTPUT
+
+# continue test
+SHOW TABLES;
+
+SELECT hex(c1),hex(c2),c3 FROM t1 ORDER BY c3;
+SELECT hex(c2),hex(c3),c1 FROM t2 ORDER BY c1;
+
+#
+# now setup replication to continue from last epoch
+--source include/ndb_setup_slave.inc
+--connection slave
+START SLAVE;
+
+#
+#
+#
+--connection master
+--sync_slave_with_master
+--connection slave
+--replace_result $MASTER_MYPORT MASTER_PORT
+--replace_column 1 <Slave_IO_State> 7 <Read_Master_Log_Pos> 8 <Relay_Log_File> 9 <Relay_Log_Pos> 16 <Replicate_Ignore_Table> 22 <Exec_Master_Log_Pos> 23 <Relay_Log_Space> 33 <Seconds_Behind_Master>
+SHOW SLAVE STATUS;
+
+SELECT hex(c1),hex(c2),c3 FROM t1 ORDER BY c3;
+SELECT hex(c2),hex(c3),c1 FROM t2 ORDER BY c1;
+
+#
+# Cleanup
+#
+
+--connection master
+DROP DATABASE ndbsynctest;
+--sync_slave_with_master
+--connection slave
+STOP SLAVE;
+
+#
+# Test some replication commands
+#
+--connection master
+reset master;
+# should now contain nothing
+select * from cluster.binlog_index;
+
+--connection slave
+reset slave;
+# should now contain nothing
+select * from cluster.apply_status;
+
+# End 5.1 Test
diff --git a/mysql-test/t/rpl_ndb_trig004.test b/mysql-test/t/rpl_ndb_trig004.test
new file mode 100644
index 00000000000..7439da563a6
--- /dev/null
+++ b/mysql-test/t/rpl_ndb_trig004.test
@@ -0,0 +1,15 @@
+#############################################################################
+# Original Author: JBM #
+# Original Date: 2006-02-14 #
+#############################################################################
+# TEST: Use before insert triggers and has the second insert fail #
+# Test is wrapped to save code and share between engines #
+#############################################################################
+
+# Includes
+-- source include/have_binlog_format_row.inc
+-- source include/have_ndb.inc
+-- source include/master-slave.inc
+let $engine_type=NDB;
+-- source extra/rpl_tests/rpl_trig004.test
+
diff --git a/mysql-test/t/rpl_openssl.test b/mysql-test/t/rpl_openssl.test
index 7d769ad448e..00ae5c935bf 100644
--- a/mysql-test/t/rpl_openssl.test
+++ b/mysql-test/t/rpl_openssl.test
@@ -45,7 +45,7 @@ select * from t1;
#checking show slave status
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR $MASTER_MYPORT MASTER_MYPORT
---replace_column 1 # 8 # 9 # 23 # 33 #
+--replace_column 1 # 6 # 7 # 8 # 9 # 10 # 11 # 16 # 22 # 23 # 33 #
show slave status;
#checking if replication works without ssl also performing clean up
@@ -59,7 +59,7 @@ save_master_pos;
connection slave;
sync_with_master;
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR $MASTER_MYPORT MASTER_MYPORT
---replace_column 1 # 8 # 9 # 23 # 33 #
+--replace_column 1 # 6 # 7 # 8 # 9 # 10 # 11 # 16 # 22 # 23 # 33 #
show slave status;
# End of 4.1 tests
diff --git a/mysql-test/t/rpl_optimize.test b/mysql-test/t/rpl_optimize.test
index 6858f52abab..80f0c052fc8 100644
--- a/mysql-test/t/rpl_optimize.test
+++ b/mysql-test/t/rpl_optimize.test
@@ -1,8 +1,17 @@
# Test for BUG#1858 "OPTIMIZE TABLE done by a client
# thread stops the slave SQL thread".
# You can replace OPTIMIZE by REPAIR.
-
-source include/master-slave.inc;
+#####################################
+# 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);
diff --git a/mysql-test/t/rpl_ps.test b/mysql-test/t/rpl_ps.test
index adf39b1e4ab..b8792722192 100644
--- a/mysql-test/t/rpl_ps.test
+++ b/mysql-test/t/rpl_ps.test
@@ -1,6 +1,9 @@
#
# 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;
@@ -20,7 +23,7 @@ set @var1= "from-master-1";
execute stmt1 using @var1;
set @var1= "from-master-2-'',";
execute stmt1 using @var1;
-select * from t1;
+SELECT * FROM t1 ORDER BY n;
set @var2= 'insert into t1 values (concat("from-var-", ?))';
prepare stmt2 from @var2;
@@ -30,7 +33,7 @@ execute stmt2 using @var1;
save_master_pos;
connection slave;
sync_with_master;
-select * from t1;
+SELECT * FROM t1 ORDER BY n;
connection master;
@@ -42,3 +45,7 @@ sync_with_master;
stop slave;
# End of 4.1 tests
+
+reset master;
+reset slave;
+disconnect master;
diff --git a/mysql-test/t/rpl_rbr_to_sbr.test b/mysql-test/t/rpl_rbr_to_sbr.test
new file mode 100644
index 00000000000..f04caf05057
--- /dev/null
+++ b/mysql-test/t/rpl_rbr_to_sbr.test
@@ -0,0 +1,47 @@
+-- source include/have_binlog_format_statement.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;
+SELECT @@GLOBAL.BINLOG_FORMAT, @@SESSION.BINLOG_FORMAT;
+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 #
+--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
+
+--exec diff $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
+
+system rm $MYSQLTEST_VARDIR/tmp/rpl_rbr_to_sbr_master.sql;
+system rm $MYSQLTEST_VARDIR/tmp/rpl_rbr_to_sbr_slave.sql;
diff --git a/mysql-test/t/rpl_redirect.test b/mysql-test/t/rpl_redirect.test
index beb18348b40..078d1048794 100644
--- a/mysql-test/t/rpl_redirect.test
+++ b/mysql-test/t/rpl_redirect.test
@@ -14,7 +14,7 @@ sync_with_master;
#discover slaves
connection master;
--replace_result $MASTER_MYPORT MASTER_PORT
---replace_column 1 # 8 # 9 # 23 # 33 #
+--replace_column 1 # 8 # 9 # 16 # 23 # 33 #
SHOW SLAVE STATUS;
--replace_result $SLAVE_MYPORT SLAVE_PORT
SHOW SLAVE HOSTS;
@@ -32,14 +32,16 @@ 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;
-select * from t1;
+SELECT * FROM t1 ORDER BY n;
+SELECT * FROM t1 ORDER BY n;
disable_rpl_parse;
-select * from t1;
+SELECT * FROM t1 ORDER BY n;
connection slave;
-select * from t1;
-drop table t1;
+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/t/rpl_relay_space_innodb-master.opt b/mysql-test/t/rpl_relay_space_innodb-master.opt
new file mode 100644
index 00000000000..627becdbfb5
--- /dev/null
+++ b/mysql-test/t/rpl_relay_space_innodb-master.opt
@@ -0,0 +1 @@
+--innodb
diff --git a/mysql-test/t/rpl_relay_space_innodb-slave.opt b/mysql-test/t/rpl_relay_space_innodb-slave.opt
new file mode 100644
index 00000000000..627becdbfb5
--- /dev/null
+++ b/mysql-test/t/rpl_relay_space_innodb-slave.opt
@@ -0,0 +1 @@
+--innodb
diff --git a/mysql-test/t/rpl_relay_space_innodb.test b/mysql-test/t/rpl_relay_space_innodb.test
new file mode 100644
index 00000000000..156d53ef856
--- /dev/null
+++ b/mysql-test/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/t/rpl_relay_space_myisam.test b/mysql-test/t/rpl_relay_space_myisam.test
new file mode 100644
index 00000000000..1d8563e7fd9
--- /dev/null
+++ b/mysql-test/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/t/rpl_relayrotate.test b/mysql-test/t/rpl_relayrotate.test
index 04f03367e20..46d54aea1d2 100644
--- a/mysql-test/t/rpl_relayrotate.test
+++ b/mysql-test/t/rpl_relayrotate.test
@@ -1,75 +1,10 @@
-# When the relay log gets rotated while the I/O thread
-# is reading a transaction, the transaction spans on two or more
-# relay logs. If STOP SLAVE occurs while the SQL thread is
-# executing a part of the transaction in the non-first relay logs,
-# we test if START SLAVE will resume in the beginning of the
-# transaction (i.e., step back to the first relay log)
-
-# The slave is started with max_binlog_size=16384 bytes,
-# to force many rotations (approximately 30 rotations)
-
-source include/have_innodb.inc;
-source include/master-slave.inc;
-connection slave;
-stop slave;
-connection master;
---disable_warnings
-create table t1 (a int) engine=innodb;
---enable_warnings
-let $1=8000;
-disable_query_log;
-begin;
-while ($1)
-{
-# eval means expand $ expressions
- eval insert into t1 values( $1 );
- dec $1;
-}
-commit;
-# This will generate a 500kB master's binlog,
-# which corresponds to 30 slave's relay logs.
-enable_query_log;
-save_master_pos;
-connection slave;
-reset slave;
-start slave;
-# We wait 1 sec for the SQL thread to be somewhere in
-# the middle of the transaction, hopefully not in
-# the first relay log, and hopefully before the COMMIT.
-# Usually it stops when the SQL thread is around the 15th relay log.
-# We cannot use MASTER_POS_WAIT() as master's position
-# increases only when the slave executes the COMMIT.
-# Note that except when using Valgrind, 1 second is enough for the I/O slave
-# thread to fetch the whole master's binlog.
-sleep 1;
-stop slave;
-# We suppose the SQL thread stopped before COMMIT.
-# If so the transaction was rolled back
-# and the table is now empty.
-# Now restart
-start slave;
-# And see if the table contains '8000'
-# which proves that the transaction restarted at
-# the right place.
-# We must wait for the transaction to commit before
-# reading:
-sync_with_master;
-select max(a) from t1;
-connection master;
-
-# The following DROP is a very important cleaning task:
-# imagine the next test is run with --skip-innodb: it will do
-# DROP TABLE IF EXISTS t1; but this will delete the frm and leave
-# some data in the InnoDB datafile (because at that time mysqld
-# does not know about InnoDB : --skip-innodb). So if later in the
-# test suite a test wants to create an InnoDB table called t1, it
-# will fail with
-# InnoDB: Error: table t1 already exists in InnoDB internal
-# InnoDB: data dictionary. Have you deleted the .frm file etc
-drop table t1;
-# wait until this drop is executed on slave
-save_master_pos;
-connection slave;
-sync_with_master;
-
-# End of 4.1 tests
+#######################################################
+# 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
+let $engine_type=innodb;
+-- source extra/rpl_tests/rpl_relayrotate.test
diff --git a/mysql-test/t/rpl_replicate_do.test b/mysql-test/t/rpl_replicate_do.test
index 9dec8c06c79..e7141c3f905 100644
--- a/mysql-test/t/rpl_replicate_do.test
+++ b/mysql-test/t/rpl_replicate_do.test
@@ -1,6 +1,5 @@
# 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;
@@ -22,7 +21,7 @@ create table t11 select * from t1;
save_master_pos;
connection slave;
sync_with_master;
-select * from t1;
+select * from t1 ORDER BY m;
select * from t2;
--error 1146
select * from t11;
@@ -33,7 +32,7 @@ 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 # 8 # 9 # 23 # 33 #
+--replace_column 1 # 7 # 8 # 9 # 16 # 22 # 23 # 33 #
show slave status;
#
diff --git a/mysql-test/t/rpl_replicate_ignore_db-slave.opt b/mysql-test/t/rpl_replicate_ignore_db-slave.opt
new file mode 100644
index 00000000000..6e3aed44f78
--- /dev/null
+++ b/mysql-test/t/rpl_replicate_ignore_db-slave.opt
@@ -0,0 +1 @@
+--replicate_ignore_db=mysqltest1
diff --git a/mysql-test/t/rpl_replicate_ignore_db.test b/mysql-test/t/rpl_replicate_ignore_db.test
new file mode 100644
index 00000000000..bcfef919fad
--- /dev/null
+++ b/mysql-test/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/t/rpl_reset_slave.test b/mysql-test/t/rpl_reset_slave.test
deleted file mode 100644
index 00b1cf68294..00000000000
--- a/mysql-test/t/rpl_reset_slave.test
+++ /dev/null
@@ -1,51 +0,0 @@
-# See SHOW SLAVE STATUS displays well after RESET SLAVE (it should display the
-# --master-* options from mysqld, as this is what is going to be used next time
-# slave threads will be started). In bug 985, it displayed old values (of before
-# RESET SLAVE).
-# See if slave crashes when doing a CREATE TEMPORARY TABLE twice, separated by
-# RESET SLAVE.
-
-source include/master-slave.inc;
-connection master;
-save_master_pos;
-connection slave;
-sync_with_master;
---replace_result $MASTER_MYPORT MASTER_PORT
---replace_column 1 # 8 # 9 # 23 # 33 #
-show slave status;
-
-stop slave;
-change master to master_user='test';
---replace_result $MASTER_MYPORT MASTER_PORT
---replace_column 1 # 8 # 9 # 23 # 33 #
-show slave status;
-
-reset slave;
---replace_result $MASTER_MYPORT MASTER_PORT
---replace_column 1 # 8 # 9 # 23 # 33 #
-show slave status;
-
-start slave;
-sync_with_master;
---replace_result $MASTER_MYPORT MASTER_PORT
---replace_column 1 # 8 # 9 # 23 # 33 #
-show slave status;
-
-# test of crash with temp tables & RESET SLAVE
-# (test to see if RESET SLAVE clears temp tables in memory and disk)
-stop slave;
-reset slave;
-start slave;
-connection master;
-create temporary table t1 (a int);
-save_master_pos;
-connection slave;
-sync_with_master;
-stop slave;
-reset slave;
-start slave;
-sync_with_master;
-show status like 'slave_open_temp_tables';
-
-# End of 4.1 tests
-#
diff --git a/mysql-test/t/rpl_rewrite_db-slave.opt b/mysql-test/t/rpl_rewrt_db-slave.opt
index a462ad19ba0..a462ad19ba0 100644
--- a/mysql-test/t/rpl_rewrite_db-slave.opt
+++ b/mysql-test/t/rpl_rewrt_db-slave.opt
diff --git a/mysql-test/t/rpl_rewrite_db.test b/mysql-test/t/rpl_rewrt_db.test
index 6b8624aff39..8acc05f6ff5 100644
--- a/mysql-test/t/rpl_rewrite_db.test
+++ b/mysql-test/t/rpl_rewrt_db.test
@@ -1,4 +1,7 @@
-source include/master-slave.inc;
+# TBF - difference in row level logging
+-- source include/have_binlog_format_statement.inc
+-- source include/master-slave.inc
+
--disable_warnings
drop database if exists mysqltest1;
--enable_warnings
diff --git a/mysql-test/t/rpl_rotate_logs.test b/mysql-test/t/rpl_rotate_logs.test
index ee49f92910a..a5c8a87c74d 100644
--- a/mysql-test/t/rpl_rotate_logs.test
+++ b/mysql-test/t/rpl_rotate_logs.test
@@ -12,6 +12,9 @@
# changes
# - Test creating a duplicate key error and recover from it
+# Requires statement logging
+-- source include/have_binlog_format_statement.inc
+
connect (master,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK);
--disable_warnings
drop table if exists t1, t2, t3, t4;
@@ -59,7 +62,7 @@ create table t1 (s text);
insert into t1 values('Could not break slave'),('Tried hard');
sync_slave_with_master;
--replace_result $MASTER_MYPORT MASTER_PORT
---replace_column 1 # 8 # 9 # 23 # 33 #
+--replace_column 1 # 8 # 9 # 16 # 23 # 33 #
show slave status;
select * from t1;
connection master;
@@ -112,7 +115,7 @@ show binary logs;
insert into t2 values (65);
sync_slave_with_master;
--replace_result $MASTER_MYPORT MASTER_PORT
---replace_column 1 # 8 # 9 # 23 # 33 #
+--replace_column 1 # 8 # 9 # 16 # 23 # 33 #
show slave status;
select * from t2;
@@ -144,7 +147,7 @@ sync_with_master;
select * from t4;
--replace_result $MASTER_MYPORT MASTER_PORT
---replace_column 1 # 8 # 9 # 23 # 33 #
+--replace_column 1 # 8 # 9 # 16 # 23 # 33 #
show slave status;
# because of concurrent insert, the table may not be up to date
# if we do not lock
diff --git a/mysql-test/t/rpl_row_001.test b/mysql-test/t/rpl_row_001.test
new file mode 100644
index 00000000000..639c55362a5
--- /dev/null
+++ b/mysql-test/t/rpl_row_001.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_001.test
diff --git a/mysql-test/t/rpl_row_4_bytes-master.opt b/mysql-test/t/rpl_row_4_bytes-master.opt
new file mode 100644
index 00000000000..0e1929507f7
--- /dev/null
+++ b/mysql-test/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/t/rpl_row_4_bytes.test b/mysql-test/t/rpl_row_4_bytes.test
new file mode 100644
index 00000000000..73ef6dd2345
--- /dev/null
+++ b/mysql-test/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/t/rpl_row_NOW.test b/mysql-test/t/rpl_row_NOW.test
new file mode 100644
index 00000000000..24a8774284a
--- /dev/null
+++ b/mysql-test/t/rpl_row_NOW.test
@@ -0,0 +1,73 @@
+#############################################################################
+# 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;
+
+# 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
+
+exec diff $MYSQLTEST_VARDIR/tmp/NOW_master.sql $MYSQLTEST_VARDIR/tmp/NOW_slave.sql;
+
+# If all is good, when can cleanup our dump files.
+system rm $MYSQLTEST_VARDIR/tmp/NOW_master.sql;
+system rm $MYSQLTEST_VARDIR/tmp/NOW_slave.sql;
+
+sync_slave_with_master;
+# End of 5.1 test case
diff --git a/mysql-test/t/rpl_row_USER.test b/mysql-test/t/rpl_row_USER.test
new file mode 100644
index 00000000000..a099a35ec27
--- /dev/null
+++ b/mysql-test/t/rpl_row_USER.test
@@ -0,0 +1,58 @@
+#############################################################################
+# Original Author: JBM #
+# Original Date: Aug/18/2005 #
+#############################################################################
+# TEST: To test the UUID() 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%';
+
+sync_slave_with_master;
+
+# End of 5.0 test case
diff --git a/mysql-test/t/rpl_row_UUID.test b/mysql-test/t/rpl_row_UUID.test
new file mode 100644
index 00000000000..6ead7c2ee9b
--- /dev/null
+++ b/mysql-test/t/rpl_row_UUID.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_UUID.test
diff --git a/mysql-test/t/rpl_row_basic_11bugs-master.opt b/mysql-test/t/rpl_row_basic_11bugs-master.opt
new file mode 100644
index 00000000000..ad03cdaa6d1
--- /dev/null
+++ b/mysql-test/t/rpl_row_basic_11bugs-master.opt
@@ -0,0 +1 @@
+--binlog_ignore_db=test_ignore
diff --git a/mysql-test/t/rpl_row_basic_11bugs.test b/mysql-test/t/rpl_row_basic_11bugs.test
new file mode 100644
index 00000000000..3a686ea6b3d
--- /dev/null
+++ b/mysql-test/t/rpl_row_basic_11bugs.test
@@ -0,0 +1,38 @@
+--source include/have_row_based.inc
+--source include/have_binlog_format_row.inc
+
+
+#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);
+--replace_regex /table_id: [0-9]+/table_id: #/
+SHOW BINLOG EVENTS FROM 102;
+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;
diff --git a/mysql-test/t/rpl_row_basic_2myisam.test b/mysql-test/t/rpl_row_basic_2myisam.test
new file mode 100644
index 00000000000..471f4d6dbc5
--- /dev/null
+++ b/mysql-test/t/rpl_row_basic_2myisam.test
@@ -0,0 +1,3 @@
+let $type= 'MYISAM' ;
+let $extra_index= ;
+-- source include/rpl_row_basic.inc
diff --git a/mysql-test/t/rpl_row_basic_3innodb-slave.opt b/mysql-test/t/rpl_row_basic_3innodb-slave.opt
new file mode 100644
index 00000000000..627becdbfb5
--- /dev/null
+++ b/mysql-test/t/rpl_row_basic_3innodb-slave.opt
@@ -0,0 +1 @@
+--innodb
diff --git a/mysql-test/t/rpl_row_basic_3innodb.test b/mysql-test/t/rpl_row_basic_3innodb.test
new file mode 100644
index 00000000000..b97f1543cc3
--- /dev/null
+++ b/mysql-test/t/rpl_row_basic_3innodb.test
@@ -0,0 +1,6 @@
+-- source include/have_innodb.inc
+
+let $type= 'INNODB' ;
+let $extra_index= ;
+-- source include/rpl_row_basic.inc
+
diff --git a/mysql-test/t/rpl_row_basic_7ndb.test b/mysql-test/t/rpl_row_basic_7ndb.test
new file mode 100644
index 00000000000..d94b4d44dbb
--- /dev/null
+++ b/mysql-test/t/rpl_row_basic_7ndb.test
@@ -0,0 +1,4 @@
+-- source include/have_ndb.inc
+let $type= 'NDB' ;
+let $extra_index= ;
+-- source include/rpl_row_basic.inc
diff --git a/mysql-test/t/rpl_row_basic_8partition.test b/mysql-test/t/rpl_row_basic_8partition.test
new file mode 100644
index 00000000000..8cad2226d4a
--- /dev/null
+++ b/mysql-test/t/rpl_row_basic_8partition.test
@@ -0,0 +1,205 @@
+############################################################
+# 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_partition.inc
+--source include/master-slave.inc
+connection master;
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+SET BINLOG_FORMAT=ROW;
+
+--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/t/rpl_row_blob_innodb-slave.opt b/mysql-test/t/rpl_row_blob_innodb-slave.opt
new file mode 100644
index 00000000000..627becdbfb5
--- /dev/null
+++ b/mysql-test/t/rpl_row_blob_innodb-slave.opt
@@ -0,0 +1 @@
+--innodb
diff --git a/mysql-test/t/rpl_row_blob_innodb.test b/mysql-test/t/rpl_row_blob_innodb.test
new file mode 100644
index 00000000000..0bce657f9f9
--- /dev/null
+++ b/mysql-test/t/rpl_row_blob_innodb.test
@@ -0,0 +1,12 @@
+#################################
+# 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
+let $engine_type=InnoDB;
+-- source extra/rpl_tests/rpl_row_blob.test
+
diff --git a/mysql-test/t/rpl_row_blob_myisam.test b/mysql-test/t/rpl_row_blob_myisam.test
new file mode 100644
index 00000000000..a470c36f9f8
--- /dev/null
+++ b/mysql-test/t/rpl_row_blob_myisam.test
@@ -0,0 +1,11 @@
+#################################
+# 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
+let $engine_type=myisam;
+-- source extra/rpl_tests/rpl_row_blob.test
+
diff --git a/mysql-test/t/rpl_row_charset.test b/mysql-test/t/rpl_row_charset.test
new file mode 100644
index 00000000000..9737c52c70f
--- /dev/null
+++ b/mysql-test/t/rpl_row_charset.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_charset.test
diff --git a/mysql-test/t/rpl_row_create_table.test b/mysql-test/t/rpl_row_create_table.test
new file mode 100644
index 00000000000..0cb0fd766a3
--- /dev/null
+++ b/mysql-test/t/rpl_row_create_table.test
@@ -0,0 +1,119 @@
+# Testing table creations for row-based replication.
+
+--source include/have_binlog_format_row.inc
+--source include/master-slave.inc
+
+# 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.
+connection slave;
+--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 # 5 #
+--replace_regex /table_id: [0-9]+/table_id: #/
+--query_vertical SHOW BINLOG EVENTS FROM 212
+--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 1062
+CREATE TABLE t7 (UNIQUE(b)) SELECT a,b FROM tt3;
+# Shouldn't be written to the binary log
+--replace_regex /table_id: [0-9]+/table_id: #/
+SHOW BINLOG EVENTS FROM 1326;
+
+# Test that INSERT-SELECT works the same way as for SBR.
+CREATE TABLE t7 (a INT, b INT UNIQUE);
+--error 1062
+INSERT INTO t7 SELECT a,b FROM tt3;
+SELECT * FROM t7 ORDER BY a,b;
+# Should be written to the binary log
+--replace_regex /table_id: [0-9]+/table_id: #/
+SHOW BINLOG EVENTS FROM 1326;
+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_regex /table_id: [0-9]+/table_id: #/
+SHOW BINLOG EVENTS FROM 1522;
+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;
+--echo **** On Master ****
+--query_vertical SHOW CREATE TABLE t8
+--query_vertical SHOW CREATE TABLE t9
+--replace_regex /table_id: [0-9]+/table_id: #/
+SHOW BINLOG EVENTS FROM 1618;
+sync_slave_with_master;
+--echo **** On Slave ****
+--query_vertical SHOW CREATE TABLE t8
+--query_vertical SHOW CREATE TABLE t9
+
+connection master;
+--disable_query_log
+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_query_log
+--enable_ps_protocol
diff --git a/mysql-test/t/rpl_row_delayed_ins.test b/mysql-test/t/rpl_row_delayed_ins.test
new file mode 100644
index 00000000000..a0e74567349
--- /dev/null
+++ b/mysql-test/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/t/rpl_row_drop.test b/mysql-test/t/rpl_row_drop.test
new file mode 100644
index 00000000000..20c217a7c3a
--- /dev/null
+++ b/mysql-test/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/t/rpl_row_err_daisychain-master.opt b/mysql-test/t/rpl_row_err_daisychain-master.opt
new file mode 100644
index 00000000000..83ed8522e72
--- /dev/null
+++ b/mysql-test/t/rpl_row_err_daisychain-master.opt
@@ -0,0 +1 @@
+--binlog-format=row
diff --git a/mysql-test/t/rpl_row_err_daisychain-slave.opt b/mysql-test/t/rpl_row_err_daisychain-slave.opt
new file mode 100644
index 00000000000..4cb7a31da81
--- /dev/null
+++ b/mysql-test/t/rpl_row_err_daisychain-slave.opt
@@ -0,0 +1 @@
+--binlog-format=statement --log-slave-updates
diff --git a/mysql-test/t/rpl_row_flsh_tbls.test b/mysql-test/t/rpl_row_flsh_tbls.test
new file mode 100644
index 00000000000..9e8efc1ac9c
--- /dev/null
+++ b/mysql-test/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= 615;
+
+# 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/t/rpl_row_func001.test b/mysql-test/t/rpl_row_func001.test
new file mode 100644
index 00000000000..53fb55118e6
--- /dev/null
+++ b/mysql-test/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/t/rpl_row_func002.test b/mysql-test/t/rpl_row_func002.test
new file mode 100644
index 00000000000..46767abd529
--- /dev/null
+++ b/mysql-test/t/rpl_row_func002.test
@@ -0,0 +1,103 @@
+#############################################################################
+# 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;
+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
+
+exec diff $MYSQLTEST_VARDIR/tmp/func002_master.sql $MYSQLTEST_VARDIR/tmp/func002_slave.sql;
+
+# End of 5.0 test case
+
diff --git a/mysql-test/t/rpl_row_func003-slave.opt b/mysql-test/t/rpl_row_func003-slave.opt
new file mode 100644
index 00000000000..627becdbfb5
--- /dev/null
+++ b/mysql-test/t/rpl_row_func003-slave.opt
@@ -0,0 +1 @@
+--innodb
diff --git a/mysql-test/t/rpl_row_func003.test b/mysql-test/t/rpl_row_func003.test
new file mode 100644
index 00000000000..abfadfe1a1a
--- /dev/null
+++ b/mysql-test/t/rpl_row_func003.test
@@ -0,0 +1,11 @@
+###################################
+# 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
+let $engine_type=INNODB;
+-- source extra/rpl_tests/rpl_row_func003.test
diff --git a/mysql-test/t/rpl_row_inexist_tbl.test b/mysql-test/t/rpl_row_inexist_tbl.test
new file mode 100644
index 00000000000..e77ea216571
--- /dev/null
+++ b/mysql-test/t/rpl_row_inexist_tbl.test
@@ -0,0 +1,27 @@
+# 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);
+sync_slave_with_master;
+drop table t1;
+
+connection master;
+insert into t1 values (1);
+insert into t1 values (2);
+
+connection slave;
+# slave should have stopped because can't find table
+wait_for_slave_to_stop;
+# see if we have a good error message:
+--replace_result $MASTER_MYPORT MASTER_MYPORT
+--replace_column 1 # 7 # 8 # 9 # 23 # 33 #
+--vertical_results
+show slave status;
+
+# cleanup
+connection master;
+drop table t1;
diff --git a/mysql-test/t/rpl_row_log-master.opt b/mysql-test/t/rpl_row_log-master.opt
new file mode 100644
index 00000000000..e0d075c3fbd
--- /dev/null
+++ b/mysql-test/t/rpl_row_log-master.opt
@@ -0,0 +1 @@
+--skip-external-locking
diff --git a/mysql-test/t/rpl_log-slave.opt b/mysql-test/t/rpl_row_log-slave.opt
index 8b137891791..8b137891791 100644
--- a/mysql-test/t/rpl_log-slave.opt
+++ b/mysql-test/t/rpl_row_log-slave.opt
diff --git a/mysql-test/t/rpl_row_log.test b/mysql-test/t/rpl_row_log.test
new file mode 100644
index 00000000000..3253ae9ecba
--- /dev/null
+++ b/mysql-test/t/rpl_row_log.test
@@ -0,0 +1,16 @@
+###################################
+# 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
+let $engine_type=MyISAM;
+-- source extra/rpl_tests/rpl_log.test
+
diff --git a/mysql-test/t/rpl_row_log_innodb-master.opt b/mysql-test/t/rpl_row_log_innodb-master.opt
new file mode 100644
index 00000000000..e0d075c3fbd
--- /dev/null
+++ b/mysql-test/t/rpl_row_log_innodb-master.opt
@@ -0,0 +1 @@
+--skip-external-locking
diff --git a/mysql-test/t/rpl_row_log_innodb-slave.opt b/mysql-test/t/rpl_row_log_innodb-slave.opt
new file mode 100644
index 00000000000..627becdbfb5
--- /dev/null
+++ b/mysql-test/t/rpl_row_log_innodb-slave.opt
@@ -0,0 +1 @@
+--innodb
diff --git a/mysql-test/t/rpl_row_log_innodb.test b/mysql-test/t/rpl_row_log_innodb.test
new file mode 100644
index 00000000000..5e5182e3519
--- /dev/null
+++ b/mysql-test/t/rpl_row_log_innodb.test
@@ -0,0 +1,13 @@
+###################################
+# 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
+let $engine_type=InnoDB;
+-- source extra/rpl_tests/rpl_log.test
+
diff --git a/mysql-test/t/rpl_row_max_relay_size.test b/mysql-test/t/rpl_row_max_relay_size.test
new file mode 100644
index 00000000000..7e5f1145801
--- /dev/null
+++ b/mysql-test/t/rpl_row_max_relay_size.test
@@ -0,0 +1,10 @@
+# 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
+-- source include/have_binlog_format_row.inc
+-- source extra/rpl_tests/rpl_max_relay_size.test
+
diff --git a/mysql-test/t/rpl_row_mysqlbinlog-master.opt b/mysql-test/t/rpl_row_mysqlbinlog-master.opt
new file mode 100644
index 00000000000..07d12817f5f
--- /dev/null
+++ b/mysql-test/t/rpl_row_mysqlbinlog-master.opt
@@ -0,0 +1 @@
+--max-binlog-size=1040384
diff --git a/mysql-test/t/rpl_row_mysqlbinlog.test b/mysql-test/t/rpl_row_mysqlbinlog.test
new file mode 100644
index 00000000000..3b4c8db86d8
--- /dev/null
+++ b/mysql-test/t/rpl_row_mysqlbinlog.test
@@ -0,0 +1,319 @@
+##################################################################
+# 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
+
+# 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 412, 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=412 $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
+################### Start 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=412 - < $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;
+DROP TABLE IF EXISTS t1, t2, t3, t04, t05, t4, t5;
+sync_slave_with_master;
+
+# End of 4.1 tests
diff --git a/mysql-test/t/rpl_row_mystery22.test b/mysql-test/t/rpl_row_mystery22.test
new file mode 100644
index 00000000000..9933fec22fc
--- /dev/null
+++ b/mysql-test/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/t/rpl_row_reset_slave.test b/mysql-test/t/rpl_row_reset_slave.test
new file mode 100644
index 00000000000..a970c161153
--- /dev/null
+++ b/mysql-test/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/t/rpl_row_sp001.test b/mysql-test/t/rpl_row_sp001.test
new file mode 100644
index 00000000000..8e01cbc4f44
--- /dev/null
+++ b/mysql-test/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
+
+--exec diff $MYSQLTEST_VARDIR/tmp/sp001_master.sql $MYSQLTEST_VARDIR/tmp/sp001_slave.sql;
+
+# If all is good, when can cleanup our dump files.
+system rm $MYSQLTEST_VARDIR/tmp/sp001_master.sql;
+system rm $MYSQLTEST_VARDIR/tmp/sp001_slave.sql;
+
+# End of 5.0 test case
diff --git a/mysql-test/t/rpl_row_sp002_innodb-master.opt b/mysql-test/t/rpl_row_sp002_innodb-master.opt
new file mode 100644
index 00000000000..627becdbfb5
--- /dev/null
+++ b/mysql-test/t/rpl_row_sp002_innodb-master.opt
@@ -0,0 +1 @@
+--innodb
diff --git a/mysql-test/t/rpl_row_sp002_innodb-slave.opt b/mysql-test/t/rpl_row_sp002_innodb-slave.opt
new file mode 100644
index 00000000000..627becdbfb5
--- /dev/null
+++ b/mysql-test/t/rpl_row_sp002_innodb-slave.opt
@@ -0,0 +1 @@
+--innodb
diff --git a/mysql-test/t/rpl_row_sp002_innodb.test b/mysql-test/t/rpl_row_sp002_innodb.test
new file mode 100644
index 00000000000..e272e34e715
--- /dev/null
+++ b/mysql-test/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/t/rpl_row_sp003-master.opt b/mysql-test/t/rpl_row_sp003-master.opt
new file mode 100644
index 00000000000..627becdbfb5
--- /dev/null
+++ b/mysql-test/t/rpl_row_sp003-master.opt
@@ -0,0 +1 @@
+--innodb
diff --git a/mysql-test/t/rpl_row_sp003-slave.opt b/mysql-test/t/rpl_row_sp003-slave.opt
new file mode 100644
index 00000000000..627becdbfb5
--- /dev/null
+++ b/mysql-test/t/rpl_row_sp003-slave.opt
@@ -0,0 +1 @@
+--innodb
diff --git a/mysql-test/t/rpl_row_sp003.test b/mysql-test/t/rpl_row_sp003.test
new file mode 100644
index 00000000000..99b30253c8a
--- /dev/null
+++ b/mysql-test/t/rpl_row_sp003.test
@@ -0,0 +1,11 @@
+#################################
+# 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
+let $engine_type=INNODB;
+-- source extra/rpl_tests/rpl_row_sp003.test
diff --git a/mysql-test/t/rpl_row_sp005.test b/mysql-test/t/rpl_row_sp005.test
new file mode 100644
index 00000000000..054fa02f514
--- /dev/null
+++ b/mysql-test/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/t/rpl_row_sp006_InnoDB-slave.opt b/mysql-test/t/rpl_row_sp006_InnoDB-slave.opt
new file mode 100644
index 00000000000..627becdbfb5
--- /dev/null
+++ b/mysql-test/t/rpl_row_sp006_InnoDB-slave.opt
@@ -0,0 +1 @@
+--innodb
diff --git a/mysql-test/t/rpl_row_sp006_InnoDB.test b/mysql-test/t/rpl_row_sp006_InnoDB.test
new file mode 100644
index 00000000000..f7e59440027
--- /dev/null
+++ b/mysql-test/t/rpl_row_sp006_InnoDB.test
@@ -0,0 +1,11 @@
+#################################
+# 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
+let $engine_type=InnoDB;
+-- source extra/rpl_tests/rpl_row_sp006.test
diff --git a/mysql-test/t/rpl_row_sp007_innodb-slave.opt b/mysql-test/t/rpl_row_sp007_innodb-slave.opt
new file mode 100644
index 00000000000..627becdbfb5
--- /dev/null
+++ b/mysql-test/t/rpl_row_sp007_innodb-slave.opt
@@ -0,0 +1 @@
+--innodb
diff --git a/mysql-test/t/rpl_row_sp007_innodb.test b/mysql-test/t/rpl_row_sp007_innodb.test
new file mode 100644
index 00000000000..41af5a5f997
--- /dev/null
+++ b/mysql-test/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/t/rpl_row_sp008.test b/mysql-test/t/rpl_row_sp008.test
new file mode 100644
index 00000000000..8e8e709a2d9
--- /dev/null
+++ b/mysql-test/t/rpl_row_sp008.test
@@ -0,0 +1,56 @@
+#############################################################################
+# 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;
+sync_slave_with_master;
+
+# End of 5.0 test case
diff --git a/mysql-test/t/rpl_row_sp009.test b/mysql-test/t/rpl_row_sp009.test
new file mode 100644
index 00000000000..92d47c6f50f
--- /dev/null
+++ b/mysql-test/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/t/rpl_row_sp010.test b/mysql-test/t/rpl_row_sp010.test
new file mode 100644
index 00000000000..28b82217517
--- /dev/null
+++ b/mysql-test/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/t/rpl_row_sp011.test b/mysql-test/t/rpl_row_sp011.test
new file mode 100644
index 00000000000..54e708492d1
--- /dev/null
+++ b/mysql-test/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
+
+exec diff $MYSQLTEST_VARDIR/tmp/sp011_master.sql $MYSQLTEST_VARDIR/tmp/sp011_slave.sql;
+
+# If all is good, when can cleanup our dump files.
+system rm $MYSQLTEST_VARDIR/tmp/sp011_master.sql;
+system rm $MYSQLTEST_VARDIR/tmp/sp011_slave.sql;
+
+# End of 5.0 test case
diff --git a/mysql-test/t/rpl_row_sp012.test b/mysql-test/t/rpl_row_sp012.test
new file mode 100644
index 00000000000..5b6fc139577
--- /dev/null
+++ b/mysql-test/t/rpl_row_sp012.test
@@ -0,0 +1,74 @@
+#############################################################################
+# 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;
+sync_slave_with_master;
+
+# End of 5.0 test case
+
diff --git a/mysql-test/t/rpl_row_stop_middle.test b/mysql-test/t/rpl_row_stop_middle.test
new file mode 100644
index 00000000000..553a026e5e7
--- /dev/null
+++ b/mysql-test/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/t/rpl_row_stop_middle_update-master.opt b/mysql-test/t/rpl_row_stop_middle_update-master.opt
new file mode 100644
index 00000000000..b7db8f97bdd
--- /dev/null
+++ b/mysql-test/t/rpl_row_stop_middle_update-master.opt
@@ -0,0 +1 @@
+--loose-binlog-row-event-max-size=256
diff --git a/mysql-test/t/rpl_row_stop_middle_update-slave.opt b/mysql-test/t/rpl_row_stop_middle_update-slave.opt
new file mode 100644
index 00000000000..ea49a27adf4
--- /dev/null
+++ b/mysql-test/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/t/rpl_row_stop_middle_update.test b/mysql-test/t/rpl_row_stop_middle_update.test
new file mode 100644
index 00000000000..29b3008e822
--- /dev/null
+++ b/mysql-test/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/t/rpl_row_trig001.test b/mysql-test/t/rpl_row_trig001.test
new file mode 100644
index 00000000000..931cab95948
--- /dev/null
+++ b/mysql-test/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
+
+exec diff $MYSQLTEST_VARDIR/tmp/trig001_master.sql $MYSQLTEST_VARDIR/tmp/trig001_slave.sql;
+
+# End of 5.0 test case
diff --git a/mysql-test/t/rpl_row_trig002.test b/mysql-test/t/rpl_row_trig002.test
new file mode 100644
index 00000000000..7ca8a68f060
--- /dev/null
+++ b/mysql-test/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/t/rpl_row_trig003.test b/mysql-test/t/rpl_row_trig003.test
new file mode 100644
index 00000000000..d4570afd094
--- /dev/null
+++ b/mysql-test/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
+
+exec diff $MYSQLTEST_VARDIR/tmp/trg003_master.sql $MYSQLTEST_VARDIR/tmp/trg003_slave.sql;
+
+# End of 5.0 test case
diff --git a/mysql-test/t/rpl_row_trig004.test b/mysql-test/t/rpl_row_trig004.test
new file mode 100644
index 00000000000..a918c602d56
--- /dev/null
+++ b/mysql-test/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/t/rpl_row_until.test b/mysql-test/t/rpl_row_until.test
new file mode 100644
index 00000000000..f2a4229cdc4
--- /dev/null
+++ b/mysql-test/t/rpl_row_until.test
@@ -0,0 +1,87 @@
+-- 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;
+sleep 2;
+wait_for_slave_to_stop;
+# here table should be still not deleted
+select * from t1;
+--replace_result $MASTER_MYPORT MASTER_MYPORT
+--replace_column 1 # 9 # 11 # 23 # 33 #
+show slave status;
+
+# this should fail right after start
+start slave until master_log_file='master-no-such-bin.000001', master_log_pos=291;
+# again this table should be still not deleted
+select * from t1;
+sleep 2;
+wait_for_slave_to_stop;
+--replace_result $MASTER_MYPORT MASTER_MYPORT
+--replace_column 1 # 9 # 11 # 23 # 33 #
+show slave status;
+
+# 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;
+sleep 2;
+wait_for_slave_to_stop;
+select * from t2;
+--replace_result $MASTER_MYPORT MASTER_MYPORT
+--replace_column 1 # 9 # 11 # 23 # 33 #
+show slave status;
+
+# 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;
+sleep 2;
+wait_for_slave_to_stop;
+# here the sql slave thread should be stopped
+--replace_result $MASTER_MYPORT MASTER_MYPORT bin.000005 bin.000004 bin.000006 bin.000004 bin.000007 bin.000004
+--replace_column 1 # 9 # 23 # 33 #
+show slave status;
+
+#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/t/rpl_row_view01.test b/mysql-test/t/rpl_row_view01.test
new file mode 100644
index 00000000000..895a922fef8
--- /dev/null
+++ b/mysql-test/t/rpl_row_view01.test
@@ -0,0 +1,88 @@
+#############################################################################
+# 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;
+sync_slave_with_master;
+
+# End of 5.1 test case
+
diff --git a/mysql-test/t/rpl_server_id1.test b/mysql-test/t/rpl_server_id1.test
index 3583f05284c..71310750b60 100644
--- a/mysql-test/t/rpl_server_id1.test
+++ b/mysql-test/t/rpl_server_id1.test
@@ -13,7 +13,7 @@ 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 #
+--replace_column 16 # 18 #
show slave status;
start slave;
insert into t1 values (1);
diff --git a/mysql-test/t/rpl_skip_error.test b/mysql-test/t/rpl_skip_error.test
index f6fc73f58f2..ff81e2f010e 100644
--- a/mysql-test/t/rpl_skip_error.test
+++ b/mysql-test/t/rpl_skip_error.test
@@ -1,3 +1,7 @@
+##########################################
+# 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);
@@ -6,14 +10,20 @@ 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;
+select * from t1 ORDER BY n;
+# Cleanup
connection master;
drop table t1;
-sync_with_master;
+sync_slave_with_master;
+
# End of 4.1 tests
diff --git a/mysql-test/t/rpl_slave_status.test b/mysql-test/t/rpl_slave_status.test
index 985cebabe7e..a4a276b63d6 100644
--- a/mysql-test/t/rpl_slave_status.test
+++ b/mysql-test/t/rpl_slave_status.test
@@ -1,11 +1,21 @@
-# Test case for BUG #10780
--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;
@@ -16,12 +26,19 @@ 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"
@@ -29,8 +46,12 @@ start slave;
--vertical_results
show slave status;
+# Cleanup (Note that slave IO thread is not running)
+connection slave;
+drop table t1;
connection master;
drop table t1;
-sync_with_master;
+
+# end of test case for BUG#10780
# end of 4.1 tests
diff --git a/mysql-test/t/rpl_sp.test b/mysql-test/t/rpl_sp.test
index 8be17be3822..f9072b5a711 100644
--- a/mysql-test/t/rpl_sp.test
+++ b/mysql-test/t/rpl_sp.test
@@ -1,3 +1,5 @@
+# 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.
@@ -339,7 +341,8 @@ drop trigger trg;
insert into t1 values (1);
select * from t1;
--replace_column 2 # 5 #
-show binlog events in 'master-bin.000001' from 98;
+--replace_regex /table_id: [0-9]+/table_id: #/
+show binlog events in 'master-bin.000001' from 102;
sync_slave_with_master;
select * from t1;
@@ -425,17 +428,10 @@ CALL p1('test');
SELECT * FROM t1;
sync_slave_with_master;
-connection slave;
-
SELECT * FROM t1;
-# Cleanup.
-
+# Cleanup
connection master;
-
DROP PROCEDURE p1;
-
-# cleanup
-connection master;
drop table t1;
sync_slave_with_master;
diff --git a/mysql-test/t/rpl_sp004.test b/mysql-test/t/rpl_sp004.test
new file mode 100644
index 00000000000..055a13cc157
--- /dev/null
+++ b/mysql-test/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.
+
+-- exec diff $MYSQLTEST_VARDIR/tmp/sp004_master.sql $MYSQLTEST_VARDIR/tmp/sp004_slave.sql
+
+
+# End of 5.0 test case
diff --git a/mysql-test/t/rpl_sp_effects.test b/mysql-test/t/rpl_sp_effects.test
index 9da5723b993..40c9a5d0b74 100644
--- a/mysql-test/t/rpl_sp_effects.test
+++ b/mysql-test/t/rpl_sp_effects.test
@@ -1,6 +1,11 @@
-# Test of replication of stored procedures (WL#2146 for MySQL 5.0)
+##########################################
+# Change Author: JBM
+# Change Date: 2006-05-02
+# Change: Added Order By for NDB testing
+##########################################
-source include/master-slave.inc;
+# Test of replication of stored procedures (WL#2146 for MySQL 5.0)
+-- source include/master-slave.inc
# ****************************************************************
connection master;
@@ -31,9 +36,9 @@ call p1();
sync_slave_with_master;
connection slave;
-select * from t1;
+SELECT * FROM t1 ORDER BY a;
connection master;
-delete from t1;
+SELECT * FROM t1 ORDER BY a;
# 2. Test SP variable name
delimiter //;
@@ -45,10 +50,10 @@ end//
delimiter ;//
call p2();
-select * from t2;
+SELECT * FROM t2 ORDER BY a;
sync_slave_with_master;
connection slave;
-select * from t2;
+SELECT * FROM t2 ORDER BY a;
connection master;
drop procedure p1;
@@ -79,19 +84,19 @@ end//
delimiter ;//
call p1(f1(1), f1(2));
-select * from t1;
+SELECT * FROM t1 ORDER BY a;
create table t2(a int);
insert into t2 values (10),(11);
-select a,f1(a) from t2;
+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;
+SELECT 'master:',a FROM t1 ORDER BY a;
sync_slave_with_master;
connection slave;
-select 'slave:',a from t1;
+SELECT 'slave:',a FROM t1 ORDER BY a;
connection master;
drop procedure p1;
@@ -103,11 +108,11 @@ delete from t1;
insert into t2 values(1),(2);
create view v1 as select f1(a) from t2;
select * from v1;
-select 'master:',a from t1;
+SELECT 'master:',a FROM t1 ORDER BY a;
sync_slave_with_master;
connection slave;
-select 'slave:',a from t1;
+SELECT 'slave:',a FROM t1 ORDER BY a;
connection master;
drop view v1;
@@ -117,11 +122,11 @@ delete from t1;
prepare s1 from 'select f1(?)';
set @xx=123;
execute s1 using @xx;
-select 'master:',a from t1;
+SELECT 'master:',a FROM t1 ORDER BY a;
sync_slave_with_master;
connection slave;
-select 'slave:',a from t1;
+SELECT 'slave:',a FROM t1 ORDER BY a;
connection master;
delete from t1;
@@ -140,12 +145,11 @@ begin
end while;
end//
delimiter ;//
-
call p1(15);
-select 'master:',a from t1;
+SELECT 'master:',a FROM t1 ORDER BY a;
sync_slave_with_master;
connection slave;
-select 'slave:',a from t1;
+SELECT 'slave:',a FROM t1 ORDER BY a;
connection master;
drop procedure p1;
@@ -190,10 +194,10 @@ select f1();
set @x=30;
call p1();
-select 'master', a from t1;
+SELECT 'master', a FROM t1 ORDER BY a;
sync_slave_with_master;
connection slave;
-select 'slave', a from t1;
+SELECT 'slave', a FROM t1 ORDER BY a;
connection master;
drop table t1;
diff --git a/mysql-test/t/rpl_sporadic_master.test b/mysql-test/t/rpl_sporadic_master.test
index 26b633a1c4f..824f7abc9f5 100644
--- a/mysql-test/t/rpl_sporadic_master.test
+++ b/mysql-test/t/rpl_sporadic_master.test
@@ -1,3 +1,6 @@
+#############################################################
+# 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
@@ -18,7 +21,7 @@ flush logs;
truncate table t1;
insert into t1 values (10),(NULL),(NULL),(NULL),(NULL),(NULL);
sync_slave_with_master;
-select * from t1;
+select * from t1 ORDER BY n;
connection master;
drop table t1,t2;
sync_slave_with_master;
diff --git a/mysql-test/t/rpl_stm_000001-slave.opt b/mysql-test/t/rpl_stm_000001-slave.opt
new file mode 100644
index 00000000000..627becdbfb5
--- /dev/null
+++ b/mysql-test/t/rpl_stm_000001-slave.opt
@@ -0,0 +1 @@
+--innodb
diff --git a/mysql-test/t/rpl_stm_000001.test b/mysql-test/t/rpl_stm_000001.test
new file mode 100644
index 00000000000..aee067b2d4a
--- /dev/null
+++ b/mysql-test/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/t/rpl_stm_EE_err2.test b/mysql-test/t/rpl_stm_EE_err2.test
new file mode 100644
index 00000000000..dbcc66686ec
--- /dev/null
+++ b/mysql-test/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_statement.inc
+let $engine_type=myisam;
+-- source extra/rpl_tests/rpl_stm_EE_err2.test
diff --git a/mysql-test/t/rpl_stm_charset.test b/mysql-test/t/rpl_stm_charset.test
new file mode 100644
index 00000000000..b103a47d78c
--- /dev/null
+++ b/mysql-test/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/t/rpl_stm_flsh_tbls.test b/mysql-test/t/rpl_stm_flsh_tbls.test
new file mode 100644
index 00000000000..3a6102de279
--- /dev/null
+++ b/mysql-test/t/rpl_stm_flsh_tbls.test
@@ -0,0 +1,8 @@
+# depends on the binlog output
+--source include/have_binlog_format_statement.inc
+
+let $rename_event_pos= 652;
+-- 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/t/rpl_stm_log-master.opt b/mysql-test/t/rpl_stm_log-master.opt
new file mode 100644
index 00000000000..e0d075c3fbd
--- /dev/null
+++ b/mysql-test/t/rpl_stm_log-master.opt
@@ -0,0 +1 @@
+--skip-external-locking
diff --git a/mysql-test/t/rpl_stm_log-slave.opt b/mysql-test/t/rpl_stm_log-slave.opt
new file mode 100644
index 00000000000..8b137891791
--- /dev/null
+++ b/mysql-test/t/rpl_stm_log-slave.opt
@@ -0,0 +1 @@
+
diff --git a/mysql-test/t/rpl_stm_log.test b/mysql-test/t/rpl_stm_log.test
new file mode 100644
index 00000000000..d11e1fd8ac1
--- /dev/null
+++ b/mysql-test/t/rpl_stm_log.test
@@ -0,0 +1,8 @@
+# Requires statement logging
+-- source include/have_binlog_format_statement.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/t/rpl_stm_max_relay_size.test b/mysql-test/t/rpl_stm_max_relay_size.test
new file mode 100644
index 00000000000..50008533388
--- /dev/null
+++ b/mysql-test/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_statement.inc
+-- source extra/rpl_tests/rpl_max_relay_size.test
+
+# End of 4.1 tests
+#
diff --git a/mysql-test/t/rpl_stm_multi_query.test b/mysql-test/t/rpl_stm_multi_query.test
new file mode 100644
index 00000000000..97c322ac780
--- /dev/null
+++ b/mysql-test/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_statement.inc
+-- source extra/rpl_tests/rpl_multi_query.test
+
+
+# End of 4.1 tests
+#
diff --git a/mysql-test/t/rpl_stm_mystery22.test b/mysql-test/t/rpl_stm_mystery22.test
new file mode 100644
index 00000000000..a43f2610350
--- /dev/null
+++ b/mysql-test/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_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/t/rpl_stm_no_op.test b/mysql-test/t/rpl_stm_no_op.test
new file mode 100644
index 00000000000..d1e0b49abe9
--- /dev/null
+++ b/mysql-test/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_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;
+sync_slave_with_master;
diff --git a/mysql-test/t/rpl_stm_reset_slave.test b/mysql-test/t/rpl_stm_reset_slave.test
new file mode 100644
index 00000000000..282033bf6d1
--- /dev/null
+++ b/mysql-test/t/rpl_stm_reset_slave.test
@@ -0,0 +1,6 @@
+# TBF - difference in row level logging
+-- source include/have_binlog_format_statement.inc
+-- source extra/rpl_tests/rpl_reset_slave.test
+
+# End of 4.1 tests
+#
diff --git a/mysql-test/t/rpl_until.test b/mysql-test/t/rpl_stm_until.test
index c404ea7e58b..9a4e4471fe1 100644
--- a/mysql-test/t/rpl_until.test
+++ b/mysql-test/t/rpl_stm_until.test
@@ -1,4 +1,7 @@
-source include/master-slave.inc;
+-- source include/have_binlog_format_statement.inc
+-- source include/master-slave.inc
+
+# Test is dependent on binlog positions
# prepare version for substitutions
let $VERSION=`select version()`;
@@ -19,12 +22,10 @@ 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;
---replace_result $VERSION VERSION
-show binlog events;
# try to replicate all queries until drop of t1
connection slave;
-start slave until master_log_file='master-bin.000001', master_log_pos=319;
+start slave until master_log_file='master-bin.000001', master_log_pos=323;
sleep 2;
wait_for_slave_to_stop;
# here table should be still not deleted
@@ -43,7 +44,7 @@ wait_for_slave_to_stop;
--replace_column 1 # 9 # 11 # 23 # 33 #
--query_vertical SHOW SLAVE STATUS
-# try replicate all until second insert to t2;
+# 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;
sleep 2;
wait_for_slave_to_stop;
diff --git a/mysql-test/t/rpl_switch_stm_row_mixed.test b/mysql-test/t/rpl_switch_stm_row_mixed.test
new file mode 100644
index 00000000000..4a79b3995c4
--- /dev/null
+++ b/mysql-test/t/rpl_switch_stm_row_mixed.test
@@ -0,0 +1,216 @@
+-- source include/have_binlog_format_row.inc
+-- source include/master-slave.inc
+
+connection master;
+--disable_warnings
+drop database if exists mysqltest1;
+create database mysqltest1;
+--enable_warnings
+use mysqltest1;
+
+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";
+insert into t1 values("work");
+execute stmt1 using @string;
+deallocate prepare stmt1;
+
+prepare stmt1 from 'insert into t1 select ?';
+insert into t1 values(concat(UUID(),"work"));
+execute stmt1 using @string;
+deallocate prepare stmt1;
+
+insert into t1 values(concat("for",UUID()));
+insert into t1 select "yesterday";
+
+# verify that temp tables prevent a switch to SBR
+create temporary table tmp(a char(3));
+insert into tmp values("see");
+--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";
+insert into t1 values("work");
+execute stmt1 using @string;
+deallocate prepare stmt1;
+
+prepare stmt1 from 'insert into t1 select ?';
+insert into t1 values("work");
+execute stmt1 using @string;
+deallocate prepare stmt1;
+
+insert into t1 values("for");
+insert into t1 select "yesterday";
+
+# test SET DEFAULT (=statement at this point of test)
+set binlog_format=default;
+select @@global.binlog_format, @@session.binlog_format;
+# due to cluster it's hard to set back to default
+--error ER_NO_DEFAULT
+set global binlog_format=default;
+select @@global.binlog_format, @@session.binlog_format;
+
+prepare stmt1 from 'insert into t1 select ?';
+set @string="emergency";
+insert into t1 values("work");
+execute stmt1 using @string;
+deallocate prepare stmt1;
+
+prepare stmt1 from 'insert into t1 select ?';
+insert into t1 values("work");
+execute stmt1 using @string;
+deallocate prepare stmt1;
+
+insert into t1 values("for");
+insert into t1 select "yesterday";
+
+# and now the mixed mode
+
+set binlog_format=mixed;
+select @@global.binlog_format, @@session.binlog_format;
+set global binlog_format=mixed;
+select @@global.binlog_format, @@session.binlog_format;
+
+prepare stmt1 from 'insert into t1 select concat(UUID(),?)';
+set @string="emergency";
+insert into t1 values("work");
+execute stmt1 using @string;
+deallocate prepare stmt1;
+
+prepare stmt1 from 'insert into t1 select ?';
+insert into t1 values(concat(UUID(),"work"));
+execute stmt1 using @string;
+deallocate prepare stmt1;
+
+insert into t1 values(concat("for",UUID()));
+insert into t1 select "yesterday";
+
+prepare stmt1 from 'insert into t1 select ?';
+insert into t1 values(concat(UUID(),"work"));
+execute stmt1 using @string;
+deallocate prepare stmt1;
+
+insert into t1 values(concat("for",UUID()));
+insert into t1 select "yesterday";
+
+# Test of CREATE TABLE SELECT
+
+create table t2 select UUID();
+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 (inside a function or trigger won't
+# work)
+
+delimiter |;
+create procedure foo()
+begin
+insert into t1 values("work");
+insert into t1 values(concat("for",UUID()));
+insert into t1 select "yesterday";
+end|
+create procedure foo2()
+begin
+insert into t1 values(concat("emergency",UUID()));
+insert into t1 values("work");
+insert into t1 values(concat("for",UUID()));
+set session binlog_format=row; # accepted for stored procs
+insert into t1 values("more work");
+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|
+delimiter ;|
+call foo();
+call foo2();
+
+# 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";
+
+# 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";
+ insert into t1 values("work");
+ execute stmt1 using @string;
+ deallocate prepare stmt1;
+ prepare stmt1 from 'insert into t1 select ?';
+ insert into t1 values(metaphon("work"));
+ execute stmt1 using @string;
+ deallocate prepare stmt1;
+ insert into t1 values(metaphon("for"));
+ insert into t1 select "yesterday";
+ create table t6 select metaphon("for");
+ create table t7 select 1 union select metaphon("for");
+ create table t8 select * from t1 where 3 in (select 1 union select 2 union select metaphon("for") union select 3);
+ create table t9 select * from t1 where 3 in (select 1 union select 2 union select curdate() union select 3);
+}
+
+# and now compare:
+
+# 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;
+if ($you_want_to_test_UDF)
+{
+ select count(*) from t6;
+ select count(*) from t7;
+ select count(*) from t8;
+ select count(*) from t9;
+}
+
+--replace_column 2 # 5 #
+--replace_regex /table_id: [0-9]+/table_id: #/
+show binlog events from 102;
+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
+
+connection master;
+drop database mysqltest1;
+sync_slave_with_master;
+
+# 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
+
+--exec diff $MYSQLTEST_VARDIR/tmp/rpl_switch_stm_row_mixed_master.sql $MYSQLTEST_VARDIR/tmp/rpl_switch_stm_row_mixed_slave.sql;
diff --git a/mysql-test/t/rpl000012.test b/mysql-test/t/rpl_temp_table.test
index 2c1c65e4202..c29fa8e676d 100644
--- a/mysql-test/t/rpl000012.test
+++ b/mysql-test/t/rpl_temp_table.test
@@ -1,37 +1,53 @@
-source include/master-slave.inc;
-connection master;
+# drop table t1 t2 t3 are included int master-slave.inc
+# meaningful only in statement-based:
-create table t2 (n int);
+-- source include/have_binlog_format_statement.inc
+-- source include/master-slave.inc
+
+
+create table t2 (n int, PRIMARY KEY(n));
create temporary table t1 (n int);
-insert into t1 values(1),(2),(3);
-insert into t2 select * from t1;
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 (100);
+insert into t3 values (1010);
insert into t2 select * from t3;
+
drop table if exists t3;
-insert into t2 values (101);
+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;
+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(6);
+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
#
@@ -41,5 +57,3 @@ drop table if exists t1,t2;
save_master_pos;
connection slave;
sync_with_master;
-
-# End of 4.1 tests
diff --git a/mysql-test/t/rpl_temporary.test b/mysql-test/t/rpl_temporary.test
index 81f0e8a0af7..0d91a9f8e91 100644
--- a/mysql-test/t/rpl_temporary.test
+++ b/mysql-test/t/rpl_temporary.test
@@ -1,4 +1,5 @@
-source include/master-slave.inc;
+
+-- source include/master-slave.inc
# Clean up old slave's binlogs.
# The slave is started with --log-slave-updates
@@ -79,11 +80,12 @@ connection con2;
insert into t2 select count(*) from t3;
drop temporary table t3;
-select * from t2;
+select * from t2 ORDER BY f;
---replace_result $VERSION VERSION
---replace_column 2 # 5 #
-show binlog events;
+# 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;
@@ -120,7 +122,7 @@ SET TIMESTAMP=1040324224;
SET @@session.pseudo_thread_id=2;
drop temporary table t3;
-select * from t2;
+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
@@ -168,7 +170,7 @@ 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);
+#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;
diff --git a/mysql-test/t/rpl_timezone.test b/mysql-test/t/rpl_timezone.test
index 0f35c9dc0b6..5a6c1cd06f8 100644
--- a/mysql-test/t/rpl_timezone.test
+++ b/mysql-test/t/rpl_timezone.test
@@ -1,5 +1,10 @@
+#######################################
+# 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,
@@ -15,68 +20,73 @@ source include/master-slave.inc;
# Some preparations
let $VERSION=`select version()`;
set timestamp=100000000; # for fixed output of mysqlbinlog
-create table t1 (t timestamp);
-create table t2 (t char(32));
+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;
-insert into t1 values ('20050101000000'), ('20050611093902');
-set time_zone='UTC';
-insert into t1 values ('20040101000000'), ('20040611093902');
-select * from t1;
+#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;
+#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'), ('20040611093902');
-select * from t1;
+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;
+SELECT * FROM t1 ORDER BY n;
connection master;
---replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
---exec $MYSQL_BINLOG --short-form $MYSQLTEST_VARDIR/log/master-bin.000001
+# 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_timezone.dat' into table t1;
-select * from t1;
+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;
+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'), ('20040611093902');
+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
+# (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 t from t1);
-select * from t1;
+insert into t2 (select * from t1);
+SELECT * FROM t1 ORDER BY n;
sync_slave_with_master;
-select * from t2;
+SELECT * FROM t2 ORDER BY n;
#
# Now let us check how well we replicate various CURRENT_* functions
@@ -84,21 +94,21 @@ select * from t2;
connection master;
delete from t2;
set timestamp=1000072000;
-insert into t2 values (current_timestamp), (current_date), (current_time);
+insert into t2 values (current_timestamp,NULL), (current_date,NULL), (current_time,NULL);
sync_slave_with_master;
-select * from t2;
+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)),
- (unix_timestamp('2001-09-09 03:46:40'));
-select * 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;
+SELECT * FROM t2 ORDER BY n;
#
# Let us check that we are allowing to set global time_zone with
@@ -112,15 +122,14 @@ set global time_zone='MET';
#
delete from t2;
set time_zone='UTC';
-insert into t2 values(convert_tz('2004-01-01 00:00:00','MET',@@time_zone));
-insert into t2 values(convert_tz('2005-01-01 00:00:00','MET','Japan'));
-select * from t2;
+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;
+SELECT * FROM t2 ORDER BY n;
# Clean up
connection master;
drop table t1, t2;
sync_slave_with_master;
-# End of 4.1 tests
diff --git a/mysql-test/t/rpl_trigger.test b/mysql-test/t/rpl_trigger.test
index 35f0a0b0a4b..591941c19eb 100644
--- a/mysql-test/t/rpl_trigger.test
+++ b/mysql-test/t/rpl_trigger.test
@@ -1,8 +1,16 @@
#
# 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_statement.inc
+--source include/master-slave.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t2;
+DROP TABLE IF EXISTS t3;
-source include/master-slave.inc;
+--enable_warnings
#
# #12482: Triggers has side effects with auto_increment values
diff --git a/mysql-test/t/rpl_trunc_temp.test b/mysql-test/t/rpl_trunc_temp.test
index b4ea3c318da..56f858dc9a2 100644
--- a/mysql-test/t/rpl_trunc_temp.test
+++ b/mysql-test/t/rpl_trunc_temp.test
@@ -1,3 +1,6 @@
+# Requires statement logging
+-- source include/have_binlog_format_statement.inc
+
source include/master-slave.inc;
#
diff --git a/mysql-test/t/rpl_user_variables.test b/mysql-test/t/rpl_user_variables.test
index dbe75a15038..08717fce114 100644
--- a/mysql-test/t/rpl_user_variables.test
+++ b/mysql-test/t/rpl_user_variables.test
@@ -1,7 +1,10 @@
+###################################
#
# Test of replicating user variables
#
-source include/master-slave.inc;
+###################################
+
+-- source include/master-slave.inc
# Disable PS as the log positions differs
--disable_ps_protocol
@@ -39,26 +42,16 @@ 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;
-save_master_pos;
-connection slave;
-sync_with_master;
-select * from t1;
---replace_column 2 # 5 #
-show binlog events from 98;
-#
-# BUG19136: Crashing log-bin and uninitialized user variables in a derived table
-# just to check nothing bad happens anymore
-#
+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;
-save_master_pos;
-
-connection slave;
-sync_with_master;
+sync_slave_with_master;
stop slave;
-
-# End of 4.1 tests
diff --git a/mysql-test/t/rpl_view.test b/mysql-test/t/rpl_view.test
index 0a0c6a6dddb..0e8c7514488 100644
--- a/mysql-test/t/rpl_view.test
+++ b/mysql-test/t/rpl_view.test
@@ -1,3 +1,5 @@
+# NYI - row-based cannot use CREATE ... SELECT
+
source include/master-slave.inc;
--disable_warnings
drop table if exists t1,v1;
@@ -7,7 +9,7 @@ reset master;
--enable_warnings
#
-# Check that createion drop of view is replicated, also check replication of
+# Check that creation drop of view is replicated, also check replication of
# updating of view
#
connection master;
@@ -43,5 +45,8 @@ select * from v1 order by a;
connection master;
drop table t1;
sync_slave_with_master;
---replace_column 2 # 5 #
-show binlog events limit 1,100;
+# 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;
diff --git a/mysql-test/t/show_check.test b/mysql-test/t/show_check.test
index 52d262677ff..a7b24a5e06c 100644
--- a/mysql-test/t/show_check.test
+++ b/mysql-test/t/show_check.test
@@ -2,6 +2,10 @@
# embedded server testing
-- source include/not_embedded.inc
+# check that CSV engine was compiled in, as the result of the test
+# depends on the presence of the log tables (which are CSV-based).
+--source include/have_csv.inc
+
#
# Test of some show commands
#
@@ -162,33 +166,28 @@ drop table t1;
SET @old_sql_mode= @@sql_mode, sql_mode= '';
SET @old_sql_quote_show_create= @@sql_quote_show_create, sql_quote_show_create= OFF;
-######### hook for WL#1324 #
---error 1103
-CREATE TABLE `a/b` (i INT);
-# the above test should WORK when WL#1324 is done,
-# it should be removed and
-# the following part should be uncommented then
-#########################################################
-# begin of part that must be uncommented when WL#1324 is done
-#########################################################
-#CREATE TABLE ```ab``cd``` (i INT);
-#SHOW CREATE TABLE ```ab``cd```;
-#DROP TABLE ```ab``cd```;
-
-#CREATE TABLE ```ab````cd``` (i INT);
-#SHOW CREATE TABLE ```ab````cd```;
-#DROP TABLE ```ab````cd```;
-#
-#CREATE TABLE ```a` (i INT);
-#SHOW CREATE TABLE ```a`;
-#DROP TABLE ```a`;
-#
-#SET sql_mode= 'ANSI_QUOTES';
-#
-#CREATE TABLE """a" (i INT);
-#SHOW CREATE TABLE """a";
-#DROP TABLE """a";
-#
+CREATE TABLE ```ab``cd``` (i INT);
+SHOW CREATE TABLE ```ab``cd```;
+DROP TABLE ```ab``cd```;
+
+CREATE TABLE ```ab````cd``` (i INT);
+SHOW CREATE TABLE ```ab````cd```;
+DROP TABLE ```ab````cd```;
+
+CREATE TABLE ```a` (i INT);
+SHOW CREATE TABLE ```a`;
+DROP TABLE ```a`;
+
+CREATE TABLE `a.1` (i INT);
+SHOW CREATE TABLE `a.1`;
+DROP TABLE `a.1`;
+
+SET sql_mode= 'ANSI_QUOTES';
+
+CREATE TABLE """a" (i INT);
+SHOW CREATE TABLE """a";
+DROP TABLE """a";
+
#Bug #4374 SHOW TABLE STATUS FROM ignores collation_connection
#set names latin1;
#create database ``;
@@ -196,9 +195,6 @@ CREATE TABLE `a/b` (i INT);
#--replace_column 7 # 8 # 9 #
#show table status from `` LIKE '';
#drop database ``;
-#########################################################
-# end of part that must be uncommented when WL#1324 is done
-#########################################################
# to test quotes around keywords.. :
@@ -313,7 +309,6 @@ connect (con3,localhost,mysqltest_3,,test);
connection con3;
--error 1142
select * from mysqltest.t1;
---error 1044
show create database mysqltest;
drop table mysqltest.t1;
drop database mysqltest;
@@ -397,7 +392,8 @@ system echo "this is a junk file for test" >> $MYSQLTEST_VARDIR/master-data/test
SHOW TABLE STATUS like 't1';
--error 1033
show create table t1;
-drop table t1;
+drop table if exists t1;
+system rm -f $MYSQLTEST_VARDIR/master-data/test/t1.frm ;
# End of 4.1 tests
@@ -424,3 +420,29 @@ DROP TABLE urkunde;
#
--error 1049
SHOW TABLES FROM non_existing_database;
+
+# End of 4.1 tests
+
+--disable_result_log
+SHOW AUTHORS;
+--enable_result_log
+
+#
+# Test for bug #9785 SELECT privilege for the whole database is needed to do SHOW CREATE DATABASE
+#
+create database mysqltest;
+show create database mysqltest;
+create table mysqltest.t1(a int);
+insert into mysqltest.t1 values(1);
+grant select on `mysqltest`.`t1` to mysqltest_4@localhost;
+connect (con4,localhost,mysqltest_4,,mysqltest);
+connection con4;
+show create database mysqltest;
+connection default;
+delete from mysql.user where user='mysqltest_4';
+delete from mysql.db where user='mysqltest_4';
+delete from mysql.tables_priv where user='mysqltest_4';
+flush privileges;
+drop database mysqltest;
+
+--echo End of 5.1 tests
diff --git a/mysql-test/t/sp-destruct.test b/mysql-test/t/sp-destruct.test
index 4f5f1cdcb9b..375d2289459 100644
--- a/mysql-test/t/sp-destruct.test
+++ b/mysql-test/t/sp-destruct.test
@@ -7,6 +7,11 @@
# In the case of trouble you might want to skip this.
#
+# embedded server returns different paths in error messages
+# in lines like 'call bug14233();'
+# mysqltest should be fixed to allow REPLACE_RESULT in error message
+-- source include/not_embedded.inc
+
# We're using --system things that probably doesn't work on Windows.
--source include/not_windows.inc
@@ -35,10 +40,13 @@ create trigger t1_ai after insert on t1 for each row call bug14233();
# Unsupported tampering with the mysql.proc definition
alter table mysql.proc drop type;
+--replace_result $MYSQL_TEST_DIR .
--error ER_SP_PROC_TABLE_CORRUPT
call bug14233();
+--replace_result $MYSQL_TEST_DIR .
--error ER_SP_PROC_TABLE_CORRUPT
create view v1 as select bug14233_f();
+--replace_result $MYSQL_TEST_DIR .
--error ER_SP_PROC_TABLE_CORRUPT
insert into t1 values (0);
diff --git a/mysql-test/t/sp-error.test b/mysql-test/t/sp-error.test
index a4ab5d98922..c9ce26b6dda 100644
--- a/mysql-test/t/sp-error.test
+++ b/mysql-test/t/sp-error.test
@@ -1705,6 +1705,24 @@ drop function if exists bug16896;
--error ER_SP_NO_AGGREGATE
create aggregate function bug16896() returns int return 1;
+#
+# End of 5.0 tests
+#
+
+#
+# Bug#16164 "Easter egg": check that SHOW AUTHORS is disabled in
+# stored functions/triggers
+#
+--disable_warnings
+drop function if exists bug16164;
+--enable_warnings
+delimiter |;
+--error ER_SP_NO_RETSET
+create function bug16164() returns int
+begin
+ show authors;
+ return 42;
+end|
#
# BUG#NNNN: New bug synopsis
diff --git a/mysql-test/t/sp-prelocking.test b/mysql-test/t/sp-prelocking.test
index a7215462afb..6287950d216 100644
--- a/mysql-test/t/sp-prelocking.test
+++ b/mysql-test/t/sp-prelocking.test
@@ -271,4 +271,6 @@ deallocate prepare stmt;
drop table t1;
drop view v1, v2, v3;
drop function bug15683;
-
+#
+# End of 5.0 tests
+#
diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test
index 1d21a5da187..8f5fcdc9d52 100644
--- a/mysql-test/t/sp.test
+++ b/mysql-test/t/sp.test
@@ -1446,11 +1446,11 @@ end|
call ifac(20)|
select * from t3|
drop table t3|
---replace_column 5 '0000-00-00 00:00:00' 6 '0000-00-00 00:00:00'
+--replace_column 4 'root@localhost' 5 '0000-00-00 00:00:00' 6 '0000-00-00 00:00:00'
show function status like '%f%'|
drop procedure ifac|
drop function fac|
---replace_column 5 '0000-00-00 00:00:00' 6 '0000-00-00 00:00:00'
+--replace_column 4 'root@localhost' 5 '0000-00-00 00:00:00' 6 '0000-00-00 00:00:00'
show function status like '%f%'|
@@ -2944,6 +2944,7 @@ begin
show warnings;
end|
--disable_parsing
+--replace_regex /table_id: [0-9]+/table_id: #/
show binlog events;
show storage engines;
show master status;
@@ -4499,9 +4500,13 @@ end|
--error 1062
select bug12379()|
select 1|
+# statement-based binlogging will show warning which row-based won't;
+# so we hide it (this warning is already tested in rpl_stm_sp.test)
+--disable_warnings
call bug12379_1()|
select 2|
call bug12379_2()|
+--enable_warnings
select 3|
--error 1062
call bug12379_3()|
@@ -5232,7 +5237,7 @@ drop procedure bug5967|
#
--disable_warnings
drop procedure if exists bug13012|
---enable_warnings
+# Disable warnings also for BACKUP/RESTORE: they are deprecated.
create procedure bug13012()
BEGIN
REPAIR TABLE t1;
@@ -5241,6 +5246,7 @@ BEGIN
RESTORE TABLE t1 FROM '../tmp';
END|
call bug13012()|
+--enable_warnings
drop procedure bug13012|
create view v1 as select * from t1|
create procedure bug13012()
diff --git a/mysql-test/t/sql_mode.test b/mysql-test/t/sql_mode.test
index b67f1a73db6..b4225ef8c4e 100644
--- a/mysql-test/t/sql_mode.test
+++ b/mysql-test/t/sql_mode.test
@@ -209,18 +209,18 @@ SELECT "a\\b", "a\\\'b", "a""\\b", "a""\\\'b";
# is not available
#
-set session sql_mode = 'NO_ENGINE_SUBSTITUTION';
---error 1289
-create table t1 (a int) engine=isam;
---error 1146
-show create table t1;
-drop table if exists t1;
-
-# for comparison, lets see the warnings...
-set session sql_mode = '';
-create table t1 (a int) engine=isam;
-show create table t1;
-drop table t1;
+#set session sql_mode = 'NO_ENGINE_SUBSTITUTION';
+#--error 1289
+#create table t1 (a int) engine=isam;
+#--error 1146
+#show create table t1;
+#drop table if exists t1;
+#
+## for comparison, lets see the warnings...
+#set session sql_mode = '';
+#create table t1 (a int) engine=isam;
+#show create table t1;
+#drop table t1;
#
# Bug #6903: ANSI_QUOTES does not come into play with SHOW CREATE FUNCTION
diff --git a/mysql-test/t/strict.test b/mysql-test/t/strict.test
index 5044a20ae9f..212150e057c 100644
--- a/mysql-test/t/strict.test
+++ b/mysql-test/t/strict.test
@@ -884,11 +884,11 @@ INSERT INTO t1 (col1,col2,col3) VALUES (NULL, '', '2004-01-01');
INSERT INTO t1 (col1,col2,col3) VALUES (102, NULL, '2004-01-01');
--error 1048
INSERT INTO t1 VALUES (103,'',NULL);
---error 1263
+--error 1048
UPDATE t1 SET col1=NULL WHERE col1 =100;
---error 1263
+--error 1048
UPDATE t1 SET col2 =NULL WHERE col2 ='hello';
---error 1263
+--error 1048
UPDATE t1 SET col2 =NULL where col3 IS NOT NULL;
INSERT IGNORE INTO t1 values (NULL,NULL,NULL);
SELECT * FROM t1;
@@ -908,7 +908,7 @@ INSERT INTO t1 (col1) VALUES (2);
INSERT INTO t1 VALUES(default(col1),default(col2));
--error 1364
INSERT INTO t1 (col1) SELECT 1;
---error 1263
+--error 1048
INSERT INTO t1 SELECT 1,NULL;
INSERT IGNORE INTO t1 values (NULL,NULL);
INSERT IGNORE INTO t1 (col1) values (3);
diff --git a/mysql-test/t/system_mysql_db.test b/mysql-test/t/system_mysql_db.test
index 27c17da2731..e3d58ab7139 100644
--- a/mysql-test/t/system_mysql_db.test
+++ b/mysql-test/t/system_mysql_db.test
@@ -2,6 +2,10 @@
# This test must examine integrity of system database "mysql"
#
+# check that CSV engine was compiled in, as the result of the test
+# depends on the presence of the log tables (which are CSV-based).
+--source include/have_csv.inc
+
# First delete some tables maybe left over from previous tests
--disable_warnings
drop table if exists t1,t1aa,t2aa;
diff --git a/mysql-test/t/system_mysql_db_fix.test b/mysql-test/t/system_mysql_db_fix.test
index 0a2ab180806..14132f5af11 100644
--- a/mysql-test/t/system_mysql_db_fix.test
+++ b/mysql-test/t/system_mysql_db_fix.test
@@ -1,6 +1,10 @@
# Embedded server doesn't support external clients
--source include/not_embedded.inc
+# check that CSV engine was compiled in, as the test relies on the presence
+# of the log tables (which are CSV-based)
+--source include/have_csv.inc
+
#
# This is the test for mysql_fix_privilege_tables
#
@@ -34,7 +38,7 @@ CREATE TABLE db (
PRIMARY KEY Host (Host,Db,User),
KEY User (User)
)
-type=ISAM;
+engine=MyISAM;
--enable-warnings
INSERT INTO db VALUES ('%','test', '','Y','Y','Y','Y','Y','Y');
@@ -52,7 +56,7 @@ CREATE TABLE host (
Drop_priv enum('N','Y') DEFAULT 'N' NOT NULL,
PRIMARY KEY Host (Host,Db)
)
-type=ISAM;
+engine=MyISAM;
--enable-warnings
--disable_warnings
@@ -71,7 +75,7 @@ CREATE TABLE user (
Process_priv enum('N','Y') DEFAULT 'N' NOT NULL,
PRIMARY KEY Host (Host,User)
)
-type=ISAM;
+engine=MyISAM;
--enable-warnings
INSERT INTO user VALUES ('localhost','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y');
@@ -86,7 +90,10 @@ INSERT INTO user VALUES ('localhost','', '','N','N','N','N','N','N','N','N','
-- disable_query_log
-DROP TABLE db, host, user, func, tables_priv, columns_priv, procs_priv, help_category, help_keyword, help_relation, help_topic, proc, time_zone, time_zone_leap_second, time_zone_name, time_zone_transition, time_zone_transition_type;
+DROP TABLE db, host, user, func, plugin, tables_priv, columns_priv,
+procs_priv, help_category, help_keyword, help_relation, help_topic, proc,
+time_zone, time_zone_leap_second, time_zone_name, time_zone_transition,
+time_zone_transition_type, general_log, slow_log, event;
-- enable_query_log
diff --git a/mysql-test/t/temp_table.test b/mysql-test/t/temp_table.test
index 3920b305b78..9121283fb32 100644
--- a/mysql-test/t/temp_table.test
+++ b/mysql-test/t/temp_table.test
@@ -117,3 +117,15 @@ select d, c from t1 left join t2 on b = c where a = 3 order by d;
drop table t1, t2;
# End of 4.1 tests
+
+#
+# Test truncate with temporary tables
+#
+
+create temporary table t1 (a int);
+insert into t1 values (4711);
+select * from t1;
+truncate t1;
+insert into t1 values (42);
+select * from t1;
+drop table t1;
diff --git a/mysql-test/t/trigger-compat.test b/mysql-test/t/trigger-compat.test
index f2e350cb161..9f7fd8bc505 100644
--- a/mysql-test/t/trigger-compat.test
+++ b/mysql-test/t/trigger-compat.test
@@ -35,8 +35,7 @@ CREATE DATABASE mysqltest_db1;
CREATE USER mysqltest_dfn@localhost;
CREATE USER mysqltest_inv@localhost;
-GRANT SUPER ON *.* TO mysqltest_dfn@localhost;
-GRANT CREATE ON mysqltest_db1.* TO mysqltest_dfn@localhost;
+GRANT CREATE, TRIGGER ON mysqltest_db1.* TO mysqltest_dfn@localhost;
#
# Create a table and the first trigger.
diff --git a/mysql-test/t/trigger-grant.test b/mysql-test/t/trigger-grant.test
index 12b929898a8..8ca8ffe904b 100644
--- a/mysql-test/t/trigger-grant.test
+++ b/mysql-test/t/trigger-grant.test
@@ -44,9 +44,124 @@ CREATE DATABASE mysqltest_db1;
CREATE USER mysqltest_dfn@localhost;
CREATE USER mysqltest_inv@localhost;
-GRANT SUPER ON *.* TO mysqltest_dfn@localhost;
GRANT CREATE ON mysqltest_db1.* TO mysqltest_dfn@localhost;
+--connect (wl2818_definer_con,localhost,mysqltest_dfn,,mysqltest_db1)
+--connection wl2818_definer_con
+--echo
+--echo ---> connection: wl2818_definer_con
+
+CREATE TABLE t1(num_value INT);
+CREATE TABLE t2(user_str TEXT);
+
+--disconnect wl2818_definer_con
+
+--connection default
+--echo
+--echo ---> connection: default
+
+GRANT INSERT, DELETE ON mysqltest_db1.t1 TO mysqltest_dfn@localhost;
+GRANT INSERT, DELETE ON mysqltest_db1.t2 TO mysqltest_dfn@localhost;
+
+#
+# Check that the user must have TRIGGER privilege to create a trigger.
+#
+
+--connection default
+--echo
+--echo ---> connection: default
+
+GRANT SUPER ON *.* TO mysqltest_dfn@localhost;
+
+--connect (wl2818_definer_con,localhost,mysqltest_dfn,,mysqltest_db1)
+--connection wl2818_definer_con
+--echo
+--echo ---> connection: wl2818_definer_con
+
+--error ER_TABLEACCESS_DENIED_ERROR
+CREATE TRIGGER trg1 AFTER INSERT ON t1
+ FOR EACH ROW
+ INSERT INTO t2 VALUES(CURRENT_USER());
+
+--disconnect wl2818_definer_con
+
+#
+# Check that the user must have TRIGGER privilege to drop a trigger.
+#
+
+--connection default
+--echo
+--echo ---> connection: default
+
+GRANT TRIGGER ON mysqltest_db1.t1 TO mysqltest_dfn@localhost;
+
+--connect (wl2818_definer_con,localhost,mysqltest_dfn,,mysqltest_db1)
+--connection wl2818_definer_con
+--echo
+--echo ---> connection: wl2818_definer_con
+
+CREATE TRIGGER trg1 AFTER INSERT ON t1
+ FOR EACH ROW
+ INSERT INTO t2 VALUES(CURRENT_USER());
+
+--disconnect wl2818_definer_con
+
+--connection default
+--echo
+--echo ---> connection: default
+
+REVOKE TRIGGER ON mysqltest_db1.t1 FROM mysqltest_dfn@localhost;
+
+--connect (wl2818_definer_con,localhost,mysqltest_dfn,,mysqltest_db1)
+--connection wl2818_definer_con
+--echo
+--echo ---> connection: wl2818_definer_con
+
+--error ER_TABLEACCESS_DENIED_ERROR
+DROP TRIGGER trg1;
+
+--disconnect wl2818_definer_con
+
+#
+# Check that the definer must have TRIGGER privilege to activate a trigger.
+#
+
+--connect (wl2818_definer_con,localhost,mysqltest_dfn,,mysqltest_db1)
+--connection wl2818_definer_con
+--echo
+--echo ---> connection: wl2818_definer_con
+
+--error ER_TABLEACCESS_DENIED_ERROR
+INSERT INTO t1 VALUES(0);
+
+--disconnect wl2818_definer_con
+
+--connection default
+--echo
+--echo ---> connection: default
+
+GRANT TRIGGER ON mysqltest_db1.t1 TO mysqltest_dfn@localhost;
+
+--connect (wl2818_definer_con,localhost,mysqltest_dfn,,mysqltest_db1)
+--connection wl2818_definer_con
+--echo
+--echo ---> connection: wl2818_definer_con
+
+INSERT INTO t1 VALUES(0);
+
+# Cleanup for further tests.
+DROP TRIGGER trg1;
+DELETE FROM t1;
+DELETE FROM t2;
+
+--disconnect wl2818_definer_con
+
+--connection default
+--echo
+--echo ---> connection: default
+
+REVOKE SUPER ON *.* FROM mysqltest_dfn@localhost;
+
#
# Check that triggers are executed under the authorization of the definer:
# - create two tables under "definer";
@@ -64,9 +179,6 @@ GRANT CREATE ON mysqltest_db1.* TO mysqltest_dfn@localhost;
--echo
--echo ---> connection: wl2818_definer_con
-CREATE TABLE t1(num_value INT);
-CREATE TABLE t2(user_str TEXT);
-
CREATE TRIGGER trg1 AFTER INSERT ON t1
FOR EACH ROW
INSERT INTO t2 VALUES(CURRENT_USER());
@@ -145,10 +257,6 @@ SELECT * FROM t2;
#
# Check DEFINER clause of CREATE TRIGGER statement.
#
-# NOTE: there is no dedicated TRIGGER privilege for CREATE TRIGGER statement.
-# SUPER privilege is used instead. I.e., if one invokes CREATE TRIGGER, it should
-# have SUPER privilege, so this test is meaningless right now.
-#
# - Check that SUPER privilege required to create a trigger with different
# definer:
# - try to create a trigger with DEFINER="definer@localhost" under
@@ -174,7 +282,26 @@ use mysqltest_db1;
DROP TRIGGER trg1;
# Check that SUPER is required to specify different DEFINER.
-# NOTE: meaningless at the moment
+
+--error ER_SPECIFIC_ACCESS_DENIED_ERROR
+CREATE DEFINER='mysqltest_inv'@'localhost'
+ TRIGGER trg1 BEFORE INSERT ON t1
+ FOR EACH ROW
+ SET @new_sum = 0;
+
+--connection default
+--echo
+--echo ---> connection: default
+
+use mysqltest_db1;
+
+GRANT SUPER ON *.* TO mysqltest_dfn@localhost;
+
+--disconnect wl2818_definer_con
+--connect (wl2818_definer_con,localhost,mysqltest_dfn,,mysqltest_db1)
+--connection wl2818_definer_con
+--echo
+--echo ---> connection: wl2818_definer_con
CREATE DEFINER='mysqltest_inv'@'localhost'
TRIGGER trg1 BEFORE INSERT ON t1
@@ -190,7 +317,7 @@ CREATE DEFINER='mysqltest_nonexs'@'localhost'
# Check that trg2 will not be activated.
---error ER_SPECIFIC_ACCESS_DENIED_ERROR
+--error ER_NO_SUCH_USER
INSERT INTO t1 VALUES(6);
#
@@ -257,6 +384,7 @@ DROP USER mysqltest_inv@localhost;
DROP DATABASE mysqltest_db1;
+
###########################################################################
#
# BUG#15166: Wrong update [was: select/update] permissions required to execute
@@ -294,8 +422,7 @@ CREATE TABLE t4(col CHAR(20)); # table for "write-value" trigger
CREATE USER mysqltest_u1@localhost;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_u1@localhost;
-GRANT SUPER ON *.* TO mysqltest_u1@localhost;
-GRANT SELECT ON mysqltest_db1.t1 TO mysqltest_u1@localhost; # to allow connect
+GRANT TRIGGER ON mysqltest_db1.* TO mysqltest_u1@localhost;
SET @mysqltest_var = NULL;
@@ -311,7 +438,6 @@ SET @mysqltest_var = NULL;
use mysqltest_db1;
-REVOKE SELECT ON mysqltest_db1.t1 FROM mysqltest_u1@localhost;
GRANT DELETE ON mysqltest_db1.* TO mysqltest_u1@localhost;
SHOW GRANTS FOR mysqltest_u1@localhost;
@@ -592,7 +718,7 @@ CREATE TABLE t2 (i1 INT);
CREATE USER mysqltest_dfn@localhost;
CREATE USER mysqltest_inv@localhost;
-GRANT EXECUTE, CREATE ROUTINE, SUPER ON *.* TO mysqltest_dfn@localhost;
+GRANT EXECUTE, CREATE ROUTINE, TRIGGER ON *.* TO mysqltest_dfn@localhost;
GRANT INSERT ON mysqltest_db1.* TO mysqltest_inv@localhost;
connect (definer,localhost,mysqltest_dfn,,mysqltest_db1);
diff --git a/mysql-test/t/trigger.test b/mysql-test/t/trigger.test
index a5bd2ba0b38..a87f289e94e 100644
--- a/mysql-test/t/trigger.test
+++ b/mysql-test/t/trigger.test
@@ -1111,9 +1111,9 @@ insert into t1 values
create function f2() returns int return (select max(b) from t2);
insert into t2 select a, f2() from t1;
load data infile '../std_data_ln/words.dat' into table t1 (a) set b:= f1();
-drop table t1, t2;
drop function f1;
drop function f2;
+drop table t1, t2;
#
# Test for bug #16021 "Wrong index given to function in trigger" which
diff --git a/mysql-test/t/upgrade.test b/mysql-test/t/upgrade.test
new file mode 100644
index 00000000000..5c5046cf7e9
--- /dev/null
+++ b/mysql-test/t/upgrade.test
@@ -0,0 +1,49 @@
+-- source include/not_embedded.inc
+
+--disable_warnings
+drop database if exists `mysqltest1`;
+drop database if exists `mysqltest-1`;
+drop database if exists `#mysql50#mysqltest-1`;
+--enable_warnings
+
+create database `mysqltest1`;
+create database `#mysql50#mysqltest-1`;
+create table `mysqltest1`.`t1` (a int);
+create table `mysqltest1`.`#mysql50#t-1` (a int);
+create table `#mysql50#mysqltest-1`.`t1` (a int);
+create table `#mysql50#mysqltest-1`.`#mysql50#t-1` (a int);
+show create database `mysqltest1`;
+--error 1049
+show create database `mysqltest-1`;
+show create database `#mysql50#mysqltest-1`;
+show tables in `mysqltest1`;
+show tables in `#mysql50#mysqltest-1`;
+
+--exec $MYSQL_CHECK --all-databases --fix-db-names --fix-table-names
+
+show create database `mysqltest1`;
+show create database `mysqltest-1`;
+--error 1049
+show create database `#mysql50#mysqltest-1`;
+show tables in `mysqltest1`;
+show tables in `mysqltest-1`;
+drop database `mysqltest1`;
+drop database `mysqltest-1`;
+
+#
+# Bug#17142: Crash if create with encoded name
+#
+--disable_warnings
+drop table if exists `txu@0023p@0023p1`;
+drop table if exists `txu#p#p1`;
+--enable_warnings
+create table `txu#p#p1` (s1 int);
+insert into `txu#p#p1` values (1);
+--error 1146
+select * from `txu@0023p@0023p1`;
+create table `txu@0023p@0023p1` (s1 int);
+insert into `txu@0023p@0023p1` values (2);
+select * from `txu@0023p@0023p1`;
+select * from `txu#p#p1`;
+drop table `txu@0023p@0023p1`;
+drop table `txu#p#p1`;
diff --git a/mysql-test/t/user_var-binlog.test b/mysql-test/t/user_var-binlog.test
index 12a5e616fa2..7f1561b925b 100644
--- a/mysql-test/t/user_var-binlog.test
+++ b/mysql-test/t/user_var-binlog.test
@@ -1,3 +1,6 @@
+# Requires statement logging
+-- source include/have_binlog_format_statement.inc
+# TODO: Create row based version once $MYSQL_BINLOG has new RB version
# Embedded server does not support binlogging
--source include/not_embedded.inc
@@ -10,7 +13,9 @@ INSERT INTO t1 VALUES(@`a b`);
set @var1= "';aaa";
SET @var2=char(ascii('a'));
insert into t1 values (@var1),(@var2);
-show binlog events from 98;
+--replace_column 2 # 5 #
+--replace_regex /table_id: [0-9]+/table_id: #/
+show binlog events from 102;
# more important than SHOW BINLOG EVENTS, mysqlbinlog (where we
# absolutely need variables names to be quoted and strings to be
# escaped).
diff --git a/mysql-test/t/variables.test b/mysql-test/t/variables.test
index be1731e7493..7aa79f0eb40 100644
--- a/mysql-test/t/variables.test
+++ b/mysql-test/t/variables.test
@@ -292,7 +292,7 @@ set sql_select_limit=1;
# reset it, so later tests don't get confused
set sql_select_limit=default;
set sql_warnings=1;
-set global table_cache=100;
+set global table_open_cache=100;
set storage_engine=myisam;
set global thread_cache_size=100;
set timestamp=1, timestamp=default;
@@ -424,9 +424,9 @@ SHOW VARIABLES LIKE 'MYISAM_DATA_POINTER_SIZE';
# Bug #6958: negative arguments to integer options wrap around
#
-SET GLOBAL table_cache=-1;
-SHOW VARIABLES LIKE 'table_cache';
-SET GLOBAL table_cache=DEFAULT;
+SET GLOBAL table_open_cache=-1;
+SHOW VARIABLES LIKE 'table_open_cache';
+SET GLOBAL table_open_cache=DEFAULT;
#
# Bugs12363: character_set_results is nullable,
diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test
index 0e8cea41a1f..535ba3da7fa 100644
--- a/mysql-test/t/view.test
+++ b/mysql-test/t/view.test
@@ -1801,7 +1801,9 @@ drop table t1;
# underlying tables (BUG#6443)
#
set sql_mode='strict_all_tables';
+--disable_warnings
CREATE TABLE t1 (col1 INT NOT NULL, col2 INT NOT NULL) ENGINE = INNODB;
+--enable_warnings
CREATE VIEW v1 (vcol1) AS SELECT col1 FROM t1;
CREATE VIEW v2 (vcol1) AS SELECT col1 FROM t1 WHERE col2 > 2;
-- error 1364
@@ -1857,7 +1859,9 @@ drop table t1;
#
# Test for bug #11771: wrong query_id in SELECT * FROM <view>
#
+--disable_warnings
CREATE TABLE t1 (f1 char) ENGINE = innodb;
+--enable_warnings
INSERT INTO t1 VALUES ('A');
CREATE VIEW v1 AS SELECT * FROM t1;
@@ -2075,6 +2079,7 @@ order by users_names;
drop view v1, v2;
drop table t1, t2;
+#
# Bug #6808 - Views: CREATE VIEW v ... FROM t AS v fails
#
diff --git a/mysql-test/t/view_grant.test b/mysql-test/t/view_grant.test
index 4663a667d25..d55323e2c56 100644
--- a/mysql-test/t/view_grant.test
+++ b/mysql-test/t/view_grant.test
@@ -1,6 +1,12 @@
# Can't test with embedded server
-- source include/not_embedded.inc
+--disable_warnings
+drop database if exists mysqltest;
+drop view if exists v1;
+--enable_warnings
+
+
# simple test of grants
grant create view on test.* to test@localhost;
show grants for test@localhost;
@@ -26,7 +32,7 @@ grant create view,select on test.* to mysqltest_1@localhost;
connect (user1,localhost,mysqltest_1,,test);
connection user1;
--- error ER_SPECIFIC_ACCESS_DENIED
+-- error ER_SPECIFIC_ACCESS_DENIED_ERROR
create definer=root@localhost view v1 as select * from mysqltest.t1;
create view v1 as select * from mysqltest.t1;
# try to modify view without DROP privilege on it
diff --git a/mysql-test/t/warnings.test b/mysql-test/t/warnings.test
index 71e847d1d8c..a1a38298345 100644
--- a/mysql-test/t/warnings.test
+++ b/mysql-test/t/warnings.test
@@ -113,17 +113,9 @@ show variables like 'max_error_count';
# Test for handler type
#
drop table t1;
-create table t1 (id int) engine=isam;
-alter table t1 engine=isam;
-drop table t1;
-
-#
-# Test for deprecated TYPE= syntax
-#
-
-create table t1 (id int) type=heap;
-alter table t1 type=myisam;
-drop table t1;
+#create table t1 (id int) engine=isam;
+#alter table t1 engine=isam;
+#drop table t1;
#
# Test for deprecated table_type variable
diff --git a/mysql-test/t/xml.test b/mysql-test/t/xml.test
new file mode 100644
index 00000000000..65d0a40291f
--- /dev/null
+++ b/mysql-test/t/xml.test
@@ -0,0 +1,345 @@
+SET @xml='<a aa1="aa1" aa2="aa2">a1<b ba1="ba1">b1<c>c1</c>b2</b>a2</a>';
+SELECT extractValue(@xml,'/a');
+SELECT extractValue(@xml,'/a/b');
+SELECT extractValue(@xml,'/a/b/c');
+SELECT extractValue(@xml,'/a/@aa1');
+SELECT extractValue(@xml,'/a/@aa2');
+SELECT extractValue(@xml,'/a/@*');
+SELECT extractValue(@xml,'//@ba1');
+
+SELECT extractValue(@xml,'//a');
+SELECT extractValue(@xml,'//b');
+SELECT extractValue(@xml,'//c');
+SELECT extractValue(@xml,'/a//b');
+SELECT extractValue(@xml,'/a//c');
+SELECT extractValue(@xml,'//*');
+SELECT extractValue(@xml,'/a//*');
+SELECT extractValue(@xml,'/./a');
+SELECT extractValue(@xml,'/a/b/.');
+SELECT extractValue(@xml,'/a/b/..');
+SELECT extractValue(@xml,'/a/b/../@aa1');
+SELECT extractValue(@xml,'/*');
+SELECT extractValue(@xml,'/*/*');
+SELECT extractValue(@xml,'/*/*/*');
+
+SELECT extractValue(@xml,'/a/child::*');
+SELECT extractValue(@xml,'/a/self::*');
+SELECT extractValue(@xml,'/a/descendant::*');
+SELECT extractValue(@xml,'/a/descendant-or-self::*');
+SELECT extractValue(@xml,'/a/attribute::*');
+SELECT extractValue(@xml,'/a/b/c/parent::*');
+SELECT extractValue(@xml,'/a/b/c/ancestor::*');
+SELECT extractValue(@xml,'/a/b/c/ancestor-or-self::*');
+SELECT extractValue(@xml,'/descendant-or-self::*');
+
+SET @xml='<a>a11<b ba="ba11" ba="ba12">b11</b><b ba="ba21" ba="ba22">b21<c>c1</c>b22</b>a12</a>';
+SELECT extractValue(@xml,'/a/b/c/ancestor-or-self::*');
+SELECT extractValue(@xml,'//@ba');
+
+SET @xml='<a><b>b</b><c>c</c></a>';
+SELECT extractValue(@xml,'/a/b');
+SELECT extractValue(@xml,'/a/c');
+SELECT extractValue(@xml,'/a/child::b');
+SELECT extractValue(@xml,'/a/child::c');
+
+SET @xml='<a><b>b1</b><c>c1</c><b>b2</b><c>c2</c></a>';
+SELECT extractValue(@xml,'/a/b[1]');
+SELECT extractValue(@xml,'/a/b[2]');
+SELECT extractValue(@xml,'/a/c[1]');
+SELECT extractValue(@xml,'/a/c[2]');
+
+SET @xml='<a><b x="xb1" x="xb2"/><c x="xc1" x="xc2"/></a>';
+SELECT extractValue(@xml,'/a//@x');
+SELECT extractValue(@xml,'/a//@x[1]');
+SELECT extractValue(@xml,'/a//@x[2]');
+
+SET @xml='<a><b>b1</b><b>b2</b><c><b>c1b1</b><b>c1b2</b></c><c><b>c2b1</c></b>/a>';
+SELECT extractValue(@xml,'//b[1]');
+SELECT extractValue(@xml,'/descendant::b[1]');
+
+SET @xml='<a><b>b1</b><b>b2</b></a>';
+SELECT extractValue(@xml,'/a/b[1+0]');
+SELECT extractValue(@xml,'/a/b[1*1]');
+SELECT extractValue(@xml,'/a/b[--1]');
+SELECT extractValue(@xml,'/a/b[2*1-1]');
+
+SELECT extractValue(@xml,'/a/b[1+1]');
+SELECT extractValue(@xml,'/a/b[1*2]');
+SELECT extractValue(@xml,'/a/b[--2]');
+SELECT extractValue(@xml,'/a/b[1*(3-1)]');
+
+SELECT extractValue(@xml,'//*[1=1]');
+SELECT extractValue(@xml,'//*[1!=1]');
+SELECT extractValue(@xml,'//*[1>1]');
+SELECT extractValue(@xml,'//*[2>1]');
+SELECT extractValue(@xml,'//*[1>2]');
+SELECT extractValue(@xml,'//*[1>=1]');
+SELECT extractValue(@xml,'//*[2>=1]');
+SELECT extractValue(@xml,'//*[1>=2]');
+SELECT extractValue(@xml,'//*[1<1]');
+SELECT extractValue(@xml,'//*[2<1]');
+SELECT extractValue(@xml,'//*[1<2]');
+SELECT extractValue(@xml,'//*[1<=1]');
+SELECT extractValue(@xml,'//*[2<=1]');
+SELECT extractValue(@xml,'//*[1<=2]');
+
+SET @xml='<a><b>b11<c>c11</c></b><b>b21<c>c21</c></b></a>';
+SELECT extractValue(@xml,'/a/b[c="c11"]');
+SELECT extractValue(@xml,'/a/b[c="c21"]');
+
+SET @xml='<a><b c="c11">b11</b><b c="c21">b21</b></a>';
+SELECT extractValue(@xml,'/a/b[@c="c11"]');
+SELECT extractValue(@xml,'/a/b[@c="c21"]');
+
+SET @xml='<a>a1<b c="c11">b11<d>d11</d></b><b c="c21">b21<d>d21</d></b></a>';
+SELECT extractValue(@xml, '/a/b[@c="c11"]/d');
+SELECT extractValue(@xml, '/a/b[@c="c21"]/d');
+SELECT extractValue(@xml, '/a/b[d="d11"]/@c');
+SELECT extractValue(@xml, '/a/b[d="d21"]/@c');
+SELECT extractValue(@xml, '/a[b="b11"]');
+SELECT extractValue(@xml, '/a[b/@c="c11"]');
+SELECT extractValue(@xml, '/a[b/d="d11"]');
+SELECT extractValue(@xml, '/a[/a/b="b11"]');
+SELECT extractValue(@xml, '/a[/a/b/@c="c11"]');
+SELECT extractValue(@xml, '/a[/a/b/d="d11"]');
+
+SELECT extractValue('<a>a</a>', '/a[false()]');
+SELECT extractValue('<a>a</a>', '/a[true()]');
+SELECT extractValue('<a>a</a>', '/a[not(false())]');
+SELECT extractValue('<a>a</a>', '/a[not(true())]');
+SELECT extractValue('<a>a</a>', '/a[true() and true()]');
+SELECT extractValue('<a>a</a>', '/a[true() and false()]');
+SELECT extractValue('<a>a</a>', '/a[false()and false()]');
+SELECT extractValue('<a>a</a>', '/a[false()and true()]');
+SELECT extractValue('<a>a</a>', '/a[true() or true()]');
+SELECT extractValue('<a>a</a>', '/a[true() or false()]');
+SELECT extractValue('<a>a</a>', '/a[false()or false()]');
+SELECT extractValue('<a>a</a>', '/a[false()or true()]');
+
+SET @xml='<a>ab<b c="c" c="e">b1</b><b c="d">b2</b><b c="f" c="e">b3</b></a>';
+select extractValue(@xml,'/a/b[@c="c"]');
+select extractValue(@xml,'/a/b[@c="d"]');
+select extractValue(@xml,'/a/b[@c="e"]');
+select extractValue(@xml,'/a/b[not(@c="e")]');
+select extractValue(@xml,'/a/b[@c!="e"]');
+select extractValue(@xml,'/a/b[@c="c" or @c="d"]');
+select extractValue(@xml,'/a/b[@c="c" and @c="e"]');
+
+SET @xml='<a><b c="c" d="d">b1</b><b d="d" e="e">b2</b></a>';
+select extractValue(@xml,'/a/b[@c]');
+select extractValue(@xml,'/a/b[@d]');
+select extractValue(@xml,'/a/b[@e]');
+select extractValue(@xml,'/a/b[not(@c)]');
+select extractValue(@xml,'/a/b[not(@d)]');
+select extractValue(@xml,'/a/b[not(@e)]');
+
+select extractValue(@xml, '/a/b[boolean(@c) or boolean(@d)]');
+select extractValue(@xml, '/a/b[boolean(@c) or boolean(@e)]');
+select extractValue(@xml, '/a/b[boolean(@d) or boolean(@e)]');
+select extractValue(@xml, '/a/b[boolean(@c) and boolean(@d)]');
+select extractValue(@xml, '/a/b[boolean(@c) and boolean(@e)]');
+select extractValue(@xml, '/a/b[boolean(@d) and boolean(@e)]');
+
+select extractValue(@xml, '/a/b[@c or @d]');
+select extractValue(@xml, '/a/b[@c or @e]');
+select extractValue(@xml, '/a/b[@d or @e]');
+select extractValue(@xml, '/a/b[@c and @d]');
+select extractValue(@xml, '/a/b[@c and @e]');
+select extractValue(@xml, '/a/b[@d and @e]');
+
+SET @xml='<a><b c="c">b1</b><b>b2</b></a>';
+SELECT extractValue(@xml,'/a/b[@*]');
+SELECT extractValue(@xml,'/a/b[not(@*)]');
+
+SELECT extractValue('<a>a</a>', '/a[ceiling(3.1)=4]');
+SELECT extractValue('<a>a</a>', '/a[floor(3.1)=3]');
+SELECT extractValue('<a>a</a>', '/a[round(3.1)=3]');
+SELECT extractValue('<a>a</a>', '/a[round(3.8)=4]');
+
+SELECT extractValue('<a><b>b</b><c>c</c></a>', '/a/b | /a/c');
+
+select extractValue('<a b="b1" b="b2" b="b3"/>','/a/@b[position()=1]');
+select extractValue('<a b="b1" b="b2" b="b3"/>','/a/@b[position()=2]');
+select extractValue('<a b="b1" b="b2" b="b3"/>','/a/@b[position()=3]');
+select extractValue('<a b="b1" b="b2" b="b3"/>','/a/@b[1=position()]');
+select extractValue('<a b="b1" b="b2" b="b3"/>','/a/@b[2=position()]');
+select extractValue('<a b="b1" b="b2" b="b3"/>','/a/@b[3=position()]');
+select extractValue('<a b="b1" b="b2" b="b3"/>','/a/@b[2>=position()]');
+select extractValue('<a b="b1" b="b2" b="b3"/>','/a/@b[2<=position()]');
+select extractValue('<a b="b1" b="b2" b="b3"/>','/a/@b[position()=3 or position()=2]');
+
+SELECT extractValue('<a>a<b>a1<c>c1</c></b><b>a2</b></a>','/a/b[count(c)=0]');
+SELECT extractValue('<a>a<b>a1<c>c1</c></b><b>a2</b></a>','/a/b[count(c)=1]');
+select extractValue('<a>a1<b ba="1" ba="2">b1</b><b>b2</b>4</a>','/a/b[sum(@ba)=3]');
+
+select extractValue('<a><b>b1</b><b>b2</b></a>','/a/b[1]');
+select extractValue('<a><b>b1</b><b>b2</b></a>','/a/b[boolean(1)]');
+select extractValue('<a><b>b1</b><b>b2</b></a>','/a/b[true()]');
+select extractValue('<a><b>b1</b><b>b2</b></a>','/a/b[number(true())]');
+
+select extractValue('<a>ab</a>','/a[contains("abc","b")]');
+select extractValue('<a>ab</a>','/a[contains(.,"a")]');
+select extractValue('<a>ab</a>','/a[contains(.,"b")]');
+select extractValue('<a>ab</a>','/a[contains(.,"c")]');
+
+select extractValue('<a b="1">ab</a>','/a[concat(@b,"2")="12"]');
+
+SET @xml='<a b="11" b="12" b="21" b="22">ab</a>';
+select extractValue(@xml, '/a/@b[substring(.,2)="1"]');
+select extractValue(@xml, '/a/@b[substring(.,2)="2"]');
+select extractValue(@xml, '/a/@b[substring(.,1,1)="1"]');
+select extractValue(@xml, '/a/@b[substring(.,1,1)="2"]');
+select extractValue(@xml, '/a/@b[substring(.,2,1)="1"]');
+select extractValue(@xml, '/a/@b[substring(.,2,1)="2"]');
+
+#
+# Bug#16319: XML: extractvalue() returns syntax errors for some functions
+#
+SET @xml='<a><b>b1</b><b>b2</b></a>';
+SELECT extractValue(@xml, '/a/b[string-length("x")=1]');
+SELECT extractValue(@xml, '/a/b[string-length("xx")=2]');
+SELECT extractValue(@xml, '/a/b[string-length("xxx")=2]');
+SELECT extractValue(@xml, '/a/b[string-length("x")]');
+SELECT extractValue(@xml, '/a/b[string-length("xx")]');
+SELECT extractValue(@xml, '/a/b[string-length()]');
+--error 1105
+SELECT extractValue(@xml, 'string-length()');
+SELECT extractValue(@xml, 'string-length("x")');
+
+SET @xml='<a b="b11" b="b12" b="b21" b="22"/>';
+select extractValue(@xml,'/a/@b');
+select extractValue(@xml,'/a/@b[contains(.,"1")]');
+select extractValue(@xml,'/a/@b[contains(.,"1")][contains(.,"2")]');
+select extractValue(@xml,'/a/@b[contains(.,"1")][contains(.,"2")][2]');
+
+SET @xml='<a>a1<b>b1<c>c1</c>b2</b>a2</a>';
+select UpdateXML('<a>a1<b>b1<c>c1</c>b2</b>a2</a>','/a/b/c','+++++++++');
+select UpdateXML('<a>a1<b>b1<c>c1</c>b2</b>a2</a>','/a/b/c','<c1>+++++++++</c1>');
+select UpdateXML('<a>a1<b>b1<c>c1</c>b2</b>a2</a>','/a/b/c','<c1/>');
+
+SET @xml='<a><b>bb</b></a>';
+select UpdateXML(@xml, '/a/b', '<b>ccc</b>');
+
+SET @xml='<a aa1="aa1" aa2="aa2"><b bb1="bb1" bb2="bb2">bb</b></a>';
+select UpdateXML(@xml, '/a/b', '<b>ccc</b>');
+select UpdateXML(@xml, '/a/@aa1', '');
+select UpdateXML(@xml, '/a/@aa1', 'aa3="aa3"');
+select UpdateXML(@xml, '/a/@aa2', '');
+select UpdateXML(@xml, '/a/@aa2', 'aa3="aa3"');
+select UpdateXML(@xml, '/a/b/@bb1', '');
+select UpdateXML(@xml, '/a/b/@bb1', 'bb3="bb3"');
+select UpdateXML(@xml, '/a/b/@bb2', '');
+select UpdateXML(@xml, '/a/b/@bb2', 'bb3="bb3"');
+
+#
+# Bug#16234 XML: Crash if ExtractValue()
+#
+SET @xml= '<order><clerk>lesser wombat</clerk></order>';
+select extractvalue(@xml,'order/clerk');
+select extractvalue(@xml,'/order/clerk');
+
+#
+# Bug#16314 XML: extractvalue() crash if vertical bar
+#
+select extractvalue('<a><b>B</b></a>','/a|/b');
+select extractvalue('<a><b>B</b></a>','/a|b');
+select extractvalue('<a>a<b>B</b></a>','/a|/b');
+select extractvalue('<a>a<b>B</b></a>','/a|b');
+select extractvalue('<a>a<b>B</b></a>','a|/b');
+
+#
+# Bug#16312 XML: extractvalue() crash if angle brackets
+#
+--error 1105
+select extractvalue('<a>A</a>','/<a>');
+
+#
+# Bug#16313 XML: extractvalue() ignores '!' in names
+#
+--error 1105
+select extractvalue('<a><b>b</b><b!>b!</b!></a>','//b!');
+
+#
+# Bug #16315 XML: extractvalue() handles self badly
+#
+select extractvalue('<a>A<b>B<c>C</c></b></a>','/a/descendant::*');
+select extractvalue('<a>A<b>B<c>C</c></b></a>','/a/self::*');
+select extractvalue('<a>A<b>B<c>C</c></b></a>','/a/descendant-or-self::*');
+# Bug #16320 XML: extractvalue() won't accept names containing underscores
+#
+select extractvalue('<A_B>A</A_B>','/A_B');
+
+#
+# Bug#16318: XML: extractvalue() incorrectly returns last() = 1
+#
+select extractvalue('<a>A<b>B1</b><b>B2</b></a>','/a/b[position()]');
+select extractvalue('<a>A<b>B1</b><b>B2</b></a>','/a/b[count(.)=last()]');
+select extractvalue('<a>A<b>B1</b><b>B2</b></a>','/a/b[last()]');
+select extractvalue('<a>A<b>B1</b><b>B2</b></a>','/a/b[last()-1]');
+select extractvalue('<a>A<b>B1</b><b>B2</b></a>','/a/b[last()=1]');
+select extractvalue('<a>A<b>B1</b><b>B2</b></a>','/a/b[last()=2]');
+select extractvalue('<a>A<b>B1</b><b>B2</b></a>','/a/b[last()=position()]');
+select extractvalue('<a>A<b>B1</b><b>B2</b></a>','/a/b[count(.)]');
+select extractvalue('<a>A<b>B1</b><b>B2</b></a>','/a/b[count(.)-1]');
+select extractvalue('<a>A<b>B1</b><b>B2</b></a>','/a/b[count(.)=1]');
+select extractvalue('<a>A<b>B1</b><b>B2</b></a>','/a/b[count(.)=2]');
+select extractvalue('<a>A<b>B1</b><b>B2</b></a>','/a/b[count(.)=position()]');
+#
+# Bug#16316: XML: extractvalue() is case-sensitive with contains()
+#
+select extractvalue('<a>Jack</a>','/a[contains(../a,"J")]');
+select extractvalue('<a>Jack</a>','/a[contains(../a,"j")]');
+select extractvalue('<a>Jack</a>','/a[contains(../a,"j")]' collate latin1_bin);
+select extractvalue('<a>Jack</a>' collate latin1_bin,'/a[contains(../a,"j")]');
+
+#
+# Bug#18285: ExtractValue not returning character
+# data within <![CDATA[]]> as expected
+#
+select ExtractValue('<tag1><![CDATA[test]]></tag1>','/tag1');
+
+#
+# Bug #18171 XML: ExtractValue: the XPath position()
+# function crashes the server!
+#
+--error 1105
+select extractValue('<e>1</e>','position()');
+--error 1105
+select extractValue('<e>1</e>','last()');
+
+
+#
+# Bug #18172 XML: Extractvalue() accepts mallformed
+# XPath without a XPath syntax error
+#
+--error 1105
+select extractValue('<e><a>1</a></e>','/e/');
+
+#
+# Bug#16233: XML: ExtractValue() fails with special characters
+#
+set names utf8;
+select extractValue('<Ñ><r>r</r></Ñ>','/Ñ/r');
+select extractValue('<r><Ñ>Ñ</Ñ></r>','/r/Ñ');
+select extractValue('<Ñ r="r"/>','/Ñ/@r');
+select extractValue('<r Ñ="Ñ"/>','/r/@Ñ');
+--disable_warnings
+DROP PROCEDURE IF EXISTS p2;
+--enable_warnings
+DELIMITER //;
+CREATE PROCEDURE p2 ()
+BEGIN
+ DECLARE p LONGTEXT CHARACTER SET UTF8 DEFAULT '<Ñ><r>A</r></Ñ>';
+ SELECT EXTRACTVALUE(p,'/Ñ/r');
+END//
+DELIMITER ;//
+CALL p2();
+DROP PROCEDURE p2;
+
+#
+# Bug#18170: XML: ExtractValue():
+# XPath expression can't use QNames (colon in names)
+#
+select extractValue('<ns:element xmlns:ns="myns"/>','count(ns:element)');
+select extractValue('<ns:element xmlns:ns="myns">a</ns:element>','/ns:element');
+select extractValue('<ns:element xmlns:ns="myns">a</ns:element>','/ns:element/@xmlns:ns');