1include/master-slave.inc
2Warnings:
3Note	####	Sending passwords in plain text without SSL/TLS is extremely insecure.
4Note	####	Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information.
5[connection master]
6SET @debug_save= @@GLOBAL.DEBUG;
7call mtr.add_suppression("test the suppression statement");
8SHOW CREATE TABLE mysql.gtid_executed;
9Table	Create Table
10gtid_executed	CREATE TABLE `gtid_executed` (
11  `source_uuid` char(36) NOT NULL COMMENT 'uuid of the source where the transaction was originally executed.',
12  `interval_start` bigint(20) NOT NULL COMMENT 'First number of interval.',
13  `interval_end` bigint(20) NOT NULL COMMENT 'Last number of interval.',
14  PRIMARY KEY (`source_uuid`,`interval_start`)
15) ENGINE=InnoDB DEFAULT CHARSET=latin1
16#
17# Verify that the specified gtid to GTID_NEXT can be reported from
18# global.gtid_executed and is stored into gtid_executed table on
19# following binlog rotation.
20#
21SET GTID_NEXT='MASTER_UUID:3';
22BEGIN;
23COMMIT;
24include/assert.inc [committed gtids MASTER_UUID:1:3]
25SET GTID_NEXT='AUTOMATIC';
26FLUSH LOGS;
27#
28# Store gtids MASTER_UUID:1:3 in gtid_executed table on binlog rotation
29#
30SELECT * FROM mysql.gtid_executed;
31source_uuid	interval_start	interval_end
32MASTER_UUID	1	1
33MASTER_UUID	3	3
34#
35# Verify that these gtids can be reported from global.gtid_executed and
36# are stored into gtid_executed table on next rotation for normal DDLs.
37#
38CREATE TABLE IF NOT EXISTS t1 (a INT) ENGINE=InnoDB;
39CREATE TABLE t2 (a INT) ENGINE=MyISAM;
40include/assert.inc [committed gtids MASTER_UUID:1-4]
41#
42# Store gtids MASTER_UUID:1-4 in gtid_executed table on binlog rotation
43#
44SET @@GLOBAL.DEBUG= '+d,compress_gtid_table';
45FLUSH LOGS;
46SET DEBUG_SYNC='now WAIT_FOR complete_compression';
47SELECT * FROM mysql.gtid_executed;
48source_uuid	interval_start	interval_end
49MASTER_UUID	1	4
50#
51# Verify that these gtids can be reported from global.gtid_executed
52# and are stored into gtid_executed table for compound statement with
53# regular and temporary tables.
54#
55CREATE TEMPORARY TABLE tmp1 (c1 INT) Engine=MyISAM;
56CREATE TABLE t3 (a INT);
57DROP TEMPORARY TABLE tmp1, t3;
58ERROR 42S02: Unknown table 'test.t3'
59DROP TABLE t3;
60include/assert.inc [committed gtids MASTER_UUID:1-8]
61#
62# Store gtids MASTER_UUID:1-8 in gtid_executed table on binlog rotation
63#
64SET @@GLOBAL.DEBUG= '+d,compress_gtid_table';
65FLUSH LOGS;
66SET DEBUG_SYNC='now WAIT_FOR complete_compression';
67SELECT * FROM mysql.gtid_executed;
68source_uuid	interval_start	interval_end
69MASTER_UUID	1	8
70#
71# Verify that transactions' gtids can be reported from
72# global.gtid_executed correctly and are stored into
73# gtid_executed table on next binlog rotation.
74#
75BEGIN;
76INSERT INTO t2 VALUES(2);
77INSERT INTO t1 VALUES(1);
78INSERT INTO t1 VALUES(2);
79COMMIT;
80#
81# Verify that specified gtid for transaction can be reported from
82# global.gtid_executed correctly and is stored into gtid_executed
83# table on next binlog rotation.
84#
85SET @@SESSION.GTID_NEXT= 'MASTER_UUID:11';
86BEGIN;
87INSERT INTO t1 VALUES(3);
88COMMIT;
89include/assert.inc [committed gtids MASTER_UUID:1-11]
90SET GTID_NEXT='AUTOMATIC';
91SET @@GLOBAL.DEBUG= '+d,compress_gtid_table';
92FLUSH LOGS;
93SET DEBUG_SYNC='now WAIT_FOR complete_compression';
94#
95# Store gtids MASTER_UUID:1-11 in gtid_executed table on binlog rotation
96#
97SELECT * FROM mysql.gtid_executed;
98source_uuid	interval_start	interval_end
99MASTER_UUID	1	11
100#
101# Verify that transaction's gtid can not be reported from
102# global.gtid_executed and is not stored into gtid_executed table
103# on next binlog rotation if the transaction is rollbacked.
104#
105BEGIN;
106INSERT INTO t1 VALUES(4);
107ROLLBACK;
108include/assert.inc [committed gtids MASTER_UUID:1-11]
109#
110# Store gtids MASTER_UUID:1-11 in gtid_executed table on binlog rotation
111#
112FLUSH LOGS;
113SELECT * FROM mysql.gtid_executed;
114source_uuid	interval_start	interval_end
115MASTER_UUID	1	11
116SET GLOBAL DEBUG= @debug_save;
117include/sync_slave_sql_with_master.inc
118#
119# connection slave
120#
121#
122# Verify that the transaction is skiped if its specified gtid is
123# already in global.gtid_executed, although not in gtid_executed table.
124#
125SET @@SESSION.GTID_NEXT= 'MASTER_UUID:6';
126INSERT INTO t1 VALUES(11);
127include/assert.inc [Table t1 must not contain 11]
128include/assert.inc [committed gtids MASTER_UUID:1-11]
129#
130# The gtid_executed table is empty on slave currently
131#
132SELECT * FROM mysql.gtid_executed;
133source_uuid	interval_start	interval_end
134#
135# Store gtids MASTER_UUID:1-11 in gtid_executed table on binlog rotation
136#
137SET GTID_NEXT='AUTOMATIC';
138FLUSH LOGS;
139SELECT * FROM mysql.gtid_executed;
140source_uuid	interval_start	interval_end
141MASTER_UUID	1	11
142#
143# Verify that the specified gtid to GTID_NEXT is stored into
144# global.gtid_executed immediately and stored into gtid_executed table
145# on next binlog rotation.
146#
147SET @@SESSION.GTID_NEXT= 'MASTER_UUID:17';
148COMMIT;
149include/assert.inc [committed gtids MASTER_UUID:1-11:17]
150#
151# Store gtids MASTER_UUID:1-11:17 in gtid_executed table
152# on next binlog rotation.
153#
154SET GTID_NEXT='AUTOMATIC';
155FLUSH LOGS;
156SELECT * FROM mysql.gtid_executed;
157source_uuid	interval_start	interval_end
158MASTER_UUID	1	11
159MASTER_UUID	17	17
160#
161# Verify that we can get the correct set of gtid_purged
162# when purging logs.
163#
164PURGE BINARY LOGS TO 'slave-bin.000003';
165include/assert.inc [purged gtids MASTER_UUID:1-11:17]
166#
167# Verify that transaction's gtid generated on slave is stored
168# into gtid_executed table on next binlog rotation.
169#
170BEGIN;
171INSERT INTO t1 VALUES(12);
172COMMIT;
173#
174# Store gtids MASTER_UUID:1-11:17 and SLAVE_UUID:1
175# in gtid_executed table on binlog rotation.
176#
177FLUSH LOGS;
178SELECT * FROM mysql.gtid_executed where source_uuid="MASTER_UUID";
179source_uuid	interval_start	interval_end
180MASTER_UUID	1	11
181MASTER_UUID	17	17
182SELECT * FROM mysql.gtid_executed where source_uuid="SLAVE_UUID";
183source_uuid	interval_start	interval_end
184SLAVE_UUID	1	1
185DROP TABLE t1, t2;
186include/rpl_end.inc
187