~ubuntu-branches/ubuntu/lucid/mysql-dfsg-5.1/lucid-security

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
include/master-slave.inc
[connection master]
SET binlog_format = STATEMENT;

*** Test 1 ***

create table t1 (a int key, b int) engine innodb;
create table t2 (a int key, b int) engine innodb;

alter table t1 engine ndb;
alter table t2 engine ndb;

insert into t1 values (1,2);

select @log_name:=log_name, @start_pos:=start_pos, @end_pos:=end_pos
from mysql.ndb_apply_status;
@log_name:=log_name	@start_pos:=start_pos	@end_pos:=end_pos
<log_name>	<start_pos>	<end_pos>

# Now check that that is in the apply_status table is consistant
# with what is in the binlog

# since insert is done with transactional engine, expect a BEGIN
# at <start_pos>

show binlog events from <binlog_start> limit 1;
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
master-bin.000001	#	Query	#	#	BEGIN

# Now the insert, one step after

show binlog events from <binlog_start> limit 1,1;
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
master-bin.000001	#	Query	#	#	use `test`; insert into t1 values (1,2)

# and the COMMIT should be at <end_pos>

show binlog events from <binlog_start> limit 2,1;
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
master-bin.000001	#	Xid	#	#	COMMIT /* XID */

begin;
insert into t1 values (2,3);
insert into t2 values (3,4);
commit;

select @log_name:=log_name, @start_pos:=start_pos, @end_pos:=end_pos
from mysql.ndb_apply_status;
@log_name:=log_name	@start_pos:=start_pos	@end_pos:=end_pos
<log_name>	<start_pos>	<end_pos>
show binlog events from <binlog_start> limit 1;
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
master-bin.000001	#	Query	#	#	BEGIN

show binlog events from <binlog_start> limit 1,2;
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
master-bin.000001	#	Query	#	#	use `test`; insert into t1 values (2,3)
master-bin.000001	#	Query	#	#	use `test`; insert into t2 values (3,4)

show binlog events from <binlog_start> limit 3,1;
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
master-bin.000001	#	Xid	#	#	COMMIT /* XID */

DROP TABLE test.t1, test.t2;
SHOW TABLES;
Tables_in_test

*** Test 2 ***

DROP DATABASE IF EXISTS tpcb;
CREATE DATABASE tpcb;

CREATE TABLE tpcb.account (id INT, bid INT, balance DECIMAL(10,2),
filler CHAR(255), PRIMARY KEY(id));

CREATE TABLE tpcb.branch (bid INT, balance DECIMAL(10,2), filler VARCHAR(255),
PRIMARY KEY(bid));

CREATE TABLE tpcb.teller (tid INT, balance DECIMAL(10,2), filler VARCHAR(255),
PRIMARY KEY(tid));

CREATE TABLE tpcb.history (id MEDIUMINT NOT NULL AUTO_INCREMENT,aid INT,
tid INT, bid INT,  amount DECIMAL(10,2),
tdate DATETIME, teller CHAR(20), uuidf LONGBLOB,
filler CHAR(80),PRIMARY KEY (id));

--- Create stored procedures & functions ---


*** Stored Procedures Created ***

USE tpcb;
ALTER TABLE account ENGINE NDB;
ALTER TABLE branch ENGINE NDB;
ALTER TABLE teller ENGINE NDB;
ALTER TABLE history ENGINE NDB;

select @log_name:=log_name, @start_pos:=start_pos, @end_pos:=end_pos
from mysql.ndb_apply_status;
@log_name:=log_name	@start_pos:=start_pos	@end_pos:=end_pos
<log_name>	<start_pos>	<end_pos>

show binlog events in 'master-bin.000001'  from <start_pos> limit 6,1;
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
master-bin.000001	#	Xid	1	<end_pos>	COMMIT /* XID */

** Test 3 **

FLUSH LOGS;

select @log_name:=log_name, @start_pos:=start_pos, @end_pos:=end_pos
from mysql.ndb_apply_status;
@log_name:=log_name	@start_pos:=start_pos	@end_pos:=end_pos
<log_name>	<start_pos>	<end_pos>

show binlog events in 'master-bin.000002'  from <start_pos> limit 6,1;
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
master-bin.000002	#	Xid	1	<end_pos>	COMMIT /* XID */

** Test 4 **

include/rpl_reset.inc

select @log_name:=log_name, @start_pos:=start_pos, @end_pos:=end_pos
from mysql.ndb_apply_status;
@log_name:=log_name	@start_pos:=start_pos	@end_pos:=end_pos
<log_name>	<start_pos>	<end_pos>

show binlog events in 'master-bin.000001'  from <start_pos> limit 6,1;
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
master-bin.000001	#	Xid	1	<end_pos>	COMMIT /* XID */

*** DUMP MASTER & SLAVE FOR COMPARE ********
DROP DATABASE tpcb;
****** Do dumps compare ************
include/rpl_end.inc