Debian Codegraph @

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

raw
1 --source include/gtid_utils.inc
2 # Clear gtid_purged to make variable settable.
3 RESET MASTER;
4
5 SET @start_global_value = @@global.gtid_purged;
6 SELECT @start_global_value;
7 SET @sql_log_bin_start_value = @@session.sql_log_bin;
8
9 #
10 # exists as global only
11 #
12 select @@global.gtid_purged;
13 --error ER_INCORRECT_GLOBAL_LOCAL_VAR
14 select @@session.gtid_purged;
15 show global variables like 'gtid_purged';
16 show session variables like 'gtid_purged';
17 --disable_warnings
18 select * from performance_schema.global_variables where variable_name='gtid_purged';
19 select * from performance_schema.session_variables where variable_name='gtid_purged';
20 --enable_warnings
21
22 --error ER_WRONG_VALUE_FOR_VAR
23 set @@global.gtid_purged = NULL;
24 select @@global.gtid_purged;
25
26 --error ER_NO_DEFAULT
27 set @@global.gtid_purged = default;
28 select @@global.gtid_purged;
29
30 #
31 # Allowed to write (regardless of GTID_MODE).
32 #
33 SET @@global.gtid_purged= '11111111-1111-1111-1111-111111111111:1-2';
34 SELECT @@global.gtid_purged;
35
36 # Not allowed to update when the new value is not a superset of the old one
37 --error ER_CANT_SET_GTID_PURGED_DUE_SETS_CONSTRAINTS
38 SET @@global.gtid_purged= '11111111-1111-1111-1111-111111111111:3';
39 SELECT @@global.gtid_purged;
40
41 SET @gtid_purged_new='11111111-1111-1111-1111-111111111111:1-2:4-5';
42
43 # The following bug blocks execution of the test in --skip-log-mode more.
44 # Bug#23534725 INCONSISTENT STATE OF GTID_PURGED IN
45 # --GTID-MODE=ON && --SKIP-LOG-BIN SETUP
46 if (`SELECT COUNT(*) = 2 FROM performance_schema.global_variables WHERE VARIABLE_NAME = 'GTID_MODE' AND VARIABLE_VALUE != 'OFF' OR VARIABLE_NAME = 'LOG_BIN' AND VARIABLE_VALUE = 'ON'`)
47 {
48 # Not allowed to update when the new value intersects with Executed_gtids
49 # which are not purged.
50 # This piece of test requries GTID mode ON, thus query log is disabled.
51 --disable_query_log
52 SET @@GTID_NEXT='11111111-1111-1111-1111-111111111111:3';
53 BEGIN;
54 COMMIT;
55 SET @@GTID_NEXT=AUTOMATIC;
56
57 --disable_result_log
58 --error ER_CANT_SET_GTID_PURGED_DUE_SETS_CONSTRAINTS
59 SET @@global.gtid_purged= '11111111-1111-1111-1111-111111111111:1-3';
60 --enable_result_log
61 --enable_query_log
62 }
63
64 # Overriding of the current value with one that includes it is allowed.
65 # The block also asserts important requirement.
66 SET @gtid_executed_old= @@GLOBAL.GTID_EXECUTED;
67 SET @@global.gtid_purged= @gtid_purged_new;
68 SELECT @@global.gtid_purged;
69 --let $assert_cond= GTID_IS_EQUAL(GTID_UNION(@gtid_executed_old, @gtid_purged_new), @@GLOBAL.GTID_EXECUTED)
70 --let $assert_text= New value of GTID_EXECUTED must be union of the old one an new purged
71 --source include/assert.inc
72
73 RESET MASTER;
74
75 # Does not initiate a transaction when autocommit is off
76 SET AUTOCOMMIT= OFF;
77 SET @@session.sql_log_bin= @sql_log_bin_start_value;
78 SET AUTOCOMMIT= ON;
79
80 --let $purged_gno_0=4
81 --eval SET @gtid_purged_init= '11111111-1111-1111-1111-111111111111:$purged_gno_0-5'
82 SET @@global.gtid_purged= @gtid_purged_init;
83
84 # Construct Executed set not necessarily equal to Purged for one of the
85 # following asserts in the append-style SET-purged case
86 if (`SELECT COUNT(*) = 1 FROM performance_schema.global_variables WHERE VARIABLE_NAME = 'GTID_MODE' AND VARIABLE_VALUE != 'OFF'`)
87 {
88 # Not allowed to update when the new value intersects with Executed_gtids
89 # which are not purged.
90 # This piece of test requries GTID mode ON, thus query log is disabled.
91 --disable_query_log
92 SET @@GTID_NEXT='11111111-1111-1111-1111-111111111111:3';
93 BEGIN;
94 COMMIT;
95 SET @@GTID_NEXT=AUTOMATIC;
96 if (`SELECT COUNT(*) = 1 FROM performance_schema.global_variables WHERE VARIABLE_NAME = 'log_bin' AND VARIABLE_VALUE = 'OFF'`)
97 {
98 --let $purged_gno_0=3
99 # Explicitly include the empty trx' gtid to the inited-purged when binlog is OFF
100 # because any executed transaction gets to the purged set automatically.
101 --eval SET @gtid_purged_init= GTID_UNION(@gtid_purged_init, '11111111-1111-1111-1111-111111111111:$purged_gno_0')
102 }
103 --enable_query_log
104 }
105
106 #
107 # The append SET-purged syntax
108 #
109 --error ER_CANT_SET_GTID_PURGED_DUE_SETS_CONSTRAINTS
110 SET @@global.gtid_purged= '+11111111-1111-1111-1111-111111111111:5';
111
112 # Memorize "old" Executed value before incrementing Purged one more time
113 SET @gtid_executed_old= @@GLOBAL.GTID_EXECUTED;
114
115 # Disjoint set may only be append
116 SET @gtid_purged_incr="11111111-1111-1111-1111-111111111111:6-6";
117 SET @@global.gtid_purged= CONCAT("+",@gtid_purged_incr);
118
119 --let $assert_cond= GTID_IS_EQUAL(GTID_UNION(@gtid_purged_init, @gtid_purged_incr), @@GLOBAL.GTID_PURGED)
120 --let $assert_text= New value of GTID_PURGED must be union of the old one and the increment
121 --source include/assert.inc
122
123 --let $assert_cond= GTID_IS_EQUAL(GTID_UNION(@gtid_executed_old, @gtid_purged_incr), @@GLOBAL.GTID_EXECUTED)
124 --let $assert_text= New value of GTID_EXECUTED must be union of the old one and the purged increment
125 --source include/assert.inc
126
127 # The '+' append qualifier must be first not white space char in the rhs
128 # string and not be following by any other but a valid GTID notating
129 # symbol or white space.
130 SET @@global.gtid_purged= '+ 11111111-1111-1111-1111-111111111111:7';
131 SET @@global.gtid_purged= ' +11111111-1111-1111-1111-111111111111:8';
132 --error ER_WRONG_VALUE_FOR_VAR
133 SET @@global.gtid_purged= ' -+11111111-1111-1111-1111-111111111111:9';
134 --error ER_WRONG_VALUE_FOR_VAR
135 SET @@global.gtid_purged= ' +-11111111-1111-1111-1111-111111111111:9';
136 #The comma past '+' symbol indicates an empty first range, hence
137 # --error 0.
138 SET @@global.gtid_purged= ' +,11111111-1111-1111-1111-111111111111:9';
139
140 --disable_query_log
141 --eval set @purged_total='11111111-1111-1111-1111-111111111111:$purged_gno_0-9'
142 --enable_query_log
143 --let $assert_cond= GTID_IS_EQUAL(@purged_total, @@GLOBAL.GTID_PURGED)
144 --let $assert_text= Computed purged set is not the same as of the global var
145 --source include/assert.inc
146
147 #
148 # Cleared by RESET MASTER.
149 #
150 RESET MASTER;
151 SELECT @@global.gtid_purged;
152 #
153 # See rpl_gtid_purged_maintained.test for a comprehensive test case.
154 #
155 --source include/gtid_utils_end.inc