Debian Codegraph @

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

raw
1
2 # default value
3
4 RESET MASTER;
5 SET @start_global_value = @@global.enforce_gtid_consistency;
6 SELECT @start_global_value;
7
8 #
9 # exists as global only
10 #
11 select @@global.enforce_gtid_consistency;
12 --error ER_INCORRECT_GLOBAL_LOCAL_VAR
13 select @@session.enforce_gtid_consistency;
14 show global variables like 'enforce_gtid_consistency';
15 show session variables like 'enforce_gtid_consistency';
16 --disable_warnings
17 select * from performance_schema.global_variables where variable_name='enforce_gtid_consistency';
18 select * from performance_schema.session_variables where variable_name='enforce_gtid_consistency';
19 --enable_warnings
20
21 #
22 # show that it is global writable
23 # test all settable values
24 #
25
26 --disable_warnings
27
28 set global enforce_gtid_consistency= 1;
29 select @@global.enforce_gtid_consistency;
30 show variables like 'enforce_gtid_consistency';
31 select variable_value from performance_schema.global_variables
32 where variable_name= 'enforce_gtid_consistency';
33
34 set global enforce_gtid_consistency= 0;
35 select @@global.enforce_gtid_consistency;
36 show variables like 'enforce_gtid_consistency';
37 select variable_value from performance_schema.global_variables
38 where variable_name= 'enforce_gtid_consistency';
39
40 set global enforce_gtid_consistency= 2;
41 select @@global.enforce_gtid_consistency;
42 show variables like 'enforce_gtid_consistency';
43 select variable_value from performance_schema.global_variables
44 where variable_name= 'enforce_gtid_consistency';
45
46 set global enforce_gtid_consistency= ON;
47 select @@global.enforce_gtid_consistency;
48 show variables like 'enforce_gtid_consistency';
49 select variable_value from performance_schema.global_variables
50 where variable_name= 'enforce_gtid_consistency';
51
52 set global enforce_gtid_consistency= OFF;
53 select @@global.enforce_gtid_consistency;
54 show variables like 'enforce_gtid_consistency';
55 select variable_value from performance_schema.global_variables
56 where variable_name= 'enforce_gtid_consistency';
57
58 set global enforce_gtid_consistency= TRUE;
59 select @@global.enforce_gtid_consistency;
60 show variables like 'enforce_gtid_consistency';
61 select variable_value from performance_schema.global_variables
62 where variable_name= 'enforce_gtid_consistency';
63
64 set global enforce_gtid_consistency= FALSE;
65 select @@global.enforce_gtid_consistency;
66 show variables like 'enforce_gtid_consistency';
67 select variable_value from performance_schema.global_variables
68 where variable_name= 'enforce_gtid_consistency';
69
70 set global enforce_gtid_consistency= WARN;
71 select @@global.enforce_gtid_consistency;
72 show variables like 'enforce_gtid_consistency';
73 select variable_value from performance_schema.global_variables
74 where variable_name= 'enforce_gtid_consistency';
75
76 --enable_warnings
77
78 --error ER_GLOBAL_VARIABLE
79 set session enforce_gtid_consistency= 1;
80 --error ER_INCORRECT_GLOBAL_LOCAL_VAR
81 select @@session.enforce_gtid_consistency;
82
83 --error ER_WRONG_VALUE_FOR_VAR
84 set global enforce_gtid_consistency= -1;
85 --error ER_WRONG_VALUE_FOR_VAR
86 set global enforce_gtid_consistency= 3;
87 --error ER_WRONG_VALUE_FOR_VAR
88 set global enforce_gtid_consistency= NULL;
89 --error ER_WRONG_VALUE_FOR_VAR
90 set global enforce_gtid_consistency= '';
91
92 set global enforce_gtid_consistency= default;
93
94 # can't set anything else than ON when gtid_mode=ON
95 set global enforce_gtid_consistency= ON;
96 set global gtid_mode=off_permissive;
97 set global gtid_mode=on_permissive;
98 set global gtid_mode=on;
99 --error ER_GTID_MODE_ON_REQUIRES_ENFORCE_GTID_CONSISTENCY_ON
100 set global enforce_gtid_consistency= WARN;
101 --error ER_GTID_MODE_ON_REQUIRES_ENFORCE_GTID_CONSISTENCY_ON
102 set global enforce_gtid_consistency= OFF;
103 set global enforce_gtid_consistency= ON;
104 set global enforce_gtid_consistency= TRUE;
105 set global enforce_gtid_consistency= 1;
106 set global gtid_mode=on_permissive;
107 set global gtid_mode=off_permissive;
108
109 # test enforce_gtid_consistency changes with autocommit off
110 CREATE TABLE t1 (a INT);
111 SET AUTOCOMMIT = 0;
112
113 ## Confirm that enforce_gtid_consistency cannot be changed when a transaction
114 ## is in progress and gtid_next is set to 'UUID:No'.
115 SET SESSION GTID_NEXT = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa:1';
116 INSERT INTO t1 VALUES (1);
117 # transaction in progress, gtid_mode variable cannot be changed
118 --error ER_VARIABLE_NOT_SETTABLE_IN_TRANSACTION
119 SET GLOBAL ENFORCE_GTID_CONSISTENCY = 'off';
120 COMMIT;
121
122 ## Confirm that enforce_gtid_consistency cannot be changed when gtid_mode is
123 ## set to 'UUID:No'.
124 SET SESSION GTID_NEXT = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa:2';
125 # GTID_NEXT was set, enforce_gtid_consistency variable cannot be changed
126 --error ER_CANT_SET_VARIABLE_WHEN_OWNING_GTID
127 SET GLOBAL ENFORCE_GTID_CONSISTENCY = 'off';
128 COMMIT;
129
130 ## Confirm that enforce_gtid_consistency cannot be changed during an anonymous
131 ## transaction.
132 SET GTID_NEXT = 'ANONYMOUS';
133 --error ER_CANT_SET_VARIABLE_WHEN_OWNING_GTID
134 SET GLOBAL ENFORCE_GTID_CONSISTENCY = 'off';
135 COMMIT;
136
137 # Set back to default and cleanup
138 SET AUTOCOMMIT = 1;
139 SET SESSION GTID_NEXT = 'AUTOMATIC';
140 SET GLOBAL GTID_MODE = 'off';
141 DROP TABLE t1;
142
143 set global enforce_gtid_consistency= @start_global_value;
144
145 #
146 # See binlog_enforce_gtid_consistency.test for a comprehensive test case.
147 #