Debian Codegraph @

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

raw
1 # ==== Purpose ====
2 #
3 # This script intends to test that privilege checks, within the applier context,
4 # aren't impacted when DDL changes are performed on the slave.
5 #
6 # ==== Requirements ====
7 #
8 # R1. Adding extra columns, on the slave, to a replicated table MUST not impact
9 # column level privilege checking.
10 # R2. Removing columns, on the slave, from a replicated table MUST not impact
11 # column level privilege checking.
12 #
13 # ==== Implementation ====
14 #
15 # TC.1) Check column level privilege checking with an extra column on the slave
16 # -----------------------------------------------------------------------------
17 # 1) Set applier privilege checks.
18 # 2) Set `binlog_row_image` to `MINIMAL`.
19 # 3) Create a table on the master.
20 # 4) Add an extra column on the slave.
21 # 5) Make a DDL change on the master.
22 # 6) Check tables have the same data on master and slave.
23 #
24 # TC.2) Check column level privilege checking with a column short on the slave
25 # ----------------------------------------------------------------------------
26 # 1) Create a table on the master with two or more columns.
27 # 2) Remove the table last column on the slave.
28 # 3) Make a DDL change on the master.
29 # 4) Check tables have the same data on master and slave.
30 #
31 # ==== References ====
32 #
33 # WL#12966 Replication with privilege checks
34 #
35 # BUG#30343310 ASSERTION `BIT < MAP->N_BITS' POST SLAVE RESTART IF SLAVE HAS
36 # MORE COLUMNS
37 #
38
39 --echo #
40 --echo # TC.1) Check column level privilege checking with an extra column on the
41 --echo # slave
42 --echo #
43
44 --source include/have_binlog_format_row.inc
45 --echo #
46 --echo # 1) Set applier privilege checks.
47 --echo #
48 --let $rpl_privilege_checks_user = *:'u1'@'localhost'
49 --let $rpl_privilege_checks_user_additional_grants = INSERT,CREATE,DROP
50 --source include/master-slave.inc
51
52 --echo #
53 --echo # 2) Set `binlog_row_image` to `MINIMAL`.
54 --echo #
55 --let $global_binlog_row_image = `SELECT @@global.binlog_row_image`
56 --let $session_binlog_row_image = `SELECT @@session.binlog_row_image`
57 SET @@global.binlog_row_image = MINIMAL;
58 SET @@session.binlog_row_image = MINIMAL;
59
60 --echo #
61 --echo # 3) Create a table on the master.
62 --echo #
63 --connection master
64 CREATE TABLE test.t1 (a INT);
65 --source include/sync_slave_sql_with_master.inc
66
67 --echo #
68 --echo # 4) Add an extra column on the slave.
69 --echo #
70 ALTER TABLE test.t1 ADD COLUMN b INT;
71 --source include/stop_slave.inc
72 --source include/start_slave.inc
73
74 --echo #
75 --echo # 5) Make a DDL change on the master.
76 --echo #
77 --connection master
78 INSERT INTO test.t1 VALUES (1);
79 --source include/sync_slave_sql_with_master.inc
80
81 --echo #
82 --echo # 6) Check tables have the same data on master and slave.
83 --echo #
84 --let $diff_tables = master:t1,slave:t1
85 --let $mask_column_list = b
86 --source include/diff_tables.inc
87
88 --echo #
89 --echo # TC.2) Check column level privilege checking with a column short on the
90 --echo # slave
91 --echo #
92
93 --echo #
94 --echo # 1) Create a table on the master with two or more columns.
95 --echo #
96 --connection master
97 CREATE TABLE test.t2 (a INT, b INT, c VARCHAR(50));
98 --source include/sync_slave_sql_with_master.inc
99
100 --echo #
101 --echo # 2) Remove the table last column on the slave.
102 --echo #
103 ALTER TABLE test.t2 DROP COLUMN c;
104 --source include/stop_slave.inc
105 --source include/start_slave.inc
106
107 --echo #
108 --echo # 3) Make a DDL change on the master.
109 --echo #
110 --connection master
111 INSERT INTO test.t2 VALUES (1,1,"a string of characters");
112 --source include/sync_slave_sql_with_master.inc
113
114 --echo #
115 --echo # 4) Check tables have the same data on master and slave.
116 --echo #
117 --let $diff_tables = master:t2,slave:t2
118 --let $mask_column_list = c
119 --source include/diff_tables.inc
120
121 # Clean up
122 --connection master
123 --replace_result $global_binlog_row_image GLOBAL_BINLOG_ROW_IMAGE
124 --eval SET @@global.binlog_row_image = $global_binlog_row_image
125 --replace_result $session_binlog_row_image SESSION_BINLOG_ROW_IMAGE
126 --eval SET @@session.binlog_row_image = $session_binlog_row_image
127 DROP TABLE t1;
128 DROP TABLE t2;
129 --source include/rpl_end.inc