mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
MDEV-32894 mysqlbinlog flashback support binlog_row_image FULL_NODUP mode
Summary ======= With FULL_NODUP mode, before image inclues all columns and after image inclues only the changed columns. flashback will swap the value of changed columns from after image to before image. For example: BI: c1, c2, c3_old, c4_old AI: c3_new, c4_new flashback will reconstruct the before and after images to BI: c1, c2, c3_new, c4_new AI: c3_old, c4_old Implementation ============== When parsing the before and after image, position and length of the fields are collected into ai_fields and bi_fields, if it is an Update_rows_event and the after image doesn't includes all columns. The changed fields are swapped between bi_fields and ai_fields. Then it recreates the before image and after image by using bi_fields and ai_fields. nullbit will be set to 1 if the field is NULL, otherwise nullbit will be 0. It also optimized flashback a little bit. - calc_row_event_length is used instead of print_verbose_one_row - swap_buff1 and swap_buff2 are removed.
This commit is contained in:
committed by
Andrew Hutchings
parent
f552febe43
commit
8bf9f21855
@@ -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
|
||||
|
Reference in New Issue
Block a user