summaryrefslogtreecommitdiffstats
path: root/mysql-test/suite/binlog
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-07-01 18:15:00 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-07-01 18:15:00 +0000
commita2a2e32c02643a0cec111511220227703fda1cd5 (patch)
tree69cc2b631234c2a8e026b9cd4d72676c61c594df /mysql-test/suite/binlog
parentReleasing progress-linux version 1:10.11.8-1~progress7.99u1. (diff)
downloadmariadb-a2a2e32c02643a0cec111511220227703fda1cd5.tar.xz
mariadb-a2a2e32c02643a0cec111511220227703fda1cd5.zip
Merging upstream version 1:11.4.2.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'mysql-test/suite/binlog')
-rw-r--r--mysql-test/suite/binlog/include/binlog_expire_warnings.inc2
-rw-r--r--mysql-test/suite/binlog/include/binlog_incident-master.opt2
-rw-r--r--mysql-test/suite/binlog/include/binlog_ioerr.inc3
-rw-r--r--mysql-test/suite/binlog/include/row_img.test56
-rw-r--r--mysql-test/suite/binlog/my.cnf4
-rw-r--r--mysql-test/suite/binlog/r/binlog_base64_flag.result33
-rw-r--r--mysql-test/suite/binlog/r/binlog_grant.result38
-rw-r--r--mysql-test/suite/binlog/r/binlog_gtid_index.result135
-rw-r--r--mysql-test/suite/binlog/r/binlog_gtid_index_crash.result28
-rw-r--r--mysql-test/suite/binlog/r/binlog_ioerr.result2
-rw-r--r--mysql-test/suite/binlog/r/binlog_mysqlbinlog_raw_flush.result1
-rw-r--r--mysql-test/suite/binlog/r/binlog_mysqlbinlog_row.result21
-rw-r--r--mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_innodb.result6
-rw-r--r--mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_myisam.result7
-rw-r--r--mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_trans.result2
-rw-r--r--mysql-test/suite/binlog/r/binlog_old_versions.result70
-rw-r--r--mysql-test/suite/binlog/r/binlog_row_ctype_ucs.result1
-rw-r--r--mysql-test/suite/binlog/r/binlog_row_img.result1365
-rw-r--r--mysql-test/suite/binlog/r/binlog_stm_ctype_ucs.result3
-rw-r--r--mysql-test/suite/binlog/r/binlog_stm_do_db.result6
-rw-r--r--mysql-test/suite/binlog/r/binlog_stm_mysqlbinlog_collate_implicit.result193
-rw-r--r--mysql-test/suite/binlog/r/binlog_unsafe.result4
-rw-r--r--mysql-test/suite/binlog/r/flashback.result54
-rw-r--r--mysql-test/suite/binlog/r/max_binlog_total_size.result123
-rw-r--r--mysql-test/suite/binlog/std_data/binlog_old_version_4_1.000001bin149436 -> 0 bytes
-rw-r--r--mysql-test/suite/binlog/std_data/bug32407.001bin368 -> 0 bytes
-rw-r--r--mysql-test/suite/binlog/std_data/ver_5_1-telco.001bin150385 -> 0 bytes
-rw-r--r--mysql-test/suite/binlog/std_data/ver_5_1_17.001bin150385 -> 0 bytes
-rw-r--r--mysql-test/suite/binlog/std_data/ver_5_1_23.001bin150402 -> 0 bytes
-rw-r--r--mysql-test/suite/binlog/std_data/ver_trunk_row_v2.001bin151722 -> 0 bytes
-rw-r--r--mysql-test/suite/binlog/t/binlog_base64_flag.test28
-rw-r--r--mysql-test/suite/binlog/t/binlog_expire_warnings.opt1
-rw-r--r--mysql-test/suite/binlog/t/binlog_grant.test33
-rw-r--r--mysql-test/suite/binlog/t/binlog_gtid_index.test229
-rw-r--r--mysql-test/suite/binlog/t/binlog_gtid_index_crash.opt1
-rw-r--r--mysql-test/suite/binlog/t/binlog_gtid_index_crash.test66
-rw-r--r--mysql-test/suite/binlog/t/binlog_killed.test2
-rw-r--r--mysql-test/suite/binlog/t/binlog_killed_simulate-master.opt2
-rw-r--r--mysql-test/suite/binlog/t/binlog_mysqlbinlog_raw_flush.test2
-rw-r--r--mysql-test/suite/binlog/t/binlog_old_versions.test153
-rw-r--r--mysql-test/suite/binlog/t/binlog_row_img.test35
-rw-r--r--mysql-test/suite/binlog/t/binlog_stm_do_db.test8
-rw-r--r--mysql-test/suite/binlog/t/binlog_stm_mysqlbinlog_collate_implicit.test77
-rw-r--r--mysql-test/suite/binlog/t/binlog_table_map_optional_metadata.test4
-rw-r--r--mysql-test/suite/binlog/t/binlog_truncate_multi_engine.test1
-rw-r--r--mysql-test/suite/binlog/t/flashback.combinations4
-rw-r--r--mysql-test/suite/binlog/t/flashback.test67
-rw-r--r--mysql-test/suite/binlog/t/max_binlog_total_size-master.opt5
-rw-r--r--mysql-test/suite/binlog/t/max_binlog_total_size.test94
49 files changed, 2626 insertions, 345 deletions
diff --git a/mysql-test/suite/binlog/include/binlog_expire_warnings.inc b/mysql-test/suite/binlog/include/binlog_expire_warnings.inc
index 3f879bff..04a00f11 100644
--- a/mysql-test/suite/binlog/include/binlog_expire_warnings.inc
+++ b/mysql-test/suite/binlog/include/binlog_expire_warnings.inc
@@ -87,7 +87,7 @@ if ($expect_binlog_off_days_and_seconds_warning) {
}
--let $assert_file = $ofile
---let $assert_select = You need to use --log-bin to make --expire-logs-days or --binlog-expire-logs-seconds work.
+--let $assert_select = You need to use --log-bin to make --expire-logs-days, --binlog-expire-logs-seconds or --max-binlog-total-size work.
--let $assert_only_after = Shutdown complete
--source include/assert_grep.inc
diff --git a/mysql-test/suite/binlog/include/binlog_incident-master.opt b/mysql-test/suite/binlog/include/binlog_incident-master.opt
index 57ce0081..4e746bf1 100644
--- a/mysql-test/suite/binlog/include/binlog_incident-master.opt
+++ b/mysql-test/suite/binlog/include/binlog_incident-master.opt
@@ -1 +1 @@
---loose-debug=+d,incident_database_resync_on_replace \ No newline at end of file
+--loose-debug-dbug=+d,incident_database_resync_on_replace
diff --git a/mysql-test/suite/binlog/include/binlog_ioerr.inc b/mysql-test/suite/binlog/include/binlog_ioerr.inc
index da6fb5ac..b710eccc 100644
--- a/mysql-test/suite/binlog/include/binlog_ioerr.inc
+++ b/mysql-test/suite/binlog/include/binlog_ioerr.inc
@@ -17,11 +17,14 @@ CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=innodb;
INSERT INTO t1 VALUES(0);
SET @saved_dbug = @@SESSION.debug_dbug;
SET SESSION debug_dbug='+d,fail_binlog_write_1';
+# The error injection is in the "legacy" code path.
+SET GLOBAL binlog_legacy_event_pos= 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=@saved_dbug;
+SET GLOBAL binlog_legacy_event_pos= 0;
INSERT INTO t1 VALUES(3);
SELECT * FROM t1;
diff --git a/mysql-test/suite/binlog/include/row_img.test b/mysql-test/suite/binlog/include/row_img.test
new file mode 100644
index 00000000..42f3f273
--- /dev/null
+++ b/mysql-test/suite/binlog/include/row_img.test
@@ -0,0 +1,56 @@
+# Auxaliary script for test binlog_row_image
+#
+CREATE TABLE t1 (c1 INT PRIMARY KEY, c2 varchar(100),
+ c3 INT DEFAULT 1000, c4 TEXT);
+CREATE TABLE t2 (c1 INT, c2 char(100), c3 INT DEFAULT 1000, c4 TEXT);
+
+FLUSH BINARY LOGS;
+--let $binlog= query_get_value(SHOW MASTER STATUS, File, 1)
+--let $datadir= `SELECT @@datadir`
+
+--let $img_mode= `SELECT @@binlog_row_image`
+--echo
+--echo #########################################################################
+--echo # binlog_row_image = $img_mode
+--echo #########################################################################
+--echo
+INSERT INTO t1 VALUES(1, "insert_to_t1", 1, repeat('a', 20)),
+ (2, "insert_to_t1", 2, repeat('a', 20)),
+ (3, "insert_to_t1", 3, repeat('a', 20));
+INSERT INTO t1(c1) VALUES(4);
+UPDATE t1 SET c2 = "only_c2_changed";
+UPDATE t1 SET c3 = 1, c4 = "c3_c4_changed";
+DELETE FROM t1 WHERE c1 = 1;
+
+--echo
+--echo # Verify that rows events are binlogged as expeced.
+--echo
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--replace_regex /^\# at .*// /.*SET (@@|TIMESTAMP).*// /.* end_log_pos .*// /xid=\d*/xid=<xid>/
+--exec $MYSQL_BINLOG --force-if-open --verbose --verbose --base64-output=DECODE-ROWS $datadir/$binlog
+
+FLUSH BINARY LOGS;
+--let $binlog= query_get_value(SHOW MASTER STATUS, File, 1)
+--let $datadir= `SELECT @@datadir`
+
+--echo
+--echo # t2 has no primary key.
+--echo # It will binlog full before and after image for all modes if the
+--echo # table has no primary key. FULL_NODUP follows the behavior.
+--echo
+INSERT INTO t2 VALUES(1, "insert_to_t2", 1, repeat('a', 20)),
+ (2, "insert_to_t2", 2, repeat('a', 20)),
+ (3, "insert_to_t2", 3, repeat('a', 20));
+INSERT INTO t2(c1) VALUES(4);
+UPDATE t2 SET c2 = "only_c2_changed";
+UPDATE t2 SET c3 = 1, c4 = "c3_c4_changed";
+DELETE FROM t2 WHERE c1 > 2;
+
+--echo
+--echo # Verify that rows events are binlogged as expeced.
+--echo
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--replace_regex /^\# at .*// /.*SET (@@|TIMESTAMP).*// /.* end_log_pos .*// /xid=\d*/xid=<xid>/
+--exec $MYSQL_BINLOG --force-if-open --verbose --verbose --base64-output=DECODE-ROWS $datadir/$binlog
+
+DROP TABLE t1, t2;
diff --git a/mysql-test/suite/binlog/my.cnf b/mysql-test/suite/binlog/my.cnf
new file mode 100644
index 00000000..a563433d
--- /dev/null
+++ b/mysql-test/suite/binlog/my.cnf
@@ -0,0 +1,4 @@
+!include include/default_my.cnf
+
+[mariadbd]
+slave_connections_needed_for_purge=0
diff --git a/mysql-test/suite/binlog/r/binlog_base64_flag.result b/mysql-test/suite/binlog/r/binlog_base64_flag.result
index c4c4fddb..4b75b712 100644
--- a/mysql-test/suite/binlog/r/binlog_base64_flag.result
+++ b/mysql-test/suite/binlog/r/binlog_base64_flag.result
@@ -1,7 +1,7 @@
call mtr.add_suppression("BINLOG_BASE64_EVENT: According to the master's version");
call mtr.add_suppression("BINLOG_BASE64_EVENT: Column 1 of table 'test.char128_utf8' cannot be converted");
-DROP TABLE IF EXISTS t1;
-==== Test BUG#32407 ====
+CREATE TABLE t1 (a int);
+INSERT INTO t1 VALUES (1), (1);
select * from t1;
a
1
@@ -49,35 +49,6 @@ a
SELECT @binlog_fragment_0, @binlog_fragment_1 as 'NULL','NULL';
@binlog_fragment_0 NULL NULL
NULL NULL NULL
-==== Test --base64-output=never on a binlog with row events ====
-/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/;
-/*!40019 SET @@session.max_delayed_threads=0*/;
-/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
-DELIMITER /*!*/;
-<#>
-ROLLBACK/*!*/;
-<#>
-use `test`/*!*/;
-SET TIMESTAMP=1196959712/*!*/;
-<#>SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.system_versioning_insert_history=0/*!*/;
-SET @@session.sql_mode=0/*!*/;
-SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
-/*!\C latin1 *//*!*/;
-SET @@session.character_set_client=latin1,@@session.collation_connection=8,@@session.collation_server=8/*!*/;
-SET @@session.lc_time_names=0/*!*/;
-SET @@session.collation_database=DEFAULT/*!*/;
-create table t1 (a int) engine= myisam
-/*!*/;
-<#>
-<#>
-<#>
-<#>
-<#>
-DELIMITER ;
-# End of log file
-ROLLBACK /* added by mysqlbinlog */;
-/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
-/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;
==== Test non-matching FD event and Row event ====
BINLOG '
4CdYRw8BAAAAYgAAAGYAAAAAAAQANS4xLjE1LW5kYi02LjEuMjQtZGVidWctbG9nAAAAAAAAAAAA
diff --git a/mysql-test/suite/binlog/r/binlog_grant.result b/mysql-test/suite/binlog/r/binlog_grant.result
index edf70561..76cc415d 100644
--- a/mysql-test/suite/binlog/r/binlog_grant.result
+++ b/mysql-test/suite/binlog/r/binlog_grant.result
@@ -16,7 +16,7 @@ set session sql_log_bin = 1;
connection plain;
[plain]
set session sql_log_bin = 1;
-ERROR 42000: Access denied; you need (at least one of) the SUPER, BINLOG ADMIN privilege(s) for this operation
+ERROR 42000: Access denied; you need (at least one of) the BINLOG ADMIN privilege(s) for this operation
**** Variable BINLOG_FORMAT ****
connection root;
[root]
@@ -25,9 +25,9 @@ set session binlog_format = row;
connection plain;
[plain]
set global binlog_format = row;
-ERROR 42000: Access denied; you need (at least one of) the SUPER, BINLOG ADMIN privilege(s) for this operation
+ERROR 42000: Access denied; you need (at least one of) the BINLOG ADMIN privilege(s) for this operation
set session binlog_format = row;
-ERROR 42000: Access denied; you need (at least one of) the SUPER, BINLOG ADMIN privilege(s) for this operation
+ERROR 42000: Access denied; you need (at least one of) the BINLOG ADMIN privilege(s) for this operation
**** Clean up ****
disconnect plain;
disconnect root;
@@ -45,7 +45,10 @@ disconnect rpl;
connection default;
DROP USER 'mysqltest_1'@'localhost';
#
-# Start of 10.5 test
+# End of 10.4 tests
+#
+#
+# Start of 10.5 tests
#
#
# MDEV-21743 Split up SUPER privilege to smaller privileges
@@ -61,29 +64,29 @@ SHOW GRANTS FOR user1@localhost;
Grants for user1@localhost
GRANT USAGE ON *.* TO `user1`@`localhost`
DROP USER user1@localhost;
-# Test if SHOW BINARY LOGS and SHOW BINGLOG STATUS are not allowed without REPLICATION CLIENT or SUPER
+# Test if SHOW BINARY LOGS and SHOW BINGLOG STATUS are not allowed without REPLICATION CLIENT
CREATE USER user1@localhost;
GRANT ALL PRIVILEGES ON *.* TO user1@localhost;
-REVOKE REPLICATION CLIENT, SUPER ON *.* FROM user1@localhost;
+REVOKE REPLICATION CLIENT ON *.* FROM user1@localhost;
connect user1,localhost,user1,,;
connection user1;
SHOW MASTER LOGS;
-ERROR 42000: Access denied; you need (at least one of) the SUPER, BINLOG MONITOR privilege(s) for this operation
+ERROR 42000: Access denied; you need (at least one of) the BINLOG MONITOR privilege(s) for this operation
SHOW BINARY LOGS;
-ERROR 42000: Access denied; you need (at least one of) the SUPER, BINLOG MONITOR privilege(s) for this operation
+ERROR 42000: Access denied; you need (at least one of) the BINLOG MONITOR privilege(s) for this operation
SHOW BINLOG STATUS;
-ERROR 42000: Access denied; you need (at least one of) the SUPER, BINLOG MONITOR privilege(s) for this operation
+ERROR 42000: Access denied; you need (at least one of) the BINLOG MONITOR privilege(s) for this operation
disconnect user1;
connection default;
DROP USER user1@localhost;
-# Test if PURGE BINARY LOGS is not allowed without BINLOG ADMIN or SUPER
+# Test if PURGE BINARY LOGS is not allowed without BINLOG ADMIN
CREATE USER user1@localhost;
GRANT ALL PRIVILEGES ON *.* TO user1@localhost;
-REVOKE BINLOG ADMIN, SUPER ON *.* FROM user1@localhost;
+REVOKE BINLOG ADMIN ON *.* FROM user1@localhost;
connect user1,localhost,user1,,;
connection user1;
PURGE BINARY LOGS BEFORE '2001-01-01 00:00:00';
-ERROR 42000: Access denied; you need (at least one of) the SUPER, BINLOG ADMIN privilege(s) for this operation
+ERROR 42000: Access denied; you need (at least one of) the BINLOG ADMIN privilege(s) for this operation
disconnect user1;
connection default;
DROP USER user1@localhost;
@@ -96,15 +99,6 @@ PURGE BINARY LOGS BEFORE '2001-01-01 00:00:00';
disconnect user1;
connection default;
DROP USER user1@localhost;
-# Test if PURGE BINLOG is allowed with SUPER
-CREATE USER user1@localhost;
-GRANT SUPER ON *.* TO user1@localhost;
-connect user1,localhost,user1,,"*NO-ONE*";
-connection user1;
-PURGE BINARY LOGS BEFORE '2001-01-01 00:00:00';
-disconnect user1;
-connection default;
-DROP USER user1@localhost;
# Test if SHOW BINLOG EVENTS is not allowed without BINLOG MONITOR
CREATE USER user1@localhost;
GRANT ALL PRIVILEGES ON *.* TO user1@localhost;
@@ -142,7 +136,7 @@ connect user1,localhost,user1,,;
RENAME TABLE t1 to t2;
connection default;
REVOKE BINLOG REPLAY ON *.* FROM user1@localhost;
-call mtr.add_suppression("Access denied; you need (at least one of) the SUPER, BINLOG REPLAY privilege(s) for this operation");
+call mtr.add_suppression("Access denied; you need (at least one of) the BINLOG REPLAY privilege(s) for this operation");
# Privilege errors are expected now:
connection user1;
connection default;
diff --git a/mysql-test/suite/binlog/r/binlog_gtid_index.result b/mysql-test/suite/binlog/r/binlog_gtid_index.result
new file mode 100644
index 00000000..e53e1aac
--- /dev/null
+++ b/mysql-test/suite/binlog/r/binlog_gtid_index.result
@@ -0,0 +1,135 @@
+SET GLOBAL binlog_gtid_index= 0;
+SET GLOBAL binlog_gtid_index= 1;
+SET @gtid1= @@gtid_binlog_pos;
+CREATE TABLE t1 (a INT PRIMARY KEY);
+SET @gtid2= @@gtid_binlog_pos;
+INSERT INTO t1 VALUES (1);
+SET @gtid3= @@gtid_binlog_pos;
+INSERT INTO t1 VALUES (2);
+INSERT INTO t1 VALUES (3);
+INSERT INTO t1 VALUES (4);
+SET @gtid4= @@gtid_binlog_pos;
+INSERT INTO t1 VALUES (5);
+SET @gtid5= @@gtid_binlog_pos;
+SET @gtid6= @@gtid_binlog_pos;
+INSERT INTO t1 VALUES (106);
+INSERT INTO t1 VALUES (107);
+Ok
+1
+Ok
+1
+Ok
+1
+Ok
+1
+Ok
+1
+Ok
+1
+FLUSH BINARY LOGS;
+Ok
+1
+Ok
+1
+Ok
+1
+Ok
+1
+Ok
+1
+Ok
+1
+*** Test that purge deletes the gtid index files. ***
+FLUSH BINARY LOGS;
+INSERT INTO t1 VALUES (200);
+FLUSH BINARY LOGS;
+INSERT INTO t1 VALUES (201);
+FLUSH BINARY LOGS;
+INSERT INTO t1 VALUES (202);
+PURGE BINARY LOGS TO 'FILE';
+*** Test missed index lookup due to missing or corrupt index file.
+FLUSH NO_WRITE_TO_BINLOG BINARY LOGS;
+INSERT INTO t1 VALUES (301);
+INSERT INTO t1 VALUES (302);
+INSERT INTO t1 VALUES (303);
+SET @gtid_pos= @@GLOBAL.gtid_binlog_pos;
+INSERT INTO t1 VALUES (304);
+INSERT INTO t1 VALUES (305);
+FLUSH NO_WRITE_TO_BINLOG STATUS;
++++ Initial status:
+SHOW STATUS LIKE 'binlog_gtid_index_%';
+Variable_name Value
+Binlog_gtid_index_hit 0
+Binlog_gtid_index_miss 0
++++ GTID Lookup in good index.
+Gtid_Lookup_Ok
+1
+SHOW STATUS LIKE 'binlog_gtid_index_%';
+Variable_name Value
+Binlog_gtid_index_hit 1
+Binlog_gtid_index_miss 0
++++ GTID Lookup, index file is missing.
+Gtid_Lookup_Ok
+1
+SHOW STATUS LIKE 'binlog_gtid_index_%';
+Variable_name Value
+Binlog_gtid_index_hit 1
+Binlog_gtid_index_miss 1
+FLUSH NO_WRITE_TO_BINLOG BINARY LOGS;
+INSERT INTO t1 VALUES (306);
+SET @gtid_pos= @@GLOBAL.gtid_binlog_pos;
+INSERT INTO t1 VALUES (307);
+INSERT INTO t1 VALUES (308);
+FLUSH NO_WRITE_TO_BINLOG BINARY LOGS;
++++ GTID Lookup, first page of index is corrupt.
+Gtid_Lookup_Ok
+1
+SHOW STATUS LIKE 'binlog_gtid_index_%';
+Variable_name Value
+Binlog_gtid_index_hit 1
+Binlog_gtid_index_miss 2
+SET @old_page_size= @@GLOBAL.binlog_gtid_index_page_size;
+SET @old_span_min= @@GLOBAL.binlog_gtid_index_span_min;
+SET GLOBAL binlog_gtid_index_page_size= 64;
+SET GLOBAL binlog_gtid_index_span_min= 1;
+FLUSH NO_WRITE_TO_BINLOG BINARY LOGS;
+INSERT INTO t1 VALUES (310);
+INSERT INTO t1 VALUES (311);
+INSERT INTO t1 VALUES (312);
+SET @gtid_pos= @@GLOBAL.gtid_binlog_pos;
+INSERT INTO t1 VALUES (313);
+INSERT INTO t1 VALUES (314);
+INSERT INTO t1 VALUES (315);
+INSERT INTO t1 VALUES (316);
+FLUSH NO_WRITE_TO_BINLOG BINARY LOGS;
+SET GLOBAL binlog_gtid_index_page_size= @old_page_size;
+SET GLOBAL binlog_gtid_index_span_min= @old_span_min;
++++ GTID Lookup, root page of index is corrupt.
+Gtid_Lookup_Ok
+1
+SHOW STATUS LIKE 'binlog_gtid_index_%';
+Variable_name Value
+Binlog_gtid_index_hit 1
+Binlog_gtid_index_miss 3
+*** Test BINLOG_GTID_POS() with too-large offset.
+FLUSH NO_WRITE_TO_BINLOG BINARY LOGS;
+INSERT INTO t1 VALUES (401);
+INSERT INTO t1 VALUES (402);
++++ Test the hot index.
+SELECT BINLOG_GTID_POS('FILE', 100000000);
+BINLOG_GTID_POS('FILE', 100000000)
+NULL
+SHOW STATUS LIKE 'binlog_gtid_index_%';
+Variable_name Value
+Binlog_gtid_index_hit 2
+Binlog_gtid_index_miss 3
+FLUSH NO_WRITE_TO_BINLOG BINARY LOGS;
++++ Test the cold index.
+SELECT BINLOG_GTID_POS('FILE', 100000000);
+BINLOG_GTID_POS('FILE', 100000000)
+NULL
+SHOW STATUS LIKE 'binlog_gtid_index_%';
+Variable_name Value
+Binlog_gtid_index_hit 3
+Binlog_gtid_index_miss 3
+DROP TABLE t1;
diff --git a/mysql-test/suite/binlog/r/binlog_gtid_index_crash.result b/mysql-test/suite/binlog/r/binlog_gtid_index_crash.result
new file mode 100644
index 00000000..91e5a6c9
--- /dev/null
+++ b/mysql-test/suite/binlog/r/binlog_gtid_index_crash.result
@@ -0,0 +1,28 @@
+*** Test that binlog GTID index is recovered after a crash.
+CREATE TABLE t1 (a INT PRIMARY KEY, b INT) ENGINE=InnoDB;
+Ok
+1
+Ok
+1
+Ok
+1
+SHOW STATUS LIKE 'binlog_gtid_index_%';
+Variable_name Value
+Binlog_gtid_index_hit 3
+Binlog_gtid_index_miss 0
+*** Crash the server, check that GTID index can be used after restart.
+SET debug_dbug="d,crash_shutdown";
+shutdown;
+ERROR HY000: Lost connection to server during query
+FLUSH NO_WRITE_TO_BINLOG STATUS;
+Ok
+1
+Ok
+1
+Ok
+1
+SHOW STATUS LIKE 'binlog_gtid_index_%';
+Variable_name Value
+Binlog_gtid_index_hit 3
+Binlog_gtid_index_miss 0
+DROP TABLE t1;
diff --git a/mysql-test/suite/binlog/r/binlog_ioerr.result b/mysql-test/suite/binlog/r/binlog_ioerr.result
index e4f00a01..aa4042d3 100644
--- a/mysql-test/suite/binlog/r/binlog_ioerr.result
+++ b/mysql-test/suite/binlog/r/binlog_ioerr.result
@@ -4,11 +4,13 @@ CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=innodb;
INSERT INTO t1 VALUES(0);
SET @saved_dbug = @@SESSION.debug_dbug;
SET SESSION debug_dbug='+d,fail_binlog_write_1';
+SET GLOBAL binlog_legacy_event_pos= 1;
INSERT INTO t1 VALUES(1);
ERROR HY000: Error writing file 'master-bin' (errno: 28 "No space left on device")
INSERT INTO t1 VALUES(2);
ERROR HY000: Error writing file 'master-bin' (errno: 28 "No space left on device")
SET SESSION debug_dbug=@saved_dbug;
+SET GLOBAL binlog_legacy_event_pos= 0;
INSERT INTO t1 VALUES(3);
SELECT * FROM t1;
a
diff --git a/mysql-test/suite/binlog/r/binlog_mysqlbinlog_raw_flush.result b/mysql-test/suite/binlog/r/binlog_mysqlbinlog_raw_flush.result
index d6977880..87152e82 100644
--- a/mysql-test/suite/binlog/r/binlog_mysqlbinlog_raw_flush.result
+++ b/mysql-test/suite/binlog/r/binlog_mysqlbinlog_raw_flush.result
@@ -1,4 +1,5 @@
RESET MASTER;
+RESET MASTER;
#
# MDEV-30698 Cover missing test cases for mariadb-binlog options
# --raw [and] --flashback
diff --git a/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row.result b/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row.result
index b793887a..4ae2a7d4 100644
--- a/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row.result
+++ b/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row.result
@@ -1934,7 +1934,6 @@ START TRANSACTION
# at #
#010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Query thread_id=# exec_time=# error_code=0 xid=<xid>
SET TIMESTAMP=1000000000/*!*/;
-SET @@session.time_zone='SYSTEM'/*!*/;
COMMIT
/*!*/;
# at #
@@ -2320,6 +2319,7 @@ DROP TABLE `t1` /* generated by server */
# at #
#010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Query thread_id=# exec_time=# error_code=0 xid=<xid>
SET TIMESTAMP=1000000000/*!*/;
+SET @@session.character_set_collations=''/*!*/;
CREATE TABLE t1 (c37 NATIONAL CHAR)
/*!*/;
# at #
@@ -2378,6 +2378,7 @@ DROP TABLE `t1` /* generated by server */
# at #
#010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Query thread_id=# exec_time=# error_code=0 xid=<xid>
SET TIMESTAMP=1000000000/*!*/;
+SET @@session.character_set_collations=''/*!*/;
CREATE TABLE t1 (c38 NATIONAL CHAR(0))
/*!*/;
# at #
@@ -2436,6 +2437,7 @@ DROP TABLE `t1` /* generated by server */
# at #
#010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Query thread_id=# exec_time=# error_code=0 xid=<xid>
SET TIMESTAMP=1000000000/*!*/;
+SET @@session.character_set_collations=''/*!*/;
CREATE TABLE t1 (c39 NATIONAL CHAR(1))
/*!*/;
# at #
@@ -2494,6 +2496,7 @@ DROP TABLE `t1` /* generated by server */
# at #
#010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Query thread_id=# exec_time=# error_code=0 xid=<xid>
SET TIMESTAMP=1000000000/*!*/;
+SET @@session.character_set_collations=''/*!*/;
CREATE TABLE t1 (c40 NATIONAL CHAR(255))
/*!*/;
# at #
@@ -2576,6 +2579,7 @@ DROP TABLE `t1` /* generated by server */
# at #
#010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Query thread_id=# exec_time=# error_code=0 xid=<xid>
SET TIMESTAMP=1000000000/*!*/;
+SET @@session.character_set_collations=''/*!*/;
CREATE TABLE t1 (c41 CHAR CHARACTER SET UCS2)
/*!*/;
# at #
@@ -2634,6 +2638,7 @@ DROP TABLE `t1` /* generated by server */
# at #
#010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Query thread_id=# exec_time=# error_code=0 xid=<xid>
SET TIMESTAMP=1000000000/*!*/;
+SET @@session.character_set_collations=''/*!*/;
CREATE TABLE t1 (c42 CHAR(0) CHARACTER SET UCS2)
/*!*/;
# at #
@@ -2692,6 +2697,7 @@ DROP TABLE `t1` /* generated by server */
# at #
#010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Query thread_id=# exec_time=# error_code=0 xid=<xid>
SET TIMESTAMP=1000000000/*!*/;
+SET @@session.character_set_collations=''/*!*/;
CREATE TABLE t1 (c43 CHAR(1) CHARACTER SET UCS2)
/*!*/;
# at #
@@ -2750,6 +2756,7 @@ DROP TABLE `t1` /* generated by server */
# at #
#010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Query thread_id=# exec_time=# error_code=0 xid=<xid>
SET TIMESTAMP=1000000000/*!*/;
+SET @@session.character_set_collations=''/*!*/;
CREATE TABLE t1 (c44 CHAR(255) CHARACTER SET UCS2)
/*!*/;
# at #
@@ -3064,6 +3071,7 @@ DROP TABLE `t1` /* generated by server */
# at #
#010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Query thread_id=# exec_time=# error_code=0 xid=<xid>
SET TIMESTAMP=1000000000/*!*/;
+SET @@session.character_set_collations=''/*!*/;
CREATE TABLE t1 (c49 NATIONAL VARCHAR(0))
/*!*/;
# at #
@@ -3122,6 +3130,7 @@ DROP TABLE `t1` /* generated by server */
# at #
#010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Query thread_id=# exec_time=# error_code=0 xid=<xid>
SET TIMESTAMP=1000000000/*!*/;
+SET @@session.character_set_collations=''/*!*/;
CREATE TABLE t1 (c50 NATIONAL VARCHAR(1))
/*!*/;
# at #
@@ -3180,6 +3189,7 @@ DROP TABLE `t1` /* generated by server */
# at #
#010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Query thread_id=# exec_time=# error_code=0 xid=<xid>
SET TIMESTAMP=1000000000/*!*/;
+SET @@session.character_set_collations=''/*!*/;
CREATE TABLE t1 (c51 NATIONAL VARCHAR(255))
/*!*/;
# at #
@@ -3262,6 +3272,7 @@ DROP TABLE `t1` /* generated by server */
# at #
#010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Query thread_id=# exec_time=# error_code=0 xid=<xid>
SET TIMESTAMP=1000000000/*!*/;
+SET @@session.character_set_collations=''/*!*/;
CREATE TABLE t1 (c52 NATIONAL VARCHAR(261))
/*!*/;
# at #
@@ -3344,6 +3355,7 @@ DROP TABLE `t1` /* generated by server */
# at #
#010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Query thread_id=# exec_time=# error_code=0 xid=<xid>
SET TIMESTAMP=1000000000/*!*/;
+SET @@session.character_set_collations=''/*!*/;
CREATE TABLE t1 (c53 VARCHAR(0) CHARACTER SET ucs2)
/*!*/;
# at #
@@ -3402,6 +3414,7 @@ DROP TABLE `t1` /* generated by server */
# at #
#010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Query thread_id=# exec_time=# error_code=0 xid=<xid>
SET TIMESTAMP=1000000000/*!*/;
+SET @@session.character_set_collations=''/*!*/;
CREATE TABLE t1 (c54 VARCHAR(1) CHARACTER SET ucs2)
/*!*/;
# at #
@@ -3460,6 +3473,7 @@ DROP TABLE `t1` /* generated by server */
# at #
#010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Query thread_id=# exec_time=# error_code=0 xid=<xid>
SET TIMESTAMP=1000000000/*!*/;
+SET @@session.character_set_collations=''/*!*/;
CREATE TABLE t1 (c55 VARCHAR(255) CHARACTER SET ucs2)
/*!*/;
# at #
@@ -3518,6 +3532,7 @@ DROP TABLE `t1` /* generated by server */
# at #
#010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Query thread_id=# exec_time=# error_code=0 xid=<xid>
SET TIMESTAMP=1000000000/*!*/;
+SET @@session.character_set_collations=''/*!*/;
CREATE TABLE t1 (c56 VARCHAR(261) CHARACTER SET ucs2)
/*!*/;
# at #
@@ -4656,6 +4671,7 @@ DROP TABLE `t1` /* generated by server */
# at #
#010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Query thread_id=# exec_time=# error_code=0 xid=<xid>
SET TIMESTAMP=1000000000/*!*/;
+SET @@session.character_set_collations=''/*!*/;
CREATE TABLE t1 (c67 TINYTEXT CHARACTER SET UCS2)
/*!*/;
# at #
@@ -4714,6 +4730,7 @@ DROP TABLE `t1` /* generated by server */
# at #
#010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Query thread_id=# exec_time=# error_code=0 xid=<xid>
SET TIMESTAMP=1000000000/*!*/;
+SET @@session.character_set_collations=''/*!*/;
CREATE TABLE t1 (c70 TEXT CHARACTER SET UCS2)
/*!*/;
# at #
@@ -4772,6 +4789,7 @@ DROP TABLE `t1` /* generated by server */
# at #
#010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Query thread_id=# exec_time=# error_code=0 xid=<xid>
SET TIMESTAMP=1000000000/*!*/;
+SET @@session.character_set_collations=''/*!*/;
CREATE TABLE t1 (c73 MEDIUMTEXT CHARACTER SET UCS2)
/*!*/;
# at #
@@ -4830,6 +4848,7 @@ DROP TABLE `t1` /* generated by server */
# at #
#010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Query thread_id=# exec_time=# error_code=0 xid=<xid>
SET TIMESTAMP=1000000000/*!*/;
+SET @@session.character_set_collations=''/*!*/;
CREATE TABLE t1 (c76 LONGTEXT CHARACTER SET UCS2)
/*!*/;
# at #
diff --git a/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_innodb.result b/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_innodb.result
index 9e88917c..c0c6b7db 100644
--- a/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_innodb.result
+++ b/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_innodb.result
@@ -2275,6 +2275,7 @@ SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C utf8mb3 *//*!*/;
SET @@session.character_set_client=utf8mb3,@@session.collation_connection=33,@@session.collation_server=X/*!*/;
+SET @@session.character_set_collations=''/*!*/;
SET @@session.lc_time_names=0/*!*/;
SET @@session.collation_database=DEFAULT/*!*/;
CREATE TABLE t1 (
@@ -5367,6 +5368,7 @@ SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C utf8mb3 *//*!*/;
SET @@session.character_set_client=utf8mb3,@@session.collation_connection=33,@@session.collation_server=X/*!*/;
+SET @@session.character_set_collations=''/*!*/;
SET @@session.lc_time_names=0/*!*/;
SET @@session.collation_database=DEFAULT/*!*/;
CREATE TABLE t1 (
@@ -5767,6 +5769,7 @@ SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C utf8mb3 *//*!*/;
SET @@session.character_set_client=utf8mb3,@@session.collation_connection=33,@@session.collation_server=X/*!*/;
+SET @@session.character_set_collations=''/*!*/;
SET @@session.lc_time_names=0/*!*/;
SET @@session.collation_database=DEFAULT/*!*/;
CREATE TABLE t1 (
@@ -5781,6 +5784,7 @@ c_1_n INT -- row number
# at #
#010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Query thread_id=# exec_time=# error_code=0 xid=<xid>
SET TIMESTAMP=1000000000/*!*/;
+SET @@session.character_set_collations=''/*!*/;
CREATE TABLE t2 (
c_2_1 DATE,
c_2_2 VARCHAR(255),
@@ -5793,6 +5797,7 @@ c_2_n INT -- row number
# at #
#010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Query thread_id=# exec_time=# error_code=0 xid=<xid>
SET TIMESTAMP=1000000000/*!*/;
+SET @@session.character_set_collations=''/*!*/;
CREATE TABLE t3 (
c_3_1 DATE,
c_3_2 VARCHAR(255),
@@ -6405,6 +6410,7 @@ SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C utf8mb3 *//*!*/;
SET @@session.character_set_client=utf8mb3,@@session.collation_connection=33,@@session.collation_server=X/*!*/;
+SET @@session.character_set_collations=''/*!*/;
SET @@session.lc_time_names=0/*!*/;
SET @@session.collation_database=DEFAULT/*!*/;
CREATE TABLE t1 (
diff --git a/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_myisam.result b/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_myisam.result
index 916bed0c..9186d065 100644
--- a/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_myisam.result
+++ b/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_myisam.result
@@ -2273,6 +2273,7 @@ SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C utf8mb3 *//*!*/;
SET @@session.character_set_client=utf8mb3,@@session.collation_connection=33,@@session.collation_server=X/*!*/;
+SET @@session.character_set_collations=''/*!*/;
SET @@session.lc_time_names=0/*!*/;
SET @@session.collation_database=DEFAULT/*!*/;
CREATE TABLE t1 (
@@ -2550,7 +2551,6 @@ START TRANSACTION
# at #
#010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Query thread_id=# exec_time=# error_code=0 xid=<xid>
SET TIMESTAMP=1000000000/*!*/;
-SET @@session.time_zone='SYSTEM'/*!*/;
COMMIT
/*!*/;
# at #
@@ -5388,6 +5388,7 @@ SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C utf8mb3 *//*!*/;
SET @@session.character_set_client=utf8mb3,@@session.collation_connection=33,@@session.collation_server=X/*!*/;
+SET @@session.character_set_collations=''/*!*/;
SET @@session.lc_time_names=0/*!*/;
SET @@session.collation_database=DEFAULT/*!*/;
CREATE TABLE t1 (
@@ -5794,6 +5795,7 @@ SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C utf8mb3 *//*!*/;
SET @@session.character_set_client=utf8mb3,@@session.collation_connection=33,@@session.collation_server=X/*!*/;
+SET @@session.character_set_collations=''/*!*/;
SET @@session.lc_time_names=0/*!*/;
SET @@session.collation_database=DEFAULT/*!*/;
CREATE TABLE t1 (
@@ -5808,6 +5810,7 @@ c_1_n INT -- row number
# at #
#010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Query thread_id=# exec_time=# error_code=0 xid=<xid>
SET TIMESTAMP=1000000000/*!*/;
+SET @@session.character_set_collations=''/*!*/;
CREATE TABLE t2 (
c_2_1 DATE,
c_2_2 VARCHAR(255),
@@ -5820,6 +5823,7 @@ c_2_n INT -- row number
# at #
#010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Query thread_id=# exec_time=# error_code=0 xid=<xid>
SET TIMESTAMP=1000000000/*!*/;
+SET @@session.character_set_collations=''/*!*/;
CREATE TABLE t3 (
c_3_1 DATE,
c_3_2 VARCHAR(255),
@@ -6442,6 +6446,7 @@ SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C utf8mb3 *//*!*/;
SET @@session.character_set_client=utf8mb3,@@session.collation_connection=33,@@session.collation_server=X/*!*/;
+SET @@session.character_set_collations=''/*!*/;
SET @@session.lc_time_names=0/*!*/;
SET @@session.collation_database=DEFAULT/*!*/;
CREATE TABLE t1 (
diff --git a/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_trans.result b/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_trans.result
index 5735b9b8..1a49ad29 100644
--- a/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_trans.result
+++ b/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_trans.result
@@ -151,6 +151,7 @@ SET @@session.sql_mode=1411383296/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C latin1 *//*!*/;
SET @@session.character_set_client=X,@@session.collation_connection=X,@@session.collation_server=X/*!*/;
+SET @@session.character_set_collations=''/*!*/;
SET @@session.lc_time_names=0/*!*/;
SET @@session.collation_database=DEFAULT/*!*/;
CREATE TABLE t1 (
@@ -164,6 +165,7 @@ c2 VARCHAR(20)
# at #
#010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Query thread_id=# exec_time=# error_code=0 xid=<xid>
SET TIMESTAMP=1000000000/*!*/;
+SET @@session.character_set_collations=''/*!*/;
CREATE TABLE t2 (
c1 INT,
c2 VARCHAR(20)
diff --git a/mysql-test/suite/binlog/r/binlog_old_versions.result b/mysql-test/suite/binlog/r/binlog_old_versions.result
deleted file mode 100644
index 30b64535..00000000
--- a/mysql-test/suite/binlog/r/binlog_old_versions.result
+++ /dev/null
@@ -1,70 +0,0 @@
-==== Read binlog with v2 row events ====
-SELECT * FROM t1 ORDER BY a;
-a b
-0 last_insert_id
-1 one
-3 last stm in trx: next event should be xid
-4 four
-62046 random
-SELECT * FROM t2 ORDER BY a;
-a b
-3 first stm in trx
-SELECT COUNT(*) FROM t3;
-COUNT(*)
-17920
-DROP TABLE t1, t2, t3;
-==== Read modern binlog (version 5.1.23) ====
-SELECT * FROM t1 ORDER BY a;
-a b
-0 last_insert_id
-1 one
-3 last stm in trx: next event should be xid
-4 four
-674568 random
-SELECT * FROM t2 ORDER BY a;
-a b
-3 first stm in trx
-SELECT COUNT(*) FROM t3;
-COUNT(*)
-17920
-DROP TABLE t1, t2, t3;
-==== Read binlog from version 5.1.17 ====
-SELECT * FROM t1 ORDER BY a;
-a b
-0 last_insert_id
-1 one
-3 last stm in trx: next event should be xid
-4 four
-764247 random
-SELECT * FROM t2 ORDER BY a;
-a b
-3 first stm in trx
-SELECT COUNT(*) FROM t3;
-COUNT(*)
-17920
-DROP TABLE t1, t2, t3;
-==== Read binlog from version 4.1 ====
-SELECT * FROM t1 ORDER BY a;
-a b
-0 last_insert_id
-4 four
-190243 random
-SELECT COUNT(*) FROM t3;
-COUNT(*)
-17920
-DROP TABLE t1, t3;
-==== Read binlog from telco tree (mysql-5.1-telco-6.1) ====
-SELECT * FROM t1 ORDER BY a;
-a b
-0 last_insert_id
-1 one
-3 last stm in trx: next event should be xid
-4 four
-703356 random
-SELECT * FROM t2 ORDER BY a;
-a b
-3 first stm in trx
-SELECT COUNT(*) FROM t3;
-COUNT(*)
-17920
-DROP TABLE t1, t2, t3;
diff --git a/mysql-test/suite/binlog/r/binlog_row_ctype_ucs.result b/mysql-test/suite/binlog/r/binlog_row_ctype_ucs.result
index c02912b8..de8a9e89 100644
--- a/mysql-test/suite/binlog/r/binlog_row_ctype_ucs.result
+++ b/mysql-test/suite/binlog/r/binlog_row_ctype_ucs.result
@@ -97,6 +97,7 @@ SET @@session.sql_mode=1411383296/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C utf8mb3 *//*!*/;
SET @@session.character_set_client=X,@@session.collation_connection=X,@@session.collation_server=X/*!*/;
+SET @@session.character_set_collations=''/*!*/;
SET @@session.lc_time_names=0/*!*/;
SET @@session.collation_database=DEFAULT/*!*/;
CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET utf8)
diff --git a/mysql-test/suite/binlog/r/binlog_row_img.result b/mysql-test/suite/binlog/r/binlog_row_img.result
new file mode 100644
index 00000000..b4c4f26e
--- /dev/null
+++ b/mysql-test/suite/binlog/r/binlog_row_img.result
@@ -0,0 +1,1365 @@
+#
+# FULL_NODUP mode works as expected
+#
+SET binlog_row_image = "FULL_NODUP";
+CREATE TABLE t1 (c1 INT PRIMARY KEY, c2 varchar(100),
+c3 INT DEFAULT 1000, c4 TEXT);
+CREATE TABLE t2 (c1 INT, c2 char(100), c3 INT DEFAULT 1000, c4 TEXT);
+FLUSH BINARY LOGS;
+
+#########################################################################
+# binlog_row_image = FULL_NODUP
+#########################################################################
+
+INSERT INTO t1 VALUES(1, "insert_to_t1", 1, repeat('a', 20)),
+(2, "insert_to_t1", 2, repeat('a', 20)),
+(3, "insert_to_t1", 3, repeat('a', 20));
+INSERT INTO t1(c1) VALUES(4);
+UPDATE t1 SET c2 = "only_c2_changed";
+UPDATE t1 SET c3 = 1, c4 = "c3_c4_changed";
+DELETE FROM t1 WHERE c1 = 1;
+
+# Verify that rows events are binlogged as expeced.
+
+/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
+DELIMITER /*!*/;
+# Warning: this binlog is either in use or was not closed properly.
+START TRANSACTION
+/*!*/;
+#Q> INSERT INTO t1 VALUES(1, "insert_to_t1", 1, repeat('a', 20)),
+#Q> (2, "insert_to_t1", 2, repeat('a', 20)),
+#Q> (3, "insert_to_t1", 3, repeat('a', 20))
+### INSERT INTO `test`.`t1`
+### SET
+### @1=1 /* INT meta=0 nullable=0 is_null=0 */
+### @2='insert_to_t1' /* VARSTRING(100) meta=100 nullable=1 is_null=0 */
+### @3=1 /* INT meta=0 nullable=1 is_null=0 */
+### @4='aaaaaaaaaaaaaaaaaaaa' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### INSERT INTO `test`.`t1`
+### SET
+### @1=2 /* INT meta=0 nullable=0 is_null=0 */
+### @2='insert_to_t1' /* VARSTRING(100) meta=100 nullable=1 is_null=0 */
+### @3=2 /* INT meta=0 nullable=1 is_null=0 */
+### @4='aaaaaaaaaaaaaaaaaaaa' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### INSERT INTO `test`.`t1`
+### SET
+### @1=3 /* INT meta=0 nullable=0 is_null=0 */
+### @2='insert_to_t1' /* VARSTRING(100) meta=100 nullable=1 is_null=0 */
+### @3=3 /* INT meta=0 nullable=1 is_null=0 */
+### @4='aaaaaaaaaaaaaaaaaaaa' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+# Number of rows: 3
+/*!\C latin1 *//*!*/;
+COMMIT
+/*!*/;
+START TRANSACTION
+/*!*/;
+#Q> INSERT INTO t1(c1) VALUES(4)
+### INSERT INTO `test`.`t1`
+### SET
+### @1=4 /* INT meta=0 nullable=0 is_null=0 */
+### @2=NULL /* VARSTRING(100) meta=100 nullable=1 is_null=1 */
+### @3=1000 /* INT meta=0 nullable=1 is_null=0 */
+### @4=NULL /* BLOB/TEXT meta=2 nullable=1 is_null=1 */
+# Number of rows: 1
+COMMIT
+/*!*/;
+START TRANSACTION
+/*!*/;
+#Q> UPDATE t1 SET c2 = "only_c2_changed"
+### UPDATE `test`.`t1`
+### WHERE
+### @1=1 /* INT meta=0 nullable=0 is_null=0 */
+### @2='insert_to_t1' /* VARSTRING(100) meta=100 nullable=1 is_null=0 */
+### @3=1 /* INT meta=0 nullable=1 is_null=0 */
+### @4='aaaaaaaaaaaaaaaaaaaa' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### SET
+### @2='only_c2_changed' /* VARSTRING(100) meta=100 nullable=1 is_null=0 */
+### UPDATE `test`.`t1`
+### WHERE
+### @1=2 /* INT meta=0 nullable=0 is_null=0 */
+### @2='insert_to_t1' /* VARSTRING(100) meta=100 nullable=1 is_null=0 */
+### @3=2 /* INT meta=0 nullable=1 is_null=0 */
+### @4='aaaaaaaaaaaaaaaaaaaa' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### SET
+### @2='only_c2_changed' /* VARSTRING(100) meta=100 nullable=1 is_null=0 */
+### UPDATE `test`.`t1`
+### WHERE
+### @1=3 /* INT meta=0 nullable=0 is_null=0 */
+### @2='insert_to_t1' /* VARSTRING(100) meta=100 nullable=1 is_null=0 */
+### @3=3 /* INT meta=0 nullable=1 is_null=0 */
+### @4='aaaaaaaaaaaaaaaaaaaa' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### SET
+### @2='only_c2_changed' /* VARSTRING(100) meta=100 nullable=1 is_null=0 */
+### UPDATE `test`.`t1`
+### WHERE
+### @1=4 /* INT meta=0 nullable=0 is_null=0 */
+### @2=NULL /* VARSTRING(100) meta=100 nullable=1 is_null=1 */
+### @3=1000 /* INT meta=0 nullable=1 is_null=0 */
+### @4=NULL /* BLOB/TEXT meta=2 nullable=1 is_null=1 */
+### SET
+### @2='only_c2_changed' /* VARSTRING(100) meta=100 nullable=1 is_null=0 */
+# Number of rows: 4
+COMMIT
+/*!*/;
+START TRANSACTION
+/*!*/;
+#Q> UPDATE t1 SET c3 = 1, c4 = "c3_c4_changed"
+### UPDATE `test`.`t1`
+### WHERE
+### @1=1 /* INT meta=0 nullable=0 is_null=0 */
+### @2='only_c2_changed' /* VARSTRING(100) meta=100 nullable=1 is_null=0 */
+### @3=1 /* INT meta=0 nullable=1 is_null=0 */
+### @4='aaaaaaaaaaaaaaaaaaaa' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### SET
+### @3=1 /* INT meta=0 nullable=1 is_null=0 */
+### @4='c3_c4_changed' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### UPDATE `test`.`t1`
+### WHERE
+### @1=2 /* INT meta=0 nullable=0 is_null=0 */
+### @2='only_c2_changed' /* VARSTRING(100) meta=100 nullable=1 is_null=0 */
+### @3=2 /* INT meta=0 nullable=1 is_null=0 */
+### @4='aaaaaaaaaaaaaaaaaaaa' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### SET
+### @3=1 /* INT meta=0 nullable=1 is_null=0 */
+### @4='c3_c4_changed' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### UPDATE `test`.`t1`
+### WHERE
+### @1=3 /* INT meta=0 nullable=0 is_null=0 */
+### @2='only_c2_changed' /* VARSTRING(100) meta=100 nullable=1 is_null=0 */
+### @3=3 /* INT meta=0 nullable=1 is_null=0 */
+### @4='aaaaaaaaaaaaaaaaaaaa' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### SET
+### @3=1 /* INT meta=0 nullable=1 is_null=0 */
+### @4='c3_c4_changed' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### UPDATE `test`.`t1`
+### WHERE
+### @1=4 /* INT meta=0 nullable=0 is_null=0 */
+### @2='only_c2_changed' /* VARSTRING(100) meta=100 nullable=1 is_null=0 */
+### @3=1000 /* INT meta=0 nullable=1 is_null=0 */
+### @4=NULL /* BLOB/TEXT meta=2 nullable=1 is_null=1 */
+### SET
+### @3=1 /* INT meta=0 nullable=1 is_null=0 */
+### @4='c3_c4_changed' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+# Number of rows: 4
+COMMIT
+/*!*/;
+START TRANSACTION
+/*!*/;
+#Q> DELETE FROM t1 WHERE c1 = 1
+### DELETE FROM `test`.`t1`
+### WHERE
+### @1=1 /* INT meta=0 nullable=0 is_null=0 */
+### @2='only_c2_changed' /* VARSTRING(100) meta=100 nullable=1 is_null=0 */
+### @3=1 /* INT meta=0 nullable=1 is_null=0 */
+### @4='c3_c4_changed' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+# Number of rows: 1
+COMMIT
+/*!*/;
+DELIMITER ;
+# End of log file
+ROLLBACK /* added by mysqlbinlog */;
+/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
+FLUSH BINARY LOGS;
+
+# t2 has no primary key.
+# It will binlog full before and after image for all modes if the
+# table has no primary key. FULL_NODUP follows the behavior.
+
+INSERT INTO t2 VALUES(1, "insert_to_t2", 1, repeat('a', 20)),
+(2, "insert_to_t2", 2, repeat('a', 20)),
+(3, "insert_to_t2", 3, repeat('a', 20));
+INSERT INTO t2(c1) VALUES(4);
+UPDATE t2 SET c2 = "only_c2_changed";
+UPDATE t2 SET c3 = 1, c4 = "c3_c4_changed";
+DELETE FROM t2 WHERE c1 > 2;
+
+# Verify that rows events are binlogged as expeced.
+
+/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
+DELIMITER /*!*/;
+# Warning: this binlog is either in use or was not closed properly.
+START TRANSACTION
+/*!*/;
+#Q> INSERT INTO t2 VALUES(1, "insert_to_t2", 1, repeat('a', 20)),
+#Q> (2, "insert_to_t2", 2, repeat('a', 20)),
+#Q> (3, "insert_to_t2", 3, repeat('a', 20))
+### INSERT INTO `test`.`t2`
+### SET
+### @1=1 /* INT meta=0 nullable=1 is_null=0 */
+### @2='insert_to_t2' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=1 /* INT meta=0 nullable=1 is_null=0 */
+### @4='aaaaaaaaaaaaaaaaaaaa' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### INSERT INTO `test`.`t2`
+### SET
+### @1=2 /* INT meta=0 nullable=1 is_null=0 */
+### @2='insert_to_t2' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=2 /* INT meta=0 nullable=1 is_null=0 */
+### @4='aaaaaaaaaaaaaaaaaaaa' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### INSERT INTO `test`.`t2`
+### SET
+### @1=3 /* INT meta=0 nullable=1 is_null=0 */
+### @2='insert_to_t2' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=3 /* INT meta=0 nullable=1 is_null=0 */
+### @4='aaaaaaaaaaaaaaaaaaaa' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+# Number of rows: 3
+/*!\C latin1 *//*!*/;
+COMMIT
+/*!*/;
+START TRANSACTION
+/*!*/;
+#Q> INSERT INTO t2(c1) VALUES(4)
+### INSERT INTO `test`.`t2`
+### SET
+### @1=4 /* INT meta=0 nullable=1 is_null=0 */
+### @2=NULL /* STRING(100) meta=65124 nullable=1 is_null=1 */
+### @3=1000 /* INT meta=0 nullable=1 is_null=0 */
+### @4=NULL /* BLOB/TEXT meta=2 nullable=1 is_null=1 */
+# Number of rows: 1
+COMMIT
+/*!*/;
+START TRANSACTION
+/*!*/;
+#Q> UPDATE t2 SET c2 = "only_c2_changed"
+### UPDATE `test`.`t2`
+### WHERE
+### @1=1 /* INT meta=0 nullable=1 is_null=0 */
+### @2='insert_to_t2' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=1 /* INT meta=0 nullable=1 is_null=0 */
+### @4='aaaaaaaaaaaaaaaaaaaa' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### SET
+### @1=1 /* INT meta=0 nullable=1 is_null=0 */
+### @2='only_c2_changed' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=1 /* INT meta=0 nullable=1 is_null=0 */
+### @4='aaaaaaaaaaaaaaaaaaaa' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### UPDATE `test`.`t2`
+### WHERE
+### @1=2 /* INT meta=0 nullable=1 is_null=0 */
+### @2='insert_to_t2' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=2 /* INT meta=0 nullable=1 is_null=0 */
+### @4='aaaaaaaaaaaaaaaaaaaa' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### SET
+### @1=2 /* INT meta=0 nullable=1 is_null=0 */
+### @2='only_c2_changed' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=2 /* INT meta=0 nullable=1 is_null=0 */
+### @4='aaaaaaaaaaaaaaaaaaaa' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### UPDATE `test`.`t2`
+### WHERE
+### @1=3 /* INT meta=0 nullable=1 is_null=0 */
+### @2='insert_to_t2' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=3 /* INT meta=0 nullable=1 is_null=0 */
+### @4='aaaaaaaaaaaaaaaaaaaa' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### SET
+### @1=3 /* INT meta=0 nullable=1 is_null=0 */
+### @2='only_c2_changed' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=3 /* INT meta=0 nullable=1 is_null=0 */
+### @4='aaaaaaaaaaaaaaaaaaaa' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### UPDATE `test`.`t2`
+### WHERE
+### @1=4 /* INT meta=0 nullable=1 is_null=0 */
+### @2=NULL /* STRING(100) meta=65124 nullable=1 is_null=1 */
+### @3=1000 /* INT meta=0 nullable=1 is_null=0 */
+### @4=NULL /* BLOB/TEXT meta=2 nullable=1 is_null=1 */
+### SET
+### @1=4 /* INT meta=0 nullable=1 is_null=0 */
+### @2='only_c2_changed' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=1000 /* INT meta=0 nullable=1 is_null=0 */
+### @4=NULL /* BLOB/TEXT meta=2 nullable=1 is_null=1 */
+# Number of rows: 4
+COMMIT
+/*!*/;
+START TRANSACTION
+/*!*/;
+#Q> UPDATE t2 SET c3 = 1, c4 = "c3_c4_changed"
+### UPDATE `test`.`t2`
+### WHERE
+### @1=1 /* INT meta=0 nullable=1 is_null=0 */
+### @2='only_c2_changed' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=1 /* INT meta=0 nullable=1 is_null=0 */
+### @4='aaaaaaaaaaaaaaaaaaaa' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### SET
+### @1=1 /* INT meta=0 nullable=1 is_null=0 */
+### @2='only_c2_changed' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=1 /* INT meta=0 nullable=1 is_null=0 */
+### @4='c3_c4_changed' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### UPDATE `test`.`t2`
+### WHERE
+### @1=2 /* INT meta=0 nullable=1 is_null=0 */
+### @2='only_c2_changed' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=2 /* INT meta=0 nullable=1 is_null=0 */
+### @4='aaaaaaaaaaaaaaaaaaaa' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### SET
+### @1=2 /* INT meta=0 nullable=1 is_null=0 */
+### @2='only_c2_changed' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=1 /* INT meta=0 nullable=1 is_null=0 */
+### @4='c3_c4_changed' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### UPDATE `test`.`t2`
+### WHERE
+### @1=3 /* INT meta=0 nullable=1 is_null=0 */
+### @2='only_c2_changed' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=3 /* INT meta=0 nullable=1 is_null=0 */
+### @4='aaaaaaaaaaaaaaaaaaaa' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### SET
+### @1=3 /* INT meta=0 nullable=1 is_null=0 */
+### @2='only_c2_changed' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=1 /* INT meta=0 nullable=1 is_null=0 */
+### @4='c3_c4_changed' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### UPDATE `test`.`t2`
+### WHERE
+### @1=4 /* INT meta=0 nullable=1 is_null=0 */
+### @2='only_c2_changed' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=1000 /* INT meta=0 nullable=1 is_null=0 */
+### @4=NULL /* BLOB/TEXT meta=2 nullable=1 is_null=1 */
+### SET
+### @1=4 /* INT meta=0 nullable=1 is_null=0 */
+### @2='only_c2_changed' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=1 /* INT meta=0 nullable=1 is_null=0 */
+### @4='c3_c4_changed' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+# Number of rows: 4
+COMMIT
+/*!*/;
+START TRANSACTION
+/*!*/;
+#Q> DELETE FROM t2 WHERE c1 > 2
+### DELETE FROM `test`.`t2`
+### WHERE
+### @1=3 /* INT meta=0 nullable=1 is_null=0 */
+### @2='only_c2_changed' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=1 /* INT meta=0 nullable=1 is_null=0 */
+### @4='c3_c4_changed' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### DELETE FROM `test`.`t2`
+### WHERE
+### @1=4 /* INT meta=0 nullable=1 is_null=0 */
+### @2='only_c2_changed' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=1 /* INT meta=0 nullable=1 is_null=0 */
+### @4='c3_c4_changed' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+# Number of rows: 2
+COMMIT
+/*!*/;
+DELIMITER ;
+# End of log file
+ROLLBACK /* added by mysqlbinlog */;
+/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
+DROP TABLE t1, t2;
+#
+# MINIMAL mode works as expected
+#
+SET binlog_row_image = "MINIMAL";
+CREATE TABLE t1 (c1 INT PRIMARY KEY, c2 varchar(100),
+c3 INT DEFAULT 1000, c4 TEXT);
+CREATE TABLE t2 (c1 INT, c2 char(100), c3 INT DEFAULT 1000, c4 TEXT);
+FLUSH BINARY LOGS;
+
+#########################################################################
+# binlog_row_image = MINIMAL
+#########################################################################
+
+INSERT INTO t1 VALUES(1, "insert_to_t1", 1, repeat('a', 20)),
+(2, "insert_to_t1", 2, repeat('a', 20)),
+(3, "insert_to_t1", 3, repeat('a', 20));
+INSERT INTO t1(c1) VALUES(4);
+UPDATE t1 SET c2 = "only_c2_changed";
+UPDATE t1 SET c3 = 1, c4 = "c3_c4_changed";
+DELETE FROM t1 WHERE c1 = 1;
+
+# Verify that rows events are binlogged as expeced.
+
+/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
+DELIMITER /*!*/;
+# Warning: this binlog is either in use or was not closed properly.
+START TRANSACTION
+/*!*/;
+#Q> INSERT INTO t1 VALUES(1, "insert_to_t1", 1, repeat('a', 20)),
+#Q> (2, "insert_to_t1", 2, repeat('a', 20)),
+#Q> (3, "insert_to_t1", 3, repeat('a', 20))
+### INSERT INTO `test`.`t1`
+### SET
+### @1=1 /* INT meta=0 nullable=0 is_null=0 */
+### @2='insert_to_t1' /* VARSTRING(100) meta=100 nullable=1 is_null=0 */
+### @3=1 /* INT meta=0 nullable=1 is_null=0 */
+### @4='aaaaaaaaaaaaaaaaaaaa' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### INSERT INTO `test`.`t1`
+### SET
+### @1=2 /* INT meta=0 nullable=0 is_null=0 */
+### @2='insert_to_t1' /* VARSTRING(100) meta=100 nullable=1 is_null=0 */
+### @3=2 /* INT meta=0 nullable=1 is_null=0 */
+### @4='aaaaaaaaaaaaaaaaaaaa' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### INSERT INTO `test`.`t1`
+### SET
+### @1=3 /* INT meta=0 nullable=0 is_null=0 */
+### @2='insert_to_t1' /* VARSTRING(100) meta=100 nullable=1 is_null=0 */
+### @3=3 /* INT meta=0 nullable=1 is_null=0 */
+### @4='aaaaaaaaaaaaaaaaaaaa' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+# Number of rows: 3
+/*!\C latin1 *//*!*/;
+COMMIT
+/*!*/;
+START TRANSACTION
+/*!*/;
+#Q> INSERT INTO t1(c1) VALUES(4)
+### INSERT INTO `test`.`t1`
+### SET
+### @1=4 /* INT meta=0 nullable=0 is_null=0 */
+# Number of rows: 1
+COMMIT
+/*!*/;
+START TRANSACTION
+/*!*/;
+#Q> UPDATE t1 SET c2 = "only_c2_changed"
+### UPDATE `test`.`t1`
+### WHERE
+### @1=1 /* INT meta=0 nullable=0 is_null=0 */
+### SET
+### @2='only_c2_changed' /* VARSTRING(100) meta=100 nullable=1 is_null=0 */
+### UPDATE `test`.`t1`
+### WHERE
+### @1=2 /* INT meta=0 nullable=0 is_null=0 */
+### SET
+### @2='only_c2_changed' /* VARSTRING(100) meta=100 nullable=1 is_null=0 */
+### UPDATE `test`.`t1`
+### WHERE
+### @1=3 /* INT meta=0 nullable=0 is_null=0 */
+### SET
+### @2='only_c2_changed' /* VARSTRING(100) meta=100 nullable=1 is_null=0 */
+### UPDATE `test`.`t1`
+### WHERE
+### @1=4 /* INT meta=0 nullable=0 is_null=0 */
+### SET
+### @2='only_c2_changed' /* VARSTRING(100) meta=100 nullable=1 is_null=0 */
+# Number of rows: 4
+COMMIT
+/*!*/;
+START TRANSACTION
+/*!*/;
+#Q> UPDATE t1 SET c3 = 1, c4 = "c3_c4_changed"
+### UPDATE `test`.`t1`
+### WHERE
+### @1=1 /* INT meta=0 nullable=0 is_null=0 */
+### SET
+### @3=1 /* INT meta=0 nullable=1 is_null=0 */
+### @4='c3_c4_changed' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### UPDATE `test`.`t1`
+### WHERE
+### @1=2 /* INT meta=0 nullable=0 is_null=0 */
+### SET
+### @3=1 /* INT meta=0 nullable=1 is_null=0 */
+### @4='c3_c4_changed' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### UPDATE `test`.`t1`
+### WHERE
+### @1=3 /* INT meta=0 nullable=0 is_null=0 */
+### SET
+### @3=1 /* INT meta=0 nullable=1 is_null=0 */
+### @4='c3_c4_changed' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### UPDATE `test`.`t1`
+### WHERE
+### @1=4 /* INT meta=0 nullable=0 is_null=0 */
+### SET
+### @3=1 /* INT meta=0 nullable=1 is_null=0 */
+### @4='c3_c4_changed' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+# Number of rows: 4
+COMMIT
+/*!*/;
+START TRANSACTION
+/*!*/;
+#Q> DELETE FROM t1 WHERE c1 = 1
+### DELETE FROM `test`.`t1`
+### WHERE
+### @1=1 /* INT meta=0 nullable=0 is_null=0 */
+# Number of rows: 1
+COMMIT
+/*!*/;
+DELIMITER ;
+# End of log file
+ROLLBACK /* added by mysqlbinlog */;
+/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
+FLUSH BINARY LOGS;
+
+# t2 has no primary key.
+# It will binlog full before and after image for all modes if the
+# table has no primary key. FULL_NODUP follows the behavior.
+
+INSERT INTO t2 VALUES(1, "insert_to_t2", 1, repeat('a', 20)),
+(2, "insert_to_t2", 2, repeat('a', 20)),
+(3, "insert_to_t2", 3, repeat('a', 20));
+INSERT INTO t2(c1) VALUES(4);
+UPDATE t2 SET c2 = "only_c2_changed";
+UPDATE t2 SET c3 = 1, c4 = "c3_c4_changed";
+DELETE FROM t2 WHERE c1 > 2;
+
+# Verify that rows events are binlogged as expeced.
+
+/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
+DELIMITER /*!*/;
+# Warning: this binlog is either in use or was not closed properly.
+START TRANSACTION
+/*!*/;
+#Q> INSERT INTO t2 VALUES(1, "insert_to_t2", 1, repeat('a', 20)),
+#Q> (2, "insert_to_t2", 2, repeat('a', 20)),
+#Q> (3, "insert_to_t2", 3, repeat('a', 20))
+### INSERT INTO `test`.`t2`
+### SET
+### @1=1 /* INT meta=0 nullable=1 is_null=0 */
+### @2='insert_to_t2' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=1 /* INT meta=0 nullable=1 is_null=0 */
+### @4='aaaaaaaaaaaaaaaaaaaa' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### INSERT INTO `test`.`t2`
+### SET
+### @1=2 /* INT meta=0 nullable=1 is_null=0 */
+### @2='insert_to_t2' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=2 /* INT meta=0 nullable=1 is_null=0 */
+### @4='aaaaaaaaaaaaaaaaaaaa' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### INSERT INTO `test`.`t2`
+### SET
+### @1=3 /* INT meta=0 nullable=1 is_null=0 */
+### @2='insert_to_t2' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=3 /* INT meta=0 nullable=1 is_null=0 */
+### @4='aaaaaaaaaaaaaaaaaaaa' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+# Number of rows: 3
+/*!\C latin1 *//*!*/;
+COMMIT
+/*!*/;
+START TRANSACTION
+/*!*/;
+#Q> INSERT INTO t2(c1) VALUES(4)
+### INSERT INTO `test`.`t2`
+### SET
+### @1=4 /* INT meta=0 nullable=1 is_null=0 */
+### @2=NULL /* STRING(100) meta=65124 nullable=1 is_null=1 */
+### @3=1000 /* INT meta=0 nullable=1 is_null=0 */
+### @4=NULL /* BLOB/TEXT meta=2 nullable=1 is_null=1 */
+# Number of rows: 1
+COMMIT
+/*!*/;
+START TRANSACTION
+/*!*/;
+#Q> UPDATE t2 SET c2 = "only_c2_changed"
+### UPDATE `test`.`t2`
+### WHERE
+### @1=1 /* INT meta=0 nullable=1 is_null=0 */
+### @2='insert_to_t2' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=1 /* INT meta=0 nullable=1 is_null=0 */
+### @4='aaaaaaaaaaaaaaaaaaaa' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### SET
+### @1=1 /* INT meta=0 nullable=1 is_null=0 */
+### @2='only_c2_changed' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=1 /* INT meta=0 nullable=1 is_null=0 */
+### @4='aaaaaaaaaaaaaaaaaaaa' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### UPDATE `test`.`t2`
+### WHERE
+### @1=2 /* INT meta=0 nullable=1 is_null=0 */
+### @2='insert_to_t2' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=2 /* INT meta=0 nullable=1 is_null=0 */
+### @4='aaaaaaaaaaaaaaaaaaaa' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### SET
+### @1=2 /* INT meta=0 nullable=1 is_null=0 */
+### @2='only_c2_changed' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=2 /* INT meta=0 nullable=1 is_null=0 */
+### @4='aaaaaaaaaaaaaaaaaaaa' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### UPDATE `test`.`t2`
+### WHERE
+### @1=3 /* INT meta=0 nullable=1 is_null=0 */
+### @2='insert_to_t2' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=3 /* INT meta=0 nullable=1 is_null=0 */
+### @4='aaaaaaaaaaaaaaaaaaaa' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### SET
+### @1=3 /* INT meta=0 nullable=1 is_null=0 */
+### @2='only_c2_changed' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=3 /* INT meta=0 nullable=1 is_null=0 */
+### @4='aaaaaaaaaaaaaaaaaaaa' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### UPDATE `test`.`t2`
+### WHERE
+### @1=4 /* INT meta=0 nullable=1 is_null=0 */
+### @2=NULL /* STRING(100) meta=65124 nullable=1 is_null=1 */
+### @3=1000 /* INT meta=0 nullable=1 is_null=0 */
+### @4=NULL /* BLOB/TEXT meta=2 nullable=1 is_null=1 */
+### SET
+### @1=4 /* INT meta=0 nullable=1 is_null=0 */
+### @2='only_c2_changed' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=1000 /* INT meta=0 nullable=1 is_null=0 */
+### @4=NULL /* BLOB/TEXT meta=2 nullable=1 is_null=1 */
+# Number of rows: 4
+COMMIT
+/*!*/;
+START TRANSACTION
+/*!*/;
+#Q> UPDATE t2 SET c3 = 1, c4 = "c3_c4_changed"
+### UPDATE `test`.`t2`
+### WHERE
+### @1=1 /* INT meta=0 nullable=1 is_null=0 */
+### @2='only_c2_changed' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=1 /* INT meta=0 nullable=1 is_null=0 */
+### @4='aaaaaaaaaaaaaaaaaaaa' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### SET
+### @1=1 /* INT meta=0 nullable=1 is_null=0 */
+### @2='only_c2_changed' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=1 /* INT meta=0 nullable=1 is_null=0 */
+### @4='c3_c4_changed' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### UPDATE `test`.`t2`
+### WHERE
+### @1=2 /* INT meta=0 nullable=1 is_null=0 */
+### @2='only_c2_changed' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=2 /* INT meta=0 nullable=1 is_null=0 */
+### @4='aaaaaaaaaaaaaaaaaaaa' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### SET
+### @1=2 /* INT meta=0 nullable=1 is_null=0 */
+### @2='only_c2_changed' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=1 /* INT meta=0 nullable=1 is_null=0 */
+### @4='c3_c4_changed' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### UPDATE `test`.`t2`
+### WHERE
+### @1=3 /* INT meta=0 nullable=1 is_null=0 */
+### @2='only_c2_changed' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=3 /* INT meta=0 nullable=1 is_null=0 */
+### @4='aaaaaaaaaaaaaaaaaaaa' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### SET
+### @1=3 /* INT meta=0 nullable=1 is_null=0 */
+### @2='only_c2_changed' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=1 /* INT meta=0 nullable=1 is_null=0 */
+### @4='c3_c4_changed' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### UPDATE `test`.`t2`
+### WHERE
+### @1=4 /* INT meta=0 nullable=1 is_null=0 */
+### @2='only_c2_changed' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=1000 /* INT meta=0 nullable=1 is_null=0 */
+### @4=NULL /* BLOB/TEXT meta=2 nullable=1 is_null=1 */
+### SET
+### @1=4 /* INT meta=0 nullable=1 is_null=0 */
+### @2='only_c2_changed' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=1 /* INT meta=0 nullable=1 is_null=0 */
+### @4='c3_c4_changed' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+# Number of rows: 4
+COMMIT
+/*!*/;
+START TRANSACTION
+/*!*/;
+#Q> DELETE FROM t2 WHERE c1 > 2
+### DELETE FROM `test`.`t2`
+### WHERE
+### @1=3 /* INT meta=0 nullable=1 is_null=0 */
+### @2='only_c2_changed' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=1 /* INT meta=0 nullable=1 is_null=0 */
+### @4='c3_c4_changed' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### DELETE FROM `test`.`t2`
+### WHERE
+### @1=4 /* INT meta=0 nullable=1 is_null=0 */
+### @2='only_c2_changed' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=1 /* INT meta=0 nullable=1 is_null=0 */
+### @4='c3_c4_changed' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+# Number of rows: 2
+COMMIT
+/*!*/;
+DELIMITER ;
+# End of log file
+ROLLBACK /* added by mysqlbinlog */;
+/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
+DROP TABLE t1, t2;
+#
+# NOBLOB mode works as expected
+#
+SET binlog_row_image = "NOBLOB";
+CREATE TABLE t1 (c1 INT PRIMARY KEY, c2 varchar(100),
+c3 INT DEFAULT 1000, c4 TEXT);
+CREATE TABLE t2 (c1 INT, c2 char(100), c3 INT DEFAULT 1000, c4 TEXT);
+FLUSH BINARY LOGS;
+
+#########################################################################
+# binlog_row_image = NOBLOB
+#########################################################################
+
+INSERT INTO t1 VALUES(1, "insert_to_t1", 1, repeat('a', 20)),
+(2, "insert_to_t1", 2, repeat('a', 20)),
+(3, "insert_to_t1", 3, repeat('a', 20));
+INSERT INTO t1(c1) VALUES(4);
+UPDATE t1 SET c2 = "only_c2_changed";
+UPDATE t1 SET c3 = 1, c4 = "c3_c4_changed";
+DELETE FROM t1 WHERE c1 = 1;
+
+# Verify that rows events are binlogged as expeced.
+
+/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
+DELIMITER /*!*/;
+# Warning: this binlog is either in use or was not closed properly.
+START TRANSACTION
+/*!*/;
+#Q> INSERT INTO t1 VALUES(1, "insert_to_t1", 1, repeat('a', 20)),
+#Q> (2, "insert_to_t1", 2, repeat('a', 20)),
+#Q> (3, "insert_to_t1", 3, repeat('a', 20))
+### INSERT INTO `test`.`t1`
+### SET
+### @1=1 /* INT meta=0 nullable=0 is_null=0 */
+### @2='insert_to_t1' /* VARSTRING(100) meta=100 nullable=1 is_null=0 */
+### @3=1 /* INT meta=0 nullable=1 is_null=0 */
+### @4='aaaaaaaaaaaaaaaaaaaa' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### INSERT INTO `test`.`t1`
+### SET
+### @1=2 /* INT meta=0 nullable=0 is_null=0 */
+### @2='insert_to_t1' /* VARSTRING(100) meta=100 nullable=1 is_null=0 */
+### @3=2 /* INT meta=0 nullable=1 is_null=0 */
+### @4='aaaaaaaaaaaaaaaaaaaa' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### INSERT INTO `test`.`t1`
+### SET
+### @1=3 /* INT meta=0 nullable=0 is_null=0 */
+### @2='insert_to_t1' /* VARSTRING(100) meta=100 nullable=1 is_null=0 */
+### @3=3 /* INT meta=0 nullable=1 is_null=0 */
+### @4='aaaaaaaaaaaaaaaaaaaa' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+# Number of rows: 3
+/*!\C latin1 *//*!*/;
+COMMIT
+/*!*/;
+START TRANSACTION
+/*!*/;
+#Q> INSERT INTO t1(c1) VALUES(4)
+### INSERT INTO `test`.`t1`
+### SET
+### @1=4 /* INT meta=0 nullable=0 is_null=0 */
+### @2=NULL /* VARSTRING(100) meta=100 nullable=1 is_null=1 */
+### @3=1000 /* INT meta=0 nullable=1 is_null=0 */
+# Number of rows: 1
+COMMIT
+/*!*/;
+START TRANSACTION
+/*!*/;
+#Q> UPDATE t1 SET c2 = "only_c2_changed"
+### UPDATE `test`.`t1`
+### WHERE
+### @1=1 /* INT meta=0 nullable=0 is_null=0 */
+### @2='insert_to_t1' /* VARSTRING(100) meta=100 nullable=1 is_null=0 */
+### @3=1 /* INT meta=0 nullable=1 is_null=0 */
+### SET
+### @1=1 /* INT meta=0 nullable=0 is_null=0 */
+### @2='only_c2_changed' /* VARSTRING(100) meta=100 nullable=1 is_null=0 */
+### @3=1 /* INT meta=0 nullable=1 is_null=0 */
+### UPDATE `test`.`t1`
+### WHERE
+### @1=2 /* INT meta=0 nullable=0 is_null=0 */
+### @2='insert_to_t1' /* VARSTRING(100) meta=100 nullable=1 is_null=0 */
+### @3=2 /* INT meta=0 nullable=1 is_null=0 */
+### SET
+### @1=2 /* INT meta=0 nullable=0 is_null=0 */
+### @2='only_c2_changed' /* VARSTRING(100) meta=100 nullable=1 is_null=0 */
+### @3=2 /* INT meta=0 nullable=1 is_null=0 */
+### UPDATE `test`.`t1`
+### WHERE
+### @1=3 /* INT meta=0 nullable=0 is_null=0 */
+### @2='insert_to_t1' /* VARSTRING(100) meta=100 nullable=1 is_null=0 */
+### @3=3 /* INT meta=0 nullable=1 is_null=0 */
+### SET
+### @1=3 /* INT meta=0 nullable=0 is_null=0 */
+### @2='only_c2_changed' /* VARSTRING(100) meta=100 nullable=1 is_null=0 */
+### @3=3 /* INT meta=0 nullable=1 is_null=0 */
+### UPDATE `test`.`t1`
+### WHERE
+### @1=4 /* INT meta=0 nullable=0 is_null=0 */
+### @2=NULL /* VARSTRING(100) meta=100 nullable=1 is_null=1 */
+### @3=1000 /* INT meta=0 nullable=1 is_null=0 */
+### SET
+### @1=4 /* INT meta=0 nullable=0 is_null=0 */
+### @2='only_c2_changed' /* VARSTRING(100) meta=100 nullable=1 is_null=0 */
+### @3=1000 /* INT meta=0 nullable=1 is_null=0 */
+# Number of rows: 4
+COMMIT
+/*!*/;
+START TRANSACTION
+/*!*/;
+#Q> UPDATE t1 SET c3 = 1, c4 = "c3_c4_changed"
+### UPDATE `test`.`t1`
+### WHERE
+### @1=1 /* INT meta=0 nullable=0 is_null=0 */
+### @2='only_c2_changed' /* VARSTRING(100) meta=100 nullable=1 is_null=0 */
+### @3=1 /* INT meta=0 nullable=1 is_null=0 */
+### SET
+### @1=1 /* INT meta=0 nullable=0 is_null=0 */
+### @2='only_c2_changed' /* VARSTRING(100) meta=100 nullable=1 is_null=0 */
+### @3=1 /* INT meta=0 nullable=1 is_null=0 */
+### @4='c3_c4_changed' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### UPDATE `test`.`t1`
+### WHERE
+### @1=2 /* INT meta=0 nullable=0 is_null=0 */
+### @2='only_c2_changed' /* VARSTRING(100) meta=100 nullable=1 is_null=0 */
+### @3=2 /* INT meta=0 nullable=1 is_null=0 */
+### SET
+### @1=2 /* INT meta=0 nullable=0 is_null=0 */
+### @2='only_c2_changed' /* VARSTRING(100) meta=100 nullable=1 is_null=0 */
+### @3=1 /* INT meta=0 nullable=1 is_null=0 */
+### @4='c3_c4_changed' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### UPDATE `test`.`t1`
+### WHERE
+### @1=3 /* INT meta=0 nullable=0 is_null=0 */
+### @2='only_c2_changed' /* VARSTRING(100) meta=100 nullable=1 is_null=0 */
+### @3=3 /* INT meta=0 nullable=1 is_null=0 */
+### SET
+### @1=3 /* INT meta=0 nullable=0 is_null=0 */
+### @2='only_c2_changed' /* VARSTRING(100) meta=100 nullable=1 is_null=0 */
+### @3=1 /* INT meta=0 nullable=1 is_null=0 */
+### @4='c3_c4_changed' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### UPDATE `test`.`t1`
+### WHERE
+### @1=4 /* INT meta=0 nullable=0 is_null=0 */
+### @2='only_c2_changed' /* VARSTRING(100) meta=100 nullable=1 is_null=0 */
+### @3=1000 /* INT meta=0 nullable=1 is_null=0 */
+### SET
+### @1=4 /* INT meta=0 nullable=0 is_null=0 */
+### @2='only_c2_changed' /* VARSTRING(100) meta=100 nullable=1 is_null=0 */
+### @3=1 /* INT meta=0 nullable=1 is_null=0 */
+### @4='c3_c4_changed' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+# Number of rows: 4
+COMMIT
+/*!*/;
+START TRANSACTION
+/*!*/;
+#Q> DELETE FROM t1 WHERE c1 = 1
+### DELETE FROM `test`.`t1`
+### WHERE
+### @1=1 /* INT meta=0 nullable=0 is_null=0 */
+### @2='only_c2_changed' /* VARSTRING(100) meta=100 nullable=1 is_null=0 */
+### @3=1 /* INT meta=0 nullable=1 is_null=0 */
+# Number of rows: 1
+COMMIT
+/*!*/;
+DELIMITER ;
+# End of log file
+ROLLBACK /* added by mysqlbinlog */;
+/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
+FLUSH BINARY LOGS;
+
+# t2 has no primary key.
+# It will binlog full before and after image for all modes if the
+# table has no primary key. FULL_NODUP follows the behavior.
+
+INSERT INTO t2 VALUES(1, "insert_to_t2", 1, repeat('a', 20)),
+(2, "insert_to_t2", 2, repeat('a', 20)),
+(3, "insert_to_t2", 3, repeat('a', 20));
+INSERT INTO t2(c1) VALUES(4);
+UPDATE t2 SET c2 = "only_c2_changed";
+UPDATE t2 SET c3 = 1, c4 = "c3_c4_changed";
+DELETE FROM t2 WHERE c1 > 2;
+
+# Verify that rows events are binlogged as expeced.
+
+/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
+DELIMITER /*!*/;
+# Warning: this binlog is either in use or was not closed properly.
+START TRANSACTION
+/*!*/;
+#Q> INSERT INTO t2 VALUES(1, "insert_to_t2", 1, repeat('a', 20)),
+#Q> (2, "insert_to_t2", 2, repeat('a', 20)),
+#Q> (3, "insert_to_t2", 3, repeat('a', 20))
+### INSERT INTO `test`.`t2`
+### SET
+### @1=1 /* INT meta=0 nullable=1 is_null=0 */
+### @2='insert_to_t2' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=1 /* INT meta=0 nullable=1 is_null=0 */
+### @4='aaaaaaaaaaaaaaaaaaaa' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### INSERT INTO `test`.`t2`
+### SET
+### @1=2 /* INT meta=0 nullable=1 is_null=0 */
+### @2='insert_to_t2' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=2 /* INT meta=0 nullable=1 is_null=0 */
+### @4='aaaaaaaaaaaaaaaaaaaa' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### INSERT INTO `test`.`t2`
+### SET
+### @1=3 /* INT meta=0 nullable=1 is_null=0 */
+### @2='insert_to_t2' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=3 /* INT meta=0 nullable=1 is_null=0 */
+### @4='aaaaaaaaaaaaaaaaaaaa' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+# Number of rows: 3
+/*!\C latin1 *//*!*/;
+COMMIT
+/*!*/;
+START TRANSACTION
+/*!*/;
+#Q> INSERT INTO t2(c1) VALUES(4)
+### INSERT INTO `test`.`t2`
+### SET
+### @1=4 /* INT meta=0 nullable=1 is_null=0 */
+### @2=NULL /* STRING(100) meta=65124 nullable=1 is_null=1 */
+### @3=1000 /* INT meta=0 nullable=1 is_null=0 */
+### @4=NULL /* BLOB/TEXT meta=2 nullable=1 is_null=1 */
+# Number of rows: 1
+COMMIT
+/*!*/;
+START TRANSACTION
+/*!*/;
+#Q> UPDATE t2 SET c2 = "only_c2_changed"
+### UPDATE `test`.`t2`
+### WHERE
+### @1=1 /* INT meta=0 nullable=1 is_null=0 */
+### @2='insert_to_t2' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=1 /* INT meta=0 nullable=1 is_null=0 */
+### @4='aaaaaaaaaaaaaaaaaaaa' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### SET
+### @1=1 /* INT meta=0 nullable=1 is_null=0 */
+### @2='only_c2_changed' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=1 /* INT meta=0 nullable=1 is_null=0 */
+### @4='aaaaaaaaaaaaaaaaaaaa' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### UPDATE `test`.`t2`
+### WHERE
+### @1=2 /* INT meta=0 nullable=1 is_null=0 */
+### @2='insert_to_t2' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=2 /* INT meta=0 nullable=1 is_null=0 */
+### @4='aaaaaaaaaaaaaaaaaaaa' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### SET
+### @1=2 /* INT meta=0 nullable=1 is_null=0 */
+### @2='only_c2_changed' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=2 /* INT meta=0 nullable=1 is_null=0 */
+### @4='aaaaaaaaaaaaaaaaaaaa' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### UPDATE `test`.`t2`
+### WHERE
+### @1=3 /* INT meta=0 nullable=1 is_null=0 */
+### @2='insert_to_t2' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=3 /* INT meta=0 nullable=1 is_null=0 */
+### @4='aaaaaaaaaaaaaaaaaaaa' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### SET
+### @1=3 /* INT meta=0 nullable=1 is_null=0 */
+### @2='only_c2_changed' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=3 /* INT meta=0 nullable=1 is_null=0 */
+### @4='aaaaaaaaaaaaaaaaaaaa' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### UPDATE `test`.`t2`
+### WHERE
+### @1=4 /* INT meta=0 nullable=1 is_null=0 */
+### @2=NULL /* STRING(100) meta=65124 nullable=1 is_null=1 */
+### @3=1000 /* INT meta=0 nullable=1 is_null=0 */
+### @4=NULL /* BLOB/TEXT meta=2 nullable=1 is_null=1 */
+### SET
+### @1=4 /* INT meta=0 nullable=1 is_null=0 */
+### @2='only_c2_changed' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=1000 /* INT meta=0 nullable=1 is_null=0 */
+### @4=NULL /* BLOB/TEXT meta=2 nullable=1 is_null=1 */
+# Number of rows: 4
+COMMIT
+/*!*/;
+START TRANSACTION
+/*!*/;
+#Q> UPDATE t2 SET c3 = 1, c4 = "c3_c4_changed"
+### UPDATE `test`.`t2`
+### WHERE
+### @1=1 /* INT meta=0 nullable=1 is_null=0 */
+### @2='only_c2_changed' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=1 /* INT meta=0 nullable=1 is_null=0 */
+### @4='aaaaaaaaaaaaaaaaaaaa' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### SET
+### @1=1 /* INT meta=0 nullable=1 is_null=0 */
+### @2='only_c2_changed' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=1 /* INT meta=0 nullable=1 is_null=0 */
+### @4='c3_c4_changed' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### UPDATE `test`.`t2`
+### WHERE
+### @1=2 /* INT meta=0 nullable=1 is_null=0 */
+### @2='only_c2_changed' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=2 /* INT meta=0 nullable=1 is_null=0 */
+### @4='aaaaaaaaaaaaaaaaaaaa' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### SET
+### @1=2 /* INT meta=0 nullable=1 is_null=0 */
+### @2='only_c2_changed' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=1 /* INT meta=0 nullable=1 is_null=0 */
+### @4='c3_c4_changed' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### UPDATE `test`.`t2`
+### WHERE
+### @1=3 /* INT meta=0 nullable=1 is_null=0 */
+### @2='only_c2_changed' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=3 /* INT meta=0 nullable=1 is_null=0 */
+### @4='aaaaaaaaaaaaaaaaaaaa' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### SET
+### @1=3 /* INT meta=0 nullable=1 is_null=0 */
+### @2='only_c2_changed' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=1 /* INT meta=0 nullable=1 is_null=0 */
+### @4='c3_c4_changed' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### UPDATE `test`.`t2`
+### WHERE
+### @1=4 /* INT meta=0 nullable=1 is_null=0 */
+### @2='only_c2_changed' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=1000 /* INT meta=0 nullable=1 is_null=0 */
+### @4=NULL /* BLOB/TEXT meta=2 nullable=1 is_null=1 */
+### SET
+### @1=4 /* INT meta=0 nullable=1 is_null=0 */
+### @2='only_c2_changed' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=1 /* INT meta=0 nullable=1 is_null=0 */
+### @4='c3_c4_changed' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+# Number of rows: 4
+COMMIT
+/*!*/;
+START TRANSACTION
+/*!*/;
+#Q> DELETE FROM t2 WHERE c1 > 2
+### DELETE FROM `test`.`t2`
+### WHERE
+### @1=3 /* INT meta=0 nullable=1 is_null=0 */
+### @2='only_c2_changed' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=1 /* INT meta=0 nullable=1 is_null=0 */
+### @4='c3_c4_changed' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### DELETE FROM `test`.`t2`
+### WHERE
+### @1=4 /* INT meta=0 nullable=1 is_null=0 */
+### @2='only_c2_changed' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=1 /* INT meta=0 nullable=1 is_null=0 */
+### @4='c3_c4_changed' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+# Number of rows: 2
+COMMIT
+/*!*/;
+DELIMITER ;
+# End of log file
+ROLLBACK /* added by mysqlbinlog */;
+/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
+DROP TABLE t1, t2;
+#
+# FULL mode works as expected
+#
+SET binlog_row_image = "FULL";
+CREATE TABLE t1 (c1 INT PRIMARY KEY, c2 varchar(100),
+c3 INT DEFAULT 1000, c4 TEXT);
+CREATE TABLE t2 (c1 INT, c2 char(100), c3 INT DEFAULT 1000, c4 TEXT);
+FLUSH BINARY LOGS;
+
+#########################################################################
+# binlog_row_image = FULL
+#########################################################################
+
+INSERT INTO t1 VALUES(1, "insert_to_t1", 1, repeat('a', 20)),
+(2, "insert_to_t1", 2, repeat('a', 20)),
+(3, "insert_to_t1", 3, repeat('a', 20));
+INSERT INTO t1(c1) VALUES(4);
+UPDATE t1 SET c2 = "only_c2_changed";
+UPDATE t1 SET c3 = 1, c4 = "c3_c4_changed";
+DELETE FROM t1 WHERE c1 = 1;
+
+# Verify that rows events are binlogged as expeced.
+
+/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
+DELIMITER /*!*/;
+# Warning: this binlog is either in use or was not closed properly.
+START TRANSACTION
+/*!*/;
+#Q> INSERT INTO t1 VALUES(1, "insert_to_t1", 1, repeat('a', 20)),
+#Q> (2, "insert_to_t1", 2, repeat('a', 20)),
+#Q> (3, "insert_to_t1", 3, repeat('a', 20))
+### INSERT INTO `test`.`t1`
+### SET
+### @1=1 /* INT meta=0 nullable=0 is_null=0 */
+### @2='insert_to_t1' /* VARSTRING(100) meta=100 nullable=1 is_null=0 */
+### @3=1 /* INT meta=0 nullable=1 is_null=0 */
+### @4='aaaaaaaaaaaaaaaaaaaa' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### INSERT INTO `test`.`t1`
+### SET
+### @1=2 /* INT meta=0 nullable=0 is_null=0 */
+### @2='insert_to_t1' /* VARSTRING(100) meta=100 nullable=1 is_null=0 */
+### @3=2 /* INT meta=0 nullable=1 is_null=0 */
+### @4='aaaaaaaaaaaaaaaaaaaa' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### INSERT INTO `test`.`t1`
+### SET
+### @1=3 /* INT meta=0 nullable=0 is_null=0 */
+### @2='insert_to_t1' /* VARSTRING(100) meta=100 nullable=1 is_null=0 */
+### @3=3 /* INT meta=0 nullable=1 is_null=0 */
+### @4='aaaaaaaaaaaaaaaaaaaa' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+# Number of rows: 3
+/*!\C latin1 *//*!*/;
+COMMIT
+/*!*/;
+START TRANSACTION
+/*!*/;
+#Q> INSERT INTO t1(c1) VALUES(4)
+### INSERT INTO `test`.`t1`
+### SET
+### @1=4 /* INT meta=0 nullable=0 is_null=0 */
+### @2=NULL /* VARSTRING(100) meta=100 nullable=1 is_null=1 */
+### @3=1000 /* INT meta=0 nullable=1 is_null=0 */
+### @4=NULL /* BLOB/TEXT meta=2 nullable=1 is_null=1 */
+# Number of rows: 1
+COMMIT
+/*!*/;
+START TRANSACTION
+/*!*/;
+#Q> UPDATE t1 SET c2 = "only_c2_changed"
+### UPDATE `test`.`t1`
+### WHERE
+### @1=1 /* INT meta=0 nullable=0 is_null=0 */
+### @2='insert_to_t1' /* VARSTRING(100) meta=100 nullable=1 is_null=0 */
+### @3=1 /* INT meta=0 nullable=1 is_null=0 */
+### @4='aaaaaaaaaaaaaaaaaaaa' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### SET
+### @1=1 /* INT meta=0 nullable=0 is_null=0 */
+### @2='only_c2_changed' /* VARSTRING(100) meta=100 nullable=1 is_null=0 */
+### @3=1 /* INT meta=0 nullable=1 is_null=0 */
+### @4='aaaaaaaaaaaaaaaaaaaa' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### UPDATE `test`.`t1`
+### WHERE
+### @1=2 /* INT meta=0 nullable=0 is_null=0 */
+### @2='insert_to_t1' /* VARSTRING(100) meta=100 nullable=1 is_null=0 */
+### @3=2 /* INT meta=0 nullable=1 is_null=0 */
+### @4='aaaaaaaaaaaaaaaaaaaa' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### SET
+### @1=2 /* INT meta=0 nullable=0 is_null=0 */
+### @2='only_c2_changed' /* VARSTRING(100) meta=100 nullable=1 is_null=0 */
+### @3=2 /* INT meta=0 nullable=1 is_null=0 */
+### @4='aaaaaaaaaaaaaaaaaaaa' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### UPDATE `test`.`t1`
+### WHERE
+### @1=3 /* INT meta=0 nullable=0 is_null=0 */
+### @2='insert_to_t1' /* VARSTRING(100) meta=100 nullable=1 is_null=0 */
+### @3=3 /* INT meta=0 nullable=1 is_null=0 */
+### @4='aaaaaaaaaaaaaaaaaaaa' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### SET
+### @1=3 /* INT meta=0 nullable=0 is_null=0 */
+### @2='only_c2_changed' /* VARSTRING(100) meta=100 nullable=1 is_null=0 */
+### @3=3 /* INT meta=0 nullable=1 is_null=0 */
+### @4='aaaaaaaaaaaaaaaaaaaa' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### UPDATE `test`.`t1`
+### WHERE
+### @1=4 /* INT meta=0 nullable=0 is_null=0 */
+### @2=NULL /* VARSTRING(100) meta=100 nullable=1 is_null=1 */
+### @3=1000 /* INT meta=0 nullable=1 is_null=0 */
+### @4=NULL /* BLOB/TEXT meta=2 nullable=1 is_null=1 */
+### SET
+### @1=4 /* INT meta=0 nullable=0 is_null=0 */
+### @2='only_c2_changed' /* VARSTRING(100) meta=100 nullable=1 is_null=0 */
+### @3=1000 /* INT meta=0 nullable=1 is_null=0 */
+### @4=NULL /* BLOB/TEXT meta=2 nullable=1 is_null=1 */
+# Number of rows: 4
+COMMIT
+/*!*/;
+START TRANSACTION
+/*!*/;
+#Q> UPDATE t1 SET c3 = 1, c4 = "c3_c4_changed"
+### UPDATE `test`.`t1`
+### WHERE
+### @1=1 /* INT meta=0 nullable=0 is_null=0 */
+### @2='only_c2_changed' /* VARSTRING(100) meta=100 nullable=1 is_null=0 */
+### @3=1 /* INT meta=0 nullable=1 is_null=0 */
+### @4='aaaaaaaaaaaaaaaaaaaa' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### SET
+### @1=1 /* INT meta=0 nullable=0 is_null=0 */
+### @2='only_c2_changed' /* VARSTRING(100) meta=100 nullable=1 is_null=0 */
+### @3=1 /* INT meta=0 nullable=1 is_null=0 */
+### @4='c3_c4_changed' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### UPDATE `test`.`t1`
+### WHERE
+### @1=2 /* INT meta=0 nullable=0 is_null=0 */
+### @2='only_c2_changed' /* VARSTRING(100) meta=100 nullable=1 is_null=0 */
+### @3=2 /* INT meta=0 nullable=1 is_null=0 */
+### @4='aaaaaaaaaaaaaaaaaaaa' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### SET
+### @1=2 /* INT meta=0 nullable=0 is_null=0 */
+### @2='only_c2_changed' /* VARSTRING(100) meta=100 nullable=1 is_null=0 */
+### @3=1 /* INT meta=0 nullable=1 is_null=0 */
+### @4='c3_c4_changed' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### UPDATE `test`.`t1`
+### WHERE
+### @1=3 /* INT meta=0 nullable=0 is_null=0 */
+### @2='only_c2_changed' /* VARSTRING(100) meta=100 nullable=1 is_null=0 */
+### @3=3 /* INT meta=0 nullable=1 is_null=0 */
+### @4='aaaaaaaaaaaaaaaaaaaa' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### SET
+### @1=3 /* INT meta=0 nullable=0 is_null=0 */
+### @2='only_c2_changed' /* VARSTRING(100) meta=100 nullable=1 is_null=0 */
+### @3=1 /* INT meta=0 nullable=1 is_null=0 */
+### @4='c3_c4_changed' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### UPDATE `test`.`t1`
+### WHERE
+### @1=4 /* INT meta=0 nullable=0 is_null=0 */
+### @2='only_c2_changed' /* VARSTRING(100) meta=100 nullable=1 is_null=0 */
+### @3=1000 /* INT meta=0 nullable=1 is_null=0 */
+### @4=NULL /* BLOB/TEXT meta=2 nullable=1 is_null=1 */
+### SET
+### @1=4 /* INT meta=0 nullable=0 is_null=0 */
+### @2='only_c2_changed' /* VARSTRING(100) meta=100 nullable=1 is_null=0 */
+### @3=1 /* INT meta=0 nullable=1 is_null=0 */
+### @4='c3_c4_changed' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+# Number of rows: 4
+COMMIT
+/*!*/;
+START TRANSACTION
+/*!*/;
+#Q> DELETE FROM t1 WHERE c1 = 1
+### DELETE FROM `test`.`t1`
+### WHERE
+### @1=1 /* INT meta=0 nullable=0 is_null=0 */
+### @2='only_c2_changed' /* VARSTRING(100) meta=100 nullable=1 is_null=0 */
+### @3=1 /* INT meta=0 nullable=1 is_null=0 */
+### @4='c3_c4_changed' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+# Number of rows: 1
+COMMIT
+/*!*/;
+DELIMITER ;
+# End of log file
+ROLLBACK /* added by mysqlbinlog */;
+/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
+FLUSH BINARY LOGS;
+
+# t2 has no primary key.
+# It will binlog full before and after image for all modes if the
+# table has no primary key. FULL_NODUP follows the behavior.
+
+INSERT INTO t2 VALUES(1, "insert_to_t2", 1, repeat('a', 20)),
+(2, "insert_to_t2", 2, repeat('a', 20)),
+(3, "insert_to_t2", 3, repeat('a', 20));
+INSERT INTO t2(c1) VALUES(4);
+UPDATE t2 SET c2 = "only_c2_changed";
+UPDATE t2 SET c3 = 1, c4 = "c3_c4_changed";
+DELETE FROM t2 WHERE c1 > 2;
+
+# Verify that rows events are binlogged as expeced.
+
+/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
+DELIMITER /*!*/;
+# Warning: this binlog is either in use or was not closed properly.
+START TRANSACTION
+/*!*/;
+#Q> INSERT INTO t2 VALUES(1, "insert_to_t2", 1, repeat('a', 20)),
+#Q> (2, "insert_to_t2", 2, repeat('a', 20)),
+#Q> (3, "insert_to_t2", 3, repeat('a', 20))
+### INSERT INTO `test`.`t2`
+### SET
+### @1=1 /* INT meta=0 nullable=1 is_null=0 */
+### @2='insert_to_t2' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=1 /* INT meta=0 nullable=1 is_null=0 */
+### @4='aaaaaaaaaaaaaaaaaaaa' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### INSERT INTO `test`.`t2`
+### SET
+### @1=2 /* INT meta=0 nullable=1 is_null=0 */
+### @2='insert_to_t2' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=2 /* INT meta=0 nullable=1 is_null=0 */
+### @4='aaaaaaaaaaaaaaaaaaaa' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### INSERT INTO `test`.`t2`
+### SET
+### @1=3 /* INT meta=0 nullable=1 is_null=0 */
+### @2='insert_to_t2' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=3 /* INT meta=0 nullable=1 is_null=0 */
+### @4='aaaaaaaaaaaaaaaaaaaa' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+# Number of rows: 3
+/*!\C latin1 *//*!*/;
+COMMIT
+/*!*/;
+START TRANSACTION
+/*!*/;
+#Q> INSERT INTO t2(c1) VALUES(4)
+### INSERT INTO `test`.`t2`
+### SET
+### @1=4 /* INT meta=0 nullable=1 is_null=0 */
+### @2=NULL /* STRING(100) meta=65124 nullable=1 is_null=1 */
+### @3=1000 /* INT meta=0 nullable=1 is_null=0 */
+### @4=NULL /* BLOB/TEXT meta=2 nullable=1 is_null=1 */
+# Number of rows: 1
+COMMIT
+/*!*/;
+START TRANSACTION
+/*!*/;
+#Q> UPDATE t2 SET c2 = "only_c2_changed"
+### UPDATE `test`.`t2`
+### WHERE
+### @1=1 /* INT meta=0 nullable=1 is_null=0 */
+### @2='insert_to_t2' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=1 /* INT meta=0 nullable=1 is_null=0 */
+### @4='aaaaaaaaaaaaaaaaaaaa' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### SET
+### @1=1 /* INT meta=0 nullable=1 is_null=0 */
+### @2='only_c2_changed' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=1 /* INT meta=0 nullable=1 is_null=0 */
+### @4='aaaaaaaaaaaaaaaaaaaa' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### UPDATE `test`.`t2`
+### WHERE
+### @1=2 /* INT meta=0 nullable=1 is_null=0 */
+### @2='insert_to_t2' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=2 /* INT meta=0 nullable=1 is_null=0 */
+### @4='aaaaaaaaaaaaaaaaaaaa' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### SET
+### @1=2 /* INT meta=0 nullable=1 is_null=0 */
+### @2='only_c2_changed' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=2 /* INT meta=0 nullable=1 is_null=0 */
+### @4='aaaaaaaaaaaaaaaaaaaa' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### UPDATE `test`.`t2`
+### WHERE
+### @1=3 /* INT meta=0 nullable=1 is_null=0 */
+### @2='insert_to_t2' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=3 /* INT meta=0 nullable=1 is_null=0 */
+### @4='aaaaaaaaaaaaaaaaaaaa' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### SET
+### @1=3 /* INT meta=0 nullable=1 is_null=0 */
+### @2='only_c2_changed' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=3 /* INT meta=0 nullable=1 is_null=0 */
+### @4='aaaaaaaaaaaaaaaaaaaa' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### UPDATE `test`.`t2`
+### WHERE
+### @1=4 /* INT meta=0 nullable=1 is_null=0 */
+### @2=NULL /* STRING(100) meta=65124 nullable=1 is_null=1 */
+### @3=1000 /* INT meta=0 nullable=1 is_null=0 */
+### @4=NULL /* BLOB/TEXT meta=2 nullable=1 is_null=1 */
+### SET
+### @1=4 /* INT meta=0 nullable=1 is_null=0 */
+### @2='only_c2_changed' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=1000 /* INT meta=0 nullable=1 is_null=0 */
+### @4=NULL /* BLOB/TEXT meta=2 nullable=1 is_null=1 */
+# Number of rows: 4
+COMMIT
+/*!*/;
+START TRANSACTION
+/*!*/;
+#Q> UPDATE t2 SET c3 = 1, c4 = "c3_c4_changed"
+### UPDATE `test`.`t2`
+### WHERE
+### @1=1 /* INT meta=0 nullable=1 is_null=0 */
+### @2='only_c2_changed' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=1 /* INT meta=0 nullable=1 is_null=0 */
+### @4='aaaaaaaaaaaaaaaaaaaa' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### SET
+### @1=1 /* INT meta=0 nullable=1 is_null=0 */
+### @2='only_c2_changed' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=1 /* INT meta=0 nullable=1 is_null=0 */
+### @4='c3_c4_changed' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### UPDATE `test`.`t2`
+### WHERE
+### @1=2 /* INT meta=0 nullable=1 is_null=0 */
+### @2='only_c2_changed' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=2 /* INT meta=0 nullable=1 is_null=0 */
+### @4='aaaaaaaaaaaaaaaaaaaa' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### SET
+### @1=2 /* INT meta=0 nullable=1 is_null=0 */
+### @2='only_c2_changed' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=1 /* INT meta=0 nullable=1 is_null=0 */
+### @4='c3_c4_changed' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### UPDATE `test`.`t2`
+### WHERE
+### @1=3 /* INT meta=0 nullable=1 is_null=0 */
+### @2='only_c2_changed' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=3 /* INT meta=0 nullable=1 is_null=0 */
+### @4='aaaaaaaaaaaaaaaaaaaa' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### SET
+### @1=3 /* INT meta=0 nullable=1 is_null=0 */
+### @2='only_c2_changed' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=1 /* INT meta=0 nullable=1 is_null=0 */
+### @4='c3_c4_changed' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### UPDATE `test`.`t2`
+### WHERE
+### @1=4 /* INT meta=0 nullable=1 is_null=0 */
+### @2='only_c2_changed' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=1000 /* INT meta=0 nullable=1 is_null=0 */
+### @4=NULL /* BLOB/TEXT meta=2 nullable=1 is_null=1 */
+### SET
+### @1=4 /* INT meta=0 nullable=1 is_null=0 */
+### @2='only_c2_changed' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=1 /* INT meta=0 nullable=1 is_null=0 */
+### @4='c3_c4_changed' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+# Number of rows: 4
+COMMIT
+/*!*/;
+START TRANSACTION
+/*!*/;
+#Q> DELETE FROM t2 WHERE c1 > 2
+### DELETE FROM `test`.`t2`
+### WHERE
+### @1=3 /* INT meta=0 nullable=1 is_null=0 */
+### @2='only_c2_changed' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=1 /* INT meta=0 nullable=1 is_null=0 */
+### @4='c3_c4_changed' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+### DELETE FROM `test`.`t2`
+### WHERE
+### @1=4 /* INT meta=0 nullable=1 is_null=0 */
+### @2='only_c2_changed' /* STRING(100) meta=65124 nullable=1 is_null=0 */
+### @3=1 /* INT meta=0 nullable=1 is_null=0 */
+### @4='c3_c4_changed' /* BLOB/TEXT meta=2 nullable=1 is_null=0 */
+# Number of rows: 2
+COMMIT
+/*!*/;
+DELIMITER ;
+# End of log file
+ROLLBACK /* added by mysqlbinlog */;
+/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
+DROP TABLE t1, t2;
+RESET MASTER;
diff --git a/mysql-test/suite/binlog/r/binlog_stm_ctype_ucs.result b/mysql-test/suite/binlog/r/binlog_stm_ctype_ucs.result
index f9dc5d64..380e6f86 100644
--- a/mysql-test/suite/binlog/r/binlog_stm_ctype_ucs.result
+++ b/mysql-test/suite/binlog/r/binlog_stm_ctype_ucs.result
@@ -99,6 +99,7 @@ SET @@session.sql_mode=1411383296/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C utf8mb3 *//*!*/;
SET @@session.character_set_client=X,@@session.collation_connection=X,@@session.collation_server=X/*!*/;
+SET @@session.character_set_collations=''/*!*/;
SET @@session.lc_time_names=0/*!*/;
SET @@session.collation_database=DEFAULT/*!*/;
CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET utf8)
@@ -126,6 +127,7 @@ START TRANSACTION
# at #
#YYMMDD HH:MM:SS server id # end_log_pos # CRC32 XXX Query thread_id=# exec_time=# error_code=0 xid=<xid>
SET TIMESTAMP=XXX/*!*/;
+SET @@session.character_set_collations=''/*!*/;
INSERT INTO t1 VALUES ('ä(i2)')
/*!*/;
# at #
@@ -171,6 +173,7 @@ START TRANSACTION
# at #
#YYMMDD HH:MM:SS server id # end_log_pos # CRC32 XXX Query thread_id=# exec_time=# error_code=0 xid=<xid>
SET TIMESTAMP=XXX/*!*/;
+SET @@session.character_set_collations=''/*!*/;
INSERT INTO t1 VALUES ('ä(p2)')
/*!*/;
# at #
diff --git a/mysql-test/suite/binlog/r/binlog_stm_do_db.result b/mysql-test/suite/binlog/r/binlog_stm_do_db.result
index c39404ae..391158b1 100644
--- a/mysql-test/suite/binlog/r/binlog_stm_do_db.result
+++ b/mysql-test/suite/binlog/r/binlog_stm_do_db.result
@@ -1,6 +1,6 @@
RESET MASTER;
-SET @old_isolation_level= @@session.tx_isolation;
-SET @@session.tx_isolation= 'READ-COMMITTED';
+SET @old_isolation_level= @@session.transaction_isolation;
+SET @@session.transaction_isolation= 'READ-COMMITTED';
CREATE DATABASE b42829;
use b42829;
CREATE TABLE t1 (x int, y int) engine=InnoDB;
@@ -43,4 +43,4 @@ master-bin.000001 # Gtid # # GTID #-#-#
master-bin.000001 # Query # # use `b42829`; CREATE TABLE t2 (x int, y int) engine=InnoDB
DROP DATABASE b42829;
DROP DATABASE b42829_filtered;
-SET @@session.tx_isolation= @old_isolation_level;
+SET @@session.transaction_isolation= @old_isolation_level;
diff --git a/mysql-test/suite/binlog/r/binlog_stm_mysqlbinlog_collate_implicit.result b/mysql-test/suite/binlog/r/binlog_stm_mysqlbinlog_collate_implicit.result
new file mode 100644
index 00000000..1b9afbe6
--- /dev/null
+++ b/mysql-test/suite/binlog/r/binlog_stm_mysqlbinlog_collate_implicit.result
@@ -0,0 +1,193 @@
+RESET MASTER;
+SET timestamp=1000000000;
+#
+# MDEV-30164 System variable for default collations
+#
+SET character_set_collations='utf8mb3=utf8mb3_bin,ucs2=ucs2_bin';
+CREATE TABLE t1 (a VARCHAR(20));
+DROP TABLE t1;
+CREATE TABLE t1 (a VARCHAR(20) CHARACTER SET utf8mb4);
+DROP TABLE t1;
+CREATE TABLE t1 (a VARCHAR(20) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin);
+DROP TABLE t1;
+CREATE TABLE t1 (a VARCHAR(20) CHARACTER SET utf8mb3);
+INSERT INTO t1 VALUES ('a00');
+INSERT INTO t1 VALUES (_utf8mb3'a01-utf8mb3');
+INSERT INTO t1 VALUES (_utf8mb4'a01-utf8mb4');
+PREPARE stmt FROM 'INSERT INTO t1 VALUES (?)';
+EXECUTE stmt USING _utf8mb3'a02-utf8mb3';
+EXECUTE stmt USING _utf8mb4'a02-utf8mb4';
+EXECUTE stmt USING CONVERT('a03-utf8mb3' USING utf8mb3);
+EXECUTE stmt USING CONVERT('a03-utf8mb4' USING utf8mb4);
+EXECUTE stmt USING IF(0,CONVERT('a04-utf8mb3' USING utf8mb3),CONVERT('a03-utf8mb4' USING utf8mb4));
+EXECUTE stmt USING IF(1,CONVERT('a04-utf8mb3' USING utf8mb3),CONVERT('a03-utf8mb4' USING utf8mb4));
+DEALLOCATE PREPARE stmt;
+DROP TABLE t1;
+PREPARE stmt FROM 'CREATE TABLE t1 (a VARCHAR(20) CHARACTER SET utf8mb4)';
+EXECUTE stmt;
+DROP TABLE t1;
+DEALLOCATE PREPARE stmt;
+PREPARE stmt FROM 'CREATE TABLE t1 (a VARCHAR(20) CHARACTER SET utf8mb3)';
+EXECUTE stmt;
+DROP TABLE t1;
+DEALLOCATE PREPARE stmt;
+EXECUTE IMMEDIATE 'CREATE TABLE t1 (a VARCHAR(20) CHARACTER SET utf8mb4)';
+DROP TABLE t1;
+EXECUTE IMMEDIATE 'CREATE TABLE t1 (a VARCHAR(20) CHARACTER SET utf8mb3)';
+DROP TABLE t1;
+FLUSH LOGS;
+
+--- ---- ---
+/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/;
+/*!40019 SET @@session.max_delayed_threads=0*/;
+/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
+DELIMITER /*!*/;
+ROLLBACK/*!*/;
+use `test`/*!*/;
+SET TIMESTAMP=1000000000/*!*/;
+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, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/;
+SET @@session.sql_mode=#/*!*/;
+SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
+/*!\C latin1 *//*!*/;
+SET @@session.character_set_client=latin1,@@session.collation_connection=8,@@session.collation_server=#/*!*/;
+SET @@session.lc_time_names=0/*!*/;
+SET @@session.collation_database=DEFAULT/*!*/;
+CREATE TABLE t1 (a VARCHAR(20))
+/*!*/;
+SET TIMESTAMP=1000000000/*!*/;
+DROP TABLE `t1` /* generated by server */
+/*!*/;
+SET TIMESTAMP=1000000000/*!*/;
+SET @@session.character_set_collations='utf8mb3=utf8mb3_bin,ucs2=ucs2_bin'/*!*/;
+CREATE TABLE t1 (a VARCHAR(20) CHARACTER SET utf8mb4)
+/*!*/;
+SET TIMESTAMP=1000000000/*!*/;
+DROP TABLE `t1` /* generated by server */
+/*!*/;
+SET TIMESTAMP=1000000000/*!*/;
+CREATE TABLE t1 (a VARCHAR(20) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin)
+/*!*/;
+SET TIMESTAMP=1000000000/*!*/;
+DROP TABLE `t1` /* generated by server */
+/*!*/;
+SET TIMESTAMP=1000000000/*!*/;
+SET @@session.character_set_collations='utf8mb3=utf8mb3_bin,ucs2=ucs2_bin'/*!*/;
+CREATE TABLE t1 (a VARCHAR(20) CHARACTER SET utf8mb3)
+/*!*/;
+START TRANSACTION
+/*!*/;
+SET TIMESTAMP=1000000000/*!*/;
+INSERT INTO t1 VALUES ('a00')
+/*!*/;
+SET TIMESTAMP=1000000000/*!*/;
+COMMIT
+/*!*/;
+START TRANSACTION
+/*!*/;
+SET TIMESTAMP=1000000000/*!*/;
+SET @@session.character_set_collations='utf8mb3=utf8mb3_bin,ucs2=ucs2_bin'/*!*/;
+INSERT INTO t1 VALUES (_utf8mb3'a01-utf8mb3')
+/*!*/;
+SET TIMESTAMP=1000000000/*!*/;
+COMMIT
+/*!*/;
+START TRANSACTION
+/*!*/;
+SET TIMESTAMP=1000000000/*!*/;
+SET @@session.character_set_collations='utf8mb3=utf8mb3_bin,ucs2=ucs2_bin'/*!*/;
+INSERT INTO t1 VALUES (_utf8mb4'a01-utf8mb4')
+/*!*/;
+SET TIMESTAMP=1000000000/*!*/;
+COMMIT
+/*!*/;
+START TRANSACTION
+/*!*/;
+SET TIMESTAMP=1000000000/*!*/;
+SET @@session.character_set_collations='utf8mb3=utf8mb3_bin,ucs2=ucs2_bin'/*!*/;
+INSERT INTO t1 VALUES ('a02-utf8mb3')
+/*!*/;
+SET TIMESTAMP=1000000000/*!*/;
+COMMIT
+/*!*/;
+START TRANSACTION
+/*!*/;
+SET TIMESTAMP=1000000000/*!*/;
+SET @@session.character_set_collations='utf8mb3=utf8mb3_bin,ucs2=ucs2_bin'/*!*/;
+INSERT INTO t1 VALUES ('a02-utf8mb4')
+/*!*/;
+SET TIMESTAMP=1000000000/*!*/;
+COMMIT
+/*!*/;
+START TRANSACTION
+/*!*/;
+SET TIMESTAMP=1000000000/*!*/;
+SET @@session.character_set_collations='utf8mb3=utf8mb3_bin,ucs2=ucs2_bin'/*!*/;
+INSERT INTO t1 VALUES ('a03-utf8mb3')
+/*!*/;
+SET TIMESTAMP=1000000000/*!*/;
+COMMIT
+/*!*/;
+START TRANSACTION
+/*!*/;
+SET TIMESTAMP=1000000000/*!*/;
+SET @@session.character_set_collations='utf8mb3=utf8mb3_bin,ucs2=ucs2_bin'/*!*/;
+INSERT INTO t1 VALUES ('a03-utf8mb4')
+/*!*/;
+SET TIMESTAMP=1000000000/*!*/;
+COMMIT
+/*!*/;
+START TRANSACTION
+/*!*/;
+SET TIMESTAMP=1000000000/*!*/;
+SET @@session.character_set_collations='utf8mb3=utf8mb3_bin,ucs2=ucs2_bin'/*!*/;
+INSERT INTO t1 VALUES ('a03-utf8mb4')
+/*!*/;
+SET TIMESTAMP=1000000000/*!*/;
+COMMIT
+/*!*/;
+START TRANSACTION
+/*!*/;
+SET TIMESTAMP=1000000000/*!*/;
+SET @@session.character_set_collations='utf8mb3=utf8mb3_bin,ucs2=ucs2_bin'/*!*/;
+INSERT INTO t1 VALUES ('a04-utf8mb3')
+/*!*/;
+SET TIMESTAMP=1000000000/*!*/;
+COMMIT
+/*!*/;
+SET TIMESTAMP=1000000000/*!*/;
+DROP TABLE `t1` /* generated by server */
+/*!*/;
+SET TIMESTAMP=1000000000/*!*/;
+SET @@session.character_set_collations='utf8mb3=utf8mb3_bin,ucs2=ucs2_bin'/*!*/;
+CREATE TABLE t1 (a VARCHAR(20) CHARACTER SET utf8mb4)
+/*!*/;
+SET TIMESTAMP=1000000000/*!*/;
+DROP TABLE `t1` /* generated by server */
+/*!*/;
+SET TIMESTAMP=1000000000/*!*/;
+SET @@session.character_set_collations='utf8mb3=utf8mb3_bin,ucs2=ucs2_bin'/*!*/;
+CREATE TABLE t1 (a VARCHAR(20) CHARACTER SET utf8mb3)
+/*!*/;
+SET TIMESTAMP=1000000000/*!*/;
+DROP TABLE `t1` /* generated by server */
+/*!*/;
+SET TIMESTAMP=1000000000/*!*/;
+SET @@session.character_set_collations='utf8mb3=utf8mb3_bin,ucs2=ucs2_bin'/*!*/;
+CREATE TABLE t1 (a VARCHAR(20) CHARACTER SET utf8mb4)
+/*!*/;
+SET TIMESTAMP=1000000000/*!*/;
+DROP TABLE `t1` /* generated by server */
+/*!*/;
+SET TIMESTAMP=1000000000/*!*/;
+SET @@session.character_set_collations='utf8mb3=utf8mb3_bin,ucs2=ucs2_bin'/*!*/;
+CREATE TABLE t1 (a VARCHAR(20) CHARACTER SET utf8mb3)
+/*!*/;
+SET TIMESTAMP=1000000000/*!*/;
+DROP TABLE `t1` /* generated by server */
+/*!*/;
+DELIMITER ;
+# End of log file
+ROLLBACK /* added by mysqlbinlog */;
+/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
+/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;
diff --git a/mysql-test/suite/binlog/r/binlog_unsafe.result b/mysql-test/suite/binlog/r/binlog_unsafe.result
index 0c0b0e77..67849fc7 100644
--- a/mysql-test/suite/binlog/r/binlog_unsafe.result
+++ b/mysql-test/suite/binlog/r/binlog_unsafe.result
@@ -2338,11 +2338,7 @@ Warnings:
Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted
Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. REPLACE... SELECT is unsafe because the order in which rows are retrieved by the SELECT determines which (if any) rows are replaced. This order cannot be predicted and may differ on master and the slave
UPDATE t1 SET a=1 LIMIT 1;
-Warnings:
-Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted
DELETE FROM t1 LIMIT 1;
-Warnings:
-Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted
CREATE PROCEDURE p1()
BEGIN
INSERT INTO t1 SELECT * FROM t1 LIMIT 1;
diff --git a/mysql-test/suite/binlog/r/flashback.result b/mysql-test/suite/binlog/r/flashback.result
index ec767f62..6ae3e194 100644
--- a/mysql-test/suite/binlog/r/flashback.result
+++ b/mysql-test/suite/binlog/r/flashback.result
@@ -706,6 +706,60 @@ DROP TABLE t1;
# MDEV-30698 Cover missing test cases for mariadb-binlog options
# --raw [and] --flashback
#
+#
+# < CASE 8 >
+# Verify flashback works well for binlog_row_image full_nodup mode
+#
+CREATE TABLE t1 (
+c01 TINYINT PRIMARY KEY,
+c02 SMALLINT,
+c03 MEDIUMINT,
+c04 INT,
+c05 BIGINT,
+c06 CHAR(10),
+c07 VARCHAR(20),
+c08 TEXT,
+c09 ENUM('one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight'),
+c10 SET('black', 'white', 'red', 'yellow'),
+c11 TIMESTAMP(3),
+c12 DATETIME(3)
+) ENGINE = InnoDB;
+INSERT INTO t1 VALUES (1, 1, 1, 1, 1, 'A', 'A', 'A', 'one', 'black',
+'2023-11-26 10:00:00.123', '2023-11-26 10:00:00');
+INSERT INTO t1 VALUES (2, 1, 1, 1, 1, 'A', 'A', 'A', 'one', 'black',
+'2023-11-26 10:00:00.123', '2023-11-26 10:00:00');
+INSERT INTO t1 VALUES (3, 1, NULL, 1, 1, 'A', 'A', 'A', 'one', 'black',
+'2023-11-26 10:00:00.123', NULL);
+INSERT INTO t1 VALUES (4, 1, NULL, 1, 1, 'A', 'A', 'A', 'one', 'black',
+'2023-11-26 10:00:00.123', NULL);
+FLUSH BINARY LOGS;
+# The update includes the cases that
+# Value -> Value
+# Value -> NULL
+# NULL -> value
+# and the changed null bits in both first and second null byte
+UPDATE t1 SET c02 = NULL, c03 = 2, c09 = 'two',
+c10 = NULL, c12 = '2023-11-26 11:00:00';
+FLUSH BINARY LOGS;
+#
+# Data before flashback
+#
+SELECT * FROM t1;
+c01 c02 c03 c04 c05 c06 c07 c08 c09 c10 c11 c12
+1 NULL 2 1 1 A A A two NULL 2023-11-26 10:00:00.123 2023-11-26 11:00:00.000
+2 NULL 2 1 1 A A A two NULL 2023-11-26 10:00:00.123 2023-11-26 11:00:00.000
+3 NULL 2 1 1 A A A two NULL 2023-11-26 10:00:00.123 2023-11-26 11:00:00.000
+4 NULL 2 1 1 A A A two NULL 2023-11-26 10:00:00.123 2023-11-26 11:00:00.000
+#
+# Data after flashback
+#
+SELECT * FROM t1;
+c01 c02 c03 c04 c05 c06 c07 c08 c09 c10 c11 c12
+1 1 1 1 1 A A A one black 2023-11-26 10:00:00.123 2023-11-26 10:00:00.000
+2 1 1 1 1 A A A one black 2023-11-26 10:00:00.123 2023-11-26 10:00:00.000
+3 1 NULL 1 1 A A A one black 2023-11-26 10:00:00.123 NULL
+4 1 NULL 1 1 A A A one black 2023-11-26 10:00:00.123 NULL
+DROP TABLE t1;
SET binlog_format=statement;
Warnings:
Warning 1105 MariaDB Galera and flashback do not support binlog format: STATEMENT
diff --git a/mysql-test/suite/binlog/r/max_binlog_total_size.result b/mysql-test/suite/binlog/r/max_binlog_total_size.result
new file mode 100644
index 00000000..93f83cf2
--- /dev/null
+++ b/mysql-test/suite/binlog/r/max_binlog_total_size.result
@@ -0,0 +1,123 @@
+select @@global.max_binlog_total_size;
+@@global.max_binlog_total_size
+1500
+select @@global.max_binlog_size;
+@@global.max_binlog_size
+4096
+#
+# MDEV-31404 Implement binlog_space_limit
+#
+FLUSH LOGS;
+FLUSH LOGS;
+FLUSH LOGS;
+show binary logs;
+Log_name File_size
+binary.000001 #
+binary.000002 #
+binary.000003 #
+binary.000004 #
+show status like "binlog_disk_use";
+Variable_name Value
+Binlog_disk_use 1552
+set @@global.slave_connections_needed_for_purge= 0;
+# binary.000001 should be deleted now
+show binary logs;
+Log_name File_size
+binary.000002 #
+binary.000003 #
+binary.000004 #
+show status like "binlog_disk_use";
+Variable_name Value
+Binlog_disk_use 1183
+CREATE TABLE `t1` (
+`v1` int(11) DEFAULT NULL,
+`v2` varchar(8000) DEFAULT NULL,
+KEY `v1` (`v1`)
+) engine=myisam;
+INSERT INTO t1 VALUES (0,repeat("a",3000));
+show status like "binlog_disk_use";
+Variable_name Value
+Binlog_disk_use 3863
+# First binary should be binary.000004
+show binary logs;
+Log_name File_size
+binary.000004 #
+INSERT INTO t1 VALUES (2,repeat("b",10));
+# First binary should be binary.000004
+show binary logs;
+Log_name File_size
+binary.000004 #
+binary.000005 #
+FLUSH LOGS;
+# First binary should be binary.000005
+show binary logs;
+Log_name File_size
+binary.000005 #
+binary.000006 #
+FLUSH LOGS;
+FLUSH LOGS;
+FLUSH LOGS;
+FLUSH LOGS;
+show binary logs;
+Log_name File_size
+binary.000008 #
+binary.000009 #
+binary.000010 #
+show status like "binlog_disk_use";
+Variable_name Value
+Binlog_disk_use 1225
+PURGE BINARY LOGS TO 'binary.000009';
+# First binary should be binary.000009
+show binary logs;
+Log_name File_size
+binary.000009 #
+binary.000010 #
+INSERT INTO t1 VALUES (3,repeat("c",4000));
+# First binary should be binary.000010
+show binary logs;
+Log_name File_size
+binary.000010 #
+binary.000011 #
+INSERT INTO t1 VALUES (4,repeat("d",3000));
+# First binary should be binary.000011
+show binary logs;
+Log_name File_size
+binary.000011 #
+RESET MASTER;
+show binary logs;
+Log_name File_size
+binary.000001 #
+show status like "binlog_disk_use";
+Variable_name Value
+Binlog_disk_use 325
+INSERT INTO t1 VALUES (5,"e");
+FLUSH LOGS;
+INSERT INTO t1 VALUES (6,repeat("f",3000));
+show binary logs;
+Log_name File_size
+binary.000002 #
+show status like "binlog_disk_use";
+Variable_name Value
+Binlog_disk_use 3647
+INSERT INTO t1 VALUES (7,repeat("g",3000));
+# binary.000001 should be deleted now
+show binary logs;
+Log_name File_size
+binary.000002 #
+binary.000003 #
+show status like "binlog_disk_use";
+Variable_name Value
+Binlog_disk_use 7338
+FLUSH LOGS;
+FLUSH LOGS;
+# binary.000002 should be deleted now
+show binary logs;
+Log_name File_size
+binary.000003 423
+binary.000004 423
+binary.000005 379
+show status like "binlog_disk_use";
+Variable_name Value
+Binlog_disk_use 1225
+DROP TABLE IF EXISTS t1;
+set @@global.slave_connections_needed_for_purge= default;
diff --git a/mysql-test/suite/binlog/std_data/binlog_old_version_4_1.000001 b/mysql-test/suite/binlog/std_data/binlog_old_version_4_1.000001
deleted file mode 100644
index 66db9668..00000000
--- a/mysql-test/suite/binlog/std_data/binlog_old_version_4_1.000001
+++ /dev/null
Binary files differ
diff --git a/mysql-test/suite/binlog/std_data/bug32407.001 b/mysql-test/suite/binlog/std_data/bug32407.001
deleted file mode 100644
index c7324370..00000000
--- a/mysql-test/suite/binlog/std_data/bug32407.001
+++ /dev/null
Binary files differ
diff --git a/mysql-test/suite/binlog/std_data/ver_5_1-telco.001 b/mysql-test/suite/binlog/std_data/ver_5_1-telco.001
deleted file mode 100644
index 76856cb0..00000000
--- a/mysql-test/suite/binlog/std_data/ver_5_1-telco.001
+++ /dev/null
Binary files differ
diff --git a/mysql-test/suite/binlog/std_data/ver_5_1_17.001 b/mysql-test/suite/binlog/std_data/ver_5_1_17.001
deleted file mode 100644
index 9b6e200e..00000000
--- a/mysql-test/suite/binlog/std_data/ver_5_1_17.001
+++ /dev/null
Binary files differ
diff --git a/mysql-test/suite/binlog/std_data/ver_5_1_23.001 b/mysql-test/suite/binlog/std_data/ver_5_1_23.001
deleted file mode 100644
index 0e9a9d14..00000000
--- a/mysql-test/suite/binlog/std_data/ver_5_1_23.001
+++ /dev/null
Binary files differ
diff --git a/mysql-test/suite/binlog/std_data/ver_trunk_row_v2.001 b/mysql-test/suite/binlog/std_data/ver_trunk_row_v2.001
deleted file mode 100644
index 28360bec..00000000
--- a/mysql-test/suite/binlog/std_data/ver_trunk_row_v2.001
+++ /dev/null
Binary files differ
diff --git a/mysql-test/suite/binlog/t/binlog_base64_flag.test b/mysql-test/suite/binlog/t/binlog_base64_flag.test
index 5311da54..6935f69b 100644
--- a/mysql-test/suite/binlog/t/binlog_base64_flag.test
+++ b/mysql-test/suite/binlog/t/binlog_base64_flag.test
@@ -2,9 +2,6 @@
# work as expected, and that BINLOG statements with row events fail if
# they are not preceded by BINLOG statements with Format description
# events.
-#
-# See also BUG#32407.
-
# BINLOG statement does not work in embedded mode.
source include/not_embedded.inc;
@@ -12,23 +9,10 @@ source include/not_embedded.inc;
call mtr.add_suppression("BINLOG_BASE64_EVENT: According to the master's version");
call mtr.add_suppression("BINLOG_BASE64_EVENT: Column 1 of table 'test.char128_utf8' cannot be converted");
-disable_warnings;
-DROP TABLE IF EXISTS t1;
-enable_warnings;
-# Test to show BUG#32407. This reads a binlog created with the
-# mysql-5.1-telco-6.1 tree, specifically at the tag
-# mysql-5.1.15-ndb-6.1.23, and applies it to the database. The test
-# should fail before BUG#32407 was fixed and succeed afterwards.
---echo ==== Test BUG#32407 ====
-
-# The binlog contains row events equivalent to:
-# CREATE TABLE t1 (a int) engine = myisam
-# INSERT INTO t1 VALUES (1), (1)
-exec $MYSQL_BINLOG suite/binlog/std_data/bug32407.001 | $MYSQL;
-# The above line should succeed and t1 should contain two ones
+CREATE TABLE t1 (a int);
+INSERT INTO t1 VALUES (1), (1);
select * from t1;
-
# Test that a BINLOG statement encoding a row event fails unless a
# Format_description_event as been supplied with an earlier BINLOG
# statement.
@@ -92,14 +76,6 @@ select * from t1;
# show "one-shot" feature of binlog_fragment variables
SELECT @binlog_fragment_0, @binlog_fragment_1 as 'NULL','NULL';
-# New mysqlbinlog supports --base64-output=never
---echo ==== Test --base64-output=never on a binlog with row events ====
-
-# mysqlbinlog should fail
---replace_regex /#[0-9][0-9][0-9][0-9][0-9][0-9] \N*/<#>/ /SET \@\@session.pseudo_thread_id.*/<#>/
-exec $MYSQL_BINLOG --base64-output=never --print-row-count=0 --print-row-event-positions=0 suite/binlog/std_data/bug32407.001;
-
-
# Test that the following fails cleanly: "First, read a
# Format_description event which has N event types. Then, read an
# event of type M>N"
diff --git a/mysql-test/suite/binlog/t/binlog_expire_warnings.opt b/mysql-test/suite/binlog/t/binlog_expire_warnings.opt
new file mode 100644
index 00000000..c85ef7d3
--- /dev/null
+++ b/mysql-test/suite/binlog/t/binlog_expire_warnings.opt
@@ -0,0 +1 @@
+--log-warnings=4
diff --git a/mysql-test/suite/binlog/t/binlog_grant.test b/mysql-test/suite/binlog/t/binlog_grant.test
index d573281f..5ece793e 100644
--- a/mysql-test/suite/binlog/t/binlog_grant.test
+++ b/mysql-test/suite/binlog/t/binlog_grant.test
@@ -30,7 +30,6 @@ connection plain;
--error ER_SPECIFIC_ACCESS_DENIED_ERROR
set session sql_log_bin = 1;
-
# Testing setting both session and global BINLOG_FORMAT variable both
# as root and as plain user.
@@ -56,7 +55,6 @@ connection default;
set global binlog_format = @saved_binlog_format;
drop user mysqltest_1@localhost;
-
# Testing if REPLICATION CLIENT privilege is enough to execute
# SHOW MASTER LOGS and SHOW BINARY.
CREATE USER 'mysqltest_1'@'localhost';
@@ -77,9 +75,12 @@ SHOW BINLOG STATUS;
connection default;
DROP USER 'mysqltest_1'@'localhost';
+--echo #
+--echo # End of 10.4 tests
+--echo #
--echo #
---echo # Start of 10.5 test
+--echo # Start of 10.5 tests
--echo #
--echo #
@@ -95,11 +96,10 @@ REVOKE REPLICATION CLIENT ON *.* FROM user1@localhost;
SHOW GRANTS FOR user1@localhost;
DROP USER user1@localhost;
-
---echo # Test if SHOW BINARY LOGS and SHOW BINGLOG STATUS are not allowed without REPLICATION CLIENT or SUPER
+--echo # Test if SHOW BINARY LOGS and SHOW BINGLOG STATUS are not allowed without REPLICATION CLIENT
CREATE USER user1@localhost;
GRANT ALL PRIVILEGES ON *.* TO user1@localhost;
-REVOKE REPLICATION CLIENT, SUPER ON *.* FROM user1@localhost;
+REVOKE REPLICATION CLIENT ON *.* FROM user1@localhost;
--connect(user1,localhost,user1,,)
--connection user1
--error ER_SPECIFIC_ACCESS_DENIED_ERROR
@@ -112,11 +112,10 @@ SHOW BINLOG STATUS;
--connection default
DROP USER user1@localhost;
-
---echo # Test if PURGE BINARY LOGS is not allowed without BINLOG ADMIN or SUPER
+--echo # Test if PURGE BINARY LOGS is not allowed without BINLOG ADMIN
CREATE USER user1@localhost;
GRANT ALL PRIVILEGES ON *.* TO user1@localhost;
-REVOKE BINLOG ADMIN, SUPER ON *.* FROM user1@localhost;
+REVOKE BINLOG ADMIN ON *.* FROM user1@localhost;
--connect(user1,localhost,user1,,)
--connection user1
--error ER_SPECIFIC_ACCESS_DENIED_ERROR
@@ -125,7 +124,6 @@ PURGE BINARY LOGS BEFORE '2001-01-01 00:00:00';
--connection default
DROP USER user1@localhost;
-
--echo # Test if PURGE BINLOG is allowed with BINLOG ADMIN
CREATE USER user1@localhost;
GRANT BINLOG ADMIN ON *.* TO user1@localhost;
@@ -136,18 +134,6 @@ PURGE BINARY LOGS BEFORE '2001-01-01 00:00:00';
connection default;
DROP USER user1@localhost;
-
---echo # Test if PURGE BINLOG is allowed with SUPER
-CREATE USER user1@localhost;
-GRANT SUPER ON *.* TO user1@localhost;
---connect(user1,localhost,user1,,"*NO-ONE*")
---connection user1
-PURGE BINARY LOGS BEFORE '2001-01-01 00:00:00';
---disconnect user1
-connection default;
-DROP USER user1@localhost;
-
-
--echo # Test if SHOW BINLOG EVENTS is not allowed without BINLOG MONITOR
CREATE USER user1@localhost;
GRANT ALL PRIVILEGES ON *.* TO user1@localhost;
@@ -160,7 +146,6 @@ SHOW BINLOG EVENTS;
--connection default
DROP USER user1@localhost;
-
--echo # Test if SHOW BINLOG EVENTS is allowed with BINLOG MONITOR
CREATE USER user1@localhost;
GRANT BINLOG MONITOR ON *.* TO user1@localhost;
@@ -196,7 +181,7 @@ RENAME TABLE t1 to t2;
--connection default
REVOKE BINLOG REPLAY ON *.* FROM user1@localhost;
-call mtr.add_suppression("Access denied; you need (at least one of) the SUPER, BINLOG REPLAY privilege(s) for this operation");
+call mtr.add_suppression("Access denied; you need (at least one of) the BINLOG REPLAY privilege(s) for this operation");
--echo # Privilege errors are expected now:
--connection user1
--error 1
diff --git a/mysql-test/suite/binlog/t/binlog_gtid_index.test b/mysql-test/suite/binlog/t/binlog_gtid_index.test
new file mode 100644
index 00000000..458b77ec
--- /dev/null
+++ b/mysql-test/suite/binlog/t/binlog_gtid_index.test
@@ -0,0 +1,229 @@
+--source include/have_binlog_format_mixed.inc
+
+SET GLOBAL binlog_gtid_index= 0;
+SET GLOBAL binlog_gtid_index= 1;
+
+--let $file= query_get_value(SHOW MASTER STATUS, File, 1)
+--let $pos1= query_get_value(SHOW MASTER STATUS, Position, 1)
+SET @gtid1= @@gtid_binlog_pos;
+CREATE TABLE t1 (a INT PRIMARY KEY);
+--let $pos2= query_get_value(SHOW MASTER STATUS, Position, 1)
+SET @gtid2= @@gtid_binlog_pos;
+INSERT INTO t1 VALUES (1);
+--let $pos3= query_get_value(SHOW MASTER STATUS, Position, 1)
+SET @gtid3= @@gtid_binlog_pos;
+INSERT INTO t1 VALUES (2);
+INSERT INTO t1 VALUES (3);
+INSERT INTO t1 VALUES (4);
+--let $pos4= query_get_value(SHOW MASTER STATUS, Position, 1)
+SET @gtid4= @@gtid_binlog_pos;
+INSERT INTO t1 VALUES (5);
+--let $pos5= query_get_value(SHOW MASTER STATUS, Position, 1)
+SET @gtid5= @@gtid_binlog_pos;
+
+--disable_query_log
+--let $i=0
+while ($i < 100) {
+ eval INSERT INTO t1 VALUES (6 + $i);
+ inc $i;
+}
+--enable_query_log
+--let $pos6= query_get_value(SHOW MASTER STATUS, Position, 1)
+SET @gtid6= @@gtid_binlog_pos;
+
+INSERT INTO t1 VALUES (106);
+INSERT INTO t1 VALUES (107);
+
+# Test first the hot and then the cold index.
+--let $i= 0
+while ($i < 2) {
+ --disable_query_log
+ eval SELECT BINLOG_GTID_POS('$file', $pos1) = @gtid1 AS Ok;
+ eval SELECT BINLOG_GTID_POS('$file', $pos2) = @gtid2 AS Ok;
+ eval SELECT BINLOG_GTID_POS('$file', $pos3) = @gtid3 AS Ok;
+ eval SELECT BINLOG_GTID_POS('$file', $pos4) = @gtid4 AS Ok;
+ eval SELECT BINLOG_GTID_POS('$file', $pos5) = @gtid5 AS Ok;
+ eval SELECT BINLOG_GTID_POS('$file', $pos6) = @gtid6 AS Ok;
+ --enable_query_log
+
+ inc $i;
+ if ($i == 1) {
+ FLUSH BINARY LOGS;
+ }
+}
+
+--echo *** Test that purge deletes the gtid index files. ***
+FLUSH BINARY LOGS;
+INSERT INTO t1 VALUES (200);
+--let $file2= query_get_value(SHOW MASTER STATUS, File, 1)
+FLUSH BINARY LOGS;
+INSERT INTO t1 VALUES (201);
+--let $file3= query_get_value(SHOW MASTER STATUS, File, 1)
+FLUSH BINARY LOGS;
+INSERT INTO t1 VALUES (202);
+--let $file4= query_get_value(SHOW MASTER STATUS, File, 1)
+
+--replace_result $file3 FILE
+eval PURGE BINARY LOGS TO '$file3';
+
+--let $MYSQLD_DATADIR= `select @@datadir`
+--error 1
+--file_exists $MYSQLD_DATADIR/$file.idx
+--error 1
+--file_exists $MYSQLD_DATADIR/$file2.idx
+--file_exists $MYSQLD_DATADIR/$file3.idx
+--file_exists $MYSQLD_DATADIR/$file4.idx
+
+--echo *** Test missed index lookup due to missing or corrupt index file.
+FLUSH NO_WRITE_TO_BINLOG BINARY LOGS;
+--let $file= query_get_value(SHOW MASTER STATUS, File, 1)
+INSERT INTO t1 VALUES (301);
+INSERT INTO t1 VALUES (302);
+INSERT INTO t1 VALUES (303);
+--let $pos= query_get_value(SHOW MASTER STATUS, Position, 1)
+SET @gtid_pos= @@GLOBAL.gtid_binlog_pos;
+INSERT INTO t1 VALUES (304);
+INSERT INTO t1 VALUES (305);
+
+# BINLOG_GTID_POS() has a side effect: it increments binlog_gtid_index_hit
+--disable_ps2_protocol
+FLUSH NO_WRITE_TO_BINLOG STATUS;
+--echo +++ Initial status:
+SHOW STATUS LIKE 'binlog_gtid_index_%';
+--echo +++ GTID Lookup in good index.
+--disable_query_log
+eval SELECT BINLOG_GTID_POS('$file', $pos) = @gtid_pos AS Gtid_Lookup_Ok;
+--enable_query_log
+SHOW STATUS LIKE 'binlog_gtid_index_%';
+--remove_file $MYSQLD_DATADIR/$file.idx
+--echo +++ GTID Lookup, index file is missing.
+--disable_query_log
+eval SELECT BINLOG_GTID_POS('$file', $pos) = @gtid_pos AS Gtid_Lookup_Ok;
+--enable_query_log
+SHOW STATUS LIKE 'binlog_gtid_index_%';
+
+FLUSH NO_WRITE_TO_BINLOG BINARY LOGS;
+--let $file= query_get_value(SHOW MASTER STATUS, File, 1)
+INSERT INTO t1 VALUES (306);
+--let $pos= query_get_value(SHOW MASTER STATUS, Position, 1)
+SET @gtid_pos= @@GLOBAL.gtid_binlog_pos;
+INSERT INTO t1 VALUES (307);
+INSERT INTO t1 VALUES (308);
+# Rotate again so we hit an on-disk index file, not the "hot" index.
+FLUSH NO_WRITE_TO_BINLOG BINARY LOGS;
+
+# Corrupt the flag byte of the first page with an unused bit.
+--let FILE_TO_CORRUPT= $MYSQLD_DATADIR/$file.idx
+--perl
+use strict;
+use warnings;
+use Fcntl qw(:DEFAULT :seek);
+sysopen F, $ENV{FILE_TO_CORRUPT}, O_RDWR
+ or die "Cannot open file $ENV{FILE_TO_CORRUPT}: $!\n";
+# Corrupt the flag byte with an unused flag.
+sysseek(F, 16, SEEK_SET)
+ or die "Cannot seek file: $!\n";
+my $buf;
+sysread(F, $buf, 1)
+ or die "Cannot read file: $!\n";
+$buf= chr(ord($buf) | 0x80);
+sysseek(F, 16, SEEK_SET)
+ or die "Cannot seek file: $!\n";
+syswrite(F, $buf, 1) == 1
+ or die "Cannot write file: $!\n";
+close F;
+EOF
+
+--echo +++ GTID Lookup, first page of index is corrupt.
+--disable_query_log
+eval SELECT BINLOG_GTID_POS('$file', $pos) = @gtid_pos AS Gtid_Lookup_Ok;
+--enable_query_log
+SHOW STATUS LIKE 'binlog_gtid_index_%';
+
+# Corrupt the last byte of the root page.
+# Set a small page-size so we test corruption in something not the header page.
+SET @old_page_size= @@GLOBAL.binlog_gtid_index_page_size;
+SET @old_span_min= @@GLOBAL.binlog_gtid_index_span_min;
+SET GLOBAL binlog_gtid_index_page_size= 64;
+SET GLOBAL binlog_gtid_index_span_min= 1;
+FLUSH NO_WRITE_TO_BINLOG BINARY LOGS;
+--let $file= query_get_value(SHOW MASTER STATUS, File, 1)
+INSERT INTO t1 VALUES (310);
+INSERT INTO t1 VALUES (311);
+INSERT INTO t1 VALUES (312);
+--let $pos= query_get_value(SHOW MASTER STATUS, Position, 1)
+SET @gtid_pos= @@GLOBAL.gtid_binlog_pos;
+INSERT INTO t1 VALUES (313);
+INSERT INTO t1 VALUES (314);
+INSERT INTO t1 VALUES (315);
+INSERT INTO t1 VALUES (316);
+FLUSH NO_WRITE_TO_BINLOG BINARY LOGS;
+SET GLOBAL binlog_gtid_index_page_size= @old_page_size;
+SET GLOBAL binlog_gtid_index_span_min= @old_span_min;
+
+--let FILE_TO_CORRUPT= $MYSQLD_DATADIR/$file.idx
+--perl
+use strict;
+use warnings;
+use Fcntl qw(:DEFAULT :seek);
+sysopen F, $ENV{FILE_TO_CORRUPT}, O_RDWR
+ or die "Cannot open file $ENV{FILE_TO_CORRUPT}: $!\n";
+# Tricky: The index is written asynchroneously, it may still be incomplete.
+# So wait for the file to be written completely with a root node at the end.
+my $count= 0;
+for (;;) {
+ my $end= sysseek(F, 0, SEEK_END);
+ if ($end > 0 && ($end % 64) == 0) {
+ # The index file is non-empty with a full page at the end, test if the
+ # root page has been fully written. This is seen as bit 2 (PAGE_FLAG_LAST)
+ # and bit 3 (PAGE_FLAG_ROOT) being set (0xc).
+ my $flag;
+ if (sysseek(F, -64, SEEK_CUR) &&
+ sysread(F, $flag, 1) &&
+ (ord($flag) & 0xc) == 0xc) {
+ last;
+ }
+ }
+ die "Timeout waiting for GTID index to be non-empty\n"
+ if ++$count >= 500;
+ # Simple way to do sub-second sleep.
+ select(undef, undef, undef, 0.050);
+}
+# Corrupt the flag byte with an unused flag.
+sysseek(F, -2, SEEK_END)
+ or die "Cannot seek file: $!\n";
+my $buf;
+sysread(F, $buf, 1)
+ or die "Cannot read file: $!\n";
+$buf= chr(ord($buf) ^ 0x4);
+sysseek(F, -2, SEEK_END)
+ or die "Cannot seek file: $!\n";
+syswrite(F, $buf, 1) == 1
+ or die "Cannot write file: $!\n";
+close F;
+EOF
+
+--echo +++ GTID Lookup, root page of index is corrupt.
+--disable_query_log
+eval SELECT BINLOG_GTID_POS('$file', $pos) = @gtid_pos AS Gtid_Lookup_Ok;
+--enable_query_log
+SHOW STATUS LIKE 'binlog_gtid_index_%';
+
+--echo *** Test BINLOG_GTID_POS() with too-large offset.
+# New binlog to skip the now corrupted one.
+FLUSH NO_WRITE_TO_BINLOG BINARY LOGS;
+--let $file= query_get_value(SHOW MASTER STATUS, File, 1)
+INSERT INTO t1 VALUES (401);
+INSERT INTO t1 VALUES (402);
+--echo +++ Test the hot index.
+--replace_result $file FILE
+eval SELECT BINLOG_GTID_POS('$file', 100000000);
+SHOW STATUS LIKE 'binlog_gtid_index_%';
+FLUSH NO_WRITE_TO_BINLOG BINARY LOGS;
+--echo +++ Test the cold index.
+--replace_result $file FILE
+eval SELECT BINLOG_GTID_POS('$file', 100000000);
+SHOW STATUS LIKE 'binlog_gtid_index_%';
+--enable_ps2_protocol
+
+DROP TABLE t1;
diff --git a/mysql-test/suite/binlog/t/binlog_gtid_index_crash.opt b/mysql-test/suite/binlog/t/binlog_gtid_index_crash.opt
new file mode 100644
index 00000000..993e6613
--- /dev/null
+++ b/mysql-test/suite/binlog/t/binlog_gtid_index_crash.opt
@@ -0,0 +1 @@
+--binlog-gtid-index-page-size=128 --binlog-gtid-index-span-min=1
diff --git a/mysql-test/suite/binlog/t/binlog_gtid_index_crash.test b/mysql-test/suite/binlog/t/binlog_gtid_index_crash.test
new file mode 100644
index 00000000..965e08a4
--- /dev/null
+++ b/mysql-test/suite/binlog/t/binlog_gtid_index_crash.test
@@ -0,0 +1,66 @@
+--source include/have_innodb.inc
+# Don't test this under valgrind, memory leaks will occur
+--source include/not_valgrind.inc
+# Avoid CrashReporter popup on Mac
+--source include/not_crashrep.inc
+# Binary must be compiled with debug for crash to occur
+--source include/have_debug.inc
+--source include/have_binlog_format_row.inc
+
+# We have an .opt file that sets a small page size and disables sparseness,
+# so we get something non-trivial in the GTID index even with a small amount
+# of binlogged events.
+
+--echo *** Test that binlog GTID index is recovered after a crash.
+CREATE TABLE t1 (a INT PRIMARY KEY, b INT) ENGINE=InnoDB;
+
+--disable_query_log
+INSERT INTO t1 VALUES (0, 0);
+INSERT INTO t1 VALUES (1, 0);
+INSERT INTO t1 VALUES (2, 0);
+--let $i= 10
+while ($i < 20) {
+ eval INSERT INTO t1 VALUES ($i, 0);
+ inc $i;
+}
+--let $file= query_get_value(SHOW MASTER STATUS, File, 1)
+--let $pos1= query_get_value(SHOW MASTER STATUS, Position, 1)
+--let $gtid1= `SELECT @@gtid_binlog_pos`
+while ($i < 30) {
+ eval INSERT INTO t1 VALUES ($i, 0);
+ inc $i;
+}
+--let $pos2= query_get_value(SHOW MASTER STATUS, Position, 1)
+--let $gtid2= `SELECT @@gtid_binlog_pos`
+while ($i < 40) {
+ eval INSERT INTO t1 VALUES ($i, 0);
+ inc $i;
+}
+--let $pos3= query_get_value(SHOW MASTER STATUS, Position, 1)
+--let $gtid3= `SELECT @@gtid_binlog_pos`
+INSERT INTO t1 VALUES (50, 0);
+INSERT INTO t1 VALUES (51, 0);
+
+--disable_ps2_protocol
+FLUSH NO_WRITE_TO_BINLOG STATUS;
+eval SELECT BINLOG_GTID_POS('$file', $pos1) = "$gtid1" AS Ok;
+eval SELECT BINLOG_GTID_POS('$file', $pos2) = "$gtid2" AS Ok;
+eval SELECT BINLOG_GTID_POS('$file', $pos3) = "$gtid3" AS Ok;
+--enable_query_log
+SHOW STATUS LIKE 'binlog_gtid_index_%';
+--enable_ps2_protocol
+
+--echo *** Crash the server, check that GTID index can be used after restart.
+--source include/crash_mysqld.inc
+
+--disable_ps2_protocol
+FLUSH NO_WRITE_TO_BINLOG STATUS;
+--disable_query_log
+eval SELECT BINLOG_GTID_POS('$file', $pos1) = "$gtid1" AS Ok;
+eval SELECT BINLOG_GTID_POS('$file', $pos2) = "$gtid2" AS Ok;
+eval SELECT BINLOG_GTID_POS('$file', $pos3) = "$gtid3" AS Ok;
+--enable_query_log
+SHOW STATUS LIKE 'binlog_gtid_index_%';
+--enable_ps2_protocol
+
+DROP TABLE t1;
diff --git a/mysql-test/suite/binlog/t/binlog_killed.test b/mysql-test/suite/binlog/t/binlog_killed.test
index 7c3a262d..271da705 100644
--- a/mysql-test/suite/binlog/t/binlog_killed.test
+++ b/mysql-test/suite/binlog/t/binlog_killed.test
@@ -67,7 +67,7 @@ let $rows= `select count(*) from t2 /* must be 2 or 0 */`;
let $MYSQLD_DATADIR= `select @@datadir`;
--let $binlog_killed_pos=query_get_value(SHOW BINLOG EVENTS, Pos, 6)
---let $binlog_killed_end_log_pos=query_get_value(SHOW BINLOG EVENTS, End_log_pos, 6)
+--let $binlog_killed_end_log_pos=query_get_value(SHOW BINLOG EVENTS, Pos, 7)
--exec $MYSQL_BINLOG --force-if-open --start-position=$binlog_killed_pos --stop-position=$binlog_killed_end_log_pos $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/kill_query_calling_sp.binlog
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--disable_result_log
diff --git a/mysql-test/suite/binlog/t/binlog_killed_simulate-master.opt b/mysql-test/suite/binlog/t/binlog_killed_simulate-master.opt
index 90c70ece..d6f14950 100644
--- a/mysql-test/suite/binlog/t/binlog_killed_simulate-master.opt
+++ b/mysql-test/suite/binlog/t/binlog_killed_simulate-master.opt
@@ -1 +1 @@
---loose-debug=d,simulate_kill_bug27571
+--loose-debug-dbug=d,simulate_kill_bug27571
diff --git a/mysql-test/suite/binlog/t/binlog_mysqlbinlog_raw_flush.test b/mysql-test/suite/binlog/t/binlog_mysqlbinlog_raw_flush.test
index 539a8fe5..e32d1e0e 100644
--- a/mysql-test/suite/binlog/t/binlog_mysqlbinlog_raw_flush.test
+++ b/mysql-test/suite/binlog/t/binlog_mysqlbinlog_raw_flush.test
@@ -23,6 +23,8 @@
# Test needs to reset the binlog as it is checking specific GTID.
RESET MASTER;
+RESET MASTER;
+
--echo #
--echo # MDEV-30698 Cover missing test cases for mariadb-binlog options
--echo # --raw [and] --flashback
diff --git a/mysql-test/suite/binlog/t/binlog_old_versions.test b/mysql-test/suite/binlog/t/binlog_old_versions.test
deleted file mode 100644
index 13010154..00000000
--- a/mysql-test/suite/binlog/t/binlog_old_versions.test
+++ /dev/null
@@ -1,153 +0,0 @@
-# Test that old binlog formats can be read.
-
-# Some previous versions of MySQL use their own binlog format,
-# especially in row-based replication. This test uses saved binlogs
-# from those old versions to test that we can replicate from old
-# versions to the present version.
-
-# Replicating from old versions to new versions is necessary in an
-# online upgrade scenario, where the .
-
-# The previous versions we currently test are:
-# - version 5.1.17 and earlier trees
-# - mysql-5.1-wl2325-xxx trees (AKA alcatel trees)
-# - mysql-5.1-telco-6.1 trees
-# For completeness, we also test mysql-5.1-new_rpl, which is supposed
-# to be the "correct" version.
-
-# All binlogs were generated with the same commands (listed at the end
-# of this test for reference). The binlogs contain the following
-# events: Table_map, Write_rows, Update_rows, Delete_rows Query, Xid,
-# User_var, Int_var, Rand, Begin_load, Append_file, Execute_load.
-
-# Related bugs: BUG#27779, BUG#31581, BUG#31582, BUG#31583, BUG#32407
-
-source include/not_embedded.inc;
-
---echo ==== Read binlog with v2 row events ====
-
-# Read binlog.
---exec $MYSQL_BINLOG --local-load=$MYSQLTEST_VARDIR/tmp/ suite/binlog/std_data/ver_trunk_row_v2.001 | $MYSQL --local-infile=1
-# Show result.
-SELECT * FROM t1 ORDER BY a;
-SELECT * FROM t2 ORDER BY a;
-SELECT COUNT(*) FROM t3;
-# Reset.
-DROP TABLE t1, t2, t3;
-
-
---echo ==== Read modern binlog (version 5.1.23) ====
-
-# Read binlog.
---exec $MYSQL_BINLOG --local-load=$MYSQLTEST_VARDIR/tmp/ suite/binlog/std_data/ver_5_1_23.001 | $MYSQL --local-infile=1
-# Show result.
-SELECT * FROM t1 ORDER BY a;
-SELECT * FROM t2 ORDER BY a;
-SELECT COUNT(*) FROM t3;
-# Reset.
-DROP TABLE t1, t2, t3;
-
-
---echo ==== Read binlog from version 5.1.17 ====
-
-# Read binlog.
---exec $MYSQL_BINLOG --local-load=$MYSQLTEST_VARDIR/tmp/ suite/binlog/std_data/ver_5_1_17.001 | $MYSQL --local-infile=1
-# Show result.
-SELECT * FROM t1 ORDER BY a;
-SELECT * FROM t2 ORDER BY a;
-SELECT COUNT(*) FROM t3;
-# Reset.
-DROP TABLE t1, t2, t3;
-
-
---echo ==== Read binlog from version 4.1 ====
-
-# In this version, neither row-based binlogging nor Xid events
-# existed, so the binlog was generated without the "row-based tests"
-# part and the "get xid event" part, and it does not create table t2.
-
-# Read binlog.
---exec $MYSQL_BINLOG --local-load=$MYSQLTEST_VARDIR/tmp/ suite/binlog/std_data/binlog_old_version_4_1.000001 | $MYSQL --local-infile=1
-# Show result.
-SELECT * FROM t1 ORDER BY a;
-SELECT COUNT(*) FROM t3;
-# Reset.
-DROP TABLE t1, t3;
-
-
---echo ==== Read binlog from telco tree (mysql-5.1-telco-6.1) ====
-
-# Read binlog.
---exec $MYSQL_BINLOG --local-load=$MYSQLTEST_VARDIR/tmp/ suite/binlog/std_data/ver_5_1-telco.001 | $MYSQL --local-infile=1
-# Show resulting tablea.
-SELECT * FROM t1 ORDER BY a;
-SELECT * FROM t2 ORDER BY a;
-SELECT COUNT(*) FROM t3;
-# Reset.
-DROP TABLE t1, t2, t3;
-
-
-#### The following commands were used to generate the binlogs ####
-#
-#source include/master-slave.inc;
-#
-## ==== initialize ====
-#USE test;
-#CREATE TABLE t1 (a int, b char(50)) ENGINE = MyISAM;
-#CREATE TABLE t2 (a int, b char(50)) ENGINE = InnoDB;
-#CREATE TABLE t3 (a char(20));
-#
-#
-## ==== row based tests ====
-#SET BINLOG_FORMAT='row';
-#
-## ---- get write, update, and delete rows events ----
-#INSERT INTO t1 VALUES (0, 'one'), (1, 'two');
-#UPDATE t1 SET a=a+1;
-#DELETE FROM t1 WHERE a=2;
-#
-#
-## ==== statement based tests ====
-#SET BINLOG_FORMAT = 'statement';
-#
-## ---- get xid events ----
-#BEGIN;
-#INSERT INTO t2 VALUES (3, 'first stm in trx');
-#INSERT INTO t1 VALUES (3, 'last stm in trx: next event should be xid');
-#COMMIT;
-#
-## ---- get user var events ----
-#SET @x = 4;
-#INSERT INTO t1 VALUES (@x, 'four');
-#
-## ---- get rand event ----
-#INSERT INTO t1 VALUES (RAND() * 1000000, 'random');
-#
-## ---- get intvar event ----
-#INSERT INTO t1 VALUES (LAST_INSERT_ID(), 'last_insert_id');
-#
-## ---- get begin, append and execute load events ----
-## double the file until we have more than 2^17 bytes, so that the
-## event has to be split and we can use Append_file_log_event.
-#
-#SET SQL_LOG_BIN=0;
-#CREATE TABLE temp (a char(20));
-#LOAD DATA INFILE '../std_data_ln/words.dat' INTO TABLE temp;
-#INSERT INTO temp SELECT * FROM temp;
-#INSERT INTO temp SELECT * FROM temp;
-#INSERT INTO temp SELECT * FROM temp;
-#INSERT INTO temp SELECT * FROM temp;
-#INSERT INTO temp SELECT * FROM temp;
-#INSERT INTO temp SELECT * FROM temp;
-#INSERT INTO temp SELECT * FROM temp;
-#INSERT INTO temp SELECT * FROM temp;
-#SELECT a FROM temp INTO OUTFILE 'big_file.dat';
-#DROP TABLE temp;
-#SET SQL_LOG_BIN=1;
-#
-#LOAD DATA INFILE 'big_file.dat' INTO TABLE t3;
-#
-#SELECT * FROM t1 ORDER BY a;
-#SELECT * FROM t2 ORDER BY a;
-#SELECT COUNT(*) FROM t3;
-#--source include/rpl_end.inc
diff --git a/mysql-test/suite/binlog/t/binlog_row_img.test b/mysql-test/suite/binlog/t/binlog_row_img.test
new file mode 100644
index 00000000..a6624e7e
--- /dev/null
+++ b/mysql-test/suite/binlog/t/binlog_row_img.test
@@ -0,0 +1,35 @@
+################################################################################
+# Support binlog_row_image FULL_NODUP mode
+#
+# In FULL_NODUP:
+# - before image includes all columns.
+# - after image includes only changed columns.
+################################################################################
+
+--source include/have_binlog_format_row.inc
+--echo #
+--echo # FULL_NODUP mode works as expected
+--echo #
+SET binlog_row_image = "FULL_NODUP";
+--source suite/binlog/include/row_img.test
+
+--echo #
+--echo # MINIMAL mode works as expected
+--echo #
+SET binlog_row_image = "MINIMAL";
+--source suite/binlog/include/row_img.test
+
+--echo #
+--echo # NOBLOB mode works as expected
+--echo #
+SET binlog_row_image = "NOBLOB";
+--source suite/binlog/include/row_img.test
+
+--echo #
+--echo # FULL mode works as expected
+--echo #
+SET binlog_row_image = "FULL";
+--source suite/binlog/include/row_img.test
+
+RESET MASTER;
+
diff --git a/mysql-test/suite/binlog/t/binlog_stm_do_db.test b/mysql-test/suite/binlog/t/binlog_stm_do_db.test
index 3ed1734f..c83753eb 100644
--- a/mysql-test/suite/binlog/t/binlog_stm_do_db.test
+++ b/mysql-test/suite/binlog/t/binlog_stm_do_db.test
@@ -19,7 +19,7 @@
#
# The test is implemented as follows:
#
-# i) set tx_isolation to read-committed.
+# i) set transaction_isolation to read-committed.
#
# ii) create two databases (one filtered other not - using
# binlog-do-db)
@@ -38,8 +38,8 @@
-- source include/have_innodb.inc
-- source include/have_binlog_format_statement.inc
RESET MASTER; # clear up binlogs
-SET @old_isolation_level= @@session.tx_isolation;
-SET @@session.tx_isolation= 'READ-COMMITTED';
+SET @old_isolation_level= @@session.transaction_isolation;
+SET @@session.transaction_isolation= 'READ-COMMITTED';
-- let $engine= InnoDB
-- let $filtered= b42829_filtered
@@ -87,4 +87,4 @@ source include/show_binlog_events.inc;
-- eval DROP DATABASE $not_filtered
-- eval DROP DATABASE $filtered
-SET @@session.tx_isolation= @old_isolation_level;
+SET @@session.transaction_isolation= @old_isolation_level;
diff --git a/mysql-test/suite/binlog/t/binlog_stm_mysqlbinlog_collate_implicit.test b/mysql-test/suite/binlog/t/binlog_stm_mysqlbinlog_collate_implicit.test
new file mode 100644
index 00000000..77dad9de
--- /dev/null
+++ b/mysql-test/suite/binlog/t/binlog_stm_mysqlbinlog_collate_implicit.test
@@ -0,0 +1,77 @@
+-- source include/have_utf8.inc
+-- source include/have_utf8mb4.inc
+-- source include/have_ucs2.inc
+-- source include/have_binlog_format_statement.inc
+-- source include/have_log_bin.inc
+
+--disable_query_log
+CALL mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
+--enable_query_log
+
+RESET MASTER;
+SET timestamp=1000000000;
+
+--echo #
+--echo # MDEV-30164 System variable for default collations
+--echo #
+
+SET character_set_collations='utf8mb3=utf8mb3_bin,ucs2=ucs2_bin';
+
+CREATE TABLE t1 (a VARCHAR(20));
+DROP TABLE t1;
+
+CREATE TABLE t1 (a VARCHAR(20) CHARACTER SET utf8mb4);
+DROP TABLE t1;
+
+CREATE TABLE t1 (a VARCHAR(20) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin);
+DROP TABLE t1;
+
+CREATE TABLE t1 (a VARCHAR(20) CHARACTER SET utf8mb3);
+
+INSERT INTO t1 VALUES ('a00');
+INSERT INTO t1 VALUES (_utf8mb3'a01-utf8mb3');
+INSERT INTO t1 VALUES (_utf8mb4'a01-utf8mb4');
+
+PREPARE stmt FROM 'INSERT INTO t1 VALUES (?)';
+EXECUTE stmt USING _utf8mb3'a02-utf8mb3';
+EXECUTE stmt USING _utf8mb4'a02-utf8mb4';
+
+EXECUTE stmt USING CONVERT('a03-utf8mb3' USING utf8mb3);
+EXECUTE stmt USING CONVERT('a03-utf8mb4' USING utf8mb4);
+
+EXECUTE stmt USING IF(0,CONVERT('a04-utf8mb3' USING utf8mb3),CONVERT('a03-utf8mb4' USING utf8mb4));
+EXECUTE stmt USING IF(1,CONVERT('a04-utf8mb3' USING utf8mb3),CONVERT('a03-utf8mb4' USING utf8mb4));
+
+DEALLOCATE PREPARE stmt;
+
+DROP TABLE t1;
+
+PREPARE stmt FROM 'CREATE TABLE t1 (a VARCHAR(20) CHARACTER SET utf8mb4)';
+EXECUTE stmt;
+DROP TABLE t1;
+DEALLOCATE PREPARE stmt;
+
+PREPARE stmt FROM 'CREATE TABLE t1 (a VARCHAR(20) CHARACTER SET utf8mb3)';
+EXECUTE stmt;
+DROP TABLE t1;
+DEALLOCATE PREPARE stmt;
+
+
+EXECUTE IMMEDIATE 'CREATE TABLE t1 (a VARCHAR(20) CHARACTER SET utf8mb4)';
+DROP TABLE t1;
+
+EXECUTE IMMEDIATE 'CREATE TABLE t1 (a VARCHAR(20) CHARACTER SET utf8mb3)';
+DROP TABLE t1;
+
+
+### Starting master-bin.000002
+FLUSH LOGS;
+
+--disable_query_log
+SELECT "--- ---- ---" as "";
+--enable_query_log
+
+let $MYSQLD_DATADIR= `select @@datadir`;
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--replace_regex /SQL_LOAD_MB-[0-9a-f]+-[0-9a-f]+/SQL_LOAD_MB-#-#/ /@@session.sql_mode=\d+/@@session.sql_mode=#/ /collation_server=\d+/collation_server=#/
+--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ $MYSQLD_DATADIR/master-bin.000001
diff --git a/mysql-test/suite/binlog/t/binlog_table_map_optional_metadata.test b/mysql-test/suite/binlog/t/binlog_table_map_optional_metadata.test
index 4577c6c1..ea439730 100644
--- a/mysql-test/suite/binlog/t/binlog_table_map_optional_metadata.test
+++ b/mysql-test/suite/binlog/t/binlog_table_map_optional_metadata.test
@@ -275,7 +275,7 @@ INSERT INTO t1 VALUES(2, "b");
# The invalid metadata will case assertion failure on Write_rows_log_event
# So we need to stop mysqlbinlog before reading Write_rows_log_event.
---let $stop_position= query_get_value(SHOW BINLOG EVENTS FROM $start_pos LIMIT 3, End_log_pos, 3)
+--let $stop_position= query_get_value(SHOW BINLOG EVENTS FROM $start_pos LIMIT 4, Pos, 4)
--source include/print_optional_metadata.inc
--echo #
@@ -291,7 +291,7 @@ INSERT INTO t1(c_point) VALUES(ST_PointFromText('POINT(10 10)'));
# The invalid metadata will case assertion failure on Write_rows_log_event
# So we need to stop mysqlbinlog before reading Write_rows_log_event.
---let $stop_position= query_get_value(SHOW BINLOG EVENTS FROM $start_pos LIMIT 3, End_log_pos, 3)
+--let $stop_position= query_get_value(SHOW BINLOG EVENTS FROM $start_pos LIMIT 4, Pos, 4)
--source include/print_optional_metadata.inc
DROP TABLE t1;
diff --git a/mysql-test/suite/binlog/t/binlog_truncate_multi_engine.test b/mysql-test/suite/binlog/t/binlog_truncate_multi_engine.test
index 12b0a743..61d097a8 100644
--- a/mysql-test/suite/binlog/t/binlog_truncate_multi_engine.test
+++ b/mysql-test/suite/binlog/t/binlog_truncate_multi_engine.test
@@ -12,6 +12,7 @@
--source include/have_debug.inc
--source include/have_debug_sync.inc
--source include/have_binlog_format_row.inc
+--source include/not_valgrind.inc
--let $old_max_binlog_size= `select @@global.max_binlog_size`
call mtr.add_suppression("Can.t init tc log");
diff --git a/mysql-test/suite/binlog/t/flashback.combinations b/mysql-test/suite/binlog/t/flashback.combinations
new file mode 100644
index 00000000..51716cbb
--- /dev/null
+++ b/mysql-test/suite/binlog/t/flashback.combinations
@@ -0,0 +1,4 @@
+[use_full_mode]
+binlog_row_image=FULL
+[use_full_nodup_mode]
+binlog_row_image=FULL_NODUP
diff --git a/mysql-test/suite/binlog/t/flashback.test b/mysql-test/suite/binlog/t/flashback.test
index 8daf3f43..fa20744b 100644
--- a/mysql-test/suite/binlog/t/flashback.test
+++ b/mysql-test/suite/binlog/t/flashback.test
@@ -372,6 +372,73 @@ DROP TABLE t1;
--error 1 # --raw mode and --flashback mode are not allowed
--exec $MYSQL_BINLOG -vv -B --raw --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000003> $MYSQLTEST_VARDIR/tmp/mysqlbinlog_row_flashback_8.sql
+--echo #
+--echo # < CASE 8 >
+--echo # Verify flashback works well for binlog_row_image full_nodup mode
+--echo #
+CREATE TABLE t1 (
+ c01 TINYINT PRIMARY KEY,
+ c02 SMALLINT,
+ c03 MEDIUMINT,
+ c04 INT,
+ c05 BIGINT,
+ c06 CHAR(10),
+ c07 VARCHAR(20),
+ c08 TEXT,
+ c09 ENUM('one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight'),
+ c10 SET('black', 'white', 'red', 'yellow'),
+ c11 TIMESTAMP(3),
+ c12 DATETIME(3)
+) ENGINE = InnoDB;
+
+INSERT INTO t1 VALUES (1, 1, 1, 1, 1, 'A', 'A', 'A', 'one', 'black',
+ '2023-11-26 10:00:00.123', '2023-11-26 10:00:00');
+INSERT INTO t1 VALUES (2, 1, 1, 1, 1, 'A', 'A', 'A', 'one', 'black',
+ '2023-11-26 10:00:00.123', '2023-11-26 10:00:00');
+INSERT INTO t1 VALUES (3, 1, NULL, 1, 1, 'A', 'A', 'A', 'one', 'black',
+ '2023-11-26 10:00:00.123', NULL);
+INSERT INTO t1 VALUES (4, 1, NULL, 1, 1, 'A', 'A', 'A', 'one', 'black',
+ '2023-11-26 10:00:00.123', NULL);
+
+--let $checksum_old= `CHECKSUM TABLE t1`
+
+FLUSH BINARY LOGS;
+--echo # The update includes the cases that
+--echo # Value -> Value
+--echo # Value -> NULL
+--echo # NULL -> value
+--echo # and the changed null bits in both first and second null byte
+
+UPDATE t1 SET c02 = NULL, c03 = 2, c09 = 'two',
+ c10 = NULL, c12 = '2023-11-26 11:00:00';
+--let $master_file= query_get_value("SHOW MASTER STATUS", File, 1)
+--let $MYSQLD_DATADIR= `select @@datadir`
+FLUSH BINARY LOGS;
+
+--echo #
+--echo # Data before flashback
+--echo #
+SELECT * FROM t1;
+
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--exec $MYSQL_BINLOG -B -vv $MYSQLD_DATADIR/$master_file > $MYSQLTEST_VARDIR/tmp/mysqlbinlog_row_flashback.sql
+--exec $MYSQL -e "SET binlog_format= ROW; source $MYSQLTEST_VARDIR/tmp/mysqlbinlog_row_flashback.sql;"
+
+--echo #
+--echo # Data after flashback
+--echo #
+SELECT * FROM t1;
+
+# After flashback, t1's checksum should be same to original checksum
+--let $checksum_new = `CHECKSUM TABLE t1`
+if ($checksum_new != $checksum_old)
+{
+ --die "After flashback, t1's checksum is different from the original checksum"
+}
+
+DROP TABLE t1;
+--remove_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog_row_flashback.sql
+
## Clear
SET binlog_format=statement;
--error ER_FLASHBACK_NOT_SUPPORTED
diff --git a/mysql-test/suite/binlog/t/max_binlog_total_size-master.opt b/mysql-test/suite/binlog/t/max_binlog_total_size-master.opt
new file mode 100644
index 00000000..9ba64a44
--- /dev/null
+++ b/mysql-test/suite/binlog/t/max_binlog_total_size-master.opt
@@ -0,0 +1,5 @@
+--log-bin=binary
+--max-binlog-total-size=1500
+--max-binlog-size=4096
+--binlog-format=row
+--slave_connections_needed_for_purge=1
diff --git a/mysql-test/suite/binlog/t/max_binlog_total_size.test b/mysql-test/suite/binlog/t/max_binlog_total_size.test
new file mode 100644
index 00000000..19e6131b
--- /dev/null
+++ b/mysql-test/suite/binlog/t/max_binlog_total_size.test
@@ -0,0 +1,94 @@
+--source include/have_log_bin.inc
+select @@global.max_binlog_total_size;
+select @@global.max_binlog_size;
+
+# Note that this test is only using MyISAM tables.
+# The reason for this is that we do not want to have engine
+# checkpoints in the binary log as it would change the number of
+# bytes in the log, which could cause random rotations.
+
+--echo #
+--echo # MDEV-31404 Implement binlog_space_limit
+--echo #
+
+FLUSH LOGS;
+FLUSH LOGS;
+FLUSH LOGS;
+source include/show_binary_logs.inc;
+show status like "binlog_disk_use";
+set @@global.slave_connections_needed_for_purge= 0;
+--echo # binary.000001 should be deleted now
+source include/show_binary_logs.inc;
+show status like "binlog_disk_use";
+
+CREATE TABLE `t1` (
+ `v1` int(11) DEFAULT NULL,
+ `v2` varchar(8000) DEFAULT NULL,
+ KEY `v1` (`v1`)
+) engine=myisam;
+INSERT INTO t1 VALUES (0,repeat("a",3000));
+show status like "binlog_disk_use";
+--echo # First binary should be binary.000004
+source include/show_binary_logs.inc;
+
+INSERT INTO t1 VALUES (2,repeat("b",10));
+--echo # First binary should be binary.000004
+# The reson why we have logs 00004 and 00005 at this point is that we first
+# do a rotate and then try to purge. However as there are still existing
+# xid's pointing to the 00004, we cannot yet purge 000004.
+# After rotate a checkpoint record will be written to 00005 which
+# will release pointers to 00004. On next binary log write or flush
+# the purge will be retried and succeed.
+
+source include/show_binary_logs.inc;
+
+FLUSH LOGS;
+--echo # First binary should be binary.000005
+source include/show_binary_logs.inc;
+
+FLUSH LOGS;
+FLUSH LOGS;
+FLUSH LOGS;
+FLUSH LOGS;
+source include/show_binary_logs.inc;
+show status like "binlog_disk_use";
+
+PURGE BINARY LOGS TO 'binary.000009';
+--echo # First binary should be binary.000009
+source include/show_binary_logs.inc;
+
+INSERT INTO t1 VALUES (3,repeat("c",4000));
+--echo # First binary should be binary.000010
+source include/show_binary_logs.inc;
+
+INSERT INTO t1 VALUES (4,repeat("d",3000));
+--echo # First binary should be binary.000011
+source include/show_binary_logs.inc;
+
+RESET MASTER;
+source include/show_binary_logs.inc;
+show status like "binlog_disk_use";
+
+INSERT INTO t1 VALUES (5,"e");
+FLUSH LOGS;
+INSERT INTO t1 VALUES (6,repeat("f",3000));
+source include/show_binary_logs.inc;
+show status like "binlog_disk_use";
+
+INSERT INTO t1 VALUES (7,repeat("g",3000));
+--echo # binary.000001 should be deleted now
+source include/show_binary_logs.inc;
+show status like "binlog_disk_use";
+
+FLUSH LOGS;
+FLUSH LOGS;
+--echo # binary.000002 should be deleted now
+show binary logs;
+show status like "binlog_disk_use";
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+set @@global.slave_connections_needed_for_purge= default;
+# End of 11.4 tests