1RESET MASTER;
2
3# A first event in a new binlog has commit parent timestamp as zero
4# and itself as one.
5CREATE TABLE t1 (a int) ENGINE= innodb;
6
7--let $binlog_file= master-bin.000001
8
9--let $logical_timestamps= 0 1
10--source include/assert_logical_timestamps.inc
11
12# A next transaction increments either counter
13
14--let $binlog_position= query_get_value(SHOW MASTER STATUS, Position, 1)
15INSERT INTO t1 SET a=1;
16
17--let $logical_timestamps= 1 2
18--source include/assert_logical_timestamps.inc
19
20# Transaction's last committed timestamp is computed at its last
21# being executed query.
22# Due to this two last logged transactions in the following sequence
23# must have the same last comitted timestamp.
24
25connect (one,localhost,root,,test);
26connect (two,localhost,root,,test);
27connect (three,localhost,root,,test);
28
29--let $rpl_connection_name=one
30--source include/rpl_connection.inc
31BEGIN;
32INSERT INTO t1 SET a=1;
33
34--let $rpl_connection_name=two
35--source include/rpl_connection.inc
36# (transaction timestamp,last committed) (2,3)
37BEGIN;
38INSERT INTO t1 SET a=2;
39COMMIT;
40
41--let $rpl_connection_name=one
42--source include/rpl_connection.inc
43INSERT INTO t1 SET a=1;
44
45--let $rpl_connection_name=two
46--source include/rpl_connection.inc
47--let $binlog_position= query_get_value(SHOW MASTER STATUS, Position, 1)
48# (3,4)
49BEGIN;
50INSERT INTO t1 SET a=2;
51COMMIT;
52
53--let $logical_timestamps= 3 4
54--source include/assert_logical_timestamps.inc
55
56
57--let $rpl_connection_name=one
58--source include/rpl_connection.inc
59# (3,5)
60--let $binlog_position= query_get_value(SHOW MASTER STATUS, Position, 1)
61COMMIT;
62--let $logical_timestamps= 3 5
63--source include/assert_logical_timestamps.inc
64
65# Two independent and concurrent (autoincrement)  transaction will either
66# have the same commit parent as the last committed of so far, or
67# one of them will be such to another.
68
69--let $binlog_position= query_get_value(SHOW MASTER STATUS, Position, 1)
70
71--let $rpl_connection_name=one
72--source include/rpl_connection.inc
73--send INSERT INTO t1 SET a=1
74
75--let $rpl_connection_name=two
76--source include/rpl_connection.inc
77--send INSERT INTO t1 SET a=2
78
79--let $rpl_connection_name=one
80--source include/rpl_connection.inc
81--reap
82--let $rpl_connection_name=two
83--source include/rpl_connection.inc
84--reap
85
86--let $logical_timestamps= 5 6;[56] 7
87--source include/assert_logical_timestamps.inc
88
89
90#
91# Testing logging of transaction that commits after binlog rotation.
92# The last committed of "rotated" transaction
93# must be set to the uninitialized (0) value.
94#
95
96--let $rpl_connection_name=one
97--source include/rpl_connection.inc
98RESET MASTER;
99INSERT INTO t1 SET a=1;
100
101--let $rpl_connection_name=two
102--source include/rpl_connection.inc
103BEGIN;
104INSERT INTO t1 SET a=2;
105
106--let $rpl_connection_name=one
107--source include/rpl_connection.inc
108BEGIN;
109INSERT INTO t1 SET a=3;
110
111--let $rpl_connection_name=two
112--source include/rpl_connection.inc
113COMMIT;
114
115# Not "rotated" 2nd transaction is logged following the regular rule.
116# Its timestamp pair of (1,2) must be found.
117--let $binlog_position=
118--let $logical_timestamps= 0 1;1 2
119--source include/assert_logical_timestamps.inc
120
121FLUSH LOGS;
122
123--let $rpl_connection_name=one
124--source include/rpl_connection.inc
125COMMIT;
126
127# Now the proof: the "rotated" transaction is logged with uninitialized last committed
128# as expected. Its timestamp pair of (0,1) must be found.
129
130--let $binlog_file= master-bin.000002
131--let $logical_timestamps= 0 1
132--source include/assert_logical_timestamps.inc
133
134#
135# Testing logging of transaction that commits after RESET MASTER.
136# The last committed of "rotated" transactions
137# must be set to the uninitialized (0) value.
138#
139
140--let $rpl_connection_name=one
141--source include/rpl_connection.inc
142RESET MASTER;
143INSERT INTO t1 SET a=1;
144
145--let $rpl_connection_name=two
146--source include/rpl_connection.inc
147BEGIN;
148INSERT INTO t1 SET a=2;
149
150--let $rpl_connection_name=one
151--source include/rpl_connection.inc
152BEGIN;
153INSERT INTO t1 SET a=3;
154
155--let $rpl_connection_name=three
156--source include/rpl_connection.inc
157BEGIN;
158INSERT INTO t1 SET a=4;
159
160--let $rpl_connection_name=two
161--source include/rpl_connection.inc
162COMMIT;
163
164# Not "rotated" 2nd transaction is logged following the regular rule.
165# Its timestamp pair of (1,2) must be found.
166--let $binlog_file= master-bin.000001
167--let $logical_timestamps= 0 1;1 2
168--source include/assert_logical_timestamps.inc
169
170RESET MASTER;
171
172--let $rpl_connection_name=one
173--source include/rpl_connection.inc
174COMMIT;
175--let $rpl_connection_name=three
176--source include/rpl_connection.inc
177COMMIT;
178
179# Now the proof: the "rotated" transactions are logged with uninitialized last committed
180# as expected. Its timestamp pair of (0,[12]) must be found.
181
182--let $logical_timestamps= 0 1;0 2
183--source include/assert_logical_timestamps.inc
184
185#
186# Cleanup
187#
188
189DROP TABLE t1;
190
191
192
193#
194# Testing DROP of multiple tables logging when a query produces few groups
195# into binary log.
196#
197
198CREATE TABLE t1 (a int) ENGINE= innodb;
199CREATE TABLE tm (a int) ENGINE= MyISAM;
200RESET MASTER;
201CREATE TEMPORARY TABLE ttm1 (a INT) ENGINE=MyISAM;
202CREATE TEMPORARY TABLE tti1 (a INT) ENGINE=Innodb;
203
204# The query is logged in three parts where only
205# the first one is sequenced.
206# Such logging is caused by just one cache is used for logging.
207
208--echo *** The query is logged in three parts.
209
210DROP TABLE tm,t1,ttm1,tti1;
211
212--let $logical_timestamps= 0 1;1 2;2 3;3 4;4 5
213# CREATE/DROP TEMPORARY TABLE is not binlogged under MIXED
214--let $logical_timestamps_mix= 0 1
215--source include/assert_logical_timestamps.inc
216
217#
218# The final grep invocation should be done by the top level part.
219# It may produce results sensitive to the test environment (e.g GTID).
220#
221