summaryrefslogtreecommitdiff
path: root/mysql-test/suite/binlog/include
diff options
context:
space:
mode:
authorMichael Widenius <monty@mariadb.org>2018-03-09 15:05:22 +0200
committerMonty <monty@mariadb.org>2018-03-29 13:59:44 +0300
commit108ed228547943c65723adf86989a5aff844e01a (patch)
tree4f8ca397d442fab9131eca5d6d46acc59a1bf999 /mysql-test/suite/binlog/include
parenta7abddeffa6a760ce948c2dfb007cdf3f1a369d5 (diff)
downloadmariadb-git-108ed228547943c65723adf86989a5aff844e01a.tar.gz
Move mysql-test-run/extra/binlog to suite/binlog/include
Diffstat (limited to 'mysql-test/suite/binlog/include')
-rw-r--r--mysql-test/suite/binlog/include/binlog.test412
-rw-r--r--mysql-test/suite/binlog/include/binlog_cache_stat.test251
-rw-r--r--mysql-test/suite/binlog/include/binlog_incident-master.opt1
-rw-r--r--mysql-test/suite/binlog/include/binlog_incident.inc68
-rw-r--r--mysql-test/suite/binlog/include/binlog_index.inc278
-rw-r--r--mysql-test/suite/binlog/include/binlog_insert_delayed.test71
-rw-r--r--mysql-test/suite/binlog/include/binlog_ioerr.inc36
-rw-r--r--mysql-test/suite/binlog/include/binlog_mysqlbinlog-cp932.inc50
-rw-r--r--mysql-test/suite/binlog/include/binlog_row_annotate.inc192
-rw-r--r--mysql-test/suite/binlog/include/binlog_truncate.test63
-rw-r--r--mysql-test/suite/binlog/include/binlog_write_error.inc108
-rw-r--r--mysql-test/suite/binlog/include/binlog_xa_recover.inc281
-rw-r--r--mysql-test/suite/binlog/include/blackhole.test208
-rw-r--r--mysql-test/suite/binlog/include/ctype_cp932.test468
-rw-r--r--mysql-test/suite/binlog/include/ctype_cp932_binlog.test35
-rw-r--r--mysql-test/suite/binlog/include/ctype_ucs_binlog.result212
-rw-r--r--mysql-test/suite/binlog/include/ctype_ucs_binlog.test63
-rw-r--r--mysql-test/suite/binlog/include/database.test94
-rw-r--r--mysql-test/suite/binlog/include/drop_table.test34
-rw-r--r--mysql-test/suite/binlog/include/drop_temp_table.test102
-rw-r--r--mysql-test/suite/binlog/include/implicit.test28
-rw-r--r--mysql-test/suite/binlog/include/insert_select-binlog.test38
-rw-r--r--mysql-test/suite/binlog/include/mix_innodb_myisam_binlog.test654
-rw-r--r--mysql-test/suite/binlog/include/mix_innodb_myisam_side_effects.test295
-rw-r--r--mysql-test/suite/binlog/include/mysqlbinlog_row_engine.inc1923
25 files changed, 5965 insertions, 0 deletions
diff --git a/mysql-test/suite/binlog/include/binlog.test b/mysql-test/suite/binlog/include/binlog.test
new file mode 100644
index 00000000000..92fcb3a792b
--- /dev/null
+++ b/mysql-test/suite/binlog/include/binlog.test
@@ -0,0 +1,412 @@
+#
+# misc binlogging tests that do not require a slave running
+#
+
+-- source include/have_log_bin.inc
+-- source include/not_embedded.inc
+-- source include/have_innodb.inc
+-- source include/have_debug.inc
+
+--disable_warnings
+drop table if exists t1, t2;
+--enable_warnings
+reset master;
+
+create table t1 (a int) engine=innodb;
+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
+source include/show_binlog_events.inc;
+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;
+# Make sure binlog checkpoint is logged before DROP TABLE to avoid random
+# result difference.
+--source include/wait_for_binlog_checkpoint.inc
+drop table t1;
+--source include/show_binlog_events.inc
+--let $binlog_file= query_get_value(SHOW MASTER STATUS, File, 1)
+--source include/show_binlog_events.inc
+--let $binlog_file=
+
+#
+# Bug#22540 - Incorrect value in column End_log_pos of
+# SHOW BINLOG EVENTS using InnoDB
+#
+
+# the following tests will show that certain queries now return
+# absolute offsets (from binlog start, rather than relative to
+# the beginning of the current transaction). under what
+# conditions it should be allowed / is sensible to put the
+# slider into the middle of a transaction is not our concern
+# here; we just guarantee that if and when it's done, the
+# user has valid offsets to use. if the setter function still
+# wants to throw a "positioning into middle of transaction"
+# warning, that's its prerogative and handled elsewhere.
+
+set @ac = @@autocommit;
+
+# first show this to work for SHOW BINLOG EVENTS
+
+set autocommit= 0;
+reset master;
+create table t1(n int) engine=innodb;
+begin;
+insert into t1 values (1);
+insert into t1 values (2);
+insert into t1 values (3);
+commit;
+drop table t1;
+--source include/show_binlog_events.inc
+
+# now show that nothing breaks if we need to read from the cache more
+# than once, resulting in split event-headers
+
+set @bcs = @@binlog_cache_size;
+set global binlog_cache_size=4096;
+reset master;
+
+create table t1 (a int, b char(255)) engine=innodb;
+
+flush status;
+show status like "binlog_cache_use";
+
+let $1=100;
+disable_query_log;
+begin;
+while ($1)
+{
+ eval insert into t1 values( $1, 'just to fill void to make transaction occupying at least two buffers of the trans cache' );
+ dec $1;
+}
+commit;
+--echo *** the following must show the counter value = 1 ***
+show status like "binlog_cache_use";
+enable_query_log;
+
+--source include/show_binlog_events.inc
+
+drop table t1;
+
+set global binlog_cache_size=@bcs;
+set session autocommit = @ac;
+
+#
+# Bug#33798: prepared statements improperly handle large unsigned ints
+#
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+reset master;
+create table t1 (a bigint unsigned, b bigint(20) unsigned);
+prepare stmt from "insert into t1 values (?,?)";
+set @a= 9999999999999999;
+set @b= 14632475938453979136;
+execute stmt using @a, @b;
+deallocate prepare stmt;
+drop table t1;
+--source include/show_binlog_events.inc
+
+
+#
+# Bug #39182: Binary log producing incompatible character set query from
+# stored procedure.
+#
+reset master;
+CREATE DATABASE bug39182 DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
+USE bug39182;
+CREATE TABLE t1 (a VARCHAR(255) COLLATE utf8_unicode_ci)
+ DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
+DELIMITER //;
+
+CREATE PROCEDURE p1()
+BEGIN
+ DECLARE s1 VARCHAR(255);
+ SET s1= "test";
+ CREATE TEMPORARY TABLE tmp1
+ SELECT * FROM t1 WHERE a LIKE CONCAT("%", s1, "%");
+ SELECT
+ COLLATION(NAME_CONST('s1', _utf8'test')) c1,
+ COLLATION(NAME_CONST('s1', _utf8'test' COLLATE utf8_unicode_ci)) c2,
+ COLLATION(s1) c3,
+ COERCIBILITY(NAME_CONST('s1', _utf8'test')) d1,
+ COERCIBILITY(NAME_CONST('s1', _utf8'test' COLLATE utf8_unicode_ci)) d2,
+ COERCIBILITY(s1) d3;
+ DROP TEMPORARY TABLE tmp1;
+END//
+
+DELIMITER ;//
+
+CALL p1();
+source include/show_binlog_events.inc;
+
+DROP PROCEDURE p1;
+DROP TABLE t1;
+DROP DATABASE bug39182;
+USE test;
+
+#
+# Bug#35383: binlog playback and replication breaks due to
+# name_const substitution
+#
+DELIMITER //;
+CREATE PROCEDURE p1(IN v1 INT)
+BEGIN
+ CREATE TABLE t1 SELECT v1;
+ DROP TABLE t1;
+END//
+CREATE PROCEDURE p2()
+BEGIN
+ DECLARE v1 INT;
+ CREATE TABLE t1 SELECT v1+1;
+ DROP TABLE t1;
+END//
+CREATE PROCEDURE p3(IN v1 INT)
+BEGIN
+ CREATE TABLE t1 SELECT 1 FROM DUAL WHERE v1!=0;
+ DROP TABLE t1;
+END//
+CREATE PROCEDURE p4(IN v1 INT)
+BEGIN
+ DECLARE v2 INT;
+ CREATE TABLE t1 SELECT 1, v1, v2;
+ DROP TABLE t1;
+ CREATE TABLE t1 SELECT 1, v1+1, v2;
+ DROP TABLE t1;
+END//
+DELIMITER ;//
+
+CALL p1(1);
+CALL p2();
+CALL p3(0);
+CALL p4(0);
+DROP PROCEDURE p1;
+DROP PROCEDURE p2;
+DROP PROCEDURE p3;
+DROP PROCEDURE p4;
+
+--echo End of 5.0 tests
+
+# Test of a too big SET INSERT_ID.
+# This should generate an error and should not be put in binlog
+# We look at the binlog further down with SHOW BINLOG EVENTS.
+
+reset master;
+create table t1 (id tinyint auto_increment primary key);
+insert into t1 values(5);
+set insert_id=128;
+--error HA_ERR_AUTOINC_ERANGE
+insert into t1 values(null) /* Not binlogged */;
+
+# The followin insert ignore will be put in binlog
+set insert_id=128;
+insert ignore into t1 values(null) /* Insert 128 */;
+
+# Insert with duplicate key error should not go into binglo
+set insert_id=5;
+--error ER_DUP_ENTRY
+insert into t1 values(null) /* Not binlogged */;
+
+# Insert with autogenerated key + duplicate key error should go into binlog
+set insert_id=5;
+insert ignore into t1 values(null) /* Insert 5 */;
+select * from t1;
+drop table t1;
+
+# Same tests but with 2 rows inserted at a time
+
+create table t1 (id tinyint auto_increment primary key) engine=myisam;
+set insert_id=128;
+--error HA_ERR_AUTOINC_ERANGE
+insert into t1 values(5),(null) /* Insert_id 128 */;
+
+# The followin insert ignore will be put in binlog
+set insert_id=128;
+insert ignore into t1 values (4),(null) /* Insert_id 128 */;
+
+# Insert with duplicate key error should not go into binglo
+set insert_id=5;
+--error ER_DUP_ENTRY
+insert into t1 values(3),(null) /* Insert_id 5 */;
+
+# Insert with autogenerated key + duplicate key error should go into binlog
+set insert_id=5;
+insert ignore into t1 values(2),(null) /* Insert_id 5 */;
+select * from t1 order by id;
+drop table t1;
+
+
+# bug#22027
+create table t1 (a int);
+create table if not exists t2 select * from t1;
+
+# bug#22762
+create temporary table tt1 (a int);
+create table if not exists t3 like tt1;
+
+# BUG#25091 (A DELETE statement to mysql database is not logged with
+# ROW mode format): Checking that some basic operations on tables in
+# the mysql database is replicated even when the current database is
+# 'mysql'.
+
+--disable_warnings
+USE mysql;
+INSERT IGNORE INTO user SET host='localhost', user='@#@', password=password('Just a test');
+UPDATE user SET password=password('Another password') WHERE host='localhost' AND user='@#@';
+DELETE FROM user WHERE host='localhost' AND user='@#@';
+--enable_warnings
+
+use test;
+source include/show_binlog_events.inc;
+drop table t1,t2,t3,tt1;
+
+-- source suite/binlog/include/binlog_insert_delayed.test
+
+#Bug #26079 max_binlog_size + innodb = not make new binlog and hang server
+# server should not hang, binlog must rotate in the end
+reset master;
+--disable_warnings
+drop table if exists t3;
+--enable_warnings
+create table t3 (a int(11) NOT NULL AUTO_INCREMENT, b text, PRIMARY KEY (a) ) engine=innodb;
+--let $binlog_file1= query_get_value(SHOW MASTER STATUS, File, 1)
+--echo File $binlog_file1
+let $it=4;
+while ($it)
+{
+insert into t3(b) values ('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');
+dec $it;
+}
+--let $binlog_file2= query_get_value(SHOW MASTER STATUS, File, 1)
+--echo *** show new binlog index after rotating ***
+--echo File $binlog_file2
+drop table t3;
+
+--echo #
+--echo # Bug #45998: database crashes when running "create as select"
+--echo #
+CREATE DATABASE test1;
+USE test1;
+DROP DATABASE test1;
+CREATE TABLE test.t1(a int);
+INSERT INTO test.t1 VALUES (1), (2);
+CREATE TABLE test.t2 SELECT * FROM test.t1;
+USE test;
+DROP TABLES t1, t2;
+
+#
+# Bug#46640
+# This test verifies if the server_id stored in the "format
+# description BINLOG statement" will override the server_id
+# of the server executing the statements.
+#
+
+connect (fresh,localhost,root,,test);
+connection fresh;
+
+RESET MASTER;
+CREATE TABLE t1 (a INT PRIMARY KEY);
+
+# Format description event, with server_id = 10;
+BINLOG '
+3u9kSA8KAAAAZgAAAGoAAAABAAQANS4xLjM1LW1hcmlhLWJldGExLWRlYnVnLWxvZwAAAAAAAAAA
+AAAAAAAAAAAAAAAAAADe72RIEzgNAAgAEgAEBAQEEgAAUwAEGggAAAAICAgC
+';
+
+# What server_id is logged for a statement? Should be our own, not the
+# one from the format description event.
+INSERT INTO t1 VALUES (1);
+
+# INSERT INTO t1 VALUES (2), with server_id=20. Check that this is logged
+# with our own server id, not the 20 from the BINLOG statement.
+BINLOG '
+3u9kSBMUAAAAKQAAAJEBAAAAABoAAAAAAAAABHRlc3QAAnQxAAEDAAA=
+3u9kSBcUAAAAIgAAALMBAAAQABoAAAAAAAEAAf/+AgAAAA==
+';
+
+# Show binlog events to check that server ids are correct.
+--replace_column 1 # 2 # 5 #
+--replace_regex /Server ver: .*, Binlog ver: .*/Server ver: #, Binlog ver: #/ /table_id: [0-9]+/table_id: #/
+SHOW BINLOG EVENTS;
+
+DROP TABLE t1;
+
+--echo
+--echo # BUG#54903 BINLOG statement toggles session variables
+--echo # ----------------------------------------------------------------------
+--echo # This test verify that BINLOG statement doesn't change current session's
+--echo # variables foreign_key_checks and unique_checks.
+--echo
+CREATE TABLE t1 (c1 INT KEY);
+
+SET @@SESSION.foreign_key_checks= ON;
+SET @@SESSION.unique_checks= ON;
+
+--echo # INSERT INTO t1 VALUES (1)
+--echo # foreign_key_checks=0 and unique_checks=0
+BINLOG '
+dfLtTBMBAAAAKQAAANcAAAAAABcAAAAAAAEABHRlc3QAAnQxAAEDAAE=
+dfLtTBcBAAAAIgAAAPkAAAAAABcAAAAAAAcAAf/+AQAAAA==
+';
+
+SELECT * FROM t1;
+--echo # Their values should be ON
+SHOW SESSION VARIABLES LIKE "foreign_key_checks";
+SHOW SESSION VARIABLES LIKE "unique_checks";
+
+--echo
+SET @@SESSION.foreign_key_checks= OFF;
+SET @@SESSION.unique_checks= OFF;
+
+--echo # INSERT INTO t1 VALUES(2)
+--echo # foreign_key_checks=1 and unique_checks=1
+BINLOG '
+dfLtTBMBAAAAKQAAAKsBAAAAABcAAAAAAAEABHRlc3QAAnQxAAEDAAE=
+dfLtTBcBAAAAIgAAAM0BAAAAABcAAAAAAAEAAf/+AgAAAA==
+';
+
+SELECT * FROM t1;
+--echo # Their values should be OFF
+SHOW SESSION VARIABLES LIKE "foreign_key_checks";
+SHOW SESSION VARIABLES LIKE "unique_checks";
+
+--echo # INSERT INTO t1 VALUES(2)
+--echo # foreign_key_checks=1 and unique_checks=1
+--echo # It should not change current session's variables, even error happens
+call mtr.add_suppression("Slave SQL.*Could not execute Write_rows_v1 event on table test.t1; Duplicate entry .2. for key .PRIMARY., Error_code: 1062");
+--error 1062
+BINLOG '
+dfLtTBMBAAAAKQAAAKsBAAAAABcAAAAAAAEABHRlc3QAAnQxAAEDAAE=
+dfLtTBcBAAAAIgAAAM0BAAAAABcAAAAAAAEAAf/+AgAAAA==
+';
+
+SELECT * FROM t1;
+--echo # Their values should be OFF
+SHOW SESSION VARIABLES LIKE "foreign_key_checks";
+SHOW SESSION VARIABLES LIKE "unique_checks";
+
+DROP TABLE t1;
+
+disconnect fresh;
+
diff --git a/mysql-test/suite/binlog/include/binlog_cache_stat.test b/mysql-test/suite/binlog/include/binlog_cache_stat.test
new file mode 100644
index 00000000000..a602b098201
--- /dev/null
+++ b/mysql-test/suite/binlog/include/binlog_cache_stat.test
@@ -0,0 +1,251 @@
+# Embedded server doesn't support binlog
+-- source include/not_embedded.inc
+-- source include/have_innodb.inc
+
+# Creating tables
+--disable_warnings
+drop table if exists t1, t2;
+--enable_warnings
+
+create table t1 (a int) engine=innodb;
+create table t2 (a int) engine=myisam;
+
+#
+# This test checks binlog_cache_use and binlog_cache_disk_use when
+# transactions are committed and after when they are aborted.
+#
+
+#
+# Checking commit.
+#
+--echo **** Preparing the enviroment to check commit and its effect on status variables.
+--echo **** Expected: binlog_cache_use = 0, binlog_cache_disk_use = 0.
+--echo **** Expected: binlog_stmt_cache_use = 0, binlog_stmt_cache_disk_use = 0.
+flush status;
+let $exp_cache= 0;
+let $got_cache= query_get_value(show status like "binlog_cache_use", Value, 1);
+let $exp_disk= 0;
+let $got_disk= query_get_value(show status like "binlog_cache_disk_use", Value, 1);
+let $exp_stmt_cache= 0;
+let $got_stmt_cache= query_get_value(show status like "binlog_stmt_cache_use", Value, 1);
+let $exp_stmt_disk= 0;
+let $got_stmt_disk= query_get_value(show status like "binlog_stmt_cache_disk_use", Value, 1);
+if (`SELECT $got_cache <> $exp_cache || $got_disk <> $exp_disk || $got_stmt_cache <> $exp_stmt_cache || $got_stmt_disk <> $exp_stmt_disk`)
+{
+ -- echo "Expected: binlog_cache_use = $exp_cache, binlog_cache_disk_use = $exp_disk but got binlog_cache_use = $got_cache, binlog_cache_disk_use = $got_disk"
+ -- echo "Expected: binlog_stmt_cache_use = $exp_stmt_cache, binlog_stmt_cache_disk_use = $exp_stmt_disk but got binlog_stmt_cache_use = $got_stmt_cache, binlog_stmt_cache_disk_use = $got_stmt_disk"
+ -- die
+}
+
+--echo **** Transactional changes which are long enough so they will be flushed to disk...
+--echo **** Expected: binlog_cache_use = 1, binlog_cache_disk_use = 1.
+--echo **** Expected: binlog_stmt_cache_use = 0, binlog_stmt_cache_disk_use = 0.
+let $1=2000;
+disable_query_log;
+begin;
+while ($1)
+{
+ eval insert into t1 values( $1 );
+ dec $1;
+}
+commit;
+enable_query_log;
+let $exp_cache= 1;
+let $got_cache= query_get_value(show status like "binlog_cache_use", Value, 1);
+let $exp_disk= 1;
+let $got_disk= query_get_value(show status like "binlog_cache_disk_use", Value, 1);
+let $exp_stmt_cache= 0;
+let $got_stmt_cache= query_get_value(show status like "binlog_stmt_cache_use", Value, 1);
+let $exp_stmt_disk= 0;
+let $got_stmt_disk= query_get_value(show status like "binlog_stmt_cache_disk_use", Value, 1);
+if (`SELECT $got_cache <> $exp_cache || $got_disk <> $exp_disk || $got_stmt_cache <> $exp_stmt_cache || $got_stmt_disk <> $exp_stmt_disk`)
+{
+ -- echo "Expected: binlog_cache_use = $exp_cache, binlog_cache_disk_use = $exp_disk but got binlog_cache_use = $got_cache, binlog_cache_disk_use = $got_disk"
+ -- echo "Expected: binlog_stmt_cache_use = $exp_stmt_cache, binlog_stmt_cache_disk_use = $exp_stmt_disk but got binlog_stmt_cache_use = $got_stmt_cache, binlog_stmt_cache_disk_use = $got_stmt_disk"
+ -- die
+}
+
+--echo **** Transactional changes which should not be flushed to disk and so should not
+--echo **** increase either binlog_cache_disk_use or binlog_stmt_cache_disk_use.
+--echo **** Expected: binlog_cache_use = 2, binlog_cache_disk_use = 1.
+--echo **** Expected: binlog_stmt_cache_use = 0, binlog_stmt_cache_disk_use = 0.
+begin;
+insert into t1 values( 1 );
+commit;
+let $exp_cache= 2;
+let $got_cache= query_get_value(show status like "binlog_cache_use", Value, 1);
+let $exp_disk= 1;
+let $got_disk= query_get_value(show status like "binlog_cache_disk_use", Value, 1);
+let $exp_stmt_cache= 0;
+let $got_stmt_cache= query_get_value(show status like "binlog_stmt_cache_use", Value, 1);
+let $exp_stmt_disk= 0;
+let $got_stmt_disk= query_get_value(show status like "binlog_stmt_cache_disk_use", Value, 1);
+if (`SELECT $got_cache <> $exp_cache || $got_disk <> $exp_disk || $got_stmt_cache <> $exp_stmt_cache || $got_stmt_disk <> $exp_stmt_disk`)
+{
+ -- echo "Expected: binlog_cache_use = $exp_cache, binlog_cache_disk_use = $exp_disk but got binlog_cache_use = $got_cache, binlog_cache_disk_use = $got_disk"
+ -- echo "Expected: binlog_stmt_cache_use = $exp_stmt_cache, binlog_stmt_cache_disk_use = $exp_stmt_disk but got binlog_stmt_cache_use = $got_stmt_cache, binlog_stmt_cache_disk_use = $got_stmt_disk"
+ -- die
+}
+
+--echo **** Non-Transactional changes which should not be flushed to disk and so should not
+--echo **** increase either binlog_cache_disk_use or binlog_stmt_cache_disk_use.
+--echo **** Expected: binlog_cache_use = 2, binlog_cache_disk_use = 1.
+--echo **** Expected: binlog_stmt_cache_use = 1, binlog_stmt_cache_disk_use = 0.
+begin;
+insert into t2 values( 1 );
+commit;
+let $exp_cache= 2;
+let $got_cache= query_get_value(show status like "binlog_cache_use", Value, 1);
+let $exp_disk= 1;
+let $got_disk= query_get_value(show status like "binlog_cache_disk_use", Value, 1);
+let $exp_stmt_cache= 1;
+let $got_stmt_cache= query_get_value(show status like "binlog_stmt_cache_use", Value, 1);
+let $exp_stmt_disk= 0;
+let $got_stmt_disk= query_get_value(show status like "binlog_stmt_cache_disk_use", Value, 1);
+if (`SELECT $got_cache <> $exp_cache || $got_disk <> $exp_disk || $got_stmt_cache <> $exp_stmt_cache || $got_stmt_disk <> $exp_stmt_disk`)
+{
+ -- echo "Expected: binlog_cache_use = $exp_cache, binlog_cache_disk_use = $exp_disk but got binlog_cache_use = $got_cache, binlog_cache_disk_use = $got_disk"
+ -- echo "Expected: binlog_stmt_cache_use = $exp_stmt_cache, binlog_stmt_cache_disk_use = $exp_stmt_disk but got binlog_stmt_cache_use = $got_stmt_cache, binlog_stmt_cache_disk_use = $got_stmt_disk"
+ -- die
+}
+
+--echo **** Mixed changes which should not be flushed to disk and so should not
+--echo **** increase either binlog_cache_disk_use or binlog_stmt_cache_disk_use.
+--echo **** Expected: binlog_cache_use = 3, binlog_cache_disk_use = 1.
+--echo **** Expected: binlog_stmt_cache_use = 2, binlog_stmt_cache_disk_use = 0.
+begin;
+insert into t1 values( 1 );
+insert into t2 values( 1 );
+commit;
+let $exp_cache= 3;
+let $got_cache= query_get_value(show status like "binlog_cache_use", Value, 1);
+let $exp_disk= 1;
+let $got_disk= query_get_value(show status like "binlog_cache_disk_use", Value, 1);
+let $exp_stmt_cache= 2;
+let $got_stmt_cache= query_get_value(show status like "binlog_stmt_cache_use", Value, 1);
+let $exp_stmt_disk= 0;
+let $got_stmt_disk= query_get_value(show status like "binlog_stmt_cache_disk_use", Value, 1);
+if (`SELECT $got_cache <> $exp_cache || $got_disk <> $exp_disk || $got_stmt_cache <> $exp_stmt_cache || $got_stmt_disk <> $exp_stmt_disk`)
+{
+ -- echo "Expected: binlog_cache_use = $exp_cache, binlog_cache_disk_use = $exp_disk but got binlog_cache_use = $got_cache, binlog_cache_disk_use = $got_disk"
+ -- echo "Expected: binlog_stmt_cache_use = $exp_stmt_cache, binlog_stmt_cache_disk_use = $exp_stmt_disk but got binlog_stmt_cache_use = $got_stmt_cache, binlog_stmt_cache_disk_use = $got_stmt_disk"
+ -- die
+}
+
+#
+# Checking abort.
+#
+--echo **** Preparing the enviroment to check abort and its effect on the status variables.
+--echo **** Expected: binlog_cache_use = 0, binlog_cache_disk_use = 0.
+--echo **** Expected: binlog_stmt_cache_use = 0, binlog_stmt_cache_disk_use = 0.
+flush status;
+let $exp_cache= 0;
+let $got_cache= query_get_value(show status like "binlog_cache_use", Value, 1);
+let $exp_disk= 0;
+let $got_disk= query_get_value(show status like "binlog_cache_disk_use", Value, 1);
+let $exp_stmt_cache= 0;
+let $got_stmt_cache= query_get_value(show status like "binlog_stmt_cache_use", Value, 1);
+let $exp_stmt_disk= 0;
+let $got_stmt_disk= query_get_value(show status like "binlog_stmt_cache_disk_use", Value, 1);
+if (`SELECT $got_cache <> $exp_cache || $got_disk <> $exp_disk || $got_stmt_cache <> $exp_stmt_cache || $got_stmt_disk <> $exp_stmt_disk`)
+{
+ -- echo "Expected: binlog_cache_use = $exp_cache, binlog_cache_disk_use = $exp_disk but got binlog_cache_use = $got_cache, binlog_cache_disk_use = $got_disk"
+ -- echo "Expected: binlog_stmt_cache_use = $exp_stmt_cache, binlog_stmt_cache_disk_use = $exp_stmt_disk but got binlog_stmt_cache_use = $got_stmt_cache, binlog_stmt_cache_disk_use = $got_stmt_disk"
+ -- die
+}
+
+--echo **** Transactional changes which are long enough so they will be flushed to disk...
+--echo **** Expected: binlog_cache_use = 1, binlog_cache_disk_use = 1.
+--echo **** Expected: binlog_stmt_cache_use = 0, binlog_stmt_cache_disk_use = 0.
+let $1=2000;
+disable_query_log;
+begin;
+while ($1)
+{
+ eval insert into t1 values( $1 );
+ dec $1;
+}
+rollback;
+enable_query_log;
+let $exp_cache= 1;
+let $got_cache= query_get_value(show status like "binlog_cache_use", Value, 1);
+let $exp_disk= 1;
+let $got_disk= query_get_value(show status like "binlog_cache_disk_use", Value, 1);
+let $exp_stmt_cache= 0;
+let $got_stmt_cache= query_get_value(show status like "binlog_stmt_cache_use", Value, 1);
+let $exp_stmt_disk= 0;
+let $got_stmt_disk= query_get_value(show status like "binlog_stmt_cache_disk_use", Value, 1);
+if (`SELECT $got_cache <> $exp_cache || $got_disk <> $exp_disk || $got_stmt_cache <> $exp_stmt_cache || $got_stmt_disk <> $exp_stmt_disk`)
+{
+ -- echo "Expected: binlog_cache_use = $exp_cache, binlog_cache_disk_use = $exp_disk but got binlog_cache_use = $got_cache, binlog_cache_disk_use = $got_disk"
+ -- echo "Expected: binlog_stmt_cache_use = $exp_stmt_cache, binlog_stmt_cache_disk_use = $exp_stmt_disk but got binlog_stmt_cache_use = $got_stmt_cache, binlog_stmt_cache_disk_use = $got_stmt_disk"
+ -- die
+}
+
+--echo **** Transactional changes which should not be flushed to disk and so should not
+--echo **** increase either binlog_cache_disk_use or binlog_stmt_cache_disk_use.
+--echo **** Expected: binlog_cache_use = 2, binlog_cache_disk_use = 1.
+--echo **** Expected: binlog_stmt_cache_use = 0, binlog_stmt_cache_disk_use = 0.
+begin;
+insert into t1 values( 1 );
+rollback;
+let $exp_cache= 2;
+let $got_cache= query_get_value(show status like "binlog_cache_use", Value, 1);
+let $exp_disk= 1;
+let $got_disk= query_get_value(show status like "binlog_cache_disk_use", Value, 1);
+let $exp_stmt_cache= 0;
+let $got_stmt_cache= query_get_value(show status like "binlog_stmt_cache_use", Value, 1);
+let $exp_stmt_disk= 0;
+let $got_stmt_disk= query_get_value(show status like "binlog_stmt_cache_disk_use", Value, 1);
+if (`SELECT $got_cache <> $exp_cache || $got_disk <> $exp_disk || $got_stmt_cache <> $exp_stmt_cache || $got_stmt_disk <> $exp_stmt_disk`)
+{
+ -- echo "Expected: binlog_cache_use = $exp_cache, binlog_cache_disk_use = $exp_disk but got binlog_cache_use = $got_cache, binlog_cache_disk_use = $got_disk"
+ -- echo "Expected: binlog_stmt_cache_use = $exp_stmt_cache, binlog_stmt_cache_disk_use = $exp_stmt_disk but got binlog_stmt_cache_use = $got_stmt_cache, binlog_stmt_cache_disk_use = $got_stmt_disk"
+ -- die
+}
+
+--echo **** Non-Transactional changes which should not be flushed to disk and so should not
+--echo **** increase either binlog_cache_disk_use or binlog_stmt_cache_disk_use.
+--echo **** Expected: binlog_cache_use = 2, binlog_cache_disk_use = 1.
+--echo **** Expected: binlog_stmt_cache_use = 1, binlog_stmt_cache_disk_use = 0.
+begin;
+insert into t2 values( 1 );
+rollback;
+let $exp_cache= 2;
+let $got_cache= query_get_value(show status like "binlog_cache_use", Value, 1);
+let $exp_disk= 1;
+let $got_disk= query_get_value(show status like "binlog_cache_disk_use", Value, 1);
+let $exp_stmt_cache= 1;
+let $got_stmt_cache= query_get_value(show status like "binlog_stmt_cache_use", Value, 1);
+let $exp_stmt_disk= 0;
+let $got_stmt_disk= query_get_value(show status like "binlog_stmt_cache_disk_use", Value, 1);
+if (`SELECT $got_cache <> $exp_cache || $got_disk <> $exp_disk || $got_stmt_cache <> $exp_stmt_cache || $got_stmt_disk <> $exp_stmt_disk`)
+{
+ -- echo "Expected: binlog_cache_use = $exp_cache, binlog_cache_disk_use = $exp_disk but got binlog_cache_use = $got_cache, binlog_cache_disk_use = $got_disk"
+ -- echo "Expected: binlog_stmt_cache_use = $exp_stmt_cache, binlog_stmt_cache_disk_use = $exp_stmt_disk but got binlog_stmt_cache_use = $got_stmt_cache, binlog_stmt_cache_disk_use = $got_stmt_disk"
+ -- die
+}
+
+--echo **** Mixed changes which should not be flushed to disk and so should not
+--echo **** increase either binlog_cache_disk_use or binlog_stmt_cache_disk_use.
+--echo **** Expected: binlog_cache_use = 3, binlog_cache_disk_use = 1.
+--echo **** Expected: binlog_stmt_cache_use = 2, binlog_stmt_cache_disk_use = 0.
+begin;
+insert into t1 values( 1 );
+insert into t2 values( 1 );
+rollback;
+let $exp_cache= 3;
+let $got_cache= query_get_value(show status like "binlog_cache_use", Value, 1);
+let $exp_disk= 1;
+let $got_disk= query_get_value(show status like "binlog_cache_disk_use", Value, 1);
+let $exp_stmt_cache= 2;
+let $got_stmt_cache= query_get_value(show status like "binlog_stmt_cache_use", Value, 1);
+let $exp_stmt_disk= 0;
+let $got_stmt_disk= query_get_value(show status like "binlog_stmt_cache_disk_use", Value, 1);
+if (`SELECT $got_cache <> $exp_cache || $got_disk <> $exp_disk || $got_stmt_cache <> $exp_stmt_cache || $got_stmt_disk <> $exp_stmt_disk`)
+{
+ -- echo "Expected: binlog_cache_use = $exp_cache, binlog_cache_disk_use = $exp_disk but got binlog_cache_use = $got_cache, binlog_cache_disk_use = $got_disk"
+ -- echo "Expected: binlog_stmt_cache_use = $exp_stmt_cache, binlog_stmt_cache_disk_use = $exp_stmt_disk but got binlog_stmt_cache_use = $got_stmt_cache, binlog_stmt_cache_disk_use = $got_stmt_disk"
+ -- die
+}
+drop table t1, t2;
diff --git a/mysql-test/suite/binlog/include/binlog_incident-master.opt b/mysql-test/suite/binlog/include/binlog_incident-master.opt
new file mode 100644
index 00000000000..57ce0081ae5
--- /dev/null
+++ b/mysql-test/suite/binlog/include/binlog_incident-master.opt
@@ -0,0 +1 @@
+--loose-debug=+d,incident_database_resync_on_replace \ No newline at end of file
diff --git a/mysql-test/suite/binlog/include/binlog_incident.inc b/mysql-test/suite/binlog/include/binlog_incident.inc
new file mode 100644
index 00000000000..dd37a58628a
--- /dev/null
+++ b/mysql-test/suite/binlog/include/binlog_incident.inc
@@ -0,0 +1,68 @@
+#
+# This include file is used by more than one test suite
+# (currently rpl and binlog_encryption).
+# Please check all dependent tests after modifying it
+#
+# Usage:
+#
+# --let $use_remote_mysqlbinlog= 1 # optional
+# --let $binlog_start_pos= <binlog position> # optional
+# --let $binlog_file= <binlog filename> # optional
+#
+# --source suite/binlog/include/binlog_incident.inc
+#
+# The script uses MYSQLBINLOG to verify certain results.
+# By default, it uses binary logs directly. If it is undesirable,
+# this behavior can be overridden by setting $use_remote_binlog
+# as shown above.
+#
+# All values will be unset after every execution of the script,
+# so if they are needed, they should be set explicitly before each call.
+#
+
+# The purpose of this test is to provide a reference for how the
+# incident log event is represented in the output from the mysqlbinlog
+# program.
+
+source include/have_log_bin.inc;
+source include/have_debug.inc;
+source include/binlog_start_pos.inc;
+
+let $MYSQLD_DATADIR= `select @@datadir`;
+RESET MASTER;
+
+CREATE TABLE t1 (a INT);
+
+INSERT INTO t1 VALUES (1),(2),(3);
+SELECT * FROM t1;
+
+# This will generate an incident log event and store it in the binary
+# log before the replace statement.
+REPLACE INTO t1 VALUES (4);
+
+DROP TABLE t1;
+FLUSH LOGS;
+
+if ($binlog_start_pos)
+{
+ --let $startpos= --start-position=$binlog_start_pos
+ --let $binlog_start_pos=
+}
+--let $filename= master-bin.000001
+if ($binlog_file)
+{
+ --let $filename= $binlog_file
+ --let $binlog_file=
+}
+--let $mysqlbinlog_args= $MYSQLD_DATADIR/$filename
+if ($use_remote_mysqlbinlog)
+{
+ --let $mysqlbinlog_args= --read-from-remote-server --protocol=tcp --host=127.0.0.1 --port=$MASTER_MYPORT -uroot $filename
+ --let $use_remote_mysqlbinlog= 0
+}
+exec $MYSQL_BINLOG $startpos $mysqlbinlog_args >$MYSQLTEST_VARDIR/tmp/binlog_incident-bug44442.sql;
+--disable_query_log
+eval SELECT cont LIKE '%RELOAD DATABASE; # Shall generate syntax error%' AS `Contain RELOAD DATABASE` FROM (SELECT load_file('$MYSQLTEST_VARDIR/tmp/binlog_incident-bug44442.sql') AS cont) AS tbl;
+--enable_query_log
+
+remove_file $MYSQLTEST_VARDIR/tmp/binlog_incident-bug44442.sql;
diff --git a/mysql-test/suite/binlog/include/binlog_index.inc b/mysql-test/suite/binlog/include/binlog_index.inc
new file mode 100644
index 00000000000..b930386a0ba
--- /dev/null
+++ b/mysql-test/suite/binlog/include/binlog_index.inc
@@ -0,0 +1,278 @@
+#
+# This include file is used by more than one test suite
+# (currently binlog and binlog_encryption).
+# Please check all dependent tests after modifying it
+#
+
+#
+# testing of purging of binary log files bug#18199/Bug#18453
+#
+source include/have_log_bin.inc;
+source include/not_embedded.inc;
+# Don't test this under valgrind, memory leaks will occur
+--source include/not_valgrind.inc
+source include/have_debug.inc;
+# Avoid CrashReporter popup on Mac
+--source include/not_crashrep.inc
+call mtr.add_suppression('Attempting backtrace');
+call mtr.add_suppression('MYSQL_BIN_LOG::purge_logs failed to process registered files that would be purged.');
+call mtr.add_suppression('MYSQL_BIN_LOG::open failed to sync the index file');
+call mtr.add_suppression('Turning logging off for the whole duration of the MySQL server process.');
+call mtr.add_suppression('Could not use .*');
+call mtr.add_suppression('MYSQL_BIN_LOG::purge_logs failed to clean registers before purging logs.');
+flush tables;
+
+let $old=`select @@debug`;
+
+RESET MASTER;
+
+let $MYSQLD_DATADIR= `select @@datadir`;
+let $INDEX=$MYSQLD_DATADIR/master-bin.index;
+
+#
+# testing purge binary logs TO
+#
+
+flush logs;
+flush logs;
+flush logs;
+
+source include/show_binary_logs.inc;
+remove_file $MYSQLD_DATADIR/master-bin.000001;
+flush tables;
+
+# there must be a warning with file names
+replace_regex /\.[\\\/]master/master/;
+--source include/wait_for_binlog_checkpoint.inc
+purge binary logs TO 'master-bin.000004';
+
+--echo *** must show a list starting from the 'TO' argument of PURGE ***
+source include/show_binary_logs.inc;
+
+#
+# testing purge binary logs BEFORE
+#
+
+reset master;
+
+flush logs;
+flush logs;
+flush logs;
+remove_file $MYSQLD_DATADIR/master-bin.000001;
+
+--echo *** must be a warning master-bin.000001 was not found ***
+let $date=`select NOW() + INTERVAL 1 MINUTE`;
+--disable_query_log
+replace_regex /\.[\\\/]master/master/;
+--source include/wait_for_binlog_checkpoint.inc
+eval purge binary logs BEFORE '$date';
+--enable_query_log
+
+--echo *** must show one record, of the active binlog, left in the index file after PURGE ***
+source include/show_binary_logs.inc;
+
+#
+# testing a fatal error
+# Turning a binlog file into a directory must be a portable setup
+#
+
+reset master;
+
+flush logs;
+flush logs;
+flush logs;
+
+remove_file $MYSQLD_DATADIR/master-bin.000001;
+mkdir $MYSQLD_DATADIR/master-bin.000001;
+
+--source include/wait_for_binlog_checkpoint.inc
+--error ER_BINLOG_PURGE_FATAL_ERR
+purge binary logs TO 'master-bin.000002';
+replace_regex /\.[\\\/]master/master/;
+show warnings;
+rmdir $MYSQLD_DATADIR/master-bin.000001;
+--disable_warnings
+reset master;
+--enable_warnings
+
+--echo # crash_purge_before_update_index
+flush logs;
+
+--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+SET SESSION debug_dbug="+d,crash_purge_before_update_index";
+--source include/wait_for_binlog_checkpoint.inc
+--error 2013
+purge binary logs TO 'master-bin.000002';
+
+--enable_reconnect
+--source include/wait_until_connected_again.inc
+
+file_exists $MYSQLD_DATADIR/master-bin.000001;
+file_exists $MYSQLD_DATADIR/master-bin.000002;
+file_exists $MYSQLD_DATADIR/master-bin.000003;
+--chmod 0644 $INDEX
+-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+-- eval SET @index=LOAD_FILE('$index')
+-- replace_regex /\.[\\\/]master/master/
+SELECT @index;
+
+--echo # crash_purge_non_critical_after_update_index
+flush logs;
+
+--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+SET SESSION debug_dbug="+d,crash_purge_non_critical_after_update_index";
+--source include/wait_for_binlog_checkpoint.inc
+--error 2013
+purge binary logs TO 'master-bin.000004';
+
+--enable_reconnect
+--source include/wait_until_connected_again.inc
+
+--error 1
+file_exists $MYSQLD_DATADIR/master-bin.000001;
+--error 1
+file_exists $MYSQLD_DATADIR/master-bin.000002;
+--error 1
+file_exists $MYSQLD_DATADIR/master-bin.000003;
+--chmod 0644 $INDEX
+-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+-- eval SET @index=LOAD_FILE('$index')
+-- replace_regex /\.[\\\/]master/master/
+SELECT @index;
+
+--echo # crash_purge_critical_after_update_index
+flush logs;
+
+--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+SET SESSION debug_dbug="+d,crash_purge_critical_after_update_index";
+--source include/wait_for_binlog_checkpoint.inc
+--error 2013
+purge binary logs TO 'master-bin.000006';
+
+--enable_reconnect
+--source include/wait_until_connected_again.inc
+
+--error 1
+file_exists $MYSQLD_DATADIR/master-bin.000004;
+--error 1
+file_exists $MYSQLD_DATADIR/master-bin.000005;
+file_exists $MYSQLD_DATADIR/master-bin.000006;
+file_exists $MYSQLD_DATADIR/master-bin.000007;
+--error 1
+file_exists $MYSQLD_DATADIR/master-bin.000008;
+--chmod 0644 $INDEX
+-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+-- eval SET @index=LOAD_FILE('$index')
+-- replace_regex /\.[\\\/]master/master/
+SELECT @index;
+
+--echo # crash_create_non_critical_before_update_index
+--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+SET SESSION debug_dbug="+d,crash_create_non_critical_before_update_index";
+--error 2013
+flush logs;
+
+--enable_reconnect
+--source include/wait_until_connected_again.inc
+
+file_exists $MYSQLD_DATADIR/master-bin.000008;
+--error 1
+file_exists $MYSQLD_DATADIR/master-bin.000009;
+--chmod 0644 $INDEX
+-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+-- eval SET @index=LOAD_FILE('$index')
+-- replace_regex /\.[\\\/]master/master/
+SELECT @index;
+
+--echo # crash_create_critical_before_update_index
+--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+SET SESSION debug_dbug="+d,crash_create_critical_before_update_index";
+--error 2013
+flush logs;
+
+--enable_reconnect
+--source include/wait_until_connected_again.inc
+
+file_exists $MYSQLD_DATADIR/master-bin.000009;
+--error 1
+file_exists $MYSQLD_DATADIR/master-bin.000010;
+--error 1
+file_exists $MYSQLD_DATADIR/master-bin.000011;
+--chmod 0644 $INDEX
+-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+-- eval SET @index=LOAD_FILE('$index')
+-- replace_regex /\.[\\\/]master/master/
+SELECT @index;
+
+--echo # crash_create_after_update_index
+--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+SET SESSION debug_dbug="+d,crash_create_after_update_index";
+--error 2013
+flush logs;
+
+--enable_reconnect
+--source include/wait_until_connected_again.inc
+
+file_exists $MYSQLD_DATADIR/master-bin.000010;
+file_exists $MYSQLD_DATADIR/master-bin.000011;
+--chmod 0644 $INDEX
+-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+-- eval SET @index=LOAD_FILE('$index')
+-- replace_regex /\.[\\\/]master/master/
+SELECT @index;
+
+--echo #
+--echo # This should put the server in unsafe state and stop
+--echo # accepting any command. If we inject a fault at this
+--echo # point and continue the execution the server crashes.
+--echo #
+
+--chmod 0644 $INDEX
+-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+-- eval SET @index=LOAD_FILE('$index')
+-- replace_regex /\.[\\\/]master/master/
+SELECT @index;
+
+--echo # fault_injection_registering_index
+SET SESSION debug_dbug="+d,fault_injection_registering_index";
+-- replace_regex /\.[\\\/]master/master/
+-- error ER_CANT_OPEN_FILE
+flush logs;
+
+--chmod 0644 $INDEX
+-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+-- eval SET @index=LOAD_FILE('$index')
+-- replace_regex /\.[\\\/]master/master/
+SELECT @index;
+
+--source include/restart_mysqld.inc
+
+--chmod 0644 $INDEX
+-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+-- eval SET @index=LOAD_FILE('$index')
+-- replace_regex /\.[\\\/]master/master/
+SELECT @index;
+
+--echo # fault_injection_updating_index
+SET SESSION debug_dbug="+d,fault_injection_updating_index";
+-- replace_regex /\.[\\\/]master/master/
+-- error ER_CANT_OPEN_FILE
+flush logs;
+
+--chmod 0644 $INDEX
+-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+-- eval SET @index=LOAD_FILE('$index')
+-- replace_regex /\.[\\\/]master/master/
+SELECT @index;
+
+--source include/restart_mysqld.inc
+
+--chmod 0644 $INDEX
+-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+-- eval SET @index=LOAD_FILE('$index')
+-- replace_regex /\.[\\\/]master/master/
+SELECT @index;
+
+eval SET SESSION debug_dbug="$old";
+
+--echo End of tests
diff --git a/mysql-test/suite/binlog/include/binlog_insert_delayed.test b/mysql-test/suite/binlog/include/binlog_insert_delayed.test
new file mode 100644
index 00000000000..8f669fc1152
--- /dev/null
+++ b/mysql-test/suite/binlog/include/binlog_insert_delayed.test
@@ -0,0 +1,71 @@
+# ==== Purpose ====
+#
+# Verify that INSERT DELAYED in mixed or row mode writes events to the
+# binlog, and that AUTO_INCREMENT works correctly.
+#
+# ==== Method ====
+#
+# Insert both single and multiple rows into an autoincrement column,
+# both with specified value and with NULL.
+#
+# With INSERT DELAYED, the rows do not show up in the table
+# immediately, so we must do source include/wait_until_rows_count.inc
+# between any two INSERT DELAYED statements. Moreover, if mixed or
+# row-based logging is used, there is also a delay between when rows
+# show up in the table and when they show up in the binlog. To ensure
+# that the rows show up in the binlog, we call FLUSH TABLES, which
+# waits until the delayed_insert thread has finished.
+#
+# We cannot read the binlog after executing INSERT DELAYED statements
+# that insert multiple rows, because that is nondeterministic. More
+# precisely, rows may be written in batches to the binlog, where each
+# batch has one Table_map_log_event and one or more
+# Write_rows_log_event. The number of rows included in each batch is
+# nondeterministic.
+#
+# ==== Related bugs ====
+#
+# BUG#20627: INSERT DELAYED does not honour auto_increment_* variables
+# Bug in this test: BUG#38068: binlog_stm_binlog fails sporadically in pushbuild
+
+reset master;
+
+create table t1 (a int not null auto_increment, primary key (a)) engine=myisam;
+
+let $table=t1;
+let $count=0;
+
+insert /* before delayed */ delayed /* after delayed */ into t1 values (207);
+inc $count;
+--source include/wait_until_rows_count.inc
+
+insert /*! delayed */ into t1 values (null);
+inc $count;
+--source include/wait_until_rows_count.inc
+
+insert delayed into t1 values (300);
+inc $count;
+--source include/wait_until_rows_count.inc
+
+# It is not enough to wait until all rows have been inserted into the
+# table. FLUSH TABLES ensures that they are in the binlog too. See
+# comment above.
+FLUSH TABLES;
+source include/show_binlog_events.inc;
+
+RESET MASTER;
+insert /* before delayed */ delayed /* after delayed */ into t1 values (null),(null),(null),(null);
+inc $count; inc $count; inc $count; inc $count;
+--source include/wait_until_rows_count.inc
+
+insert /*! delayed */ into t1 values (null),(null),(400),(null);
+inc $count; inc $count; inc $count; inc $count;
+--source include/wait_until_rows_count.inc
+
+if (`SELECT @@SESSION.BINLOG_FORMAT = 'STATEMENT'`) {
+ FLUSH TABLES;
+ source include/show_binlog_events.inc;
+}
+
+select * from t1;
+drop table t1;
diff --git a/mysql-test/suite/binlog/include/binlog_ioerr.inc b/mysql-test/suite/binlog/include/binlog_ioerr.inc
new file mode 100644
index 00000000000..8d1069bacb0
--- /dev/null
+++ b/mysql-test/suite/binlog/include/binlog_ioerr.inc
@@ -0,0 +1,36 @@
+#
+# This include file is used by more than one test suite
+# (currently binlog and binlog_encryption).
+# Please check all dependent tests after modifying it
+#
+
+source include/have_debug.inc;
+source include/have_innodb.inc;
+source include/have_log_bin.inc;
+source include/have_binlog_format_mixed_or_statement.inc;
+
+CALL mtr.add_suppression("Error writing file 'master-bin'");
+
+RESET MASTER;
+
+CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=innodb;
+INSERT INTO t1 VALUES(0);
+SET SESSION debug_dbug='+d,fail_binlog_write_1';
+--error ER_ERROR_ON_WRITE
+INSERT INTO t1 VALUES(1);
+--error ER_ERROR_ON_WRITE
+INSERT INTO t1 VALUES(2);
+SET SESSION debug_dbug='';
+INSERT INTO t1 VALUES(3);
+SELECT * FROM t1;
+
+# Actually the output from this currently shows a bug.
+# The injected IO error leaves partially written transactions in the binlog in
+# the form of stray "BEGIN" events.
+# These should disappear from the output if binlog error handling is improved
+# (see MySQL Bug#37148 and WL#1790).
+--replace_regex /\/\* xid=.* \*\//\/* XID *\// /Server ver: .*, Binlog ver: .*/Server ver: #, Binlog ver: #/ /table_id: [0-9]+/table_id: #/
+--replace_column 1 BINLOG 2 POS 5 ENDPOS
+SHOW BINLOG EVENTS;
+
+DROP TABLE t1;
diff --git a/mysql-test/suite/binlog/include/binlog_mysqlbinlog-cp932.inc b/mysql-test/suite/binlog/include/binlog_mysqlbinlog-cp932.inc
new file mode 100644
index 00000000000..3646c34b027
--- /dev/null
+++ b/mysql-test/suite/binlog/include/binlog_mysqlbinlog-cp932.inc
@@ -0,0 +1,50 @@
+#
+# This include file is used by more than one test suite
+# (currently binlog and binlog_encryption).
+# Please check all dependent tests after modifying it
+#
+# Usage:
+# --let $use_remote_mysqlbinlog= 1 # optional
+# --source suite/binlog/include/binlog_mysqlbinlog-cp932.inc
+#
+# By default, the script calls mysqlbinlog to read binary logs directly.
+# If it is undesirable, this behavior can be overridden by setting
+# $use_remote_binlog as shown above.
+# The value will be unset after every execution of the script,
+# so if it is needed, it should be set explicitly before each call.
+
+
+# disabled in embedded until tools running is fixed with embedded
+--source include/not_embedded.inc
+
+-- source include/have_binlog_format_mixed_or_statement.inc
+-- source include/have_cp932.inc
+-- source include/have_log_bin.inc
+
+RESET MASTER;
+
+# Bug#16217 (mysql client did not know how not switch its internal charset)
+create table t3 (f text character set utf8);
+create table t4 (f text character set cp932);
+--exec $MYSQL --default-character-set=utf8 test -e "insert into t3 values(_utf8'ソ')"
+--exec $MYSQL --default-character-set=cp932 test -e "insert into t4 values(_cp932'ƒ\');"
+flush logs;
+rename table t3 to t03, t4 to t04;
+let $MYSQLD_DATADIR= `select @@datadir`;
+
+--let $mysqlbinlog_args= $MYSQLD_DATADIR/master-bin.000001
+if ($use_remote_mysqlbinlog)
+{
+ --let $mysqlbinlog_args= --read-from-remote-server --protocol=tcp --host=127.0.0.1 --port=$MASTER_MYPORT -uroot master-bin.000001
+ --let $use_remote_mysqlbinlog= 0
+}
+
+--exec $MYSQL_BINLOG --short-form $mysqlbinlog_args | $MYSQL --default-character-set=utf8
+# original and recovered data must be equal
+select HEX(f) from t03;
+select HEX(f) from t3;
+select HEX(f) from t04;
+select HEX(f) from t4;
+
+drop table t3, t4, t03, t04;
+--echo End of 5.0 tests
diff --git a/mysql-test/suite/binlog/include/binlog_row_annotate.inc b/mysql-test/suite/binlog/include/binlog_row_annotate.inc
new file mode 100644
index 00000000000..a5fdba8daf2
--- /dev/null
+++ b/mysql-test/suite/binlog/include/binlog_row_annotate.inc
@@ -0,0 +1,192 @@
+#
+# This include file is used by more than one test suite
+# (currently binlog and binlog_encryption).
+# Please check all dependent tests after modifying it
+#
+# Usage:
+# --let use_remote_mysqlbinlog= 1 # optional
+# --source suite/binlog/include/binlog_row_annotate.inc
+#
+# By default, the script uses mysqlbinlog both with direct access to files
+# and via connection to the server. In some cases, direct access to files
+# might be impossible (e.g. with encryption). If use_remote_mysqlbinlog
+# flag is set, this part of the logic will be omitted.
+#
+
+###############################################################################
+# WL47: Store in binlog text of statements that caused RBR events
+# new event: ANNOTATE_ROWS_EVENT
+# new master option: --binlog-annotate-row-events
+# new mysqlbinlog option: --skip-annotate-row-events
+#
+# Intended to test that:
+# *** If the --binlog-annotate-row-events option is switched on on master
+# then Annotate_rows events:
+# - are generated;
+# - are generated only once for "multi-table-maps" rbr queries;
+# - are not generated when the corresponding queries are filtered away;
+# - are generated when the corresponding queries are filtered away partialy
+# (e.g. in case of multi-delete).
+# *** Annotate_rows events are printed by mysqlbinlog started without
+# --skip-annotate-row-events options both in remote and local cases.
+# *** Annotate_rows events are not printed by mysqlbinlog started with
+# --skip-annotate-row-events options both in remote and local cases.
+###############################################################################
+
+set @old_binlog_checksum=@@binlog_checksum;
+set global binlog_checksum=NONE;
+--let datadir= `select @@datadir`
+
+--source include/have_log_bin.inc
+--source include/binlog_start_pos.inc
+--source include/have_binlog_format_row.inc
+
+set sql_mode="";
+
+# Fix timestamp to avoid varying results
+SET timestamp=1000000000;
+
+# Delete all existing binary logs
+RESET MASTER;
+
+CREATE DATABASE test1;
+CREATE TABLE test1.t1(a int);
+
+CREATE DATABASE test2;
+CREATE TABLE test2.t2(a int);
+CREATE VIEW test2.v2 AS SELECT * FROM test2.t2;
+
+CREATE DATABASE test3;
+CREATE TABLE test3.t3(a int);
+
+CREATE DATABASE xtest1;
+CREATE TABLE xtest1.xt1(a int);
+
+CREATE DATABASE xtest2;
+CREATE TABLE xtest2.xt2(a int);
+
+# By default SESSION binlog_annotate_row_events = OFF
+
+INSERT INTO test1.t1 VALUES (1), (2), (3);
+
+SET SESSION binlog_annotate_row_events = ON;
+
+INSERT INTO test2.t2 VALUES (1), (2), (3);
+INSERT INTO test3.t3 VALUES (1), (2), (3);
+
+# This query generates two Table maps but the Annotate
+# event should appear only once before the first Table map
+DELETE test1.t1, test2.t2
+ FROM test1.t1 INNER JOIN test2.t2 INNER JOIN test3.t3
+ WHERE test1.t1.a=test2.t2.a AND test2.t2.a=test3.t3.a;
+
+# This event should be filtered out together with Annotate event
+INSERT INTO xtest1.xt1 VALUES (1), (2), (3);
+
+# This event should pass the filter
+INSERT INTO test2.v2 VALUES (1), (2), (3);
+
+# This event should pass the filter only for test2.t2 part
+DELETE xtest1.xt1, test2.t2
+ FROM xtest1.xt1 INNER JOIN test2.t2 INNER JOIN test3.t3
+ WHERE xtest1.xt1.a=test2.t2.a AND test2.t2.a=test3.t3.a;
+
+# These events should be filtered out together with Annotate events
+INSERT INTO xtest1.xt1 VALUES (1), (2), (3);
+INSERT INTO xtest2.xt2 VALUES (1), (2), (3);
+DELETE xtest1.xt1, xtest2.xt2
+ FROM xtest1.xt1 INNER JOIN xtest2.xt2 INNER JOIN test3.t3
+ WHERE xtest1.xt1.a=xtest2.xt2.a AND xtest2.xt2.a=test3.t3.a;
+
+FLUSH LOGS;
+
+--echo #####################################################################################
+--echo # The following Annotate_rows events should appear below:
+--echo # - INSERT INTO test2.t2 VALUES (1), (2), (3)
+--echo # - INSERT INTO test3.t3 VALUES (1), (2), (3)
+--echo # - DELETE test1.t1, test2.t2 FROM <...>
+--echo # - INSERT INTO test2.t2 VALUES (1), (2), (3)
+--echo # - DELETE xtest1.xt1, test2.t2 FROM <...>
+--echo #####################################################################################
+
+--source include/show_binlog_events.inc
+
+if (!$use_remote_mysqlbinlog)
+{
+ --echo #
+ --echo #####################################################################################
+ --echo # mysqlbinlog
+ --echo # The following Annotates should appear in this output:
+ --echo # - INSERT INTO test2.t2 VALUES (1), (2), (3)
+ --echo # - INSERT INTO test3.t3 VALUES (1), (2), (3)
+ --echo # - DELETE test1.t1, test2.t2 FROM <...> (with two subsequent Table maps)
+ --echo # - INSERT INTO test2.t2 VALUES (1), (2), (3)
+ --echo # - DELETE xtest1.xt1, test2.t2 FROM <...> (with one subsequent Table map)
+ --echo #####################################################################################
+
+ --replace_regex /server id [0-9]*/server id #/ /server v [^ ]*/server v #.##.##/ /exec_time=[0-9]*/exec_time=#/ /thread_id=[0-9]*/thread_id=#/ /table id [0-9]*/table id #/ /mapped to number [0-9]*/mapped to number #/ /end_log_pos [0-9]*/end_log_pos #/ /# at [0-9]*/# at #/
+ --exec $MYSQL_BINLOG --base64-output=decode-rows -v -v $datadir/master-bin.000001
+
+ --echo #
+ --echo #####################################################################################
+ --echo # mysqlbinlog --database=test1
+ --echo # The following Annotate should appear in this output:
+ --echo # - DELETE test1.t1, test2.t2 FROM <...>
+ --echo #####################################################################################
+
+ --replace_regex /server id [0-9]*/server id #/ /server v [^ ]*/server v #.##.##/ /exec_time=[0-9]*/exec_time=#/ /thread_id=[0-9]*/thread_id=#/ /table id [0-9]*/table id #/ /mapped to number [0-9]*/mapped to number #/ /end_log_pos [0-9]*/end_log_pos #/ /# at [0-9]*/# at #/
+ --exec $MYSQL_BINLOG --base64-output=decode-rows --database=test1 -v -v $datadir/master-bin.000001
+
+ --echo #
+ --echo #####################################################################################
+ --echo # mysqlbinlog --skip-annotate-row-events
+ --echo # No Annotates should appear in this output
+ --echo #####################################################################################
+
+ --replace_regex /server id [0-9]*/server id #/ /server v [^ ]*/server v #.##.##/ /exec_time=[0-9]*/exec_time=#/ /thread_id=[0-9]*/thread_id=#/ /table id [0-9]*/table id #/ /mapped to number [0-9]*/mapped to number #/ /end_log_pos [0-9]*/end_log_pos #/ /# at [0-9]*/# at #/
+ --exec $MYSQL_BINLOG --base64-output=decode-rows --skip-annotate-row-events -v -v $datadir/master-bin.000001
+
+ --let use_remote_mysqlbinlog= 0
+}
+
+--echo #
+--echo #####################################################################################
+--echo # mysqlbinlog --read-from-remote-server
+--echo # The following Annotates should appear in this output:
+--echo # - INSERT INTO test2.t2 VALUES (1), (2), (3)
+--echo # - INSERT INTO test3.t3 VALUES (1), (2), (3)
+--echo # - DELETE test1.t1, test2.t2 FROM <...> (with two subsequent Table maps)
+--echo # - INSERT INTO test2.t2 VALUES (1), (2), (3)
+--echo # - DELETE xtest1.xt1, test2.t2 FROM <...> (with one subsequent Table map)
+--echo #####################################################################################
+
+--replace_regex /server id [0-9]*/server id #/ /server v [^ ]*/server v #.##.##/ /exec_time=[0-9]*/exec_time=#/ /thread_id=[0-9]*/thread_id=#/ /table id [0-9]*/table id #/ /mapped to number [0-9]*/mapped to number #/ /end_log_pos [0-9]*/end_log_pos #/ /# at [0-9]*/# at #/
+--exec $MYSQL_BINLOG --base64-output=decode-rows -v -v --read-from-remote-server --user=root --host=localhost --port=$MASTER_MYPORT master-bin.000001
+
+--echo #
+--echo #####################################################################################
+--echo # mysqlbinlog --read-from-remote-server --database=test1
+--echo # The following Annotate should appear in this output:
+--echo # - DELETE test1.t1, test2.t2 FROM <...>
+--echo #####################################################################################
+
+--replace_regex /server id [0-9]*/server id #/ /server v [^ ]*/server v #.##.##/ /exec_time=[0-9]*/exec_time=#/ /thread_id=[0-9]*/thread_id=#/ /table id [0-9]*/table id #/ /mapped to number [0-9]*/mapped to number #/ /end_log_pos [0-9]*/end_log_pos #/ /# at [0-9]*/# at #/
+--exec $MYSQL_BINLOG --base64-output=decode-rows --database=test1 -v -v --read-from-remote-server --user=root --host=localhost --port=$MASTER_MYPORT master-bin.000001
+
+--echo #
+--echo #####################################################################################
+--echo # mysqlbinlog --read-from-remote-server --skip-annotate-row-events
+--echo # No Annotates should appear in this output
+--echo #####################################################################################
+
+--replace_regex /server id [0-9]*/server id #/ /server v [^ ]*/server v #.##.##/ /exec_time=[0-9]*/exec_time=#/ /thread_id=[0-9]*/thread_id=#/ /table id [0-9]*/table id #/ /mapped to number [0-9]*/mapped to number #/ /end_log_pos [0-9]*/end_log_pos #/ /# at [0-9]*/# at #/
+--exec $MYSQL_BINLOG --base64-output=decode-rows --skip-annotate-row-events -v -v --read-from-remote-server --user=root --host=localhost --port=$MASTER_MYPORT master-bin.000001
+
+# Clean-up
+
+set global binlog_checksum=@old_binlog_checksum;
+DROP DATABASE test1;
+DROP DATABASE test2;
+DROP DATABASE test3;
+DROP DATABASE xtest1;
+DROP DATABASE xtest2;
diff --git a/mysql-test/suite/binlog/include/binlog_truncate.test b/mysql-test/suite/binlog/include/binlog_truncate.test
new file mode 100644
index 00000000000..4d297cd2d5c
--- /dev/null
+++ b/mysql-test/suite/binlog/include/binlog_truncate.test
@@ -0,0 +1,63 @@
+# BUG #36763: TRUNCATE TABLE fails to replicate when stmt-based
+# binlogging is not supported.
+
+# This should always be logged as a statement, even when executed as a
+# row-by-row deletion.
+
+# $before_truncate A statement to execute (just) before issuing the
+# TRUNCATE TABLE
+
+
+eval CREATE TABLE t1 (a INT) ENGINE=$engine;
+eval CREATE TABLE t2 (a INT) ENGINE=$engine;
+INSERT INTO t2 VALUES (1),(2),(3);
+let $binlog_start = query_get_value("SHOW MASTER STATUS", Position, 1);
+if ($before_truncate) {
+ eval $before_truncate;
+}
+--echo **** Truncate of empty table shall be logged
+TRUNCATE TABLE t1;
+
+if ($before_truncate) {
+ eval $before_truncate;
+}
+TRUNCATE TABLE t2;
+source include/show_binlog_events.inc;
+
+DROP TABLE t1,t2;
+
+--echo #
+--echo # Bug#42643: InnoDB does not support replication of TRUNCATE TABLE
+--echo #
+
+eval CREATE TABLE t1 (a INT) ENGINE=$engine;
+eval CREATE TABLE t2 (a INT) ENGINE=$engine;
+INSERT INTO t1 VALUES (1),(2);
+
+let $binlog_start = query_get_value("SHOW MASTER STATUS", Position, 1);
+if ($before_truncate) {
+ eval $before_truncate;
+}
+
+BEGIN;
+INSERT INTO t2 SELECT * FROM t1;
+
+connect (truncate,localhost,root,,);
+send TRUNCATE TABLE t1;
+
+connection default;
+INSERT INTO t2 SELECT * FROM t1;
+SELECT COUNT(*) FROM t2;
+COMMIT;
+
+connection truncate;
+--echo # Reaping TRUNCATE TABLE
+--reap
+SELECT COUNT(*) FROM t1;
+SELECT COUNT(*) FROM t2;
+
+connection default;
+
+source include/show_binlog_events.inc;
+disconnect truncate;
+DROP TABLE t1,t2;
diff --git a/mysql-test/suite/binlog/include/binlog_write_error.inc b/mysql-test/suite/binlog/include/binlog_write_error.inc
new file mode 100644
index 00000000000..fa3ba087a7e
--- /dev/null
+++ b/mysql-test/suite/binlog/include/binlog_write_error.inc
@@ -0,0 +1,108 @@
+#
+# This include file is used by more than one test suite
+# (currently binlog and binlog_encryption).
+# Please check all dependent tests after modifying it
+#
+
+#
+# === Name ===
+#
+# binlog_write_error.test
+#
+# === Description ===
+#
+# This test case check if the error of writing binlog file is properly
+# reported and handled when executing statements.
+#
+# === Related Bugs ===
+#
+# BUG#37148
+#
+
+source include/have_log_bin.inc;
+source include/have_debug.inc;
+source include/have_binlog_format_mixed_or_statement.inc;
+
+--echo #
+--echo # Initialization
+--echo #
+
+disable_warnings;
+DROP TABLE IF EXISTS t1, t2;
+DROP FUNCTION IF EXISTS f1;
+DROP FUNCTION IF EXISTS f2;
+DROP PROCEDURE IF EXISTS p1;
+DROP PROCEDURE IF EXISTS p2;
+DROP TRIGGER IF EXISTS tr1;
+DROP TRIGGER IF EXISTS tr2;
+DROP VIEW IF EXISTS v1, v2;
+enable_warnings;
+
+--echo #
+--echo # Test injecting binlog write error when executing queries
+--echo #
+
+let $query= CREATE TABLE t1 (a INT);
+source include/binlog_inject_error.inc;
+
+INSERT INTO t1 VALUES (1),(2),(3);
+
+let $query= INSERT INTO t1 VALUES (4),(5),(6);
+source include/binlog_inject_error.inc;
+
+let $query= UPDATE t1 set a=a+1;
+source include/binlog_inject_error.inc;
+
+let $query= DELETE FROM t1;
+source include/binlog_inject_error.inc;
+
+let $query= CREATE TRIGGER tr1 AFTER INSERT ON t1 FOR EACH ROW INSERT INTO t1 VALUES (new.a + 100);
+source include/binlog_inject_error.inc;
+
+let $query= DROP TRIGGER tr1;
+source include/binlog_inject_error.inc;
+
+let $query= ALTER TABLE t1 ADD (b INT);
+source include/binlog_inject_error.inc;
+
+let $query= CREATE VIEW v1 AS SELECT a FROM t1;
+source include/binlog_inject_error.inc;
+
+let $query= DROP VIEW v1;
+source include/binlog_inject_error.inc;
+
+let $query= CREATE PROCEDURE p1(OUT rows_cnt INT) SELECT count(*) INTO rows_cnt FROM t1;
+source include/binlog_inject_error.inc;
+
+let $query= DROP PROCEDURE p1;
+source include/binlog_inject_error.inc;
+
+let $query= DROP TABLE t1;
+source include/binlog_inject_error.inc;
+
+let $query= CREATE FUNCTION f1() RETURNS INT return 1;
+source include/binlog_inject_error.inc;
+
+let $query= DROP FUNCTION f1;
+source include/binlog_inject_error.inc;
+
+let $query= CREATE USER user1;
+source include/binlog_inject_error.inc;
+
+let $query= REVOKE ALL PRIVILEGES, GRANT OPTION FROM user1;
+source include/binlog_inject_error.inc;
+
+let $query= DROP USER user1;
+source include/binlog_inject_error.inc;
+
+--echo #
+--echo # Cleanup
+--echo #
+
+disable_warnings;
+DROP TABLE IF EXISTS t1, t2;
+DROP FUNCTION IF EXISTS f1;
+DROP PROCEDURE IF EXISTS p1;
+DROP TRIGGER IF EXISTS tr1;
+DROP VIEW IF EXISTS v1, v2;
+enable_warnings;
diff --git a/mysql-test/suite/binlog/include/binlog_xa_recover.inc b/mysql-test/suite/binlog/include/binlog_xa_recover.inc
new file mode 100644
index 00000000000..de2703377cc
--- /dev/null
+++ b/mysql-test/suite/binlog/include/binlog_xa_recover.inc
@@ -0,0 +1,281 @@
+#
+# This include file is used by more than one test suite
+# (currently binlog and binlog_encryption).
+# Please check all dependent tests after modifying it
+#
+
+--source include/have_innodb.inc
+--source include/have_debug.inc
+--source include/have_debug_sync.inc
+--source include/have_binlog_format_row.inc
+# Valgrind does not work well with test that crashes the server
+--source include/not_valgrind.inc
+
+# (We do not need to restore these settings, as we crash the server).
+SET GLOBAL max_binlog_size= 4096;
+SET GLOBAL innodb_flush_log_at_trx_commit= 1;
+RESET MASTER;
+
+CREATE TABLE t1 (a INT PRIMARY KEY, b MEDIUMTEXT) ENGINE=Innodb;
+# Insert some data to force a couple binlog rotations (3), so we get some
+# normal binlog checkpoints before starting the test.
+INSERT INTO t1 VALUES (100, REPEAT("x", 4100));
+# Wait for the master-bin.000002 binlog checkpoint to appear.
+--let $wait_for_all= 0
+--let $show_statement= SHOW BINLOG EVENTS IN "master-bin.000002"
+--let $field= Info
+--let $condition= = "master-bin.000002"
+--source include/wait_show_condition.inc
+INSERT INTO t1 VALUES (101, REPEAT("x", 4100));
+--let $wait_for_all= 0
+--let $show_statement= SHOW BINLOG EVENTS IN "master-bin.000003"
+--let $field= Info
+--let $condition= = "master-bin.000003"
+--source include/wait_show_condition.inc
+INSERT INTO t1 VALUES (102, REPEAT("x", 4100));
+--let $wait_for_all= 0
+--let $show_statement= SHOW BINLOG EVENTS IN "master-bin.000004"
+--let $field= Info
+--let $condition= = "master-bin.000004"
+--source include/wait_show_condition.inc
+
+# Now start a bunch of transactions that span multiple binlog
+# files. Leave then in the state prepared-but-not-committed in the engine
+# and crash the server. Check that crash recovery is able to recover all
+# of them.
+#
+# We use debug_sync to get all the transactions into the prepared state before
+# we commit any of them. This is because the prepare step flushes the InnoDB
+# redo log - including any commits made before, so recovery would become
+# unnecessary, decreasing the value of this test.
+#
+# We arrange to have con1 with a prepared transaction in master-bin.000004,
+# con2 and con3 with a prepared transaction in master-bin.000005, and a new
+# empty master-bin.000006. So the latest binlog checkpoint should be
+# master-bin.000006.
+
+connect(con1,localhost,root,,);
+# First wait after prepare and before write to binlog.
+SET DEBUG_SYNC= "ha_commit_trans_before_log_and_order SIGNAL con1_wait WAIT_FOR con1_cont";
+# Then complete InnoDB commit in memory (but not commit checkpoint / write to
+# disk), and hang until crash, leaving a transaction to be XA recovered.
+SET DEBUG_SYNC= "commit_after_group_release_commit_ordered SIGNAL con1_ready WAIT_FOR _ever";
+send INSERT INTO t1 VALUES (1, REPEAT("x", 4100));
+
+connection default;
+SET DEBUG_SYNC= "now WAIT_FOR con1_wait";
+
+connect(con2,localhost,root,,);
+SET DEBUG_SYNC= "ha_commit_trans_before_log_and_order SIGNAL con2_wait WAIT_FOR con2_cont";
+SET DEBUG_SYNC= "commit_after_group_release_commit_ordered SIGNAL con2_ready WAIT_FOR _ever";
+send INSERT INTO t1 VALUES (2, NULL);
+
+connection default;
+SET DEBUG_SYNC= "now WAIT_FOR con2_wait";
+
+connect(con3,localhost,root,,);
+SET DEBUG_SYNC= "ha_commit_trans_before_log_and_order SIGNAL con3_wait WAIT_FOR con3_cont";
+SET DEBUG_SYNC= "commit_after_group_release_commit_ordered SIGNAL con3_ready WAIT_FOR _ever";
+send INSERT INTO t1 VALUES (3, REPEAT("x", 4100));
+
+connection default;
+SET DEBUG_SYNC= "now WAIT_FOR con3_wait";
+
+connect(con4,localhost,root,,);
+SET DEBUG_SYNC= "ha_commit_trans_before_log_and_order SIGNAL con4_wait WAIT_FOR con4_cont";
+SET SESSION debug_dbug="+d,crash_commit_after_log";
+send INSERT INTO t1 VALUES (4, NULL);
+
+connection default;
+SET DEBUG_SYNC= "now WAIT_FOR con4_wait";
+
+SET DEBUG_SYNC= "now SIGNAL con1_cont";
+SET DEBUG_SYNC= "now WAIT_FOR con1_ready";
+SET DEBUG_SYNC= "now SIGNAL con2_cont";
+SET DEBUG_SYNC= "now WAIT_FOR con2_ready";
+SET DEBUG_SYNC= "now SIGNAL con3_cont";
+SET DEBUG_SYNC= "now WAIT_FOR con3_ready";
+
+# Check that everything is committed in binary log.
+--source include/show_binary_logs.inc
+--let $binlog_file= master-bin.000003
+--let $binlog_start= 4
+--source include/show_binlog_events.inc
+--let $binlog_file= master-bin.000004
+--source include/show_binlog_events.inc
+--let $binlog_file= master-bin.000005
+--source include/show_binlog_events.inc
+--let $binlog_file= master-bin.000006
+--source include/show_binlog_events.inc
+
+
+# Check that server will not purge too much.
+PURGE BINARY LOGS TO "master-bin.000006";
+--source include/show_binary_logs.inc
+
+# Now crash the server with one more transaction in prepared state.
+--write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+wait-binlog_xa_recover.test
+EOF
+--error 0,2006,2013
+SET DEBUG_SYNC= "now SIGNAL con4_cont";
+connection con4;
+--error 2006,2013
+reap;
+
+--append_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+restart-group_commit_binlog_pos.test
+EOF
+
+connection default;
+--enable_reconnect
+--source include/wait_until_connected_again.inc
+
+# Check that all transactions are recovered.
+SELECT a FROM t1 ORDER BY a;
+
+--echo Test that with multiple binlog checkpoints, recovery starts from the last one.
+SET GLOBAL max_binlog_size= 4096;
+SET GLOBAL innodb_flush_log_at_trx_commit= 1;
+RESET MASTER;
+
+# Rotate to binlog master-bin.000003 while delaying binlog checkpoints.
+# So we get multiple binlog checkpoints in master-bin.000003.
+# Then complete the checkpoints, crash, and check that we only scan
+# the necessary binlog file (ie. that we use the _last_ checkpoint).
+
+connect(con10,localhost,root,,);
+SET DEBUG_SYNC= "commit_after_group_release_commit_ordered SIGNAL con10_ready WAIT_FOR con10_cont";
+send INSERT INTO t1 VALUES (10, REPEAT("x", 4100));
+
+connection default;
+SET DEBUG_SYNC= "now WAIT_FOR con10_ready";
+
+connect(con11,localhost,root,,);
+SET DEBUG_SYNC= "commit_after_group_release_commit_ordered SIGNAL con11_ready WAIT_FOR con11_cont";
+send INSERT INTO t1 VALUES (11, REPEAT("x", 4100));
+
+connection default;
+SET DEBUG_SYNC= "now WAIT_FOR con11_ready";
+
+connect(con12,localhost,root,,);
+SET DEBUG_SYNC= "commit_after_group_release_commit_ordered SIGNAL con12_ready WAIT_FOR con12_cont";
+send INSERT INTO t1 VALUES (12, REPEAT("x", 4100));
+
+connection default;
+SET DEBUG_SYNC= "now WAIT_FOR con12_ready";
+INSERT INTO t1 VALUES (13, NULL);
+
+--source include/show_binary_logs.inc
+--let $binlog_file= master-bin.000004
+--let $binlog_start= 4
+--source include/show_binlog_events.inc
+
+SET DEBUG_SYNC= "now SIGNAL con10_cont";
+connection con10;
+reap;
+connection default;
+
+# We need to sync the test case with the background processing of the
+# commit checkpoint, otherwise we get nondeterministic results.
+SET @old_dbug= @@global.DEBUG_DBUG;
+SET GLOBAL debug_dbug="+d,binlog_background_checkpoint_processed";
+
+SET DEBUG_SYNC= "now SIGNAL con12_cont";
+connection con12;
+reap;
+connection default;
+SET DEBUG_SYNC= "now WAIT_FOR binlog_background_checkpoint_processed";
+SET GLOBAL debug_dbug= @old_dbug;
+
+SET DEBUG_SYNC= "now SIGNAL con11_cont";
+connection con11;
+reap;
+
+connection default;
+# Wait for the last (master-bin.000004) binlog checkpoint to appear.
+--let $wait_for_all= 0
+--let $show_statement= SHOW BINLOG EVENTS IN "master-bin.000004"
+--let $field= Info
+--let $condition= = "master-bin.000004"
+--source include/wait_show_condition.inc
+
+--echo Checking that master-bin.000004 is the last binlog checkpoint
+--source include/show_binlog_events.inc
+
+--echo Now crash the server
+# It is not too easy to test XA recovery, as it runs early during server
+# startup, before any connections can be made.
+# What we do is set a DBUG error insert which will crash if XA recovery
+# starts from any other binlog than master-bin.000004 (check the file
+# binlog_xa_recover-master.opt). Then we will fail here if XA recovery
+# would start from the wrong place.
+--write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+wait-binlog_xa_recover.test
+EOF
+SET SESSION debug_dbug="+d,crash_commit_after_log";
+--error 2006,2013
+INSERT INTO t1 VALUES (14, NULL);
+
+--append_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+restart-group_commit_binlog_pos.test
+EOF
+
+connection default;
+--enable_reconnect
+--source include/wait_until_connected_again.inc
+
+# Check that all transactions are recovered.
+SELECT a FROM t1 ORDER BY a;
+
+
+--echo *** Check that recovery works if we crashed early during rotate, before
+--echo *** binlog checkpoint event could be written.
+
+SET GLOBAL max_binlog_size= 4096;
+SET GLOBAL innodb_flush_log_at_trx_commit= 1;
+RESET MASTER;
+
+# We need some initial data to reach binlog master-bin.000004. Otherwise
+# crash recovery fails due to the error insert used for previous test.
+INSERT INTO t1 VALUES (21, REPEAT("x", 4100));
+INSERT INTO t1 VALUES (22, REPEAT("x", 4100));
+# Wait for the master-bin.000003 binlog checkpoint to appear.
+--let $wait_for_all= 0
+--let $show_statement= SHOW BINLOG EVENTS IN "master-bin.000003"
+--let $field= Info
+--let $condition= = "master-bin.000003"
+--source include/wait_show_condition.inc
+INSERT INTO t1 VALUES (23, REPEAT("x", 4100));
+# Wait for the last (master-bin.000004) binlog checkpoint to appear.
+--let $wait_for_all= 0
+--let $show_statement= SHOW BINLOG EVENTS IN "master-bin.000004"
+--let $field= Info
+--let $condition= = "master-bin.000004"
+--source include/wait_show_condition.inc
+
+--write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+wait-binlog_xa_recover.test
+EOF
+SET SESSION debug_dbug="+d,crash_before_write_checkpoint_event";
+--error 2006,2013
+INSERT INTO t1 VALUES (24, REPEAT("x", 4100));
+
+--append_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+restart-group_commit_binlog_pos.test
+EOF
+
+--enable_reconnect
+--source include/wait_until_connected_again.inc
+
+# Check that all transactions are recovered.
+SELECT a FROM t1 ORDER BY a;
+
+--source include/show_binary_logs.inc
+--let $binlog_file= master-bin.000004
+--let $binlog_start= 4
+--source include/show_binlog_events.inc
+
+# Cleanup
+connection default;
+DROP TABLE t1;
diff --git a/mysql-test/suite/binlog/include/blackhole.test b/mysql-test/suite/binlog/include/blackhole.test
new file mode 100644
index 00000000000..90146d41471
--- /dev/null
+++ b/mysql-test/suite/binlog/include/blackhole.test
@@ -0,0 +1,208 @@
+#
+# Simple test for blackhole example
+# Taken from the select test
+#
+-- source include/not_embedded.inc
+-- source include/have_blackhole.inc
+-- source include/have_log_bin.inc
+
+CALL mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
+
+# The server need to be started in $MYSQLTEST_VARDIR since it
+# uses ../../std_data/
+-- source include/uses_vardir.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;
+eval load data infile '../../std_data/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;
+
+--source include/show_binlog_events.inc
+
+drop table t1,t2,t3;
+
+#
+# BUG#27998 - mysqld crashed when executing INSERT DELAYED on a BLACKHOLE
+# table
+#
+CREATE TABLE t1(a INT) ENGINE=BLACKHOLE;
+INSERT DELAYED INTO t1 VALUES(1);
+DROP TABLE t1;
+
+
+#
+#Bug#19717: DELETE Query Error on BLACKHOLE when using WHERE on column with UNIQUE INDEX
+#
+CREATE TABLE t1(a INT, b INT) ENGINE=BLACKHOLE;
+DELETE FROM t1 WHERE a=10;
+ALTER TABLE t1 ADD INDEX(a);
+DELETE FROM t1 WHERE a=10;
+ALTER TABLE t1 DROP INDEX a;
+ALTER TABLE t1 ADD UNIQUE INDEX(a);
+DELETE FROM t1 WHERE a=10;
+ALTER TABLE t1 DROP INDEX a;
+ALTER TABLE t1 ADD PRIMARY KEY(a);
+DELETE FROM t1 WHERE a=10;
+DROP TABLE t1;
+
+
+# Test that a transaction which is rolled back does not go into binlog
+# and that a transaction which is committed does
+
+reset master;
+create table t1 (a int) engine=blackhole;
+set autocommit=0;
+start transaction;
+insert into t1 values(1);
+commit;
+
+let $master_log_pos_1= query_get_value(SHOW MASTER STATUS, Position, 1);
+
+start transaction;
+insert into t1 values(2);
+rollback;
+
+let $master_log_pos_2= query_get_value(SHOW MASTER STATUS, Position, 1);
+if ($master_log_pos_2 != $master_log_pos_1)
+{
+ echo $master_log_pos_1 $master_log_pos_2;
+ die Rollbacked transaction has been binlogged;
+}
+
+set autocommit=1;
+drop table if exists t1;
+
+#
+# Bug#35178 INSERT_ID not written to binary log for inserts against BLACKHOLE backed tables
+#
+#
+# the test checks that explicitly prescribed with set insert_id= value
+# preceeds the following autoincrement insert in a blachhole
+#
+
+reset master;
+create table t1 (a int auto_increment, primary key (a)) engine=blackhole;
+
+# not insert_id prescribed insert binlogs with the default set insert_id 1
+insert into t1 values (11), (NULL), (NULL), (NULL);
+set insert_id= 3;
+insert into t1 values (NULL), (33), (NULL);
+set insert_id= 5;
+insert into t1 values (55), (NULL);
+source include/show_binlog_events2.inc;
+
+# cleanup
+drop table t1;
+
+
+# End of tests
diff --git a/mysql-test/suite/binlog/include/ctype_cp932.test b/mysql-test/suite/binlog/include/ctype_cp932.test
new file mode 100644
index 00000000000..f42bffd30df
--- /dev/null
+++ b/mysql-test/suite/binlog/include/ctype_cp932.test
@@ -0,0 +1,468 @@
+-- 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 @test_character_set= 'cp932';
+SET @test_collation= 'cp932_japanese_ci';
+-- source include/ctype_common.inc
+
+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
+-- source include/ctype_like_range_f1f2.inc
+SET collation_connection='cp932_bin';
+-- source include/ctype_filesort.inc
+-- source include/ctype_like_range_f1f2.inc
+
+#
+# Bug#29333 myisam corruption with
+# character set cp932 collate cp932_japanese_ci
+#
+create table t2 (a char(1));
+insert into t2 values ('0'),('1'),('2'),('3'),('4'),('5'),('6'),('7');
+insert into t2 values ('8'),('9'),('A'),('B'),('C'),('D'),('E'),('F');
+create table t1 (
+ a varchar(2) character set cp932
+) engine=myisam;
+--disable_warnings
+insert into t1
+select unhex(concat(t24.a, t23.a, t22.a, t21.a))
+from t2 t21, t2 t22, t2 t23, t2 t24;
+--enable_warnings
+delete from t1 where a='';
+alter table t1 add key(a);
+check table t1;
+drop table t1;
+drop table t2;
+
+
+#
+# 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 ignore into t1 values ('ab');
+select * from t1;
+insert ignore into t1 values ('abc');
+select * from t1;
+drop table t1;
+
+#
+# Bug#25815 Data truncated for column TEXT
+#
+set names utf8;
+create table t1 (a text) default character set cp932;
+insert into t1 values (_utf8 0xE38182);
+show warnings;
+select * from t1;
+select hex(a) from t1;
+drop table t1;
+
+#
+# BUG#16217 - MySQL client misinterpretes multi-byte char as escape `\'
+#
+
+# new command \C or charset
+--exec $MYSQL --default-character-set=utf8 test -e "\C cp932 \g"
+--exec $MYSQL --default-character-set=cp932 test -e "charset utf8;"
+
+# its usage to switch internally in mysql to requested charset
+--exec $MYSQL --default-character-set=utf8 test -e "charset cp932; select 'ƒ\'; create table t1 (c_cp932 TEXT CHARACTER SET cp932); insert into t1 values('ƒ\'); select * from t1; drop table t1;"
+--exec $MYSQL --default-character-set=utf8 test -e "charset cp932; select 'ƒ\'"
+--exec $MYSQL --default-character-set=utf8 test -e "/*charset cp932 */; set character_set_client= cp932; select 'ƒ\'"
+--exec $MYSQL --default-character-set=utf8 test -e "/*!\C cp932 */; set character_set_client= cp932; select 'ƒ\'"
diff --git a/mysql-test/suite/binlog/include/ctype_cp932_binlog.test b/mysql-test/suite/binlog/include/ctype_cp932_binlog.test
new file mode 100644
index 00000000000..5c172afd122
--- /dev/null
+++ b/mysql-test/suite/binlog/include/ctype_cp932_binlog.test
@@ -0,0 +1,35 @@
+-- source include/not_embedded.inc
+-- source include/have_cp932.inc
+-- source include/have_log_bin.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;
+source include/show_binlog_events.inc;
+SELECT HEX(f1) FROM t1;
+DROP table t1;
+# end test for bug#11338
+
+# End of 4.1 tests
diff --git a/mysql-test/suite/binlog/include/ctype_ucs_binlog.result b/mysql-test/suite/binlog/include/ctype_ucs_binlog.result
new file mode 100644
index 00000000000..c358cfcd4f2
--- /dev/null
+++ b/mysql-test/suite/binlog/include/ctype_ucs_binlog.result
@@ -0,0 +1,212 @@
+SET TIMESTAMP=10000;
+create table t2 (c char(30)) charset=ucs2;
+set @v=convert('abc' using ucs2);
+reset master;
+insert into t2 values (@v);
+include/show_binlog_events.inc
+Log_name Pos Event_type Server_id End_log_pos Info
+master-bin.000001 # Gtid # # BEGIN GTID #-#-#
+master-bin.000001 # User var # # @`v`=_ucs2 X'006100620063' COLLATE ucs2_general_ci
+master-bin.000001 # Query # # use `test`; insert into t2 values (@v)
+master-bin.000001 # Query # # COMMIT
+flush logs;
+/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/;
+/*!40019 SET @@session.max_insert_delayed_threads=0*/;
+/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
+DELIMITER /*!*/;
+ROLLBACK/*!*/;
+BEGIN
+/*!*/;
+SET @`v`:=_ucs2 X'006100620063' COLLATE `ucs2_general_ci`/*!*/;
+use `test`/*!*/;
+SET TIMESTAMP=10000/*!*/;
+SET @@session.pseudo_thread_id=999999999/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.sql_mode=1342177280/*!*/;
+SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
+/*!\C latin1 *//*!*/;
+SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/;
+SET @@session.lc_time_names=0/*!*/;
+SET @@session.collation_database=DEFAULT/*!*/;
+insert into t2 values (@v)
+/*!*/;
+SET TIMESTAMP=10000/*!*/;
+COMMIT
+/*!*/;
+DELIMITER ;
+# End of log file
+ROLLBACK /* added by mysqlbinlog */;
+/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
+/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;
+drop table t2;
+#
+# Start of 10.2 tests
+#
+#
+# MDEV-10866 Extend PREPARE and EXECUTE IMMEDIATE to understand expressions
+#
+FLUSH LOGS;
+SET NAMES utf8;
+CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET utf8);
+EXECUTE IMMEDIATE 'INSERT INTO t1 VALUES (''ä(i1)'')';
+EXECUTE IMMEDIATE CONVERT('INSERT INTO t1 VALUES (''ä(i2)'')' USING ucs2);
+SET @stmt=CONVERT('INSERT INTO t1 VALUES (''ä(i3)'')' USING ucs2);
+EXECUTE IMMEDIATE @stmt;
+PREPARE stmt FROM 'INSERT INTO t1 VALUES (''ä(p1)'')';
+EXECUTE stmt;
+PREPARE stmt FROM CONVERT('INSERT INTO t1 VALUES (''ä(p2)'')' USING ucs2);
+EXECUTE stmt;
+SET @stmt=CONVERT('INSERT INTO t1 VALUES (''ä(p3)'')' USING ucs2);
+PREPARE stmt FROM @stmt;
+EXECUTE stmt;
+DEALLOCATE PREPARE stmt;
+SELECT * FROM t1;
+a
+ä(i1)
+ä(i2)
+ä(i3)
+ä(p1)
+ä(p2)
+ä(p3)
+DROP TABLE t1;
+FLUSH LOGS;
+/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/;
+/*!40019 SET @@session.max_insert_delayed_threads=0*/;
+/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
+DELIMITER /*!*/;
+# at #
+#700101 6:46:40 server id # end_log_pos # CRC32 XXX Start: binlog v 4, server v #.##.## created 700101 6:46:40
+# at #
+#700101 6:46:40 server id # end_log_pos # CRC32 XXX Gtid list [#-#-#]
+# at #
+#700101 6:46:40 server id # end_log_pos # CRC32 XXX Binlog checkpoint master-bin.000002
+# at #
+#700101 6:46:40 server id # end_log_pos # CRC32 XXX Binlog checkpoint master-bin.000003
+# at #
+#700101 6:46:40 server id # end_log_pos # CRC32 XXX GTID #-#-# ddl
+/*!100101 SET @@session.skip_parallel_replication=0*//*!*/;
+/*!100001 SET @@session.gtid_domain_id=#*//*!*/;
+/*!100001 SET @@session.server_id=#*//*!*/;
+/*!100001 SET @@session.gtid_seq_no=#*//*!*/;
+# at #
+#700101 6:46:40 server id # end_log_pos # CRC32 XXX Query thread_id=# exec_time=# error_code=0
+use `test`/*!*/;
+SET TIMESTAMP=10000/*!*/;
+SET @@session.pseudo_thread_id=#/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/;
+SET @@session.sql_mode=1342177280/*!*/;
+SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
+/*!\C utf8 *//*!*/;
+SET @@session.character_set_client=33,@@session.collation_connection=33,@@session.collation_server=8/*!*/;
+SET @@session.lc_time_names=0/*!*/;
+SET @@session.collation_database=DEFAULT/*!*/;
+CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET utf8)
+/*!*/;
+# at #
+#700101 6:46:40 server id # end_log_pos # CRC32 XXX GTID #-#-#
+/*!100001 SET @@session.gtid_seq_no=#*//*!*/;
+BEGIN
+/*!*/;
+# at #
+#700101 6:46:40 server id # end_log_pos # CRC32 XXX Query thread_id=# exec_time=# error_code=0
+SET TIMESTAMP=10000/*!*/;
+INSERT INTO t1 VALUES ('ä(i1)')
+/*!*/;
+# at #
+#700101 6:46:40 server id # end_log_pos # CRC32 XXX Query thread_id=# exec_time=# error_code=0
+SET TIMESTAMP=10000/*!*/;
+COMMIT
+/*!*/;
+# at #
+#700101 6:46:40 server id # end_log_pos # CRC32 XXX GTID #-#-#
+/*!100001 SET @@session.gtid_seq_no=#*//*!*/;
+BEGIN
+/*!*/;
+# at #
+#700101 6:46:40 server id # end_log_pos # CRC32 XXX Query thread_id=# exec_time=# error_code=0
+SET TIMESTAMP=10000/*!*/;
+INSERT INTO t1 VALUES ('ä(i2)')
+/*!*/;
+# at #
+#700101 6:46:40 server id # end_log_pos # CRC32 XXX Query thread_id=# exec_time=# error_code=0
+SET TIMESTAMP=10000/*!*/;
+COMMIT
+/*!*/;
+# at #
+#700101 6:46:40 server id # end_log_pos # CRC32 XXX GTID #-#-#
+/*!100001 SET @@session.gtid_seq_no=#*//*!*/;
+BEGIN
+/*!*/;
+# at #
+#700101 6:46:40 server id # end_log_pos # CRC32 XXX Query thread_id=# exec_time=# error_code=0
+SET TIMESTAMP=10000/*!*/;
+INSERT INTO t1 VALUES ('ä(i3)')
+/*!*/;
+# at #
+#700101 6:46:40 server id # end_log_pos # CRC32 XXX Query thread_id=# exec_time=# error_code=0
+SET TIMESTAMP=10000/*!*/;
+COMMIT
+/*!*/;
+# at #
+#700101 6:46:40 server id # end_log_pos # CRC32 XXX GTID #-#-#
+/*!100001 SET @@session.gtid_seq_no=#*//*!*/;
+BEGIN
+/*!*/;
+# at #
+#700101 6:46:40 server id # end_log_pos # CRC32 XXX Query thread_id=# exec_time=# error_code=0
+SET TIMESTAMP=10000/*!*/;
+INSERT INTO t1 VALUES ('ä(p1)')
+/*!*/;
+# at #
+#700101 6:46:40 server id # end_log_pos # CRC32 XXX Query thread_id=# exec_time=# error_code=0
+SET TIMESTAMP=10000/*!*/;
+COMMIT
+/*!*/;
+# at #
+#700101 6:46:40 server id # end_log_pos # CRC32 XXX GTID #-#-#
+/*!100001 SET @@session.gtid_seq_no=#*//*!*/;
+BEGIN
+/*!*/;
+# at #
+#700101 6:46:40 server id # end_log_pos # CRC32 XXX Query thread_id=# exec_time=# error_code=0
+SET TIMESTAMP=10000/*!*/;
+INSERT INTO t1 VALUES ('ä(p2)')
+/*!*/;
+# at #
+#700101 6:46:40 server id # end_log_pos # CRC32 XXX Query thread_id=# exec_time=# error_code=0
+SET TIMESTAMP=10000/*!*/;
+COMMIT
+/*!*/;
+# at #
+#700101 6:46:40 server id # end_log_pos # CRC32 XXX GTID #-#-#
+/*!100001 SET @@session.gtid_seq_no=#*//*!*/;
+BEGIN
+/*!*/;
+# at #
+#700101 6:46:40 server id # end_log_pos # CRC32 XXX Query thread_id=# exec_time=# error_code=0
+SET TIMESTAMP=10000/*!*/;
+INSERT INTO t1 VALUES ('ä(p3)')
+/*!*/;
+# at #
+#700101 6:46:40 server id # end_log_pos # CRC32 XXX Query thread_id=# exec_time=# error_code=0
+SET TIMESTAMP=10000/*!*/;
+COMMIT
+/*!*/;
+# at #
+#700101 6:46:40 server id # end_log_pos # CRC32 XXX GTID #-#-# ddl
+/*!100001 SET @@session.gtid_seq_no=#*//*!*/;
+# at #
+#700101 6:46:40 server id # end_log_pos # CRC32 XXX Query thread_id=# exec_time=# error_code=0
+SET TIMESTAMP=10000/*!*/;
+DROP TABLE `t1` /* generated by server */
+/*!*/;
+# at #
+#700101 6:46:40 server id # end_log_pos # CRC32 XXX Rotate to master-bin.000004 pos: 4
+DELIMITER ;
+# End of log file
+ROLLBACK /* added by mysqlbinlog */;
+/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
+/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;
+#
+# End of 10.2 tests
+#
diff --git a/mysql-test/suite/binlog/include/ctype_ucs_binlog.test b/mysql-test/suite/binlog/include/ctype_ucs_binlog.test
new file mode 100644
index 00000000000..8a4df14d4b3
--- /dev/null
+++ b/mysql-test/suite/binlog/include/ctype_ucs_binlog.test
@@ -0,0 +1,63 @@
+--source include/not_embedded.inc
+--source include/have_ucs2.inc
+--source include/have_log_bin.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);
+source include/show_binlog_events.inc;
+# more important than SHOW BINLOG EVENTS, mysqlbinlog (where we
+# absolutely need variables names to be quoted and strings to be
+# escaped).
+flush logs;
+let $MYSQLD_DATADIR= `select @@datadir`;
+--exec $MYSQL_BINLOG --short-form $MYSQLD_DATADIR/master-bin.000001
+drop table t2;
+
+# End of 4.1 tests
+
+
+--echo #
+--echo # Start of 10.2 tests
+--echo #
+
+--echo #
+--echo # MDEV-10866 Extend PREPARE and EXECUTE IMMEDIATE to understand expressions
+--echo #
+
+SET TIMESTAMP=UNIX_TIMESTAMP('1970-01-01 06:46:40');
+
+FLUSH LOGS;
+SET NAMES utf8;
+CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET utf8);
+EXECUTE IMMEDIATE 'INSERT INTO t1 VALUES (''ä(i1)'')';
+EXECUTE IMMEDIATE CONVERT('INSERT INTO t1 VALUES (''ä(i2)'')' USING ucs2);
+SET @stmt=CONVERT('INSERT INTO t1 VALUES (''ä(i3)'')' USING ucs2);
+EXECUTE IMMEDIATE @stmt;
+
+PREPARE stmt FROM 'INSERT INTO t1 VALUES (''ä(p1)'')';
+EXECUTE stmt;
+PREPARE stmt FROM CONVERT('INSERT INTO t1 VALUES (''ä(p2)'')' USING ucs2);
+EXECUTE stmt;
+SET @stmt=CONVERT('INSERT INTO t1 VALUES (''ä(p3)'')' USING ucs2);
+PREPARE stmt FROM @stmt;
+EXECUTE stmt;
+DEALLOCATE PREPARE stmt;
+
+SELECT * FROM t1;
+DROP TABLE t1;
+FLUSH LOGS;
+let $MYSQLD_DATADIR= `select @@datadir`;
+--replace_regex /TIMESTAMP=[0-9]*/TIMESTAMP=XXX/ /# at [0-9]*/# at #/ /(exec_time=|end_log_pos |Xid = |thread_id=|server id |table id |mapped to number )[0-9]+/\1#/ /server v [^ ]*/server v #.##.##/ /CRC32 0x[0-9a-f]*/CRC32 XXX/ /GTID [0-9]+-[0-9]+-[0-9]+/GTID #-#-#/ /Gtid list [[][0-9]+-[0-9]+-[0-9]+[\]]/Gtid list [#-#-#]/ /session[.](gtid_domain_id|server_id|gtid_seq_no)=[0-9]+/session.\1=#/ /(^#|created )[0-9]{6} [ 1][0-9]:[0-9]{2}:[0-9]{2}/\1YYMMDD HH:MM:SS/
+--exec $MYSQL_BINLOG --base64-output=decode-rows -vv $MYSQLD_DATADIR/master-bin.000003
+
+SET TIMESTAMP=DEFAULT;
+
+--echo #
+--echo # End of 10.2 tests
+--echo #
diff --git a/mysql-test/suite/binlog/include/database.test b/mysql-test/suite/binlog/include/database.test
new file mode 100644
index 00000000000..097a501cc34
--- /dev/null
+++ b/mysql-test/suite/binlog/include/database.test
@@ -0,0 +1,94 @@
+source include/have_log_bin.inc;
+source include/not_embedded.inc;
+
+# Checking that the drop of a database does not replicate anything in
+# addition to the drop of the database
+
+reset master;
+create database testing_1;
+use testing_1;
+create table t1 (a int);
+create function sf1 (a int) returns int return a+1;
+create trigger tr1 before insert on t1 for each row insert into t2 values (2*new.a);
+create procedure sp1 (a int) insert into t1 values(a);
+drop database testing_1;
+source include/show_binlog_events.inc;
+
+# BUG#38773: DROP DATABASE cause switch to stmt-mode when there are
+# temporary tables open
+
+use test;
+reset master;
+create temporary table tt1 (a int);
+create table t1 (a int);
+insert into t1 values (1);
+disable_warnings;
+drop database if exists mysqltest1;
+enable_warnings;
+insert into t1 values (1);
+drop table tt1, t1;
+source include/show_binlog_events.inc;
+
+FLUSH STATUS;
+
+--echo
+--echo # 'DROP TABLE IF EXISTS <deleted tables>' is binlogged
+--echo # when 'DROP DATABASE' fails and at least one table is deleted
+--echo # from the database.
+RESET MASTER;
+CREATE DATABASE testing_1;
+USE testing_1;
+CREATE TABLE t1(c1 INT);
+CREATE TABLE t2(c1 INT);
+
+let $prefix= `SELECT UUID()`;
+--echo # Create a file in the database directory
+--replace_result $prefix FAKE_FILE
+eval SELECT 'hello' INTO OUTFILE 'fake_file.$prefix';
+
+--echo
+--echo # 'DROP DATABASE' will fail if there is any other file in the the
+--echo # database directory
+
+# Use '/' instead of '\' in the error message. On windows platform, dir is
+# formed with '\'.
+--replace_regex /\\testing_1\\*/\/testing_1\// /66/39/ /93/39/ /17/39/ /247/39/ /File exists/Directory not empty/
+--error 1010
+DROP DATABASE testing_1;
+let $wait_binlog_event= DROP TABLE IF EXIST;
+source include/wait_for_binlog_event.inc;
+let $MYSQLD_DATADIR= `SELECT @@datadir`;
+
+--echo
+--echo # Remove the fake file.
+--remove_file $MYSQLD_DATADIR/testing_1/fake_file.$prefix
+--echo # Now we can drop the database.
+DROP DATABASE testing_1;
+
+
+--echo #
+--echo # Bug#11765416 58381: FAILED DROP DATABASE CAN BREAK STATEMENT
+--echo # BASED REPLICATION
+--echo #
+
+USE test;
+--disable_warnings
+DROP DATABASE IF EXISTS db1;
+DROP TABLE IF EXISTS t3;
+--enable_warnings
+
+CREATE DATABASE db1;
+CREATE TABLE db1.t1 (a INT);
+CREATE TABLE db1.t2 (b INT, KEY(b)) engine=innodb;
+CREATE TABLE t3 (a INT, KEY (a), FOREIGN KEY(a) REFERENCES db1.t2(b))
+ engine=innodb;
+RESET MASTER;
+
+--error ER_ROW_IS_REFERENCED_2
+DROP DATABASE db1; # Fails because of the fk
+SHOW TABLES FROM db1; # t1 was dropped, t2 remains
+--source include/show_binlog_events.inc # Check that the binlog drops t1
+
+# Cleanup
+DROP TABLE t3;
+DROP DATABASE db1;
diff --git a/mysql-test/suite/binlog/include/drop_table.test b/mysql-test/suite/binlog/include/drop_table.test
new file mode 100644
index 00000000000..c55cbb67560
--- /dev/null
+++ b/mysql-test/suite/binlog/include/drop_table.test
@@ -0,0 +1,34 @@
+#
+# Bug#989: If DROP TABLE while there's an active transaction, wrong binlog order
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+connect (con1,localhost,root,,);
+connect (con2,localhost,root,,);
+
+connection con1;
+RESET MASTER;
+CREATE TABLE t1 (a INT);
+SET AUTOCOMMIT=OFF;
+BEGIN;
+INSERT INTO t1 VALUES(1);
+
+connection con2;
+--send DROP TABLE t1;
+
+connection con1;
+COMMIT;
+
+connection con2;
+--reap
+
+connection default;
+
+--disconnect con1
+--disconnect con2
+
+let $VERSION=`select version()`;
+source include/show_binlog_events.inc;
diff --git a/mysql-test/suite/binlog/include/drop_temp_table.test b/mysql-test/suite/binlog/include/drop_temp_table.test
new file mode 100644
index 00000000000..c852ee4c8a0
--- /dev/null
+++ b/mysql-test/suite/binlog/include/drop_temp_table.test
@@ -0,0 +1,102 @@
+
+--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);
+
+##############################################################################
+# BUG#46572 DROP TEMPORARY table IF EXISTS does not have a consistent behavior
+# in ROW mode
+#
+# In RBR, 'DROP TEMPORARY TABLE ...' statement should never be binlogged no
+# matter if the tables exist or not. In contrast, both in SBR and MBR, the
+# statement should be always binlogged no matter if the tables exist or not.
+##############################################################################
+CREATE TEMPORARY TABLE tmp(c1 int);
+CREATE TEMPORARY TABLE tmp1(c1 int);
+CREATE TEMPORARY TABLE tmp2(c1 int);
+CREATE TEMPORARY TABLE tmp3(c1 int);
+CREATE TABLE t(c1 int);
+
+DROP TEMPORARY TABLE IF EXISTS tmp;
+
+--disable_warnings
+# Before fixing BUG#46572, 'DROP TEMPORARY TABLE IF EXISTS...' statement was
+# binlogged when the table did not exist in RBR.
+DROP TEMPORARY TABLE IF EXISTS tmp;
+
+# In RBR, 'DROP TEMPORARY TABLE ...' statement is never binlogged no matter if
+# the tables exist or not.
+DROP TEMPORARY TABLE IF EXISTS tmp, tmp1;
+DROP TEMPORARY TABLE tmp3;
+
+#In RBR, tmp2 will NOT be binlogged, because it is a temporary table.
+DROP TABLE IF EXISTS tmp2, t;
+
+#In RBR, tmp2 will be binlogged, because it does not exist and master do not know
+# whether it is a temporary table or not.
+DROP TABLE IF EXISTS tmp2, t;
+--enable_warnings
+
+SELECT GET_LOCK("a",10);
+
+#
+# BUG48216 Replication fails on all slaves after upgrade to 5.0.86 on master
+#
+# When the session is closed, any temporary tables of the session are dropped
+# and are binlogged. But it will be binlogged with a wrong database name when
+# the length of the database name('drop-temp-table-test') is greater than the
+# current database name('test').
+#
+USE test;
+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()`;
+source include/show_binlog_events.inc;
+DROP DATABASE `drop-temp+table-test`;
+
+
+#
+# Bug #54842: DROP TEMPORARY TABLE not binlogged after manual switching binlog format to ROW
+#
+# Sanity test. Checking that implicit DROP event is logged.
+#
+# After BUG#52616, the switch to ROW mode becomes effective even
+# if there are open temporary tables. As such the implicit drop
+# for temporary tables on session closing must be logged.
+#
+
+RESET MASTER;
+
+CREATE TABLE t1 ( i text );
+
+--connect(con1,localhost,root,,)
+CREATE TEMPORARY TABLE ttmp1 ( i text );
+SET @@session.binlog_format=ROW;
+INSERT INTO t1 VALUES ('1');
+SELECT @@session.binlog_format;
+--disconnect con1
+
+-- connection default
+--let $wait_binlog_event= DROP
+--source include/wait_for_binlog_event.inc
+-- source include/show_binlog_events.inc
+RESET MASTER;
+
+DROP TABLE t1;
+
+# End of 4.1 tests
diff --git a/mysql-test/suite/binlog/include/implicit.test b/mysql-test/suite/binlog/include/implicit.test
new file mode 100644
index 00000000000..de906fc0605
--- /dev/null
+++ b/mysql-test/suite/binlog/include/implicit.test
@@ -0,0 +1,28 @@
+# First part: outside a transaction
+RESET MASTER;
+eval $prepare;
+
+INSERT INTO t1 VALUES (1);
+source include/show_binlog_events.inc;
+eval $statement;
+source include/show_binlog_events.inc;
+if ($cleanup) {
+ eval $cleanup;
+}
+
+# Second part: inside a transaction
+RESET MASTER;
+eval $prepare;
+BEGIN;
+INSERT INTO t1 VALUES (2);
+source include/show_binlog_events.inc;
+eval $statement;
+source include/show_binlog_events.inc;
+INSERT INTO t1 VALUES (3);
+source include/show_binlog_events.inc;
+COMMIT;
+source include/show_binlog_events.inc;
+if ($cleanup) {
+ eval $cleanup;
+}
+
diff --git a/mysql-test/suite/binlog/include/insert_select-binlog.test b/mysql-test/suite/binlog/include/insert_select-binlog.test
new file mode 100644
index 00000000000..ef22373a628
--- /dev/null
+++ b/mysql-test/suite/binlog/include/insert_select-binlog.test
@@ -0,0 +1,38 @@
+# Embedded server doesn't support binlog
+-- source include/not_embedded.inc
+-- source include/have_log_bin.inc
+
+--disable_warnings
+drop table if exists t1,t2;
+--enable_warnings
+
+# 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 ER_DUP_ENTRY
+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()`;
+source include/show_binlog_events.inc;
+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 ER_DUP_ENTRY
+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()`;
+source include/show_binlog_events.inc;
+drop table t1;
+
+# End of 4.1 tests
diff --git a/mysql-test/suite/binlog/include/mix_innodb_myisam_binlog.test b/mysql-test/suite/binlog/include/mix_innodb_myisam_binlog.test
new file mode 100644
index 00000000000..74fbe6b482a
--- /dev/null
+++ b/mysql-test/suite/binlog/include/mix_innodb_myisam_binlog.test
@@ -0,0 +1,654 @@
+# 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.
+
+-- source include/have_log_bin.inc
+-- source include/have_innodb.inc
+
+call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
+
+--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;
+
+source include/show_binlog_events.inc;
+
+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;
+
+source include/show_binlog_events.inc;
+
+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;
+
+source include/show_binlog_events.inc;
+
+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 :)
+
+source include/show_binlog_events.inc;
+
+# 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);
+source include/show_binlog_events.inc;
+
+# 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;
+
+source include/show_binlog_events.inc;
+
+# 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;
+source include/show_binlog_events.inc;
+insert into t1 values(11);
+commit;
+
+source include/show_binlog_events.inc;
+
+# 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;
+
+source include/show_binlog_events.inc;
+
+delete from t1;
+delete from t2;
+reset master;
+
+begin;
+insert into t1 values(13);
+insert into t2 select * from t1;
+rollback;
+
+source include/show_binlog_events.inc;
+
+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;
+
+source include/show_binlog_events.inc;
+
+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 :)
+
+source include/show_binlog_events.inc;
+
+# 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 engine=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;
+
+connection con3;
+commit;
+
+connection con2;
+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",0);
+set autocommit=0;
+create table t2 (n int) engine=innodb;
+insert into t2 values (3);
+disconnect con2;
+connection con3;
+select get_lock("lock1",60);
+source include/show_binlog_events.inc;
+do release_lock("lock1");
+drop table t0,t2;
+
+# End of 4.1 tests
+
+#
+# Test behaviour of CREATE ... SELECT when mixing MyISAM and InnoDB tables
+#
+
+set autocommit=0;
+CREATE TABLE t1 (a int, b int) engine=myisam;
+reset master;
+INSERT INTO t1 values (1,1),(1,2);
+--error ER_DUP_ENTRY
+CREATE TABLE t2 (primary key (a)) engine=innodb select * from t1;
+# This should give warning
+DROP TABLE if exists t2;
+INSERT INTO t1 values (3,3);
+--error ER_DUP_ENTRY
+CREATE TEMPORARY TABLE t2 (primary key (a)) engine=innodb select * from t1;
+ROLLBACK;
+# This should give warning
+DROP TABLE IF EXISTS t2;
+
+CREATE TABLE t2 (a int, b int, primary key (a)) engine=innodb;
+INSERT INTO t1 VALUES (4,4);
+CREATE TABLE IF NOT EXISTS t2 (primary key (a)) engine=innodb select * from t1;
+SELECT * from t2;
+TRUNCATE table t2;
+INSERT INTO t1 VALUES (5,5);
+--error ER_DUP_ENTRY
+INSERT INTO t2 select * from t1;
+SELECT * FROM t2;
+DROP TABLE t2;
+
+INSERT INTO t1 values (6,6);
+CREATE TEMPORARY TABLE t2 (a int, b int, primary key (a)) engine=innodb ;
+INSERT INTO t1 values (7,7);
+ROLLBACK;
+INSERT INTO t1 values (8,8);
+CREATE TEMPORARY TABLE IF NOT EXISTS t2 (primary key (a)) engine=innodb select * from t1;
+COMMIT;
+INSERT INTO t1 values (9,9);
+CREATE TEMPORARY TABLE IF NOT EXISTS t2 (primary key (a)) engine=innodb select * from t1;
+ROLLBACK;
+SELECT * from t2;
+TRUNCATE table t2;
+INSERT INTO t1 values (10,10);
+--error ER_DUP_ENTRY
+INSERT INTO t2 select * from t1;
+SELECT * from t1;
+INSERT INTO t2 values (100,100);
+CREATE TEMPORARY TABLE IF NOT EXISTS t2 (primary key (a)) engine=innodb select * from t1;
+COMMIT;
+INSERT INTO t2 values (101,101);
+CREATE TEMPORARY TABLE IF NOT EXISTS t2 (primary key (a)) engine=innodb select * from t1;
+ROLLBACK;
+SELECT * from t2;
+DROP TABLE t1,t2;
+source include/show_binlog_events.inc;
+
+# 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
+if (`select @@binlog_format = 'STATEMENT' || @@binlog_format = 'MIXED'`)
+{
+ --let $binlog_rollback= query_get_value(SHOW BINLOG EVENTS, Pos, 11)
+ --let $binlog_query= query_get_value(SHOW BINLOG EVENTS, Info, 11)
+ if ($binlog_query != ROLLBACK) {
+ --echo Wrong query from SHOW BINLOG EVENTS. Expected ROLLBACK, got '$binlog_query'
+ --source include/show_rpl_debug_info.inc
+ --die Wrong value for slave parameter
+ }
+}
+flush logs;
+
+let $MYSQLD_DATADIR= `select @@datadir`;
+# 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)
+
+-- source include/binlog_start_pos.inc
+
+if (`select @@binlog_format = 'ROW'`)
+{
+ --echo There is nothing to roll back; transactional changes are removed from the trans cache.
+}
+
+if (`select @@binlog_format = 'STATEMENT' || @@binlog_format = 'MIXED'`)
+{
+ --exec $MYSQL_BINLOG --start-position=$binlog_rollback $MYSQLD_DATADIR/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\\n/*!*/;%ROLLBACK /* added by mysqlbinlog */;%" OR
+ @a like "%#%error_code=0%ROLLBACK\\r\\n/*!*/;%ROLLBACK /* added by mysqlbinlog */;%",
+ @a not like "%#%error_code=%error_code=%";
+}
+drop table t1, t2;
+
+#
+# Bug #27417 thd->no_trans_update.stmt lost value inside of SF-exec-stack
+# bug #28960 non-trans temp table changes with insert .. select
+# not binlogged after rollback
+#
+# testing appearence of insert into temp_table in binlog.
+# There are two branches of execution that require different setup.
+
+## send_eof() branch
+
+# prepare
+
+create temporary table tt (a int unique);
+create table ti (a int) engine=innodb;
+reset master;
+
+# action
+
+begin;
+insert into ti values (1);
+insert into ti values (2) ;
+# This is SAFE because --binlog-direct-non-transactional-updates=FALSE
+insert into tt select * from ti;
+rollback;
+
+# check
+
+select count(*) from tt /* 2 */;
+source include/show_binlog_events.inc;
+select count(*) from ti /* zero */;
+insert into ti select * from tt;
+select * from ti /* that is what slave would miss - a bug */;
+
+
+## send_error() branch
+delete from ti;
+delete from tt where a=1;
+reset master;
+
+# action
+
+begin;
+insert into ti values (1);
+insert into ti values (2) /* to make the dup error in the following */;
+--error ER_DUP_ENTRY
+insert into tt select * from ti /* one affected and error */;
+rollback;
+
+# check
+
+source include/show_binlog_events.inc;
+select count(*) from ti /* zero */;
+insert into ti select * from tt;
+select * from tt /* that is what otherwise slave missed - the bug */;
+
+drop table ti, tt;
+
+
+#
+# Bug #27417 thd->no_trans_update.stmt lost value inside of SF-exec-stack
+#
+# Testing asserts: if there is a side effect of modifying non-transactional
+# table thd->no_trans_update.stmt must be TRUE;
+# the assert is active with debug build
+#
+
+--disable_warnings
+drop function if exists bug27417;
+drop table if exists t1,t2;
+--enable_warnings
+# side effect table
+CREATE TABLE t1 (a int NOT NULL auto_increment primary key) ENGINE=MyISAM;
+# target tables
+CREATE TABLE t2 (a int NOT NULL auto_increment, PRIMARY KEY (a));
+
+delimiter |;
+create function bug27417(n int)
+RETURNS int(11)
+begin
+ insert into t1 values (null);
+ return n;
+end|
+delimiter ;|
+
+reset master;
+
+# execute
+
+insert into t2 values (bug27417(1));
+insert into t2 select bug27417(2);
+reset master;
+
+--error ER_DUP_ENTRY
+insert into t2 values (bug27417(2));
+source include/show_binlog_events.inc; /* only (!) with fixes for #23333 will show there is the query */;
+select count(*) from t1 /* must be 3 */;
+
+reset master;
+select count(*) from t2;
+delete from t2 where a=bug27417(3);
+select count(*) from t2 /* nothing got deleted */;
+source include/show_binlog_events.inc; /* the query must be in regardless of #23333 */;
+select count(*) from t1 /* must be 5 */;
+
+--enable_info
+delete t2 from t2 where t2.a=bug27417(100) /* must not affect t2 */;
+--disable_info
+select count(*) from t1 /* must be 7 */;
+
+# function bug27417 remains for the following testing of bug#23333
+drop table t1,t2;
+
+#
+# Bug#23333 using the patch (and the test) for bug#27471
+#
+# throughout the bug tests
+# t1 - non-trans side effects gatherer;
+# t2 - transactional table;
+#
+
+CREATE TABLE t1 (a int NOT NULL auto_increment primary key) ENGINE=MyISAM;
+CREATE TABLE t2 (a int, PRIMARY KEY (a)) ENGINE=InnoDB;
+CREATE TABLE t3 (a int, PRIMARY KEY (a), b int unique) ENGINE=MyISAM;
+CREATE TABLE t4 (a int, PRIMARY KEY (a), b int unique) ENGINE=Innodb;
+CREATE TABLE t5 (a int, PRIMARY KEY (a)) ENGINE=InnoDB;
+
+
+#
+# INSERT
+#
+
+# prepare
+
+ insert into t2 values (1);
+ reset master;
+
+# execute
+
+ --error ER_DUP_ENTRY
+ insert into t2 values (bug27417(1));
+
+# check
+
+ source include/show_binlog_events.inc; /* the output must denote there is the query */;
+ select count(*) from t1 /* must be 1 */;
+
+#
+# INSERT SELECT
+#
+
+# prepare
+ delete from t1;
+ delete from t2;
+ insert into t2 values (2);
+ reset master;
+
+# execute
+
+ --error ER_DUP_ENTRY
+ insert into t2 select bug27417(1) union select bug27417(2);
+
+# check
+
+ source include/show_binlog_events.inc; /* the output must denote there is the query */;
+ select count(*) from t1 /* must be 2 */;
+
+#
+# UPDATE inc multi-update
+#
+
+# prepare
+ delete from t1;
+ insert into t3 values (1,1),(2,3),(3,4);
+ reset master;
+
+# execute
+ --error ER_DUP_ENTRY
+ update t3 set b=b+bug27417(1);
+
+# check
+ source include/show_binlog_events.inc; /* the output must denote there is the query */;
+ select count(*) from t1 /* must be 2 */;
+
+## multi_update::send_eof() branch
+
+# prepare
+ delete from t3;
+ delete from t4;
+ insert into t3 values (1,1);
+ insert into t4 values (1,1),(2,2);
+
+ reset master;
+
+# execute
+ --error ER_DUP_ENTRY
+ UPDATE t4,t3 SET t4.a=t3.a + bug27417(1) /* top level non-ta table */;
+
+# check
+ source include/show_binlog_events.inc; /* the output must denote there is the query */;
+ select count(*) from t1 /* must be 4 */;
+
+## send_error() branch of multi_update
+
+# prepare
+ delete from t1;
+ delete from t3;
+ delete from t4;
+ insert into t3 values (1,1),(2,2);
+ insert into t4 values (1,1),(2,2);
+
+ reset master;
+
+# execute
+ --error ER_DUP_ENTRY
+ UPDATE t3,t4 SET t3.a=t4.a + bug27417(1);
+
+# check
+ select count(*) from t1 /* must be 1 */;
+
+# cleanup
+ drop table t4;
+
+
+#
+# DELETE incl multi-delete
+#
+
+# prepare
+ delete from t1;
+ delete from t2;
+ delete from t3;
+ insert into t2 values (1);
+ insert into t3 values (1,1);
+ create trigger trg_del before delete on t2 for each row
+ insert into t3 values (bug27417(1), 2);
+ reset master;
+
+# execute
+ --error ER_DUP_ENTRY
+ delete from t2;
+# check
+ source include/show_binlog_events.inc; /* the output must denote there is the query */;
+ select count(*) from t1 /* must be 1 */;
+
+# cleanup
+ drop trigger trg_del;
+
+# prepare
+ delete from t1;
+ delete from t2;
+ delete from t5;
+ create trigger trg_del_t2 after delete on t2 for each row
+ insert into t1 values (1);
+ insert into t2 values (2),(3);
+ insert into t5 values (1),(2);
+ reset master;
+
+# execute
+ --error ER_DUP_ENTRY
+ delete t2.* from t2,t5 where t2.a=t5.a + 1;
+
+# check
+ source include/show_binlog_events.inc; /* the output must denote there is the query */;
+ select count(*) from t1 /* must be 1 */;
+
+
+#
+# LOAD DATA
+#
+
+# prepare
+ delete from t1;
+ create table t4 (a int default 0, b int primary key) engine=innodb;
+ insert into t4 values (0, 17);
+ reset master;
+
+# execute
+ --error ER_DUP_ENTRY
+ load data infile '../../std_data/rpl_loaddata.dat' into table t4 (a, @b) set b= @b + bug27417(2);
+# check
+ select * from t4;
+ select count(*) from t1 /* must be 2 */;
+ source include/show_binlog_events.inc; /* the output must denote there is the query */;
+
+#
+# bug#23333 cleanup
+#
+
+
+drop trigger trg_del_t2;
+drop table t1,t2,t3,t4,t5;
+drop function bug27417;
+
+
+--echo end of tests
+
diff --git a/mysql-test/suite/binlog/include/mix_innodb_myisam_side_effects.test b/mysql-test/suite/binlog/include/mix_innodb_myisam_side_effects.test
new file mode 100644
index 00000000000..7eca19bc834
--- /dev/null
+++ b/mysql-test/suite/binlog/include/mix_innodb_myisam_side_effects.test
@@ -0,0 +1,295 @@
+# the file to be sourced from binlog.binlog_mix_innodb_myisam
+
+#
+# Bug #27417 thd->no_trans_update.stmt lost value inside of SF-exec-stack
+# bug #28960 non-trans temp table changes with insert .. select
+# not binlogged after rollback
+#
+# testing appearence of insert into temp_table in binlog.
+# There are two branches of execution that require different setup.
+
+# checking binlog content filled with row-based events due to
+# a used stored function modifies non-transactional table
+
+## send_eof() branch
+
+# prepare
+
+create temporary table tt (a int unique);
+create table ti (a int) engine=innodb;
+reset master;
+
+# action
+
+begin;
+insert into ti values (1);
+insert into ti values (2) ;
+# This is SAFE because --binlog-direct-non-transactional-updates=FALSE
+insert into tt select * from ti;
+rollback;
+
+# check
+
+select count(*) from tt /* 2 */;
+source include/show_binlog_events.inc;
+select count(*) from ti /* zero */;
+insert into ti select * from tt;
+select * from ti /* that is what slave would miss - bug#28960 */;
+
+
+## send_error() branch
+delete from ti;
+delete from tt where a=1;
+reset master;
+
+# action
+
+begin;
+insert into ti values (1);
+insert into ti values (2) /* to make the dup error in the following */;
+--error ER_DUP_ENTRY
+insert into tt select * from ti /* one affected and error */;
+rollback;
+
+# check
+
+source include/show_binlog_events.inc; # nothing in binlog with row bilog format
+select count(*) from ti /* zero */;
+insert into ti select * from tt;
+select * from tt /* that is what otherwise slave missed - the bug */;
+
+drop table ti;
+
+
+#
+# Bug #27417 thd->no_trans_update.stmt lost value inside of SF-exec-stack
+#
+# Testing asserts: if there is a side effect of modifying non-transactional
+# table thd->no_trans_update.stmt must be TRUE;
+# the assert is active with debug build
+#
+
+--disable_warnings
+drop function if exists bug27417;
+drop table if exists t1,t2;
+--enable_warnings
+# side effect table
+CREATE TABLE t1 (a int NOT NULL auto_increment primary key) ENGINE=MyISAM;
+# target tables
+CREATE TABLE t2 (a int NOT NULL auto_increment, PRIMARY KEY (a));
+
+delimiter |;
+create function bug27417(n int)
+RETURNS int(11)
+begin
+ insert into t1 values (null);
+ return n;
+end|
+delimiter ;|
+
+reset master;
+
+# execute
+
+insert into t2 values (bug27417(1));
+insert into t2 select bug27417(2);
+reset master;
+
+--error ER_DUP_ENTRY
+insert into t2 values (bug27417(2));
+source include/show_binlog_events.inc; #only (!) with fixes for #23333 will show there is the query
+select count(*) from t1 /* must be 3 */;
+
+reset master;
+select count(*) from t2;
+delete from t2 where a=bug27417(3);
+select count(*) from t2 /* nothing got deleted */;
+source include/show_binlog_events.inc; # the query must be in regardless of #23333
+select count(*) from t1 /* must be 5 */;
+
+--enable_info
+delete t2 from t2 where t2.a=bug27417(100) /* must not affect t2 */;
+--disable_info
+select count(*) from t1 /* must be 7 */;
+
+# function bug27417 remains for the following testing of bug#23333
+drop table t1,t2;
+
+#
+# Bug#23333 using the patch (and the test) for bug#27471
+# throughout the bug tests
+# t1 - non-trans side effects gatherer;
+# t2 - transactional table;
+#
+CREATE TABLE t1 (a int NOT NULL auto_increment primary key) ENGINE=MyISAM;
+CREATE TABLE t2 (a int, PRIMARY KEY (a)) ENGINE=InnoDB;
+CREATE TABLE t3 (a int, PRIMARY KEY (a), b int unique) ENGINE=MyISAM;
+CREATE TABLE t4 (a int, PRIMARY KEY (a), b int unique) ENGINE=Innodb;
+CREATE TABLE t5 (a int, PRIMARY KEY (a)) ENGINE=InnoDB;
+
+
+#
+# INSERT
+#
+
+# prepare
+
+ insert into t2 values (1);
+ reset master;
+
+# execute
+
+ --error ER_DUP_ENTRY
+ insert into t2 values (bug27417(1));
+
+# check
+
+ source include/show_binlog_events.inc; # must be event of the query
+ select count(*) from t1 /* must be 1 */;
+
+#
+# INSERT SELECT
+#
+
+# prepare
+ delete from t1;
+ delete from t2;
+ insert into t2 values (2);
+ reset master;
+
+# execute
+
+ --error ER_DUP_ENTRY
+ insert into t2 select bug27417(1) union select bug27417(2);
+
+# check
+
+ source include/show_binlog_events.inc; # must be events of the query
+ select count(*) from t1 /* must be 2 */;
+
+#
+# UPDATE inc multi-update
+#
+
+# prepare
+ delete from t1;
+ insert into t3 values (1,1),(2,3),(3,4);
+ reset master;
+
+# execute
+ --error ER_DUP_ENTRY
+ update t3 set b=b+bug27417(1);
+
+# check
+ source include/show_binlog_events.inc; # must be events of the query
+ select count(*) from t1 /* must be 2 */;
+
+## multi_update::send_eof() branch
+
+# prepare
+ delete from t3;
+ delete from t4;
+ insert into t3 values (1,1);
+ insert into t4 values (1,1),(2,2);
+
+ reset master;
+
+# execute
+ --error ER_DUP_ENTRY
+ UPDATE t4,t3 SET t4.a=t3.a + bug27417(1) /* top level non-ta table */;
+
+# check
+ source include/show_binlog_events.inc; # the offset must denote there is the query
+ select count(*) from t1 /* must be 4 */;
+
+## send_error() branch of multi_update
+
+# prepare
+ delete from t1;
+ delete from t3;
+ delete from t4;
+ insert into t3 values (1,1),(2,2);
+ insert into t4 values (1,1),(2,2);
+
+ reset master;
+
+# execute
+ --error ER_DUP_ENTRY
+ UPDATE t3,t4 SET t3.a = t4.a + bug27417(1) where t3.a = 1;
+
+# check
+ select count(*) from t1 /* must be 1 */;
+
+# cleanup
+ drop table t4;
+
+
+#
+# DELETE incl multi-delete
+#
+
+# prepare
+ delete from t1;
+ delete from t2;
+ delete from t3;
+ insert into t2 values (1);
+ insert into t3 values (1,1);
+ create trigger trg_del before delete on t2 for each row
+ insert into t3 values (bug27417(1), 2);
+ reset master;
+
+# execute
+ --error ER_DUP_ENTRY
+ delete from t2;
+# check
+ source include/show_binlog_events.inc; # the offset must denote there is the query
+ select count(*) from t1 /* must be 1 */;
+
+# cleanup
+ drop trigger trg_del;
+
+# prepare
+ delete from t1;
+ delete from t2;
+ delete from t5;
+ create trigger trg_del_t2 after delete on t2 for each row
+ insert into t1 values (1);
+ insert into t2 values (2),(3);
+ insert into t5 values (1),(2);
+ reset master;
+
+# execute
+ --error ER_DUP_ENTRY
+ delete t2.* from t2,t5 where t2.a=t5.a + 1;
+
+# check
+ source include/show_binlog_events.inc; # must be events of the query
+ select count(*) from t1 /* must be 1 */;
+
+
+#
+# LOAD DATA
+#
+
+# prepare
+ delete from t1;
+ create table t4 (a int default 0, b int primary key) engine=innodb;
+ insert into t4 values (0, 17);
+ reset master;
+
+# execute
+ --error ER_DUP_ENTRY
+ load data infile '../../std_data/rpl_loaddata.dat' into table t4 (a, @b) set b= @b + bug27417(2);
+# check
+ select * from t4;
+ select count(*) from t1 /* must be 2 */;
+ source include/show_binlog_events.inc; # must be events of the query
+
+#
+# bug#23333 cleanup
+#
+
+
+drop trigger trg_del_t2;
+drop table t1,t2,t3,t4,t5;
+drop function bug27417;
diff --git a/mysql-test/suite/binlog/include/mysqlbinlog_row_engine.inc b/mysql-test/suite/binlog/include/mysqlbinlog_row_engine.inc
new file mode 100644
index 00000000000..8cc56caaec6
--- /dev/null
+++ b/mysql-test/suite/binlog/include/mysqlbinlog_row_engine.inc
@@ -0,0 +1,1923 @@
+# mysqlbinlog_row.test
+#
+# Show that mysqlbinlog displays human readable comments to
+# row-based log events.
+#
+# Procedure:
+# Create a table that represents all-known types in 5.1.
+# Write rows that contain the mins, maxes, and NULL for each type.
+# Write a random or "problematic" value (i.e. one that might require
+# escaping if it's represented as a string-y type) for each type.
+# Update each of these rows.
+# Delete each of these rows.
+# Inspect the binlog.
+#
+# Bug#31455 - mysqlbinlog don't print user readable info about RBR events
+#
+
+--source include/have_log_bin.inc
+set sql_mode="";
+
+SET NAMES 'utf8';
+#SHOW VARIABLES LIKE 'character_set%';
+
+
+--echo #
+--echo # Preparatory cleanup.
+--echo #
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2, t3;
+--enable_warnings
+
+--echo #
+--echo # We need a fixed timestamp to avoid varying results.
+--echo #
+SET timestamp=1000000000;
+
+--echo #
+--echo # ===================================================
+--echo # Test #1 - Insert/update/delete with all data types.
+--echo # ===================================================
+--echo #
+--echo # Delete all existing binary logs.
+--echo #
+RESET MASTER;
+
+--echo #
+--echo # Create a test table with all data types.
+--echo #
+eval CREATE TABLE t1 (
+ c01 BIT,
+ c02 BIT(64),
+ c03 TINYINT,
+ c04 TINYINT UNSIGNED,
+ c05 TINYINT ZEROFILL,
+ c06 BOOL,
+ c07 SMALLINT,
+ c08 SMALLINT UNSIGNED,
+ c09 SMALLINT ZEROFILL,
+ c10 MEDIUMINT,
+ c11 MEDIUMINT UNSIGNED,
+ c12 MEDIUMINT ZEROFILL,
+ c13 INT,
+ c14 INT UNSIGNED,
+ c15 INT ZEROFILL,
+ c16 BIGINT,
+ c17 BIGINT UNSIGNED,
+ c18 BIGINT ZEROFILL,
+ c19 FLOAT,
+ c20 FLOAT UNSIGNED,
+ c21 FLOAT ZEROFILL,
+ c22 DOUBLE,
+ c23 DOUBLE UNSIGNED,
+ c24 DOUBLE ZEROFILL,
+ c25 DECIMAL,
+ c26 DECIMAL UNSIGNED,
+ c27 DECIMAL ZEROFILL,
+ #
+ c28 DATE,
+ c29 DATETIME,
+ c30 TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+ c31 TIME,
+ c32 YEAR,
+ #
+ c33 CHAR,
+ c34 CHAR(0),
+ c35 CHAR(1),
+ c36 CHAR(255),
+ c37 NATIONAL CHAR,
+ c38 NATIONAL CHAR(0),
+ c39 NATIONAL CHAR(1),
+ c40 NATIONAL CHAR(255),
+ c41 CHAR CHARACTER SET UCS2,
+ c42 CHAR(0) CHARACTER SET UCS2,
+ c43 CHAR(1) CHARACTER SET UCS2,
+ c44 CHAR(255) CHARACTER SET UCS2,
+ #
+ c45 VARCHAR(0),
+ c46 VARCHAR(1),
+ c47 VARCHAR(255),
+ c48 VARCHAR(261),
+ c49 NATIONAL VARCHAR(0),
+ c50 NATIONAL VARCHAR(1),
+ c51 NATIONAL VARCHAR(255),
+ c52 NATIONAL VARCHAR(261),
+ c53 VARCHAR(0) CHARACTER SET UCS2,
+ c54 VARCHAR(1) CHARACTER SET UCS2,
+ c55 VARCHAR(255) CHARACTER SET UCS2,
+ c56 VARCHAR(261) CHARACTER SET UCS2,
+ #
+ c57 BINARY,
+ c58 BINARY(0),
+ c59 BINARY(1),
+ c60 BINARY(255),
+ #
+ c61 VARBINARY(0),
+ c62 VARBINARY(1),
+ c63 VARBINARY(255),
+ c64 VARBINARY(261),
+ #
+ c65 TINYBLOB,
+ c66 TINYTEXT,
+ c67 TINYTEXT CHARACTER SET UCS2,
+ c68 BLOB,
+ c69 TEXT,
+ c70 TEXT CHARACTER SET UCS2,
+ c71 MEDIUMBLOB,
+ c72 MEDIUMTEXT,
+ c73 MEDIUMTEXT CHARACTER SET UCS2,
+ c74 LONGBLOB,
+ c75 LONGTEXT,
+ c76 LONGTEXT CHARACTER SET UCS2,
+ #
+ c77 ENUM('a','b','c'),
+ c78 SET('a','b','c'),
+ #
+ crn INT -- row number
+ ) ENGINE=$engine_type DEFAULT CHARSET latin1;
+
+--echo #
+--echo # Insert minimum values.
+--echo #
+INSERT INTO t1 VALUES (
+ b'0', -- c01
+ b'0000000000000000000000000000000000000000000000000000000000000000', -- c02
+ -128, -- c03
+ 0, -- c04
+ 000, -- c05
+ false, -- c06
+ -32768, -- c07
+ 0, -- c08
+ 00000, -- c09
+ -8388608, -- c10
+ 0, -- c11
+ 00000000, -- c12
+ -2147483648, -- c13
+ 0, -- c14
+ 0000000000, -- c15
+ -9223372036854775808, -- c16
+ 0, -- c17
+ 00000000000000000000, -- c18
+ -3.402823466E+38, -- c19
+ 1.175494351E-38, -- c20
+ 000000000000, -- c21
+ -1.7976931348623E+308, -- c22 three digits cut for ps-protocol
+ 2.2250738585072E-308, -- c23 three digits cut for ps-protocol
+ 0000000000000000000000, -- c24
+ -9999999999, -- c25
+ 0, -- c26
+ 0000000000, -- c27
+ #
+ '1000-01-01', -- c28
+ '1000-01-01 00:00:00', -- c29
+ '1970-01-02 00:00:01', -- c30 one day later due to timezone issues
+ '-838:59:59', -- c31
+ '1901', -- c32
+ #
+ '', -- c33
+ '', -- c34
+ '', -- c35
+ '', -- c36
+ '', -- c37
+ '', -- c38
+ '', -- c39
+ '', -- c40
+ '', -- c41
+ '', -- c42
+ '', -- c43
+ '', -- c44
+ #
+ '', -- c45
+ '', -- c46
+ '', -- c47
+ '', -- c48
+ '', -- c49
+ '', -- c50
+ '', -- c51
+ '', -- c52
+ '', -- c53
+ '', -- c54
+ '', -- c55
+ '', -- c56
+ #
+ '', -- c57
+ '', -- c58
+ '', -- c59
+ '', -- c60
+ #
+ '', -- c61
+ '', -- c62
+ '', -- c63
+ '', -- c64
+ #
+ '', -- c65
+ '', -- c66
+ '', -- c67
+ '', -- c68
+ '', -- c69
+ '', -- c70
+ '', -- c71
+ '', -- c72
+ '', -- c73
+ '', -- c74
+ '', -- c75
+ '', -- c76
+ #
+ 'a', -- c77
+ '', -- c78
+ #
+ 1 -- crn -- row number
+ );
+
+--echo #
+--echo # Insert maximum values.
+--echo #
+INSERT INTO t1 VALUES (
+ b'1', -- c01
+ b'1111111111111111111111111111111111111111111111111111111111111111', -- c02
+ 127, -- c03
+ 255, -- c04
+ 255, -- c05
+ true, -- c06
+ 32767, -- c07
+ 65535, -- c08
+ 65535, -- c09
+ 8388607, -- c10
+ 16777215, -- c11
+ 16777215, -- c12
+ 2147483647, -- c13
+ 4294967295, -- c14
+ 4294967295, -- c15
+ 9223372036854775807, -- c16
+ 18446744073709551615, -- c17
+ 18446744073709551615, -- c18
+ 3.402823466E+38, -- c19
+ 3.402823466E+38, -- c20
+ 3.402823466E+38, -- c21
+ 1.7976931348623E+308, -- c22 three digits cut for ps-protocol
+ 1.7976931348623E+308, -- c23 three digits cut for ps-protocol
+ 1.7976931348623E+308, -- c24 three digits cut for ps-protocol
+ 9999999999, -- c25
+ 9999999999, -- c26
+ 9999999999, -- c27
+ #
+ '9999-12-31', -- c28
+ '9999-12-31 23:59:59', -- c29
+ '2038-01-08 03:14:07', -- c30 one day earlier due to timezone issues
+ '838:59:59', -- c31
+ '2155', -- c32
+ #
+ x'ff', -- c33
+ '', -- c34
+ x'ff', -- c35
+ REPEAT(x'ff',255), -- c36
+ _utf8 x'efbfbf', -- c37
+ '', -- c38
+ _utf8 x'efbfbf', -- c39
+ REPEAT(_utf8 x'efbfbf',255), -- c40
+ _ucs2 x'ffff', -- c41
+ '', -- c42
+ _ucs2 x'ffff', -- c43
+ REPEAT(_ucs2 x'ffff',255), -- c44
+ #
+ '', -- c45
+ x'ff', -- c46
+ REPEAT(x'ff',255), -- c47
+ REPEAT(x'ff',261), -- c48
+ '', -- c49
+ _utf8 x'efbfbf', -- c50
+ REPEAT(_utf8 x'efbfbf',255), -- c51
+ REPEAT(_utf8 x'efbfbf',261), -- c52
+ '', -- c53
+ _ucs2 x'ffff', -- c54
+ REPEAT(_ucs2 x'ffff',255), -- c55
+ REPEAT(_ucs2 x'ffff',261), -- c56
+ #
+ x'ff', -- c57
+ '', -- c58
+ x'ff', -- c59
+ REPEAT(x'ff',255), -- c60
+ #
+ '', -- c61
+ x'ff', -- c62
+ REPEAT(x'ff',255), -- c63
+ REPEAT(x'ff',261), -- c64
+ #
+ 'tinyblob', -- c65 not using maximum value here
+ 'tinytext', -- c66 not using maximum value here
+ 'tinytext-ucs2', -- c67 not using maximum value here
+ 'blob', -- c68 not using maximum value here
+ 'text', -- c69 not using maximum value here
+ 'text-ucs2', -- c70 not using maximum value here
+ 'mediumblob', -- c71 not using maximum value here
+ 'mediumtext', -- c72 not using maximum value here
+ 'mediumtext-ucs2', -- c73 not using maximum value here
+ 'longblob', -- c74 not using maximum value here
+ 'longtext', -- c75 not using maximum value here
+ 'longtext-ucs2', -- c76 not using maximum value here
+ #
+ 'c', -- c77
+ 'a,b,c', -- c78
+ #
+ 2 -- crn -- row number
+ );
+
+--echo #
+--echo # Insert a row with NULL values and one with arbitrary values.
+--echo #
+INSERT INTO t1 VALUES (
+ NULL, -- c01
+ NULL, -- c02
+ NULL, -- c03
+ NULL, -- c04
+ NULL, -- c05
+ NULL, -- c06
+ NULL, -- c07
+ NULL, -- c08
+ NULL, -- c09
+ NULL, -- c10
+ NULL, -- c11
+ NULL, -- c12
+ NULL, -- c13
+ NULL, -- c14
+ NULL, -- c15
+ NULL, -- c16
+ NULL, -- c17
+ NULL, -- c18
+ NULL, -- c19
+ NULL, -- c20
+ NULL, -- c21
+ NULL, -- c22
+ NULL, -- c23
+ NULL, -- c24
+ NULL, -- c25
+ NULL, -- c26
+ NULL, -- c27
+ #
+ NULL, -- c28
+ NULL, -- c29
+ NULL, -- c30
+ NULL, -- c31
+ NULL, -- c32
+ #
+ NULL, -- c33
+ NULL, -- c34
+ NULL, -- c35
+ NULL, -- c36
+ NULL, -- c37
+ NULL, -- c38
+ NULL, -- c39
+ NULL, -- c40
+ NULL, -- c41
+ NULL, -- c42
+ NULL, -- c43
+ NULL, -- c44
+ #
+ NULL, -- c45
+ NULL, -- c46
+ NULL, -- c47
+ NULL, -- c48
+ NULL, -- c49
+ NULL, -- c50
+ NULL, -- c51
+ NULL, -- c52
+ NULL, -- c53
+ NULL, -- c54
+ NULL, -- c55
+ NULL, -- c56
+ #
+ NULL, -- c57
+ NULL, -- c58
+ NULL, -- c59
+ NULL, -- c60
+ #
+ NULL, -- c61
+ NULL, -- c62
+ NULL, -- c63
+ NULL, -- c64
+ #
+ NULL, -- c65
+ NULL, -- c66
+ NULL, -- c67
+ NULL, -- c68
+ NULL, -- c69
+ NULL, -- c70
+ NULL, -- c71
+ NULL, -- c72
+ NULL, -- c73
+ NULL, -- c74
+ NULL, -- c75
+ NULL, -- c76
+ #
+ NULL, -- c77
+ NULL, -- c78
+ #
+ 3 -- crn -- row number
+ ), (
+ b'1', -- c01
+ b'1111111111111111111111111111111111111111111111111111111111111111', -- c02
+ 127, -- c03
+ 0, -- c04
+ 001, -- c05
+ true, -- c06
+ 32767, -- c07
+ 0, -- c08
+ 00001, -- c09
+ 8388607, -- c10
+ 0, -- c11
+ 00000001, -- c12
+ 2147483647, -- c13
+ 0, -- c14
+ 0000000001, -- c15
+ 9223372036854775807, -- c16
+ 0, -- c17
+ 00000000000000000001, -- c18
+ -1.175494351E-38, -- c19
+ 1.175494351E-38, -- c20
+ 000000000000001, -- c21
+ -2.2250738585072E-308, -- c22
+ 2.2250738585072E-308, -- c23
+ 00000000000000000000001, -- c24
+ -9999999999, -- c25
+ 9999999999, -- c26
+ 0000000001, -- c27
+ #
+ '2008-08-04', -- c28
+ '2008-08-04 16:18:06', -- c29
+ '2008-08-04 16:18:24', -- c30
+ '16:18:47', -- c31
+ '2008', -- c32
+ #
+ 'a', -- c33
+ '', -- c34
+ 'e', -- c35
+ REPEAT('i',255), -- c36
+ _utf8 x'c3a4', -- c37
+ '', -- c38
+ _utf8 x'c3b6', -- c39
+ REPEAT(_utf8 x'c3bc',255), -- c40
+ _ucs2 x'00e4', -- c41
+ '', -- c42
+ _ucs2 x'00f6', -- c43
+ REPEAT(_ucs2 x'00fc',255), -- c44
+ #
+ '', -- c45
+ 'a', -- c46
+ REPEAT('e',255), -- c47
+ REPEAT('i',261), -- c48
+ '', -- c49
+ _utf8 x'c3a4', -- c50
+ REPEAT(_utf8 x'c3b6',255), -- c51
+ REPEAT(_utf8 x'c3bc',261), -- c52
+ '', -- c53
+ _ucs2 x'00e4', -- c54
+ REPEAT(_ucs2 x'00f6',255), -- c55
+ REPEAT(_ucs2 x'00fc',261), -- c56
+ #
+ '0', -- c57
+ '', -- c58
+ '1', -- c59
+ REPEAT('1',255), -- c60
+ #
+ '', -- c61
+ 'b', -- c62
+ REPEAT('c',255), -- c63
+ REPEAT('\'',261), -- c64
+ #
+ 'tinyblob', -- c65
+ 'tinytext', -- c66
+ 'tinytext-ucs2', -- c67
+ 'blob', -- c68
+ 'text', -- c69
+ 'text-ucs2', -- c70
+ 'mediumblob', -- c71
+ 'mediumtext', -- c72
+ 'mediumtext-ucs2', -- c73
+ 'longblob', -- c74
+ 'longtext', -- c75
+ 'longtext-ucs2', -- c76
+ #
+ 'b', -- c77
+ 'b,c', -- c78
+ #
+ 4 -- crn -- row number
+ );
+
+--echo #
+--echo # Show what we have in the table.
+--echo # Do not display bit type output. It's binary and confuses diff.
+--echo # Also BINARY with nul-bytes should be avoided.
+--echo #
+--replace_column 1 # 2 # 57 # 58 # 59 # 60 #
+query_vertical SELECT * FROM t1;
+
+--echo #
+--echo # NOTE: For matching FLOAT and DOUBLE values in WHERE conditions,
+--echo # don't use exact match, but < or > and tweak the numbers a bit.
+--echo #
+--echo # Show how much rows are affected by each statement.
+--echo #
+--enable_info
+
+--echo #
+--echo # Update min values to max values.
+--echo #
+UPDATE t1 SET
+ c01 = b'1',
+ c02 = b'1111111111111111111111111111111111111111111111111111111111111111',
+ c03 = 127,
+ c04 = 255,
+ c05 = 255,
+ c06 = true,
+ c07 = 32767,
+ c08 = 65535,
+ c09 = 65535,
+ c10 = 8388607,
+ c11 = 16777215,
+ c12 = 16777215,
+ c13 = 2147483647,
+ c14 = 4294967295,
+ c15 = 4294967295,
+ c16 = 9223372036854775807,
+ c17 = 18446744073709551615,
+ c18 = 18446744073709551615,
+ c19 = 3.402823466E+38,
+ c20 = 3.402823466E+38,
+ c21 = 3.402823466E+38,
+ c22 = 1.7976931348623E+308,
+ c23 = 1.7976931348623E+308,
+ c24 = 1.7976931348623E+308,
+ c25 = 9999999999,
+ c26 = 9999999999,
+ c27 = 9999999999,
+ #
+ c28 = '9999-12-31',
+ c29 = '9999-12-31 23:59:59',
+ c30 = '2038-01-08 03:14:07',
+ c31 = '838:59:59',
+ c32 = '2155',
+ #
+ c33 = x'ff',
+ c34 = '',
+ c35 = x'ff',
+ c36 = REPEAT(x'ff',255),
+ c37 = _utf8 x'efbfbf',
+ c38 = '',
+ c39 = _utf8 x'efbfbf',
+ c40 = REPEAT(_utf8 x'efbfbf',255),
+ c41 = _ucs2 x'ffff',
+ c42 = '',
+ c43 = _ucs2 x'ffff',
+ c44 = REPEAT(_ucs2 x'ffff',255),
+ #
+ c45 = '',
+ c46 = x'ff',
+ c47 = REPEAT(x'ff',255),
+ c48 = REPEAT(x'ff',261),
+ c49 = '',
+ c50 = _utf8 x'efbfbf',
+ c51 = REPEAT(_utf8 x'efbfbf',255),
+ c52 = REPEAT(_utf8 x'efbfbf',261),
+ c53 = '',
+ c54 = _ucs2 x'ffff',
+ c55 = REPEAT(_ucs2 x'ffff',255),
+ c56 = REPEAT(_ucs2 x'ffff',261),
+ #
+ c57 = x'ff',
+ c58 = '',
+ c59 = x'ff',
+ c60 = REPEAT(x'ff',255),
+ #
+ c61 = '',
+ c62 = x'ff',
+ c63 = REPEAT(x'ff',255),
+ c64 = REPEAT(x'ff',261),
+ #
+ c65 = 'tinyblob',
+ c66 = 'tinytext',
+ c67 = 'tinytext-ucs2',
+ c68 = 'blob',
+ c69 = 'text',
+ c70 = 'text-ucs2',
+ c71 = 'mediumblob',
+ c72 = 'mediumtext',
+ c73 = 'mediumtext-ucs2',
+ c74 = 'longblob',
+ c75 = 'longtext',
+ c76 = 'longtext-ucs2',
+ #
+ c77 = 'c',
+ c78 = 'a,b,c',
+ #
+ crn = crn
+ #
+ WHERE
+ #
+ c01 = b'0' AND
+ c02 = b'0000000000000000000000000000000000000000000000000000000000000000' AND
+ c03 = -128 AND
+ c04 = 0 AND
+ c05 = 000 AND
+ c06 = false AND
+ c07 = -32768 AND
+ c08 = 0 AND
+ c09 = 00000 AND
+ c10 = -8388608 AND
+ c11 = 0 AND
+ c12 = 00000000 AND
+ c13 = -2147483648 AND
+ c14 = 0 AND
+ c15 = 0000000000 AND
+ c16 = -9223372036854775808 AND
+ c17 = 0 AND
+ c18 = 00000000000000000000 AND
+ c19 < -3.402823465E+38 AND
+ c20 < 1.175494352E-38 AND
+ c21 = 000000000000 AND
+ c22 < -1.7976931348622E+308 AND
+ c23 < 2.2250738585073E-308 AND
+ c24 = 0000000000000000000000 AND
+ c25 = -9999999999 AND
+ c26 = 0 AND
+ c27 = 0000000000 AND
+ #
+ c28 = '1000-01-01' AND
+ c29 = '1000-01-01 00:00:00' AND
+ c30 = '1970-01-02 00:00:01' AND
+ c31 = '-838:59:59' AND
+ c32 = '1901' AND
+ #
+ c33 = '' AND
+ c34 = '' AND
+ c35 = '' AND
+ c36 = '' AND
+ c37 = '' AND
+ c38 = '' AND
+ c39 = '' AND
+ c40 = '' AND
+ c41 = '' AND
+ c42 = '' AND
+ c43 = '' AND
+ c44 = '' AND
+ #
+ c45 = '' AND
+ c46 = '' AND
+ c47 = '' AND
+ c48 = '' AND
+ c49 = '' AND
+ c50 = '' AND
+ c51 = '' AND
+ c52 = '' AND
+ c53 = '' AND
+ c54 = '' AND
+ c55 = '' AND
+ c56 = '' AND
+ #
+ # this does not reproduce the inserted value: c57 = '' AND
+ c58 = '' AND
+ # this does not reproduce the inserted value: c59 = '' AND
+ # this does not reproduce the inserted value: c60 = '' AND
+ #
+ c61 = '' AND
+ c62 = '' AND
+ c63 = '' AND
+ c64 = '' AND
+ #
+ c65 = '' AND
+ c66 = '' AND
+ c67 = '' AND
+ c68 = '' AND
+ c69 = '' AND
+ c70 = '' AND
+ c71 = '' AND
+ c72 = '' AND
+ c73 = '' AND
+ c74 = '' AND
+ c75 = '' AND
+ c76 = '' AND
+ #
+ c77 = 'a' AND
+ c78 = '' AND
+ #
+ crn = 1;
+
+--echo #
+--echo # Update max values to min values.
+--echo #
+UPDATE t1 SET
+ c01 = b'0',
+ c02 = b'0000000000000000000000000000000000000000000000000000000000000000',
+ c03 = -128,
+ c04 = 0,
+ c05 = 000,
+ c06 = false,
+ c07 = -32768,
+ c08 = 0,
+ c09 = 00000,
+ c10 = -8388608,
+ c11 = 0,
+ c12 = 00000000,
+ c13 = -2147483648,
+ c14 = 0,
+ c15 = 0000000000,
+ c16 = -9223372036854775808,
+ c17 = 0,
+ c18 = 00000000000000000000,
+ c19 = -3.402823466E+38,
+ c20 = 1.175494351E-38,
+ c21 = 000000000000,
+ c22 = -1.7976931348623E+308,
+ c23 = 2.2250738585072E-308,
+ c24 = 0000000000000000000000,
+ c25 = -9999999999,
+ c26 = 0,
+ c27 = 0000000000,
+ #
+ c28 = '1000-01-01',
+ c29 = '1000-01-01 00:00:00',
+ c30 = '1970-01-02 00:00:01',
+ c31 = '-838:59:59',
+ c32 = '1901',
+ #
+ c33 = '',
+ c34 = '',
+ c35 = '',
+ c36 = '',
+ c37 = '',
+ c38 = '',
+ c39 = '',
+ c40 = '',
+ c41 = '',
+ c42 = '',
+ c43 = '',
+ c44 = '',
+ #
+ c45 = '',
+ c46 = '',
+ c47 = '',
+ c48 = '',
+ c49 = '',
+ c50 = '',
+ c51 = '',
+ c52 = '',
+ c53 = '',
+ c54 = '',
+ c55 = '',
+ c56 = '',
+ #
+ c57 = '',
+ c58 = '',
+ c59 = '',
+ c60 = '',
+ #
+ c61 = '',
+ c62 = '',
+ c63 = '',
+ c64 = '',
+ #
+ c65 = '',
+ c66 = '',
+ c67 = '',
+ c68 = '',
+ c69 = '',
+ c70 = '',
+ c71 = '',
+ c72 = '',
+ c73 = '',
+ c74 = '',
+ c75 = '',
+ c76 = '',
+ #
+ c77 = 'a',
+ c78 = '',
+ #
+ crn = crn
+ #
+ WHERE
+ #
+ c01 = b'1' AND
+ # the below does not reproduce the inserted value:
+ #c02 = b'1111111111111111111111111111111111111111111111111111111111111111' AND
+ c03 = 127 AND
+ c04 = 255 AND
+ c05 = 255 AND
+ c06 = true AND
+ c07 = 32767 AND
+ c08 = 65535 AND
+ c09 = 65535 AND
+ c10 = 8388607 AND
+ c11 = 16777215 AND
+ c12 = 16777215 AND
+ c13 = 2147483647 AND
+ c14 = 4294967295 AND
+ c15 = 4294967295 AND
+ c16 = 9223372036854775807 AND
+ c17 = 18446744073709551615 AND
+ c18 = 18446744073709551615 AND
+ c19 > 3.402823465E+38 AND
+ c20 > 3.402823465E+38 AND
+ c21 > 3.402823465E+38 AND
+ c22 > 1.7976931348622E+308 AND
+ c23 > 1.7976931348622E+308 AND
+ c24 > 1.7976931348622E+308 AND
+ c25 = 9999999999 AND
+ c26 = 9999999999 AND
+ c27 = 9999999999 AND
+ #
+ c28 = '9999-12-31' AND
+ c29 = '9999-12-31 23:59:59' AND
+ c30 = '2038-01-08 03:14:07' AND
+ c31 = '838:59:59' AND
+ c32 = '2155' AND
+ #
+ c33 = x'ff' AND
+ c34 = '' AND
+ c35 = x'ff' AND
+ c36 = REPEAT(x'ff',255) AND
+ c37 = _utf8 x'efbfbf' AND
+ c38 = '' AND
+ c39 = _utf8 x'efbfbf' AND
+ c40 = REPEAT(_utf8 x'efbfbf',255) AND
+ c41 = _ucs2 x'ffff' AND
+ c42 = '' AND
+ c43 = _ucs2 x'ffff' AND
+ c44 = REPEAT(_ucs2 x'ffff',255) AND
+ #
+ c45 = '' AND
+ c46 = x'ff' AND
+ c47 = REPEAT(x'ff',255) AND
+ c48 = REPEAT(x'ff',261) AND
+ c49 = '' AND
+ c50 = _utf8 x'efbfbf' AND
+ c51 = REPEAT(_utf8 x'efbfbf',255) AND
+ c52 = REPEAT(_utf8 x'efbfbf',261) AND
+ c53 = '' AND
+ c54 = _ucs2 x'ffff' AND
+ c55 = REPEAT(_ucs2 x'ffff',255) AND
+ c56 = REPEAT(_ucs2 x'ffff',261) AND
+ #
+ c57 = x'ff' AND
+ c58 = '' AND
+ c59 = x'ff' AND
+ c60 = REPEAT(x'ff',255) AND
+ #
+ c61 = '' AND
+ c62 = x'ff' AND
+ c63 = REPEAT(x'ff',255) AND
+ c64 = REPEAT(x'ff',261) AND
+ #
+ c65 = 'tinyblob' AND
+ c66 = 'tinytext' AND
+ c67 = 'tinytext-ucs2' AND
+ c68 = 'blob' AND
+ c69 = 'text' AND
+ c70 = 'text-ucs2' AND
+ c71 = 'mediumblob' AND
+ c72 = 'mediumtext' AND
+ c73 = 'mediumtext-ucs2' AND
+ c74 = 'longblob' AND
+ c75 = 'longtext' AND
+ c76 = 'longtext-ucs2' AND
+ #
+ c77 = 'c' AND
+ c78 = 'a,b,c' AND
+ #
+ crn = 2;
+
+--echo #
+--echo # Update NULL values to arbitrary values.
+--echo #
+UPDATE t1 SET
+ c01 = b'1',
+ c02 = b'1111111111111111111111111111111111111111111111111111111111111111',
+ c03 = 127,
+ c04 = 0,
+ c05 = 001,
+ c06 = true,
+ c07 = 32767,
+ c08 = 0,
+ c09 = 00001,
+ c10 = 8388607,
+ c11 = 0,
+ c12 = 00000001,
+ c13 = 2147483647,
+ c14 = 0,
+ c15 = 0000000001,
+ c16 = 9223372036854775807,
+ c17 = 0,
+ c18 = 00000000000000000001,
+ c19 = -1.175494351E-38,
+ c20 = 1.175494351E-38,
+ c21 = 000000000000001,
+ c22 = -2.2250738585072E-308,
+ c23 = 2.2250738585072E-308,
+ c24 = 00000000000000000000001,
+ c25 = -9999999999,
+ c26 = 9999999999,
+ c27 = 0000000001,
+ #
+ c28 = '2008-08-04',
+ c29 = '2008-08-04 16:18:06',
+ c30 = '2008-08-04 16:18:24',
+ c31 = '16:18:47',
+ c32 = '2008',
+ #
+ c33 = 'a',
+ c34 = '',
+ c35 = 'e',
+ c36 = REPEAT('i',255),
+ c37 = _utf8 x'c3a4',
+ c38 = '',
+ c39 = _utf8 x'c3b6',
+ c40 = REPEAT(_utf8 x'c3bc',255),
+ c41 = _ucs2 x'00e4',
+ c42 = '',
+ c43 = _ucs2 x'00f6',
+ c44 = REPEAT(_ucs2 x'00fc',255),
+ #
+ c45 = '',
+ c46 = 'a',
+ c47 = REPEAT('e',255),
+ c48 = REPEAT('i',261),
+ c49 = '',
+ c50 = _utf8 x'c3a4',
+ c51 = REPEAT(_utf8 x'c3b6',255),
+ c52 = REPEAT(_utf8 x'c3bc',261),
+ c53 = '',
+ c54 = _ucs2 x'00e4',
+ c55 = REPEAT(_ucs2 x'00f6',255),
+ c56 = REPEAT(_ucs2 x'00fc',261),
+ #
+ c57 = '0',
+ c58 = '',
+ c59 = '1',
+ c60 = REPEAT('1',255),
+ #
+ c61 = '',
+ c62 = 'b',
+ c63 = REPEAT('c',255),
+ c64 = REPEAT('\'',261),
+ #
+ c65 = 'tinyblob',
+ c66 = 'tinytext',
+ c67 = 'tinytext-ucs2',
+ c68 = 'blob',
+ c69 = 'text',
+ c70 = 'text-ucs2',
+ c71 = 'mediumblob',
+ c72 = 'mediumtext',
+ c73 = 'mediumtext-ucs2',
+ c74 = 'longblob',
+ c75 = 'longtext',
+ c76 = 'longtext-ucs2',
+ #
+ c77 = 'b',
+ c78 = 'b,c',
+ #
+ crn = crn
+ #
+ WHERE
+ #
+ c01 IS NULL AND
+ c02 IS NULL AND
+ c03 IS NULL AND
+ c04 IS NULL AND
+ c05 IS NULL AND
+ c06 IS NULL AND
+ c07 IS NULL AND
+ c08 IS NULL AND
+ c09 IS NULL AND
+ c10 IS NULL AND
+ c11 IS NULL AND
+ c12 IS NULL AND
+ c13 IS NULL AND
+ c14 IS NULL AND
+ c15 IS NULL AND
+ c16 IS NULL AND
+ c17 IS NULL AND
+ c18 IS NULL AND
+ c19 IS NULL AND
+ c20 IS NULL AND
+ c21 IS NULL AND
+ c22 IS NULL AND
+ c23 IS NULL AND
+ c24 IS NULL AND
+ c25 IS NULL AND
+ c26 IS NULL AND
+ c27 IS NULL AND
+ #
+ c28 IS NULL AND
+ c29 IS NULL AND
+ # this got a timestamp instead of NULL: c30 IS NULL AND
+ c31 IS NULL AND
+ c32 IS NULL AND
+ #
+ c33 IS NULL AND
+ c34 IS NULL AND
+ c35 IS NULL AND
+ c36 IS NULL AND
+ c37 IS NULL AND
+ c38 IS NULL AND
+ c39 IS NULL AND
+ c40 IS NULL AND
+ c41 IS NULL AND
+ c42 IS NULL AND
+ c43 IS NULL AND
+ c44 IS NULL AND
+ #
+ c45 IS NULL AND
+ c46 IS NULL AND
+ c47 IS NULL AND
+ c48 IS NULL AND
+ c49 IS NULL AND
+ c50 IS NULL AND
+ c51 IS NULL AND
+ c52 IS NULL AND
+ c53 IS NULL AND
+ c54 IS NULL AND
+ c55 IS NULL AND
+ c56 IS NULL AND
+ #
+ c57 IS NULL AND
+ c58 IS NULL AND
+ c59 IS NULL AND
+ c60 IS NULL AND
+ #
+ c61 IS NULL AND
+ c62 IS NULL AND
+ c63 IS NULL AND
+ c64 IS NULL AND
+ #
+ c65 IS NULL AND
+ c66 IS NULL AND
+ c67 IS NULL AND
+ c68 IS NULL AND
+ c69 IS NULL AND
+ c70 IS NULL AND
+ c71 IS NULL AND
+ c72 IS NULL AND
+ c73 IS NULL AND
+ c74 IS NULL AND
+ c75 IS NULL AND
+ c76 IS NULL AND
+ #
+ c77 IS NULL AND
+ c78 IS NULL AND
+ #
+ crn = 3;
+
+--echo #
+--echo # Update arbitrary values to NULL values.
+--echo #
+UPDATE t1 SET
+ c01 = NULL,
+ c02 = NULL,
+ c03 = NULL,
+ c04 = NULL,
+ c05 = NULL,
+ c06 = NULL,
+ c07 = NULL,
+ c08 = NULL,
+ c09 = NULL,
+ c10 = NULL,
+ c11 = NULL,
+ c12 = NULL,
+ c13 = NULL,
+ c14 = NULL,
+ c15 = NULL,
+ c16 = NULL,
+ c17 = NULL,
+ c18 = NULL,
+ c19 = NULL,
+ c20 = NULL,
+ c21 = NULL,
+ c22 = NULL,
+ c23 = NULL,
+ c24 = NULL,
+ c25 = NULL,
+ c26 = NULL,
+ c27 = NULL,
+ #
+ c28 = NULL,
+ c29 = NULL,
+ c30 = NULL,
+ c31 = NULL,
+ c32 = NULL,
+ #
+ c33 = NULL,
+ c34 = NULL,
+ c35 = NULL,
+ c36 = NULL,
+ c37 = NULL,
+ c38 = NULL,
+ c39 = NULL,
+ c40 = NULL,
+ c41 = NULL,
+ c42 = NULL,
+ c43 = NULL,
+ c44 = NULL,
+ #
+ c45 = NULL,
+ c46 = NULL,
+ c47 = NULL,
+ c48 = NULL,
+ c49 = NULL,
+ c50 = NULL,
+ c51 = NULL,
+ c52 = NULL,
+ c53 = NULL,
+ c54 = NULL,
+ c55 = NULL,
+ c56 = NULL,
+ #
+ c57 = NULL,
+ c58 = NULL,
+ c59 = NULL,
+ c60 = NULL,
+ #
+ c61 = NULL,
+ c62 = NULL,
+ c63 = NULL,
+ c64 = NULL,
+ #
+ c65 = NULL,
+ c66 = NULL,
+ c67 = NULL,
+ c68 = NULL,
+ c69 = NULL,
+ c70 = NULL,
+ c71 = NULL,
+ c72 = NULL,
+ c73 = NULL,
+ c74 = NULL,
+ c75 = NULL,
+ c76 = NULL,
+ #
+ c77 = NULL,
+ c78 = NULL,
+ #
+ crn = crn
+ #
+ WHERE
+ #
+ c01 = b'1' AND
+ # the below does not reproduce the inserted value:
+ #c02 = b'1111111111111111111111111111111111111111111111111111111111111111' AND
+ c03 = 127 AND
+ c04 = 0 AND
+ c05 = 001 AND
+ c06 = true AND
+ c07 = 32767 AND
+ c08 = 0 AND
+ c09 = 00001 AND
+ c10 = 8388607 AND
+ c11 = 0 AND
+ c12 = 00000001 AND
+ c13 = 2147483647 AND
+ c14 = 0 AND
+ c15 = 0000000001 AND
+ c16 = 9223372036854775807 AND
+ c17 = 0 AND
+ c18 = 00000000000000000001 AND
+ c19 > -1.175494352E-38 AND
+ c20 < 1.175494352E-38 AND
+ c21 = 000000000000001 AND
+ c22 > -2.2250738585073E-308 AND
+ c23 < 2.2250738585073E-308 AND
+ c24 = 00000000000000000000001 AND
+ c25 = -9999999999 AND
+ c26 = 9999999999 AND
+ c27 = 0000000001 AND
+ #
+ c28 = '2008-08-04' AND
+ c29 = '2008-08-04 16:18:06' AND
+ c30 = '2008-08-04 16:18:24' AND
+ c31 = '16:18:47' AND
+ c32 = '2008' AND
+ #
+ c33 = 'a' AND
+ c34 = '' AND
+ c35 = 'e' AND
+ c36 = REPEAT('i',255) AND
+ c37 = _utf8 x'c3a4' AND
+ c38 = '' AND
+ c39 = _utf8 x'c3b6' AND
+ c40 = REPEAT(_utf8 x'c3bc',255) AND
+ c41 = _ucs2 x'00e4' AND
+ c42 = '' AND
+ c43 = _ucs2 x'00f6' AND
+ c44 = REPEAT(_ucs2 x'00fc',255) AND
+ #
+ c45 = '' AND
+ c46 = 'a' AND
+ c47 = REPEAT('e',255) AND
+ c48 = REPEAT('i',261) AND
+ c49 = '' AND
+ c50 = _utf8 x'c3a4' AND
+ c51 = REPEAT(_utf8 x'c3b6',255) AND
+ c52 = REPEAT(_utf8 x'c3bc',261) AND
+ c53 = '' AND
+ c54 = _ucs2 x'00e4' AND
+ c55 = REPEAT(_ucs2 x'00f6',255) AND
+ c56 = REPEAT(_ucs2 x'00fc',261) AND
+ #
+ c57 = '0' AND
+ c58 = '' AND
+ c59 = '1' AND
+ c60 = REPEAT('1',255) AND
+ #
+ c61 = '' AND
+ c62 = 'b' AND
+ c63 = REPEAT('c',255) AND
+ c64 = REPEAT('\'',261) AND
+ #
+ c65 = 'tinyblob' AND
+ c66 = 'tinytext' AND
+ c67 = 'tinytext-ucs2' AND
+ c68 = 'blob' AND
+ c69 = 'text' AND
+ c70 = 'text-ucs2' AND
+ c71 = 'mediumblob' AND
+ c72 = 'mediumtext' AND
+ c73 = 'mediumtext-ucs2' AND
+ c74 = 'longblob' AND
+ c75 = 'longtext' AND
+ c76 = 'longtext-ucs2' AND
+ #
+ c77 = 'b' AND
+ c78 = 'b,c' AND
+ #
+ crn = 4;
+
+--echo #
+--echo # Show what we have in the table.
+--echo # Do not display bit type output. It's binary and confuses diff.
+--echo # Also BINARY with nul-bytes should be avoided.
+--echo #
+--replace_column 1 # 2 # 57 # 58 # 59 # 60 #
+query_vertical SELECT * FROM t1;
+
+--echo #
+--echo # Delete the row that has max values now.
+--echo #
+DELETE FROM t1 WHERE
+ #
+ c01 = b'1' AND
+ # the below does not reproduce the inserted value:
+ #c02 = b'1111111111111111111111111111111111111111111111111111111111111111' AND
+ c03 = 127 AND
+ c04 = 255 AND
+ c05 = 255 AND
+ c06 = true AND
+ c07 = 32767 AND
+ c08 = 65535 AND
+ c09 = 65535 AND
+ c10 = 8388607 AND
+ c11 = 16777215 AND
+ c12 = 16777215 AND
+ c13 = 2147483647 AND
+ c14 = 4294967295 AND
+ c15 = 4294967295 AND
+ c16 = 9223372036854775807 AND
+ c17 = 18446744073709551615 AND
+ c18 = 18446744073709551615 AND
+ c19 > 3.402823465E+38 AND
+ c20 > 3.402823465E+38 AND
+ c21 > 3.402823465E+38 AND
+ c22 > 1.7976931348622E+308 AND
+ c23 > 1.7976931348622E+308 AND
+ c24 > 1.7976931348622E+308 AND
+ c25 = 9999999999 AND
+ c26 = 9999999999 AND
+ c27 = 9999999999 AND
+ #
+ c28 = '9999-12-31' AND
+ c29 = '9999-12-31 23:59:59' AND
+ c30 = '2038-01-08 03:14:07' AND
+ c31 = '838:59:59' AND
+ c32 = '2155' AND
+ #
+ c33 = x'ff' AND
+ c34 = '' AND
+ c35 = x'ff' AND
+ c36 = REPEAT(x'ff',255) AND
+ c37 = _utf8 x'efbfbf' AND
+ c38 = '' AND
+ c39 = _utf8 x'efbfbf' AND
+ c40 = REPEAT(_utf8 x'efbfbf',255) AND
+ c41 = _ucs2 x'ffff' AND
+ c42 = '' AND
+ c43 = _ucs2 x'ffff' AND
+ c44 = REPEAT(_ucs2 x'ffff',255) AND
+ #
+ c45 = '' AND
+ c46 = x'ff' AND
+ c47 = REPEAT(x'ff',255) AND
+ c48 = REPEAT(x'ff',261) AND
+ c49 = '' AND
+ c50 = _utf8 x'efbfbf' AND
+ c51 = REPEAT(_utf8 x'efbfbf',255) AND
+ c52 = REPEAT(_utf8 x'efbfbf',261) AND
+ c53 = '' AND
+ c54 = _ucs2 x'ffff' AND
+ c55 = REPEAT(_ucs2 x'ffff',255) AND
+ c56 = REPEAT(_ucs2 x'ffff',261) AND
+ #
+ c57 = x'ff' AND
+ c58 = '' AND
+ c59 = x'ff' AND
+ c60 = REPEAT(x'ff',255) AND
+ #
+ c61 = '' AND
+ c62 = x'ff' AND
+ c63 = REPEAT(x'ff',255) AND
+ c64 = REPEAT(x'ff',261) AND
+ #
+ c65 = 'tinyblob' AND
+ c66 = 'tinytext' AND
+ c67 = 'tinytext-ucs2' AND
+ c68 = 'blob' AND
+ c69 = 'text' AND
+ c70 = 'text-ucs2' AND
+ c71 = 'mediumblob' AND
+ c72 = 'mediumtext' AND
+ c73 = 'mediumtext-ucs2' AND
+ c74 = 'longblob' AND
+ c75 = 'longtext' AND
+ c76 = 'longtext-ucs2' AND
+ #
+ c77 = 'c' AND
+ c78 = 'a,b,c' AND
+ #
+ crn = 1;
+
+--echo #
+--echo # Delete the row that has min values now.
+--echo #
+DELETE FROM t1 WHERE
+ #
+ c01 = b'0' AND
+ c02 = b'0000000000000000000000000000000000000000000000000000000000000000' AND
+ c03 = -128 AND
+ c04 = 0 AND
+ c05 = 000 AND
+ c06 = false AND
+ c07 = -32768 AND
+ c08 = 0 AND
+ c09 = 00000 AND
+ c10 = -8388608 AND
+ c11 = 0 AND
+ c12 = 00000000 AND
+ c13 = -2147483648 AND
+ c14 = 0 AND
+ c15 = 0000000000 AND
+ c16 = -9223372036854775808 AND
+ c17 = 0 AND
+ c18 = 00000000000000000000 AND
+ c19 < -3.402823465E+38 AND
+ c20 < 1.175494352E-38 AND
+ c21 = 000000000000 AND
+ c22 < -1.7976931348622E+308 AND
+ c23 < 2.2250738585073E-308 AND
+ c24 = 0000000000000000000000 AND
+ c25 = -9999999999 AND
+ c26 = 0 AND
+ c27 = 0000000000 AND
+ #
+ c28 = '1000-01-01' AND
+ c29 = '1000-01-01 00:00:00' AND
+ c30 = '1970-01-02 00:00:01' AND
+ c31 = '-838:59:59' AND
+ c32 = '1901' AND
+ #
+ c33 = '' AND
+ c34 = '' AND
+ c35 = '' AND
+ c36 = '' AND
+ c37 = '' AND
+ c38 = '' AND
+ c39 = '' AND
+ c40 = '' AND
+ c41 = '' AND
+ c42 = '' AND
+ c43 = '' AND
+ c44 = '' AND
+ #
+ c45 = '' AND
+ c46 = '' AND
+ c47 = '' AND
+ c48 = '' AND
+ c49 = '' AND
+ c50 = '' AND
+ c51 = '' AND
+ c52 = '' AND
+ c53 = '' AND
+ c54 = '' AND
+ c55 = '' AND
+ c56 = '' AND
+ #
+ # this does not reproduce the inserted value: c57 = '' AND
+ c58 = '' AND
+ # this does not reproduce the inserted value: c59 = '' AND
+ # this does not reproduce the inserted value: c60 = '' AND
+ #
+ c61 = '' AND
+ c62 = '' AND
+ c63 = '' AND
+ c64 = '' AND
+ #
+ c65 = '' AND
+ c66 = '' AND
+ c67 = '' AND
+ c68 = '' AND
+ c69 = '' AND
+ c70 = '' AND
+ c71 = '' AND
+ c72 = '' AND
+ c73 = '' AND
+ c74 = '' AND
+ c75 = '' AND
+ c76 = '' AND
+ #
+ c77 = 'a' AND
+ c78 = '' AND
+ #
+ crn = 2;
+
+--echo #
+--echo # Delete the row that has arbitrary values now.
+--echo #
+DELETE FROM t1 WHERE
+ #
+ c01 = b'1' AND
+ # the below does not reproduce the inserted value:
+ #c02 = b'1111111111111111111111111111111111111111111111111111111111111111' AND
+ c03 = 127 AND
+ c04 = 0 AND
+ c05 = 001 AND
+ c06 = true AND
+ c07 = 32767 AND
+ c08 = 0 AND
+ c09 = 00001 AND
+ c10 = 8388607 AND
+ c11 = 0 AND
+ c12 = 00000001 AND
+ c13 = 2147483647 AND
+ c14 = 0 AND
+ c15 = 0000000001 AND
+ c16 = 9223372036854775807 AND
+ c17 = 0 AND
+ c18 = 00000000000000000001 AND
+ c19 > -1.175494352E-38 AND
+ c20 < 1.175494352E-38 AND
+ c21 = 000000000000001 AND
+ c22 > -2.2250738585073E-308 AND
+ c23 < 2.2250738585073E-308 AND
+ c24 = 00000000000000000000001 AND
+ c25 = -9999999999 AND
+ c26 = 9999999999 AND
+ c27 = 0000000001 AND
+ #
+ c28 = '2008-08-04' AND
+ c29 = '2008-08-04 16:18:06' AND
+ c30 = '2008-08-04 16:18:24' AND
+ c31 = '16:18:47' AND
+ c32 = '2008' AND
+ #
+ c33 = 'a' AND
+ c34 = '' AND
+ c35 = 'e' AND
+ c36 = REPEAT('i',255) AND
+ c37 = _utf8 x'c3a4' AND
+ c38 = '' AND
+ c39 = _utf8 x'c3b6' AND
+ c40 = REPEAT(_utf8 x'c3bc',255) AND
+ c41 = _ucs2 x'00e4' AND
+ c42 = '' AND
+ c43 = _ucs2 x'00f6' AND
+ c44 = REPEAT(_ucs2 x'00fc',255) AND
+ #
+ c45 = '' AND
+ c46 = 'a' AND
+ c47 = REPEAT('e',255) AND
+ c48 = REPEAT('i',261) AND
+ c49 = '' AND
+ c50 = _utf8 x'c3a4' AND
+ c51 = REPEAT(_utf8 x'c3b6',255) AND
+ c52 = REPEAT(_utf8 x'c3bc',261) AND
+ c53 = '' AND
+ c54 = _ucs2 x'00e4' AND
+ c55 = REPEAT(_ucs2 x'00f6',255) AND
+ c56 = REPEAT(_ucs2 x'00fc',261) AND
+ #
+ c57 = '0' AND
+ c58 = '' AND
+ c59 = '1' AND
+ c60 = REPEAT('1',255) AND
+ #
+ c61 = '' AND
+ c62 = 'b' AND
+ c63 = REPEAT('c',255) AND
+ c64 = REPEAT('\'',261) AND
+ #
+ c65 = 'tinyblob' AND
+ c66 = 'tinytext' AND
+ c67 = 'tinytext-ucs2' AND
+ c68 = 'blob' AND
+ c69 = 'text' AND
+ c70 = 'text-ucs2' AND
+ c71 = 'mediumblob' AND
+ c72 = 'mediumtext' AND
+ c73 = 'mediumtext-ucs2' AND
+ c74 = 'longblob' AND
+ c75 = 'longtext' AND
+ c76 = 'longtext-ucs2' AND
+ #
+ c77 = 'b' AND
+ c78 = 'b,c' AND
+ #
+ crn = 3;
+
+--echo #
+--echo # Delete the row that has NULL values now.
+--echo #
+DELETE FROM t1 WHERE
+ #
+ c01 IS NULL AND
+ c02 IS NULL AND
+ c03 IS NULL AND
+ c04 IS NULL AND
+ c05 IS NULL AND
+ c06 IS NULL AND
+ c07 IS NULL AND
+ c08 IS NULL AND
+ c09 IS NULL AND
+ c10 IS NULL AND
+ c11 IS NULL AND
+ c12 IS NULL AND
+ c13 IS NULL AND
+ c14 IS NULL AND
+ c15 IS NULL AND
+ c16 IS NULL AND
+ c17 IS NULL AND
+ c18 IS NULL AND
+ c19 IS NULL AND
+ c20 IS NULL AND
+ c21 IS NULL AND
+ c22 IS NULL AND
+ c23 IS NULL AND
+ c24 IS NULL AND
+ c25 IS NULL AND
+ c26 IS NULL AND
+ c27 IS NULL AND
+ #
+ c28 IS NULL AND
+ c29 IS NULL AND
+ # this got a timestamp instead of NULL: c30 IS NULL AND
+ c31 IS NULL AND
+ c32 IS NULL AND
+ #
+ c33 IS NULL AND
+ c34 IS NULL AND
+ c35 IS NULL AND
+ c36 IS NULL AND
+ c37 IS NULL AND
+ c38 IS NULL AND
+ c39 IS NULL AND
+ c40 IS NULL AND
+ c41 IS NULL AND
+ c42 IS NULL AND
+ c43 IS NULL AND
+ c44 IS NULL AND
+ #
+ c45 IS NULL AND
+ c46 IS NULL AND
+ c47 IS NULL AND
+ c48 IS NULL AND
+ c49 IS NULL AND
+ c50 IS NULL AND
+ c51 IS NULL AND
+ c52 IS NULL AND
+ c53 IS NULL AND
+ c54 IS NULL AND
+ c55 IS NULL AND
+ c56 IS NULL AND
+ #
+ c57 IS NULL AND
+ c58 IS NULL AND
+ c59 IS NULL AND
+ c60 IS NULL AND
+ #
+ c61 IS NULL AND
+ c62 IS NULL AND
+ c63 IS NULL AND
+ c64 IS NULL AND
+ #
+ c65 IS NULL AND
+ c66 IS NULL AND
+ c67 IS NULL AND
+ c68 IS NULL AND
+ c69 IS NULL AND
+ c70 IS NULL AND
+ c71 IS NULL AND
+ c72 IS NULL AND
+ c73 IS NULL AND
+ c74 IS NULL AND
+ c75 IS NULL AND
+ c76 IS NULL AND
+ #
+ c77 IS NULL AND
+ c78 IS NULL AND
+ #
+ crn = 4;
+
+--echo #
+--echo # Show what we have in the table. Should be empty now.
+--echo #
+query_vertical SELECT * FROM t1;
+
+--echo #
+--echo # Hide how much rows are affected by each statement.
+--echo #
+--disable_info
+
+--echo #
+--echo # Flush all log buffers to the log file.
+--echo #
+FLUSH LOGS;
+
+--echo #
+--echo # Call mysqlbinlog to display the log file contents.
+--echo #
+let $MYSQLD_DATADIR= `select @@datadir`;
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/ /exec_time=[0-9]*/exec_time=#/ /end_log_pos [0-9]*/end_log_pos #/ /# at [0-9]*/# at #/ /Xid = [0-9]*/Xid = #/ /thread_id=[0-9]*/thread_id=#/ /table id [0-9]*/table id #/ /mapped to number [0-9]*/mapped to number #/ /server v [^ ]*/server v #.##.##/ /(@[0-9]*=[0-9-]*[.][0-9]{1,3})[0-9e+-]*[^ ]*[ ]*(.*(FLOAT|DOUBLE).*[*].)/\1... \2/ /CRC32 0x[0-9a-f]*/CRC32 XXX/
+--exec $MYSQL_BINLOG --base64-output=decode-rows -v -v $MYSQLD_DATADIR/master-bin.000001
+
+--echo #
+--echo # Cleanup.
+--echo #
+DROP TABLE t1;
+
+--echo #
+--echo # =========================================
+--echo # Test #2 - Multi-row insert/update/delete.
+--echo # =========================================
+--echo #
+--echo # Delete all existing binary logs.
+--echo #
+RESET MASTER;
+
+--echo #
+--echo # Create a test table with selected data types.
+--echo #
+eval CREATE TABLE t1 (
+ c28 DATE,
+ c47 VARCHAR(24),
+ crn INT -- row number
+ ) ENGINE=$engine_type DEFAULT CHARSET latin1;
+
+--echo #
+--echo # Show how much rows are affected by each statement.
+--echo #
+--enable_info
+
+--echo #
+--echo # Multi-row insert.
+--echo #
+INSERT INTO t1 VALUES
+ ('2008-08-01','VARCHAR-01',1),
+ ('2008-08-02','VARCHAR-02',2),
+ ('2008-08-03','VARCHAR-03',3),
+ ('2008-08-04','VARCHAR-04',4),
+ ('2008-08-05','VARCHAR-05',5),
+ ('2008-08-06','VARCHAR-06',6),
+ ('2008-08-07','VARCHAR-07',7),
+ ('2008-08-08','VARCHAR-08',8),
+ ('2008-08-09','VARCHAR-09',9);
+
+--echo #
+--echo # Multi-row update.
+--echo #
+UPDATE t1 SET c28 = ADDDATE(c28,10) WHERE crn < 8;
+
+--echo #
+--echo # Show what we have in the table.
+--echo #
+SELECT * FROM t1;
+
+--echo #
+--echo # Multi-row delete.
+--echo #
+DELETE FROM t1 WHERE crn < 8;
+
+--echo #
+--echo # Show what we have in the table.
+--echo #
+SELECT * FROM t1;
+
+--echo #
+--echo # Hide how much rows are affected by each statement.
+--echo #
+--disable_info
+
+--echo #
+--echo # Flush all log buffers to the log file.
+--echo #
+FLUSH LOGS;
+
+--echo #
+--echo # Call mysqlbinlog to display the log file contents.
+--echo #
+let $MYSQLD_DATADIR= `select @@datadir`;
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/ /exec_time=[0-9]*/exec_time=#/ /end_log_pos [0-9]*/end_log_pos #/ /# at [0-9]*/# at #/ /Xid = [0-9]*/Xid = #/ /thread_id=[0-9]*/thread_id=#/ /table id [0-9]*/table id #/ /mapped to number [0-9]*/mapped to number #/ /server v [^ ]*/server v #.##.##/ /(@[0-9]*=[0-9-]*[.][0-9]{1,3})[0-9e+-]*[^ ]*[ ]*(.*(FLOAT|DOUBLE).*[*].)/\1... \2/ /CRC32 0x[0-9a-f]*/CRC32 XXX/
+--exec $MYSQL_BINLOG --base64-output=decode-rows -v -v $MYSQLD_DATADIR/master-bin.000001
+
+--echo #
+--echo # Cleanup.
+--echo #
+DROP TABLE t1;
+
+--echo #
+--echo # ====================================
+--echo # Test #3 - Multi-table update/delete.
+--echo # ====================================
+--echo #
+--echo # Delete all existing binary logs.
+--echo #
+RESET MASTER;
+
+--echo #
+--echo # Create test tables with selected data types.
+--echo #
+eval CREATE TABLE t1 (
+ c_1_1 DATE,
+ c_1_2 VARCHAR(255),
+ c_1_n INT -- row number
+ ) ENGINE=$engine_type DEFAULT CHARSET latin1;
+#
+eval CREATE TABLE t2 (
+ c_2_1 DATE,
+ c_2_2 VARCHAR(255),
+ c_2_n INT -- row number
+ ) ENGINE=$engine_type DEFAULT CHARSET latin1;
+#
+eval CREATE TABLE t3 (
+ c_3_1 DATE,
+ c_3_2 VARCHAR(255),
+ c_3_n INT -- row number
+ ) ENGINE=$engine_type DEFAULT CHARSET latin1;
+
+--echo #
+--echo # Show how much rows are affected by each statement.
+--echo #
+--enable_info
+
+--echo #
+--echo # Insert data.
+--echo #
+INSERT INTO t1 VALUES
+ ('2008-01-01','VARCHAR-01-01',11),
+ ('2008-01-02','VARCHAR-01-02',2),
+ ('2008-01-03','VARCHAR-01-03',3),
+ ('2008-01-04','VARCHAR-01-04',4),
+ ('2008-01-05','VARCHAR-01-05',5),
+ ('2008-01-06','VARCHAR-01-06',6),
+ ('2008-01-07','VARCHAR-01-07',7),
+ ('2008-01-08','VARCHAR-01-08',18),
+ ('2008-01-09','VARCHAR-01-09',19);
+#
+INSERT INTO t2 VALUES
+ ('2008-02-01','VARCHAR-02-01',21),
+ ('2008-02-02','VARCHAR-02-02',2),
+ ('2008-02-03','VARCHAR-02-03',3),
+ ('2008-02-04','VARCHAR-02-04',4),
+ ('2008-02-05','VARCHAR-02-05',5),
+ ('2008-02-06','VARCHAR-02-06',6),
+ ('2008-02-07','VARCHAR-02-07',7),
+ ('2008-02-08','VARCHAR-02-08',28),
+ ('2008-02-09','VARCHAR-02-09',29);
+#
+INSERT INTO t3 VALUES
+ ('2008-03-01','VARCHAR-03-01',31),
+ ('2008-03-02','VARCHAR-03-02',2),
+ ('2008-03-03','VARCHAR-03-03',3),
+ ('2008-03-04','VARCHAR-03-04',4),
+ ('2008-03-05','VARCHAR-03-05',5),
+ ('2008-03-06','VARCHAR-03-06',6),
+ ('2008-03-07','VARCHAR-03-07',7),
+ ('2008-03-08','VARCHAR-03-08',38),
+ ('2008-03-09','VARCHAR-03-09',39);
+
+--echo #
+--echo # Multi-table update.
+--echo #
+UPDATE t1,t2,t3 SET
+ c_1_1 = ADDDATE(c_1_1,INTERVAL 10 YEAR),
+ c_2_1 = ADDDATE(c_2_1,INTERVAL 20 YEAR),
+ c_3_1 = ADDDATE(c_3_1,INTERVAL 30 YEAR)
+ WHERE c_1_n = c_2_n AND c_2_n = c_3_n;
+
+--echo #
+--echo # Show what we have in the tables.
+--echo #
+SELECT * FROM t1;
+SELECT * FROM t2;
+SELECT * FROM t3;
+
+--echo #
+--echo # Multi-table delete.
+--echo #
+DELETE FROM t1,t2,t3 USING t1 INNER JOIN t2 INNER JOIN t3
+ WHERE c_1_n = c_2_n AND c_2_n = c_3_n;
+
+--echo #
+--echo # Show what we have in the tables.
+--echo #
+SELECT * FROM t1;
+SELECT * FROM t2;
+SELECT * FROM t3;
+
+--echo #
+--echo # Hide how much rows are affected by each statement.
+--echo #
+--disable_info
+
+--echo #
+--echo # Flush all log buffers to the log file.
+--echo #
+FLUSH LOGS;
+
+--echo #
+--echo # Call mysqlbinlog to display the log file contents.
+--echo #
+let $MYSQLD_DATADIR= `select @@datadir`;
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/ /exec_time=[0-9]*/exec_time=#/ /end_log_pos [0-9]*/end_log_pos #/ /# at [0-9]*/# at #/ /Xid = [0-9]*/Xid = #/ /thread_id=[0-9]*/thread_id=#/ /table id [0-9]*/table id #/ /mapped to number [0-9]*/mapped to number #/ /server v [^ ]*/server v #.##.##/ /(@[0-9]*=[0-9-]*[.][0-9]{1,3})[0-9e+-]*[^ ]*[ ]*(.*(FLOAT|DOUBLE).*[*].)/\1... \2/ /CRC32 0x[0-9a-f]*/CRC32 XXX/
+--exec $MYSQL_BINLOG --base64-output=decode-rows -v -v $MYSQLD_DATADIR/master-bin.000001
+
+--echo #
+--echo # Cleanup.
+--echo #
+DROP TABLE t1, t2, t3;
+
+--echo #
+--echo # ===========================
+--echo # Test #4 - LOAD DATA INFILE.
+--echo # ===========================
+--echo #
+--echo # Delete all existing binary logs.
+--echo #
+RESET MASTER;
+
+--echo #
+--echo # Create a test table with selected data types.
+--echo #
+eval CREATE TABLE t1 (
+ c1 INT DEFAULT 100,
+ c2 INT,
+ c3 VARCHAR(60)
+ ) ENGINE=$engine_type DEFAULT CHARSET latin1;
+
+--echo #
+--echo # Show how much rows are affected by each statement.
+--echo #
+--enable_info
+
+--echo #
+--echo # Load data.
+--echo #
+LOAD DATA INFILE '../../std_data/loaddata5.dat'
+ INTO TABLE t1 FIELDS TERMINATED BY '' ENCLOSED BY '' (c1,c2)
+ SET c3 = 'Wow';
+
+--echo #
+--echo # Show what we have in the table.
+--echo #
+SELECT * FROM t1;
+
+--echo #
+--echo # Hide how much rows are affected by each statement.
+--echo #
+--disable_info
+
+--echo #
+--echo # Flush all log buffers to the log file.
+--echo #
+FLUSH LOGS;
+
+--echo #
+--echo # Call mysqlbinlog to display the log file contents.
+--echo #
+let $MYSQLD_DATADIR= `select @@datadir`;
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/ /exec_time=[0-9]*/exec_time=#/ /end_log_pos [0-9]*/end_log_pos #/ /# at [0-9]*/# at #/ /Xid = [0-9]*/Xid = #/ /thread_id=[0-9]*/thread_id=#/ /table id [0-9]*/table id #/ /mapped to number [0-9]*/mapped to number #/ /server v [^ ]*/server v #.##.##/ /(@[0-9]*=[0-9-]*[.][0-9]{1,3})[0-9e+-]*[^ ]*[ ]*(.*(FLOAT|DOUBLE).*[*].)/\1... \2/ /CRC32 0x[0-9a-f]*/CRC32 XXX/
+--exec $MYSQL_BINLOG --base64-output=decode-rows -v -v $MYSQLD_DATADIR/master-bin.000001
+
+--echo #
+--echo # Cleanup.
+--echo #
+DROP TABLE t1;
+
+