Debian Codegraph @

mysql-test/suite/rpl/t/rpl_row_jsondiff_generated_col.test

raw
1 # ==== Requirements ====
2 #
3 # When a table has generated columns depending on a JSON column,
4 # replication should work correctly when there are partial updates
5 # of the JSON column.
6 #
7 # ==== References ====
8 #
9 # - Implemented in WL#2955 RBR replication of partial JSON updates
10 # - See also rpl_row_jsondiff_error for violations of slave-only constraints
11 # on generated columns.
12
13 #--source include/have_binlog_format_row.inc
14 --source include/master-slave.inc
15
16 --echo ######## Configure ########
17
18 --let $replace_combination_from= BOTH.BINLOG_FORMAT=ROW,MIXED,STATEMENT
19 --let $replace_combination_to= GLOBAL.SLAVE_ROWS_SEARCH_ALGORITHMS=INDEX_SCAN,HASH_SCAN,TABLE_SCAN
20 --source include/rpl_connection_master.inc
21 --source include/begin_replace_combination.inc
22 SET @old_binlog_row_image= @@SESSION.BINLOG_ROW_IMAGE;
23 SET @old_binlog_row_value_options= @@SESSION.BINLOG_ROW_VALUE_OPTIONS;
24 SET @@SESSION.BINLOG_ROW_IMAGE= MINIMAL;
25 SET @@SESSION.BINLOG_ROW_VALUE_OPTIONS= PARTIAL_JSON;
26
27 --source include/rpl_connection_slave.inc
28 # To avoid an error 'ER_RUNNING_APPLIER_PREVENTS_SWITCH_GLOBAL_BINLOG_FORMAT',
29 # which will be caused by the following include/end_replace_combination.inc
30 --source include/stop_slave_sql.inc
31 --source include/begin_replace_combination.inc
32 --source include/start_slave_sql.inc
33 SET @old_binlog_row_image= @@GLOBAL.BINLOG_ROW_IMAGE;
34 SET @old_binlog_row_value_options= @@GLOBAL.BINLOG_ROW_VALUE_OPTIONS;
35 SET @@GLOBAL.BINLOG_ROW_IMAGE= MINIMAL;
36 SET @@GLOBAL.BINLOG_ROW_VALUE_OPTIONS= PARTIAL_JSON;
37 --source include/stop_slave.inc
38 --source include/start_slave.inc
39
40 --echo ######## Initialize ########
41
42 --source include/rpl_connection_master.inc
43
44 CREATE TABLE t (i INT, j JSON,
45 v VARCHAR(256) AS (JSON_PRETTY(j)) VIRTUAL,
46 s VARCHAR(256) AS (JSON_PRETTY(j)) STORED);
47
48 INSERT INTO t (j) VALUES ('[{"a":"abc"},{"b":"abcd"}]'),
49 ('{"key":[{"key":"value"},{"key":"value2"}]}');
50
51 --echo ######## Test ########
52
53 --source include/sync_slave_sql_with_master.inc
54 --source include/rpl_connection_master.inc
55 --let $diff_tables= master:t, slave:t
56 --source include/diff_tables.inc
57
58 UPDATE t SET j= JSON_REPLACE(j, '$[0].a',"a");
59 --source include/sync_slave_sql_with_master.inc
60
61 --source include/rpl_connection_master.inc
62 --let $diff_tables= master:t, slave:t
63 --source include/diff_tables.inc
64
65 UPDATE t SET j= JSON_SET(j, '$.key[0]', "a");
66 --source include/sync_slave_sql_with_master.inc
67
68 --source include/rpl_connection_master.inc
69 --let $diff_tables= master:t, slave:t
70 --source include/diff_tables.inc
71
72 UPDATE t SET j= JSON_REMOVE(j, '$.key[0].key');
73 --source include/sync_slave_sql_with_master.inc
74
75 --source include/rpl_connection_master.inc
76 --let $diff_tables= master:t, slave:t
77 --source include/diff_tables.inc
78
79 --echo ######## Clean up ########
80
81 DROP TABLE t;
82 SET @@SESSION.BINLOG_ROW_VALUE_OPTIONS= @old_binlog_row_value_options;
83 SET @@SESSION.BINLOG_ROW_IMAGE= @old_binlog_row_image;
84 --source include/end_replace_combination.inc
85
86 --source include/sync_slave_sql_with_master.inc
87 SET @@GLOBAL.BINLOG_ROW_VALUE_OPTIONS= @old_binlog_row_value_options;
88 SET @@GLOBAL.BINLOG_ROW_IMAGE= @old_binlog_row_image;
89 # To avoid an error 'ER_RUNNING_APPLIER_PREVENTS_SWITCH_GLOBAL_BINLOG_FORMAT',
90 # which will be caused by the following include/end_replace_combination.inc
91 --source include/stop_slave_sql.inc
92 --source include/end_replace_combination.inc
93
94 --let $rpl_only_running_threads= 1
95 --source include/rpl_end.inc