@@ -18,31 +18,31 @@ drop table t3;
1818connection con1;
1919select @@global.read_only;
2020@@global.read_only
21- 1
21+ ON
2222create table t3 (a int);
23- ERROR HY000: The MariaDB server is running with the --read-only option so it cannot execute this statement
23+ ERROR HY000: The MariaDB server is running with the --read-only=ON option so it cannot execute this statement
2424insert into t1 values(1);
25- ERROR HY000: The MariaDB server is running with the --read-only option so it cannot execute this statement
25+ ERROR HY000: The MariaDB server is running with the --read-only=ON option so it cannot execute this statement
2626drop trigger trg1;
27- ERROR HY000: The MariaDB server is running with the --read-only option so it cannot execute this statement
27+ ERROR HY000: The MariaDB server is running with the --read-only=ON option so it cannot execute this statement
2828update t1 set a=1 where 1=0;
29- ERROR HY000: The MariaDB server is running with the --read-only option so it cannot execute this statement
29+ ERROR HY000: The MariaDB server is running with the --read-only=ON option so it cannot execute this statement
3030update t1,t2 set t1.a=t2.a+1 where t1.a=t2.a;
31- ERROR HY000: The MariaDB server is running with the --read-only option so it cannot execute this statement
31+ ERROR HY000: The MariaDB server is running with the --read-only=ON option so it cannot execute this statement
3232delete t1,t2 from t1,t2 where t1.a=t2.a;
33- ERROR HY000: The MariaDB server is running with the --read-only option so it cannot execute this statement
33+ ERROR HY000: The MariaDB server is running with the --read-only=ON option so it cannot execute this statement
3434create temporary table t3 (a int);
3535create temporary table t4 (a int) select * from t3;
3636insert into t3 values(1);
3737insert into t4 select * from t3;
3838create table t3 (a int);
39- ERROR HY000: The MariaDB server is running with the --read-only option so it cannot execute this statement
39+ ERROR HY000: The MariaDB server is running with the --read-only=ON option so it cannot execute this statement
4040update t1,t3 set t1.a=t3.a+1 where t1.a=t3.a;
41- ERROR HY000: The MariaDB server is running with the --read-only option so it cannot execute this statement
41+ ERROR HY000: The MariaDB server is running with the --read-only=ON option so it cannot execute this statement
4242update t1,t3 set t3.a=t1.a+1 where t1.a=t3.a;
4343update t4,t3 set t4.a=t3.a+1 where t4.a=t3.a;
4444delete t1 from t1,t3 where t1.a=t3.a;
45- ERROR HY000: The MariaDB server is running with the --read-only option so it cannot execute this statement
45+ ERROR HY000: The MariaDB server is running with the --read-only=ON option so it cannot execute this statement
4646delete t3 from t1,t3 where t1.a=t3.a;
4747delete t4 from t3,t4 where t4.a=t3.a;
4848create temporary table t1 (a int);
@@ -51,7 +51,7 @@ update t1,t3 set t1.a=t3.a+1 where t1.a=t3.a;
5151delete t1 from t1,t3 where t1.a=t3.a;
5252drop table t1;
5353insert into t1 values(1);
54- ERROR HY000: The MariaDB server is running with the --read-only option so it cannot execute this statement
54+ ERROR HY000: The MariaDB server is running with the --read-only=ON option so it cannot execute this statement
5555drop temporary table if exists t1;
5656Warnings:
5757Note 1051 Unknown table 'test.t1'
@@ -69,11 +69,11 @@ set global read_only=1;
6969connection con1;
7070select @@global.read_only;
7171@@global.read_only
72- 0
72+ OFF
7373unlock tables ;
7474select @@global.read_only;
7575@@global.read_only
76- 1
76+ ON
7777connection default;
7878reap;
7979connection default;
@@ -88,11 +88,11 @@ unlock tables ;
8888set global read_only=1;
8989select @@global.read_only;
9090@@global.read_only
91- 1
91+ ON
9292connection con1;
9393select @@global.read_only;
9494@@global.read_only
95- 1
95+ ON
9696unlock tables ;
9797connection default;
9898connection default;
@@ -108,7 +108,7 @@ set global read_only=1;
108108connection con1;
109109select @@global.read_only;
110110@@global.read_only
111- 1
111+ ON
112112ROLLBACK;
113113connection default;
114114set global read_only=0;
@@ -124,7 +124,7 @@ set global read_only=1;
124124connection default;
125125select @@global.read_only;
126126@@global.read_only
127- 1
127+ ON
128128unlock tables;
129129disconnect root2;
130130drop temporary table ttt;
@@ -157,11 +157,11 @@ flush privileges;
157157connect con_bug27440,127.0.0.1,mysqltest_u1,,test,$MASTER_MYPORT,;
158158connection con_bug27440;
159159create database mysqltest_db2;
160- ERROR HY000: The MariaDB server is running with the --read-only option so it cannot execute this statement
160+ ERROR HY000: The MariaDB server is running with the --read-only=ON option so it cannot execute this statement
161161show databases like '%mysqltest_db2%';
162162Database (%mysqltest_db2%)
163163drop database mysqltest_db1;
164- ERROR HY000: The MariaDB server is running with the --read-only option so it cannot execute this statement
164+ ERROR HY000: The MariaDB server is running with the --read-only=ON option so it cannot execute this statement
165165disconnect con_bug27440;
166166connection default;
167167delete from mysql.user where User like 'mysqltest_%';
@@ -179,7 +179,7 @@ GRANT ALTER ON test1.* TO user1@localhost;
179179CREATE DATABASE test1;
180180SET GLOBAL read_only=1;
181181ALTER DATABASE test1 CHARACTER SET utf8;
182- ERROR HY000: The MariaDB server is running with the --read-only option so it cannot execute this statement
182+ ERROR HY000: The MariaDB server is running with the --read-only=ON option so it cannot execute this statement
183183SET GLOBAL read_only=0;
184184DROP DATABASE test1;
185185DROP USER user1@localhost;
@@ -210,21 +210,131 @@ connection con1;
210210START TRANSACTION;
211211# Check that table updates are still disallowed.
212212INSERT INTO t1 VALUES (3);
213- ERROR HY000: The MariaDB server is running with the --read-only option so it cannot execute this statement
213+ ERROR HY000: The MariaDB server is running with the --read-only=ON option so it cannot execute this statement
214214UPDATE t1 SET a= 1;
215- ERROR HY000: The MariaDB server is running with the --read-only option so it cannot execute this statement
215+ ERROR HY000: The MariaDB server is running with the --read-only=ON option so it cannot execute this statement
216216DELETE FROM t1;
217- ERROR HY000: The MariaDB server is running with the --read-only option so it cannot execute this statement
217+ ERROR HY000: The MariaDB server is running with the --read-only=ON option so it cannot execute this statement
218218COMMIT;
219219START TRANSACTION READ ONLY;
220220COMMIT;
221221# Explicit RW trans is not allowed without super privilege
222222START TRANSACTION READ WRITE;
223- ERROR HY000: The MariaDB server is running with the --read-only option so it cannot execute this statement
223+ ERROR HY000: The MariaDB server is running with the --read-only=ON option so it cannot execute this statement
224224COMMIT;
225225disconnect con1;
226226connection default;
227227DROP USER user1;
228228SET GLOBAL read_only= 0;
229229DROP TABLE t1;
230230# End of 10.0 tests
231+ #
232+ # MDEV-36425 Extend read_only to also block share locks and super user
233+ #
234+ CREATE USER user1;
235+ GRANT ALL on test.* to user1;
236+ connect con1, localhost, user1;
237+ connection default;
238+ CREATE TABLE t1 (a int primary key auto_increment);
239+ insert into t1 values (1),(2);
240+ show variables like "read_only";
241+ Variable_name Value
242+ read_only OFF
243+ SET GLOBAL read_only=1;
244+ show variables like "read_only";
245+ Variable_name Value
246+ read_only ON
247+ # admin
248+ insert into t1 values ();
249+ lock tables t1 read;
250+ unlock tables;
251+ lock tables t1 write;
252+ unlock tables;
253+ begin;
254+ select count(*) from t1 LOCK IN SHARE MODE;
255+ count(*)
256+ 3
257+ select count(*) from t1,(select a from t1 LOCK IN SHARE MODE) as t2;
258+ count(*)
259+ 9
260+ commit;
261+ # user
262+ connection con1;
263+ insert into t1 values ();
264+ ERROR HY000: The MariaDB server is running with the --read-only=ON option so it cannot execute this statement
265+ lock tables t1 read;
266+ unlock tables;
267+ lock tables t1 write;
268+ ERROR HY000: The MariaDB server is running with the --read-only=ON option so it cannot execute this statement
269+ unlock tables;
270+ begin;
271+ select count(*) from t1 LOCK IN SHARE MODE;
272+ count(*)
273+ 3
274+ select count(*) from t1,(select a from t1 LOCK IN SHARE MODE) as t2;
275+ count(*)
276+ 9
277+ commit;
278+ connection default;
279+ SET GLOBAL read_only=2;
280+ show variables like "read_only";
281+ Variable_name Value
282+ read_only NO_LOCK
283+ # admin
284+ insert into t1 values ();
285+ lock tables t1 read;
286+ unlock tables;
287+ lock tables t1 write;
288+ unlock tables;
289+ begin;
290+ select count(*) from t1 LOCK IN SHARE MODE;
291+ count(*)
292+ 4
293+ select count(*) from t1,(select a from t1 LOCK IN SHARE MODE) as t2;
294+ count(*)
295+ 16
296+ commit;
297+ #user
298+ connection con1;
299+ insert into t1 values ();
300+ ERROR HY000: The MariaDB server is running with the --read-only=NO_LOCK option so it cannot execute this statement
301+ lock tables t1 read;
302+ ERROR HY000: The MariaDB server is running with the --read-only=NO_LOCK option so it cannot execute this statement
303+ unlock tables;
304+ lock tables t1 write;
305+ ERROR HY000: The MariaDB server is running with the --read-only=NO_LOCK option so it cannot execute this statement
306+ unlock tables;
307+ begin;
308+ select count(*) from t1 LOCK IN SHARE MODE;
309+ ERROR HY000: The MariaDB server is running with the --read-only=NO_LOCK option so it cannot execute this statement
310+ select count(*) from t1,(select a from t1 LOCK IN SHARE MODE) as t2;
311+ ERROR HY000: The MariaDB server is running with the --read-only=NO_LOCK option so it cannot execute this statement
312+ commit;
313+ connection default;
314+ SET GLOBAL read_only=3;
315+ show variables like "read_only";
316+ Variable_name Value
317+ read_only NO_LOCK_NO_ADMIN
318+ # admin
319+ insert into t1 values ();
320+ ERROR HY000: The MariaDB server is running with the --read-only=NO_LOCK_NO_ADMIN option so it cannot execute this statement
321+ lock tables t1 read;
322+ ERROR HY000: The MariaDB server is running with the --read-only=NO_LOCK_NO_ADMIN option so it cannot execute this statement
323+ unlock tables;
324+ lock tables t1 write;
325+ ERROR HY000: The MariaDB server is running with the --read-only=NO_LOCK_NO_ADMIN option so it cannot execute this statement
326+ unlock tables;
327+ begin;
328+ select count(*) from t1 LOCK IN SHARE MODE;
329+ ERROR HY000: The MariaDB server is running with the --read-only=NO_LOCK_NO_ADMIN option so it cannot execute this statement
330+ select count(*) from t1,(select a from t1 LOCK IN SHARE MODE) as t2;
331+ ERROR HY000: The MariaDB server is running with the --read-only=NO_LOCK_NO_ADMIN option so it cannot execute this statement
332+ commit;
333+ SET GLOBAL read_only=0;
334+ select count(*) from t1;
335+ count(*)
336+ 4
337+ drop table t1;
338+ drop user user1;
339+ disconnect con1;
340+ # End of 11.8 tests
0 commit comments