~ubuntu-branches/ubuntu/precise/mysql-5.1/precise

« back to all changes in this revision

Viewing changes to mysql-test/extra/binlog_tests/binlog.test

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Tretkowski
  • Date: 2010-03-17 14:56:02 UTC
  • Revision ID: james.westby@ubuntu.com-20100317145602-x7e30l1b2sb5s6w6
Tags: upstream-5.1.45
ImportĀ upstreamĀ versionĀ 5.1.45

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#
 
2
# misc binlogging tests that do not require a slave running
 
3
#
 
4
 
 
5
-- source include/have_log_bin.inc
 
6
-- source include/not_embedded.inc
 
7
-- source include/have_innodb.inc
 
8
-- source include/have_debug.inc
 
9
 
 
10
--disable_warnings
 
11
drop table if exists t1, t2;
 
12
--enable_warnings
 
13
reset master;
 
14
 
 
15
create table t1 (a int) engine=innodb;
 
16
create table t2 (a int) engine=innodb;
 
17
begin;
 
18
insert t1 values (5);
 
19
commit;
 
20
begin;
 
21
insert t2 values (5);
 
22
commit;
 
23
# first COMMIT must be Query_log_event, second - Xid_log_event
 
24
source include/show_binlog_events.inc;
 
25
drop table t1,t2;
 
26
 
 
27
#
 
28
# binlog rotation after one big transaction
 
29
#
 
30
reset master;
 
31
let $1=100;
 
32
 
 
33
create table t1 (n int) engine=innodb;
 
34
begin;
 
35
--disable_query_log
 
36
while ($1)
 
37
{
 
38
 eval insert into t1 values($1 + 4);
 
39
 dec $1;
 
40
}
 
41
--enable_query_log
 
42
commit;
 
43
drop table t1;
 
44
--replace_column 2 # 5 #
 
45
--replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\//
 
46
show binlog events in 'master-bin.000001' from 106;
 
47
--replace_column 2 # 5 #
 
48
--replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\//
 
49
show binlog events in 'master-bin.000002' from 106;
 
50
 
 
51
 
 
52
#
 
53
# Bug#22540 - Incorrect value in column End_log_pos of
 
54
# SHOW BINLOG EVENTS using InnoDB
 
55
#
 
56
 
 
57
# the following tests will show that certain queries now return
 
58
# absolute offsets (from binlog start, rather than relative to
 
59
# the beginning of the current transaction).  under what
 
60
# conditions it should be allowed / is sensible to put the
 
61
# slider into the middle of a transaction is not our concern
 
62
# here; we just guarantee that if and when it's done, the
 
63
# user has valid offsets to use.  if the setter function still
 
64
# wants to throw a "positioning into middle of transaction"
 
65
# warning, that's its prerogative and handled elsewhere.
 
66
 
 
67
set @ac = @@autocommit;
 
68
 
 
69
# first show this to work for SHOW BINLOG EVENTS
 
70
 
 
71
set autocommit= 0;
 
72
reset master;
 
73
create table t1(n int) engine=innodb;
 
74
begin;
 
75
insert into t1 values (1);
 
76
insert into t1 values (2);
 
77
insert into t1 values (3);
 
78
commit;
 
79
drop table t1;
 
80
--replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/ /Server ver: [^,]*,/Server version,/
 
81
show binlog events from 0;
 
82
 
 
83
# now show that nothing breaks if we need to read from the cache more
 
84
# than once, resulting in split event-headers
 
85
 
 
86
set @bcs = @@binlog_cache_size;
 
87
set global binlog_cache_size=4096;
 
88
reset master;
 
89
 
 
90
create table t1 (a int) engine=innodb;
 
91
 
 
92
let $1=400;
 
93
disable_query_log;
 
94
begin;
 
95
while ($1)
 
96
{
 
97
 eval insert into t1 values( $1 );
 
98
 dec $1;
 
99
}
 
100
commit;
 
101
enable_query_log;
 
102
 
 
103
--replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/ /Server ver: [^,]*,/Server version,/
 
104
show binlog events from 0;
 
105
 
 
106
drop table t1;
 
107
 
 
108
set global binlog_cache_size=@bcs;
 
109
set session autocommit = @ac;
 
110
 
 
111
#
 
112
# Bug#33798: prepared statements improperly handle large unsigned ints
 
113
#
 
