mariadb/mysql-test/suite/binlog/include/row_img.test
Libing Song a119c5f998 MDEV-32589 FULL_NODUP mode for binlog_row_image
This patch provides a new mode FULL_NODUP to binlog_row_image system
variable. With FULL_NODUP mode, all columns are included in before
image, but only updated columns are included in after image for UPDATE.
While all columns are included in the after image for INSERT.

FULL_NODUP is for replacing FULL mode. It includes all data of
the before and after image as FULL mode, but it uses less storage
especially in the case that only a few columns are updated.

Note: It will binlog full before and after image for all modes if the
      table has no primary key. FULL_NODUP follows the behavior.
2023-11-23 08:28:54 +00:00

56 lines
2.2 KiB
Text

# 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;