Debian Codegraph @

mysql-test/suite/sys_vars/t/gtid_mode_basic.test

raw
1
2 # default value
3
4 RESET MASTER;
5 SET @start_global_value = @@global.gtid_mode;
6 SELECT @start_global_value;
7
8 SET @start_enforce_gtid_consistency= @@global.enforce_gtid_consistency;
9 SET @@global.enforce_gtid_consistency = ON;
10
11 #
12 # exists as global only
13 #
14 select @@global.gtid_mode;
15 --error ER_INCORRECT_GLOBAL_LOCAL_VAR
16 select @@session.gtid_mode;
17 --error ER_GLOBAL_VARIABLE
18 set gtid_mode = @start_global_value;
19 --error ER_GLOBAL_VARIABLE
20 set @@session.gtid_mode = @start_global_value;
21 show global variables like 'gtid_mode';
22 show session variables like 'gtid_mode';
23 --disable_warnings
24 select * from performance_schema.global_variables where variable_name='gtid_mode';
25 select * from performance_schema.session_variables where variable_name='gtid_mode';
26 --enable_warnings
27
28 #
29 # show that it is settable and can only change at most one step at a time
30 #
31 set global gtid_mode = OFF;
32 --error ER_GTID_MODE_CAN_ONLY_CHANGE_ONE_STEP_AT_A_TIME
33 set global gtid_mode = ON_PERMISSIVE;
34 --error ER_GTID_MODE_CAN_ONLY_CHANGE_ONE_STEP_AT_A_TIME
35 set global gtid_mode = ON;
36
37 set global gtid_mode = OFF_PERMISSIVE;
38 set global gtid_mode = OFF_PERMISSIVE;
39 --error ER_GTID_MODE_CAN_ONLY_CHANGE_ONE_STEP_AT_A_TIME
40 set global gtid_mode = ON;
41
42 set global gtid_mode = ON_PERMISSIVE;
43 set global gtid_mode = ON_PERMISSIVE;
44 --error ER_GTID_MODE_CAN_ONLY_CHANGE_ONE_STEP_AT_A_TIME
45 set global gtid_mode = OFF;
46
47 set global gtid_mode = ON;
48 set global gtid_mode = ON;
49 --error ER_GTID_MODE_CAN_ONLY_CHANGE_ONE_STEP_AT_A_TIME
50 set global gtid_mode = OFF;
51 --error ER_GTID_MODE_CAN_ONLY_CHANGE_ONE_STEP_AT_A_TIME
52 set global gtid_mode = OFF_PERMISSIVE;
53
54 set global gtid_mode = ON_PERMISSIVE;
55 set global gtid_mode = OFF_PERMISSIVE;
56 set global gtid_mode = OFF;
57
58 --error ER_WRONG_VALUE_FOR_VAR
59 set global gtid_mode = NULL;
60 select @@global.gtid_mode;
61
62 set global gtid_mode = default;
63 select @@global.gtid_mode;
64
65 set global gtid_mode = OFF_PERMISSIVE;
66 set global gtid_mode = default;
67 select @@global.gtid_mode;
68
69 set global gtid_mode = OFF_PERMISSIVE;
70 set global gtid_mode = ON_PERMISSIVE;
71 --error ER_GTID_MODE_CAN_ONLY_CHANGE_ONE_STEP_AT_A_TIME
72 set global gtid_mode = default;
73 select @@global.gtid_mode;
74
75 set global gtid_mode = ON;
76 --error ER_GTID_MODE_CAN_ONLY_CHANGE_ONE_STEP_AT_A_TIME
77 set global gtid_mode = default;
78 select @@global.gtid_mode;
79
80 --error ER_GLOBAL_VARIABLE
81 set session gtid_mode = ON;
82
83 # can set ON when sql_replica_skip_counter > 0 with a warning
84 set global gtid_mode = on_permissive;
85 set global sql_replica_skip_counter = 1;
86 set global gtid_mode = on;
87
88 --let $assert_text= A warning will be generated stating "The value of sql_replica_skip_counter will only take effect for channels running with"
89 --let $warning_code= query_get_value(SHOW WARNINGS, Code, 1)
90 --let $expected_code= convert_error(ER_SQL_REPLICA_SKIP_COUNTER_USED_WITH_GTID_MODE_ON)
91 --let $assert_cond= $warning_code = $expected_code
92 --source include/assert.inc
93
94 # No warning for setting to 0
95 set global sql_replica_skip_counter = 0;
96 set global gtid_mode = on;
97
98 # can set everything except ON when enforce_gtid_consistency!=ON
99 set global gtid_mode = on_permissive;
100 SET @@global.enforce_gtid_consistency = OFF;
101
102 set global gtid_mode = off_permissive;
103 set global gtid_mode = off;
104 set global gtid_mode = off_permissive;
105 set global gtid_mode = on_permissive;
106 --error ER_CANT_SET_GTID_MODE
107 set global gtid_mode = on;
108
109 SET @@global.enforce_gtid_consistency = WARN;
110
111 set global gtid_mode = off_permissive;
112 set global gtid_mode = off;
113 set global gtid_mode = off_permissive;
114 set global gtid_mode = on_permissive;
115 --error ER_CANT_SET_GTID_MODE
116 set global gtid_mode = on;
117
118 #
119 # WL6591 Restore backup on existing GTID-aware server - make
120 # GTID_PURGED settable always.
121 # OWNED_GTIDs constraints: in-progress
122 # transactions' gtids must not overlap with the assigned value.
123 #
124 RESET MASTER;
125 --connect (con1,localhost,root,,,,)
126 SET @@GTID_NEXT='11111111-1111-1111-1111-111111111111:1';
127 BEGIN;
128
129 --connection default
130 --error ER_CANT_SET_GTID_PURGED_DUE_SETS_CONSTRAINTS
131 SET @@global.gtid_purged= '11111111-1111-1111-1111-111111111111:1-2';
132 # --error 0
133 SET @@global.gtid_purged= '11111111-1111-1111-1111-111111111111:2-2';
134 --error ER_CANT_SET_GTID_PURGED_DUE_SETS_CONSTRAINTS
135 SET @@global.gtid_purged= '+11111111-1111-1111-1111-111111111111:1-1';
136 # --error 0
137 SET @@global.gtid_purged= '+11111111-1111-1111-1111-111111111111:3-3';
138 SELECT @@global.gtid_purged;
139
140 --connection con1
141 ROLLBACK;
142
143 --connection default
144
145 # test gtid_mode changes with autocommit off
146
147 CREATE TABLE t1 (a INT);
148 SET AUTOCOMMIT = 0;
149
150 ## Confirm that gtid_mode cannot be changed when a transaction
151 ## is in progress and gtid_next is set to 'UUID:No'.
152 SET SESSION GTID_NEXT = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa:1';
153 INSERT INTO t1 VALUES (1);
154 # transaction in progress, gtid_mode variable cannot be changed
155 --error ER_VARIABLE_NOT_SETTABLE_IN_TRANSACTION
156 SET GLOBAL GTID_MODE = 'off_permissive';
157 COMMIT;
158
159 ## Confirm that gtid_mode cannot be changed when gtid_mode is
160 ## set to 'UUID:No'.
161 SET SESSION GTID_NEXT = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa:2';
162 # GTID_NEXT was set, gtid_mode variable cannot be changed
163 --error ER_CANT_SET_VARIABLE_WHEN_OWNING_GTID
164 SET GLOBAL GTID_MODE = 'off_permissive';
165 COMMIT;
166
167 ## Confirm that gtid_mode cannot be changed during an anonymous
168 ## transaction.
169 SET GTID_NEXT = 'ANONYMOUS';
170 --error ER_CANT_SET_VARIABLE_WHEN_OWNING_GTID
171 SET GLOBAL GTID_MODE = 'off_permissive';
172 COMMIT;
173
174 # Set back to default and cleanup
175 SET AUTOCOMMIT = 1;
176 SET SESSION GTID_NEXT = 'AUTOMATIC';
177 DROP TABLE t1;
178 SET GLOBAL GTID_MODE ='off_permissive';
179 SET GLOBAL GTID_MODE = 'off';
180
181 SET @@global.enforce_gtid_consistency = @start_enforce_gtid_consistency;
182
183 #
184 # See rpl_gtid_mode.test for a comprehensive test case.
185 #