114
--disable_warnings
 
115
drop table if exists t1;
 
116
--enable_warnings
 
117
reset master;
 
118
create table t1 (a bigint unsigned, b bigint(20) unsigned);
 
119
prepare stmt from "insert into t1 values (?,?)";
 
120
set @a= 9999999999999999;
 
121
set @b= 14632475938453979136;
 
122
execute stmt using @a, @b;
 
123
deallocate prepare stmt;
 
124
drop table t1;
 
125
--replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/ /Server ver: [^,]*,/Server version,/
 
126
show binlog events from 0;
 
127
 
 
128
 
 
129
#
 
130
# Bug #39182: Binary log producing incompatible character set query from 
 
131
# stored procedure.
 
132
#
 
133
reset master;
 
134
CREATE DATABASE bug39182 DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
 
135
USE bug39182;
 
136
CREATE TABLE t1 (a VARCHAR(255) COLLATE utf8_unicode_ci)
 
137
  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
 
138
 
 
139
DELIMITER //;
 
140
 
 
141
CREATE PROCEDURE p1()
 
142
BEGIN
 
143
  DECLARE s1 VARCHAR(255);
 
144
  SET s1= "test";
 
145
  CREATE TEMPORARY TABLE tmp1
 
146
    SELECT * FROM t1 WHERE a LIKE CONCAT("%", s1, "%");
 
147
  SELECT 
 
148
    COLLATION(NAME_CONST('s1', _utf8'test')) c1,
 
149
    COLLATION(NAME_CONST('s1', _utf8'test' COLLATE utf8_unicode_ci)) c2,
 
150
    COLLATION(s1) c3,
 
151
    COERCIBILITY(NAME_CONST('s1', _utf8'test')) d1,
 
152
    COERCIBILITY(NAME_CONST('s1', _utf8'test' COLLATE utf8_unicode_ci)) d2,
 
153
    COERCIBILITY(s1) d3;
 
154
  DROP TEMPORARY TABLE tmp1;
 
155
END//
 
156
 
 
157
DELIMITER ;//
 
158
 
 
159
CALL p1();
 
160
source include/show_binlog_events.inc;
 
161
 
 
162
DROP PROCEDURE p1;
 
163
DROP TABLE t1;
 
164
DROP DATABASE bug39182;
 
165
USE test;
 
166
 
 
167
#
 
168
# Bug#35383: binlog playback and replication breaks due to 
 
169
# name_const substitution
 
170
#
 
171
DELIMITER //;
 
172
CREATE PROCEDURE p1(IN v1 INT)
 
173
BEGIN
 
174
  CREATE TABLE t1 SELECT v1;
 
175
  DROP TABLE t1;
 
176
END//
 
177
CREATE PROCEDURE p2()
 
178
BEGIN
 
179
  DECLARE v1 INT;
 
180
  CREATE TABLE t1 SELECT v1+1;
 
181
  DROP TABLE t1;
 
182
END//
 
183
CREATE PROCEDURE p3(IN v1 INT)
 
184
BEGIN
 
185
  CREATE TABLE t1 SELECT 1 FROM DUAL WHERE v1!=0;
 
186
  DROP TABLE t1;
 
187
END//
 
188
CREATE PROCEDURE p4(IN v1 INT)
 
189
BEGIN
 
190
  DECLARE v2 INT;
 
191
  CREATE TABLE t1 SELECT 1, v1, v2;
 
192
  DROP TABLE t1;
 
193
  CREATE TABLE t1 SELECT 1, v1+1, v2;
 
194
  DROP TABLE t1;
 
195
END//
 
196
DELIMITER ;//
 
197
 
 
198
CALL p1(1);
 
199
CALL p2();
 
200
CALL p3(0);
 
201
CALL p4(0);
 
202
DROP PROCEDURE p1;
 
203
DROP PROCEDURE p2;
 
204
DROP PROCEDURE p3;
 
205
DROP PROCEDURE p4;
 
206
 
 
207
--echo End of 5.0 tests
 
208
 
 
209
# Test of a too big SET INSERT_ID: see if the truncated value goes
 
210
# into binlog (right), or the too big value (wrong); we look at the
 
211
# binlog further down with SHOW BINLOG EVENTS.
 
212
reset master;
 
213
create table t1 (id tinyint auto_increment primary key);
 
214
set insert_id=128;
 
215
insert into t1 values(null);
 
