~drizzle-trunk/drizzle/development

1 by brian
clean slate
1
# Test case for BUG #11733
2
-- source include/master-slave.inc
3
-- source include/have_innodb.inc
4
5
# Create a test and replicate it to slave
6
connection master;
7
create user test;
8
sync_slave_with_master;
9
10
# Setting the master readonly :
11
# - the variable @@readonly is not replicated on the slave
12
13
connect (master2,127.0.0.1,test,,test,$MASTER_MYPORT,);
14
connect (slave2,127.0.0.1,test,,test,$SLAVE_MYPORT,);
15
16
connection master1;
17
18
create table t1(a int) engine=InnoDB;
19
create table t2(a int) engine=MyISAM;
20
insert into t1 values(1001);
21
insert into t2 values(2001);
22
23
connection master;
24
set global read_only=1;
25
26
connection master1;
27
select @@read_only;
28
select * from t1;
29
select * from t2;
30
31
sync_slave_with_master;
32
select @@read_only;
33
select * from t1;
34
select * from t2;
35
36
# - replication of transactions
37
connection master;
38
set global read_only=0;
39
40
connection master1;
41
BEGIN;
42
insert into t1 values(1002);
43
insert into t2 values(2002);
44
45
connection master2;
46
BEGIN;
47
insert into t1 values(1003);
48
insert into t2 values(2003);
49
50
connection master;
51
set global read_only=1;
52
53
connection master1;
54
## works even with read_only=1, because master1 is root
55
COMMIT;
56
57
connection master2;
58
--error ER_OPTION_PREVENTS_STATEMENT
59
COMMIT;
60
61
connection master;
62
set global read_only=0;
63
64
connection master1;
65
insert into t1 values(1004);
66
insert into t2 values(2004);
67
68
select * from t1;
69
select * from t2;
70
71
sync_slave_with_master;
72
select * from t1;
73
select * from t2;
74
75
# Setting the slave readonly : replication will pass
76
# 
77
connection slave1;
78
set global read_only=1;
79
80
connection slave;
81
select @@read_only;
82
# Make sure the replicated table is also transactional
83
show create table t1;
84
# Make sure the replicated table is not transactional
85
show create table t2;
86
87
connection master;
88
insert into t1 values(1005);
89
insert into t2 values(2005);
90
select * from t1;
91
select * from t2;
92
93
sync_slave_with_master;
94
connection slave;
95
select * from t1;
96
select * from t2;
97
98
# Non root user can not write on the slave
99
connection slave2;
100
--error ER_OPTION_PREVENTS_STATEMENT
101
insert into t1 values(1006);
102
--error ER_OPTION_PREVENTS_STATEMENT
103
insert into t2 values(2006);
104
105
## Cleanup
106
connection master;
107
drop user test;
108
drop table t1;
109
drop table t2;
110
sync_slave_with_master;
111
set global read_only=0;
112
113