1
DROP TABLE IF EXISTS t1,t2,t3;
2
grant CREATE, SELECT, DROP on *.* to test@localhost;
3
set global read_only=0;
4
create table t1 (a int);
5
insert into t1 values(1);
6
create table t2 select * from t1;
7
set global read_only=1;
8
create table t3 (a int);
10
select @@global.read_only;
13
create table t3 (a int);
14
ERROR HY000: The MySQL server is running with the --read-only option so it cannot execute this statement
15
insert into t1 values(1);
16
ERROR HY000: The MySQL server is running with the --read-only option so it cannot execute this statement
17
update t1 set a=1 where 1=0;
18
ERROR HY000: The MySQL server is running with the --read-only option so it cannot execute this statement
19
update t1,t2 set t1.a=t2.a+1 where t1.a=t2.a;
20
ERROR HY000: The MySQL server is running with the --read-only option so it cannot execute this statement
21
delete t1,t2 from t1,t2 where t1.a=t2.a;
22
ERROR HY000: The MySQL server is running with the --read-only option so it cannot execute this statement
23
create temporary table t3 (a int);
24
create temporary table t4 (a int) select * from t3;
25
insert into t3 values(1);
26
insert into t4 select * from t3;
27
update t1,t3 set t1.a=t3.a+1 where t1.a=t3.a;
28
ERROR HY000: The MySQL server is running with the --read-only option so it cannot execute this statement
29
update t1,t3 set t3.a=t1.a+1 where t1.a=t3.a;
30
update t4,t3 set t4.a=t3.a+1 where t4.a=t3.a;
31
delete t1 from t1,t3 where t1.a=t3.a;
32
ERROR HY000: The MySQL server is running with the --read-only option so it cannot execute this statement
33
delete t3 from t1,t3 where t1.a=t3.a;
34
delete t4 from t3,t4 where t4.a=t3.a;
35
create temporary table t1 (a int);
36
insert into t1 values(1);
37
update t1,t3 set t1.a=t3.a+1 where t1.a=t3.a;
38
delete t1 from t1,t3 where t1.a=t3.a;
40
insert into t1 values(1);
41
ERROR HY000: The MySQL server is running with the --read-only option so it cannot execute this statement
42
set global read_only=0;
45
set global read_only=1;
46
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
48
set global read_only=1;
49
select @@global.read_only;
53
select @@global.read_only;
56
set global read_only=0;
59
set global read_only=1;
60
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
62
set global read_only=1;
63
select @@global.read_only;
67
select @@global.read_only;
70
set global read_only=0;
73
set global read_only=1;
74
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
76
set global read_only=1;
77
select @@global.read_only;
81
set global read_only=0;
82
flush tables with read lock;
83
set global read_only=1;
85
set global read_only=0;
86
flush tables with read lock;
87
set global read_only=1;
88
select @@global.read_only;
92
drop temporary table ttt;
93
ERROR 42S02: Unknown table 'ttt'
94
drop temporary table if exists ttt;
96
Note 1051 Unknown table 'ttt'
97
set global read_only=0;
99
drop user test@localhost;
101
# Bug #27440 read_only allows create and drop database
103
set global read_only= 1;
104
drop database if exists mysqltest_db1;
105
drop database if exists mysqltest_db2;
106
delete from mysql.user where User like 'mysqltest_%';
107
delete from mysql.db where User like 'mysqltest_%';
108
delete from mysql.tables_priv where User like 'mysqltest_%';
109
delete from mysql.columns_priv where User like 'mysqltest_%';
111
grant all on mysqltest_db2.* to `mysqltest_u1`@`%`;
112
create database mysqltest_db1;
113
grant all on mysqltest_db1.* to `mysqltest_u1`@`%`;
115
create database mysqltest_db2;
116
ERROR HY000: The MySQL server is running with the --read-only option so it cannot execute this statement
117
show databases like '%mysqltest_db2%';
118
Database (%mysqltest_db2%)
119
drop database mysqltest_db1;
120
ERROR HY000: The MySQL server is running with the --read-only option so it cannot execute this statement
121
delete from mysql.user where User like 'mysqltest_%';
122
delete from mysql.db where User like 'mysqltest_%';
123
delete from mysql.tables_priv where User like 'mysqltest_%';
124
delete from mysql.columns_priv where User like 'mysqltest_%';
126
drop database mysqltest_db1;
127
set global read_only=0;