216
select * from t1;
 
217
drop table t1;
 
218
 
 
219
# bug#22027 
 
220
create table t1 (a int);
 
221
create table if not exists t2 select * from t1;
 
222
 
 
223
# bug#22762
 
224
create temporary table tt1 (a int);
 
225
create table if not exists t3 like tt1;
 
226
 
 
227
# BUG#25091 (A DELETE statement to mysql database is not logged with
 
228
# ROW mode format): Checking that some basic operations on tables in
 
229
# the mysql database is replicated even when the current database is
 
230
# 'mysql'.
 
231
 
 
232
--disable_warnings
 
233
USE mysql;
 
234
INSERT INTO user SET host='localhost', user='@#@', password=password('Just a test');
 
235
UPDATE user SET password=password('Another password') WHERE host='localhost' AND user='@#@';
 
236
DELETE FROM user WHERE host='localhost' AND user='@#@';
 
237
--enable_warnings
 
238
 
 
239
use test;
 
240
source include/show_binlog_events.inc;
 
241
drop table t1,t2,t3,tt1;
 
242
 
 
243
-- source extra/binlog_tests/binlog_insert_delayed.test
 
244
 
 
245
#Bug #26079 max_binlog_size + innodb = not make new binlog and hang server
 
246
# server should not hang, binlog must rotate in the end
 
247
reset master;
 
248
--disable_warnings
 
249
drop table if exists t3;
 
250
--enable_warnings
 
251
create table t3 (a int(11) NOT NULL AUTO_INCREMENT, b text, PRIMARY KEY (a) ) engine=innodb;
 
252
show master status;
 
253
let $it=4;
 
254
while ($it)
 
255
{
 
256
insert into t3(b) values ('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');
 
257
dec $it;
 
258
}
 
259
show master status /* must show new binlog index after rotating */;
 
260
drop table t3;
 
261
 
 
262
--echo #
 
263
--echo # Bug #45998: database crashes when running "create as select"
 
264
--echo #
 
265
CREATE DATABASE test1;
 
266
USE test1;
 
267
DROP DATABASE test1;
 
268
CREATE TABLE test.t1(a int);
 
269
INSERT INTO test.t1 VALUES (1), (2);
 
270
CREATE TABLE test.t2 SELECT * FROM test.t1;
 
271
USE test;
 
272
DROP TABLES t1, t2;
 
273
 
 
274
#
 
275
# Bug#46640
 
276
# This test verifies if the server_id stored in the "format 
 
277
# description BINLOG statement" will override the server_id 
 
278
# of the server executing the statements.
 
279
#
 
280
 
 
281
connect (fresh,localhost,root,,test);
 
282
connection fresh;
 
283
 
 
284
RESET MASTER;
 
285
CREATE TABLE t1 (a INT PRIMARY KEY);
 
286
 
 
287
# Format description event, with server_id = 10;
 
288
BINLOG '
 
289
3u9kSA8KAAAAZgAAAGoAAAABAAQANS4xLjM1LW1hcmlhLWJldGExLWRlYnVnLWxvZwAAAAAAAAAA
 
290
AAAAAAAAAAAAAAAAAADe72RIEzgNAAgAEgAEBAQEEgAAUwAEGggAAAAICAgC
 
291
';
 
292
 
 
293
# What server_id is logged for a statement? Should be our own, not the
 
294
# one from the format description event.
 
295
INSERT INTO t1 VALUES (1);
 
296
 
 
297
# INSERT INTO t1 VALUES (2), with server_id=20. Check that this is logged
 
298
# with our own server id, not the 20 from the BINLOG statement.
 
299
BINLOG '
 
300
3u9kSBMUAAAAKQAAAJEBAAAAABoAAAAAAAAABHRlc3QAAnQxAAEDAAA=
 
301
3u9kSBcUAAAAIgAAALMBAAAQABoAAAAAAAEAAf/+AgAAAA==
 
302
';
 
303
 
 
304
# Show binlog events to check that server ids are correct.
 
305
--replace_column 1 # 2 # 5 #
 
306
--replace_regex /Server ver: .*, Binlog ver: .*/Server ver: #, Binlog ver: #/ /table_id: [0-9]+/table_id: #/
 
307
SHOW BINLOG EVENTS;
 
308
 
 
309
DROP TABLE t1;
 
310
disconnect fresh;
 
311