Debian Codegraph @

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

raw
1 # ==== Purpose ====
2 #
3 # This script tests that the `PRIVILEGE_CHECKS_USER` related columns and data
4 # are succesfully intitialized and instantiated during an upgrade.
5 #
6 # ==== Requirements ====
7 #
8 # R1. Upgrading from a version that doesn't have the proper system table columns
9 # will create those columns.
10 #
11 # R2. Upgrading from a FILE repository setup to a TABLE repository setup will
12 # instantiate the system table columns.
13 #
14 # R3. Upgrading from a TABLE repository setup to a FILE repository setup will
15 # instantiate the info files.
16 #
17 # ==== Implementation ====
18 #
19 # TC1. Upgrade from FILE to TABLE with PRIVILEGE_CHECKS_USER not configured
20 # -------------------------------------------------------------------------
21 # 1) Create a table and insert a record on the master.
22 # 2) Synchronize master and slave and stop the slave.
23 # 3) Remove the columns from `mysql.slave_relay_log_info` that regard
24 # `PRIVILEGE_CHECKS_USER`.
25 # 4) Ensure the slave has no information on system tables regarding
26 # `PRIVILEGE_CHECKS_USER`.
27 # 5) Restart the server with `--relay-log-info-repository=TABLE
28 # --upgrade=FORCE`.
29 # 6) Ensure the slave now has structure information on system tables regarding
30 # `PRIVILEGE_CHECKS_USER` but related columns aren't instantiated.
31 # 7) Change `PRIVILEGE_CHECKS_USER` and check the table is consistent.
32 #
33 # ==== References ====
34 #
35 # WL#12966 Replication with privilege checks
36 #
37
38 --source include/no_valgrind_without_big.inc
39 --source include/have_binlog_format_row.inc
40 --source include/not_mts_replica_parallel_workers.inc
41
42 --echo #
43 --echo # TC1. Upgrade from FILE to TABLE with PRIVILEGE_CHECKS_USER not
44 --echo # configured
45 --echo # --------------------------------------------------------------
46 --echo #
47
48 --source include/not_have_privilege_checks_user.inc
49 --source include/master-slave.inc
50
51 # 1) Create a table and insert a record on the master.
52 --source include/rpl_connection_master.inc
53 CREATE TABLE t (c INT);
54 INSERT INTO t VALUES (1), (2);
55
56 # 2) Synchronize master and slave and stop the slave.
57 --source include/sync_slave_sql_with_master.inc
58 --source include/stop_slave.inc
59
60 # 3) Remove the columns from `mysql.slave_relay_log_info` that regard
61 # `PRIVILEGE_CHECKS_USER`.
62 ALTER TABLE mysql.slave_relay_log_info DROP COLUMN Privilege_checks_username;
63 ALTER TABLE mysql.slave_relay_log_info DROP COLUMN Privilege_checks_hostname;
64
65 # 4) Ensure the slave has no information on system tables regarding
66 # `PRIVILEGE_CHECKS_USER`.
67 --let $configured_priv_checks_user = `SELECT COUNT(*) FROM performance_schema.replication_applier_configuration WHERE Privilege_Checks_User is NULL`
68 --let $channels_in_table = `SELECT COUNT(*) FROM mysql.slave_relay_log_info`
69 --let $priv_checks_columns = `SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = 'mysql' AND table_name = 'slave_relay_log_info' AND column_name LIKE 'Privilege_checks%'`
70
71 --let $assert_text = Configured PRIVILEGE_CHECKS_USER appears in PFS table with NULL value
72 --let $assert_cond = $configured_priv_checks_user = 1
73 --source include/assert.inc
74
75 --let $assert_text = Table mysql.slave_relay_log_info has no information since --relay-log-info-repository=FILE
76 --let $assert_cond = $channels_in_table = 0
77 --source include/assert.inc
78
79 --let $assert_text = Table mysql.slave_relay_log_info has no columns regarding PRIVILEGE_CHECKS_USER
80 --let $assert_cond = $priv_checks_columns = 0
81 --source include/assert.inc
82
83 # 5) Restart the server with `--relay-log-info-repository=TABLE --upgrade=FORCE`.
84 --let $rpl_server_number = 2
85 --source include/rpl_stop_server.inc
86
87 --let $rpl_server_number = 2
88 --let $rpl_server_parameters = --relay-log-info-repository=TABLE --upgrade=FORCE
89 --let $explicit_default_wait_counter = 15000
90 --source include/rpl_start_server.inc
91 --source include/start_slave.inc
92
93 # 6) Ensure the slave now has structure information on system tables regarding
94 # `PRIVILEGE_CHECKS_USER` but related columns aren't instantiated.
95 --source include/rpl_connection_slave.inc
96 --let $channels_in_table = `SELECT COUNT(*) FROM mysql.slave_relay_log_info WHERE Privilege_checks_username is NULL AND Privilege_checks_hostname is NULL`
97 --let $priv_checks_columns = `SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = 'mysql' AND table_name = 'slave_relay_log_info' AND column_name LIKE 'Privilege_checks%'`
98
99 --let $assert_text = Table mysql.slave_relay_log_info has columns for PRIVILEGE_CHECKS_USER
100 --let $assert_cond = $priv_checks_columns = 2
101 --source include/assert.inc
102
103 --let $assert_text = Table mysql.slave_relay_log_info has info for channel and PRIVILEGE_CHECKS_USER since --relay-log-info-repository=TABLE
104 --let $assert_cond = $channels_in_table = 1
105 --source include/assert.inc
106
107 # 7) Change `PRIVILEGE_CHECKS_USER` and check the table is consistent.
108 --source include/stop_slave.inc
109 --let $applier_user = 'u1'@'localhost'
110 --eval CREATE USER $applier_user;
111 --eval GRANT CREATE,INSERT,DROP,REPLICATION_APPLIER,SESSION_VARIABLES_ADMIN ON *.* TO $applier_user
112 --eval CHANGE REPLICATION SOURCE TO PRIVILEGE_CHECKS_USER = $applier_user, REQUIRE_ROW_FORMAT = 1
113 --source include/start_slave.inc
114
115 --let $channels_in_table = `SELECT COUNT(*) FROM mysql.slave_relay_log_info WHERE CONCAT("'", Privilege_checks_username, "'@'", Privilege_checks_hostname, "'") = "$applier_user"`
116 --let $assert_text = Table mysql.slave_relay_log_info has info for channel and PRIVILEGE_CHECKS_USER = $applier_user
117 --let $assert_cond = $channels_in_table = 1
118 --source include/assert.inc
119
120 # Clean up
121 --source include/rpl_connection_master.inc
122 DROP TABLE t;
123 --source include/sync_slave_sql_with_master.inc
124 --eval DROP USER $applier_user;
125
126 --source include/stop_slave.inc
127 CHANGE REPLICATION SOURCE TO PRIVILEGE_CHECKS_USER = NULL;
128 SET GLOBAL relay_log_info_repository="FILE";
129 --source include/start_slave.inc
130
131 --source include/rpl_end.inc