Debian Codegraph @

mysql-test/suite/binlog/t/binlog_multi_valued_index.test

raw
1 --source include/have_log_bin.inc
2 --source include/have_binlog_format_row.inc
3 --source include/have_grep.inc
4
5 # ==== Requirements ====
6 #
7 # R1. When using binlog_transaction_dependency_tracking = 'WRITESET', two
8 # transactions that conflict on a unique multi-valued index must be marked as
9 # dependent in the binary log.
10 # R2. When using binlog_row_image=MINIMAL, the before-image shall not be
11 # generated from a multi-valued index.
12 #
13 # ==== Implementation ====
14 #
15 # To test R1:
16 # 1. Create a table with a multi-valued index
17 # 2. Insert rows that conflict only on a multi-valued index
18 # 3. Verify that the logical timestamps are set in a way that indicates the
19 # transactions are dependent
20 #
21 # To test R2;
22 # 1. Set binlog_row_image=MINIMAL
23 # 2. Create a table having only one index, a unique multi-valued index
24 # 3. Update/delete rows
25 # 4. Use mysqlbinlog -v -v to verify that the full row is included, and not
26 # just the columns of the multi-valued index
27 #
28 # ==== References ====
29 #
30 # WL#8955: Add support for multi-valued indexes
31
32 --let $mysqlbinlog_only_decoded_rows = 1
33 --source include/save_binlog_position.inc
34
35 CREATE TABLE t1 (id INT, c INT, j JSON NOT NULL,
36 UNIQUE INDEX i1((CAST(CAST(j AS JSON) AS UNSIGNED ARRAY))));
37 SET @@session.binlog_row_image = MINIMAL;
38 INSERT INTO t1 VALUES (1, 1, '[1,2,3,4]'), (2, 2, '[5,6,7,8]');
39 UPDATE t1 SET j = '[9,0]' WHERE JSON_CONTAINS(CAST(j AS JSON),'2');
40 SET @@session.binlog_row_image = FULL;
41 INSERT INTO t1 VALUES (10, 10, '[10,20,30,40]'), (20, 20, '[50,60,70,80]');
42 UPDATE t1 SET j = '[11,12,13,14]' WHERE JSON_CONTAINS(CAST(j AS JSON),'10');
43 SET @@session.binlog_row_image = NOBLOB;
44 INSERT INTO t1 VALUES (100, 100, '[100,200,300,400]'),
45 (200, 200, '[500,600,700,800]');
46 UPDATE t1 SET j = '[101,201,301,401]' WHERE JSON_CONTAINS(CAST(j AS JSON),'200');
47 DROP TABLE t1;
48
49 FLUSH LOGS;
50 --source include/mysqlbinlog.inc
51 --source include/save_binlog_position.inc
52
53 --echo # Check that when the only unique NOT NULL index is a functional index,
54 --echo # the binary log contains a full before-image regardless of
55 --echo # binlog_row_image.
56 CREATE TABLE t1 (id INT, c INT, j JSON NOT NULL,
57 UNIQUE INDEX i1((CAST(CAST(j AS JSON) AS UNSIGNED ARRAY))));
58 INSERT INTO t1 VALUES (1, 1, '[1,2,3,4]'), (2, 2, '[5,6,7,8]');
59
60 SET binlog_row_image = MINIMAL;
61 UPDATE t1 SET j = '[2,9,10]' WHERE JSON_CONTAINS(CAST(j AS JSON),'2');
62
63 SET binlog_row_image = FULL;
64 UPDATE t1 SET j = '[2,11,12]' WHERE JSON_CONTAINS(CAST(j AS JSON),'2');
65
66 SET binlog_row_image = NOBLOB;
67 UPDATE t1 SET j = '[2,13,14]' WHERE JSON_CONTAINS(CAST(j AS JSON),'2');
68
69 DROP TABLE t1;
70
71 FLUSH LOGS;
72 --source include/mysqlbinlog.inc