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