2009-02-11 10:27:52 +01:00
|
|
|
set @start_read_only= @@global.read_only;
|
2005-10-17 10:52:34 +02:00
|
|
|
DROP TABLE IF EXISTS t1,t2,t3;
|
2015-08-11 18:45:38 +02:00
|
|
|
create user test@localhost;
|
2005-10-17 10:52:34 +02:00
|
|
|
grant CREATE, SELECT, DROP on *.* to test@localhost;
|
2016-03-25 17:51:22 +01:00
|
|
|
connect con1,localhost,test,,test;
|
2009-02-11 10:27:52 +01:00
|
|
|
connection default;
|
2005-10-17 10:52:34 +02:00
|
|
|
set global read_only=0;
|
2009-02-11 10:27:52 +01:00
|
|
|
connection con1;
|
2005-10-17 10:52:34 +02:00
|
|
|
create table t1 (a int);
|
2015-03-05 17:11:23 +01:00
|
|
|
create trigger trg1 before insert on t1 for each row set @a:=1;
|
2005-10-17 10:52:34 +02:00
|
|
|
insert into t1 values(1);
|
|
|
|
create table t2 select * from t1;
|
2009-02-11 10:27:52 +01:00
|
|
|
connection default;
|
2005-10-17 10:52:34 +02:00
|
|
|
set global read_only=1;
|
|
|
|
create table t3 (a int);
|
|
|
|
drop table t3;
|
2009-02-11 10:27:52 +01:00
|
|
|
connection con1;
|
2005-10-17 10:52:34 +02:00
|
|
|
select @@global.read_only;
|
|
|
|
@@global.read_only
|
|
|
|
1
|
|
|
|
create table t3 (a int);
|
2011-12-12 23:58:40 +01:00
|
|
|
ERROR HY000: The MariaDB server is running with the --read-only option so it cannot execute this statement
|
2005-10-17 10:52:34 +02:00
|
|
|
insert into t1 values(1);
|
2011-12-12 23:58:40 +01:00
|
|
|
ERROR HY000: The MariaDB server is running with the --read-only option so it cannot execute this statement
|
2015-03-05 17:11:23 +01:00
|
|
|
drop trigger trg1;
|
|
|
|
ERROR HY000: The MariaDB server is running with the --read-only option so it cannot execute this statement
|
2005-11-07 16:18:46 +01:00
|
|
|
update t1 set a=1 where 1=0;
|
2011-12-12 23:58:40 +01:00
|
|
|
ERROR HY000: The MariaDB server is running with the --read-only option so it cannot execute this statement
|
2005-10-17 10:52:34 +02:00
|
|
|
update t1,t2 set t1.a=t2.a+1 where t1.a=t2.a;
|
2011-12-12 23:58:40 +01:00
|
|
|
ERROR HY000: The MariaDB server is running with the --read-only option so it cannot execute this statement
|
2005-10-17 10:52:34 +02:00
|
|
|
delete t1,t2 from t1,t2 where t1.a=t2.a;
|
2011-12-12 23:58:40 +01:00
|
|
|
ERROR HY000: The MariaDB server is running with the --read-only option so it cannot execute this statement
|
2005-10-17 10:52:34 +02:00
|
|
|
create temporary table t3 (a int);
|
|
|
|
create temporary table t4 (a int) select * from t3;
|
|
|
|
insert into t3 values(1);
|
|
|
|
insert into t4 select * from t3;
|
|
|
|
update t1,t3 set t1.a=t3.a+1 where t1.a=t3.a;
|
2011-12-12 23:58:40 +01:00
|
|
|
ERROR HY000: The MariaDB server is running with the --read-only option so it cannot execute this statement
|
2005-10-17 10:52:34 +02:00
|
|
|
update t1,t3 set t3.a=t1.a+1 where t1.a=t3.a;
|
|
|
|
update t4,t3 set t4.a=t3.a+1 where t4.a=t3.a;
|
|
|
|
delete t1 from t1,t3 where t1.a=t3.a;
|
2011-12-12 23:58:40 +01:00
|
|
|
ERROR HY000: The MariaDB server is running with the --read-only option so it cannot execute this statement
|
2005-10-17 10:52:34 +02:00
|
|
|
delete t3 from t1,t3 where t1.a=t3.a;
|
|
|
|
delete t4 from t3,t4 where t4.a=t3.a;
|
|
|
|
create temporary table t1 (a int);
|
|
|
|
insert into t1 values(1);
|
|
|
|
update t1,t3 set t1.a=t3.a+1 where t1.a=t3.a;
|
|
|
|
delete t1 from t1,t3 where t1.a=t3.a;
|
|
|
|
drop table t1;
|
|
|
|
insert into t1 values(1);
|
2011-12-12 23:58:40 +01:00
|
|
|
ERROR HY000: The MariaDB server is running with the --read-only option so it cannot execute this statement
|
2009-02-11 10:27:52 +01:00
|
|
|
connection default;
|
2006-11-21 04:40:35 +01:00
|
|
|
set global read_only=0;
|
|
|
|
lock table t1 write;
|
2009-02-11 10:27:52 +01:00
|
|
|
connection con1;
|
2006-11-21 04:40:35 +01:00
|
|
|
lock table t2 write;
|
2009-02-11 10:27:52 +01:00
|
|
|
connection default;
|
2006-11-21 04:40:35 +01:00
|
|
|
set global read_only=1;
|
|
|
|
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
|
|
|
|
unlock tables ;
|
2009-02-11 10:27:52 +01:00
|
|
|
send set global read_only=1;
|
2006-11-21 04:40:35 +01:00
|
|
|
set global read_only=1;
|
2009-02-11 10:27:52 +01:00
|
|
|
connection con1;
|
2006-11-21 04:40:35 +01:00
|
|
|
select @@global.read_only;
|
|
|
|
@@global.read_only
|
|
|
|
0
|
|
|
|
unlock tables ;
|
|
|
|
select @@global.read_only;
|
|
|
|
@@global.read_only
|
|
|
|
1
|
2009-02-11 10:27:52 +01:00
|
|
|
connection default;
|
|
|
|
reap;
|
|
|
|
connection default;
|
2006-11-21 04:40:35 +01:00
|
|
|
set global read_only=0;
|
|
|
|
lock table t1 read;
|
2009-02-11 10:27:52 +01:00
|
|
|
connection con1;
|
2006-11-21 04:40:35 +01:00
|
|
|
lock table t2 read;
|
2009-02-11 10:27:52 +01:00
|
|
|
connection default;
|
2006-11-21 04:40:35 +01:00
|
|
|
set global read_only=1;
|
|
|
|
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
|
|
|
|
unlock tables ;
|
|
|
|
set global read_only=1;
|
|
|
|
select @@global.read_only;
|
|
|
|
@@global.read_only
|
2012-06-04 17:39:28 +02:00
|
|
|
1
|
|
|
|
connection con1;
|
2006-11-21 04:40:35 +01:00
|
|
|
select @@global.read_only;
|
|
|
|
@@global.read_only
|
|
|
|
1
|
2012-06-04 17:39:28 +02:00
|
|
|
unlock tables ;
|
2009-02-11 10:27:52 +01:00
|
|
|
connection default;
|
|
|
|
connection default;
|
2006-11-21 04:40:35 +01:00
|
|
|
set global read_only=0;
|
|
|
|
BEGIN;
|
2009-02-11 10:27:52 +01:00
|
|
|
connection con1;
|
2006-11-21 04:40:35 +01:00
|
|
|
BEGIN;
|
2009-02-11 10:27:52 +01:00
|
|
|
connection default;
|
2006-11-21 04:40:35 +01:00
|
|
|
set global read_only=1;
|
|
|
|
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
|
|
|
|
ROLLBACK;
|
|
|
|
set global read_only=1;
|
2009-02-11 10:27:52 +01:00
|
|
|
connection con1;
|
2006-11-21 04:40:35 +01:00
|
|
|
select @@global.read_only;
|
|
|
|
@@global.read_only
|
|
|
|
1
|
|
|
|
ROLLBACK;
|
2009-02-11 10:27:52 +01:00
|
|
|
connection default;
|
2006-11-21 04:40:35 +01:00
|
|
|
set global read_only=0;
|
|
|
|
flush tables with read lock;
|
|
|
|
set global read_only=1;
|
|
|
|
unlock tables;
|
2016-03-25 17:51:22 +01:00
|
|
|
connect root2,localhost,root,,test;
|
2009-02-11 10:27:52 +01:00
|
|
|
connection default;
|
2006-11-21 04:40:35 +01:00
|
|
|
set global read_only=0;
|
|
|
|
flush tables with read lock;
|
2009-02-11 10:27:52 +01:00
|
|
|
connection root2;
|
2006-11-21 04:40:35 +01:00
|
|
|
set global read_only=1;
|
2009-02-11 10:27:52 +01:00
|
|
|
connection default;
|
2006-11-21 04:40:35 +01:00
|
|
|
select @@global.read_only;
|
|
|
|
@@global.read_only
|
|
|
|
1
|
|
|
|
unlock tables;
|
2016-03-25 17:51:22 +01:00
|
|
|
disconnect root2;
|
2006-11-20 15:35:23 +01:00
|
|
|
drop temporary table ttt;
|
2013-07-03 18:02:48 +02:00
|
|
|
ERROR 42S02: Unknown table 'test.ttt'
|
2006-11-20 15:35:23 +01:00
|
|
|
drop temporary table if exists ttt;
|
|
|
|
Warnings:
|
2013-07-03 18:02:48 +02:00
|
|
|
Note 1051 Unknown table 'test.ttt'
|
2009-02-11 10:27:52 +01:00
|
|
|
connection default;
|
2006-12-12 21:22:46 +01:00
|
|
|
set global read_only=0;
|
2016-03-25 17:51:22 +01:00
|
|
|
disconnect con1;
|
2005-10-17 10:52:34 +02:00
|
|
|
drop table t1,t2;
|
|
|
|
drop user test@localhost;
|
2007-12-07 15:39:41 +01:00
|
|
|
#
|
2009-03-03 21:34:18 +01:00
|
|
|
# Bug#27440 read_only allows create and drop database
|
2007-12-07 15:39:41 +01:00
|
|
|
#
|
2007-12-10 10:32:07 +01:00
|
|
|
set global read_only= 1;
|
2007-12-07 15:39:41 +01:00
|
|
|
drop database if exists mysqltest_db1;
|
|
|
|
drop database if exists mysqltest_db2;
|
|
|
|
delete from mysql.user where User like 'mysqltest_%';
|
|
|
|
delete from mysql.db where User like 'mysqltest_%';
|
|
|
|
delete from mysql.tables_priv where User like 'mysqltest_%';
|
|
|
|
delete from mysql.columns_priv where User like 'mysqltest_%';
|
|
|
|
flush privileges;
|
2015-08-11 18:45:38 +02:00
|
|
|
create user `mysqltest_u1`@`%`;
|
2007-12-07 15:39:41 +01:00
|
|
|
grant all on mysqltest_db2.* to `mysqltest_u1`@`%`;
|
|
|
|
create database mysqltest_db1;
|
|
|
|
grant all on mysqltest_db1.* to `mysqltest_u1`@`%`;
|
|
|
|
flush privileges;
|
2016-03-25 17:51:22 +01:00
|
|
|
connect con_bug27440,127.0.0.1,mysqltest_u1,,test,$MASTER_MYPORT,;
|
2009-02-11 10:27:52 +01:00
|
|
|
connection con_bug27440;
|
2007-12-07 15:39:41 +01:00
|
|
|
create database mysqltest_db2;
|
2011-12-12 23:58:40 +01:00
|
|
|
ERROR HY000: The MariaDB server is running with the --read-only option so it cannot execute this statement
|
2007-12-07 15:39:41 +01:00
|
|
|
show databases like '%mysqltest_db2%';
|
|
|
|
Database (%mysqltest_db2%)
|
|
|
|
drop database mysqltest_db1;
|
2011-12-12 23:58:40 +01:00
|
|
|
ERROR HY000: The MariaDB server is running with the --read-only option so it cannot execute this statement
|
2009-02-11 10:27:52 +01:00
|
|
|
disconnect con_bug27440;
|
|
|
|
connection default;
|
2007-12-07 15:39:41 +01:00
|
|
|
delete from mysql.user where User like 'mysqltest_%';
|
|
|
|
delete from mysql.db where User like 'mysqltest_%';
|
|
|
|
delete from mysql.tables_priv where User like 'mysqltest_%';
|
|
|
|
delete from mysql.columns_priv where User like 'mysqltest_%';
|
|
|
|
flush privileges;
|
|
|
|
drop database mysqltest_db1;
|
2009-02-11 10:27:52 +01:00
|
|
|
set global read_only= @start_read_only;
|
2012-08-25 17:57:17 +02:00
|
|
|
#
|
|
|
|
# WL#5968 Implement START TRANSACTION READ (WRITE|ONLY);
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# Test interaction with read_only system variable.
|
|
|
|
DROP TABLE IF EXISTS t1;
|
|
|
|
CREATE TABLE t1(a INT);
|
|
|
|
INSERT INTO t1 VALUES (1), (2);
|
|
|
|
CREATE USER user1;
|
2016-03-25 17:51:22 +01:00
|
|
|
connect con1, localhost, user1;
|
|
|
|
connection default;
|
2012-08-25 17:57:17 +02:00
|
|
|
SET GLOBAL read_only= 1;
|
|
|
|
# All allowed with super privilege
|
|
|
|
START TRANSACTION;
|
|
|
|
COMMIT;
|
|
|
|
START TRANSACTION READ ONLY;
|
|
|
|
COMMIT;
|
|
|
|
START TRANSACTION READ WRITE;
|
|
|
|
COMMIT;
|
|
|
|
# We allow implicit RW transaction without super privilege
|
|
|
|
# for compatibility reasons
|
2016-03-25 17:51:22 +01:00
|
|
|
connection con1;
|
2012-08-25 17:57:17 +02:00
|
|
|
START TRANSACTION;
|
|
|
|
# Check that table updates are still disallowed.
|
|
|
|
INSERT INTO t1 VALUES (3);
|
|
|
|
ERROR HY000: The MariaDB server is running with the --read-only option so it cannot execute this statement
|
|
|
|
UPDATE t1 SET a= 1;
|
|
|
|
ERROR HY000: The MariaDB server is running with the --read-only option so it cannot execute this statement
|
|
|
|
DELETE FROM t1;
|
|
|
|
ERROR HY000: The MariaDB server is running with the --read-only option so it cannot execute this statement
|
|
|
|
COMMIT;
|
|
|
|
START TRANSACTION READ ONLY;
|
|
|
|
COMMIT;
|
|
|
|
# Explicit RW trans is not allowed without super privilege
|
|
|
|
START TRANSACTION READ WRITE;
|
|
|
|
ERROR HY000: The MariaDB server is running with the --read-only option so it cannot execute this statement
|
|
|
|
COMMIT;
|
2016-03-25 17:51:22 +01:00
|
|
|
disconnect con1;
|
|
|
|
connection default;
|
2012-08-25 17:57:17 +02:00
|
|
|
DROP USER user1;
|
|
|
|
SET GLOBAL read_only= 0;
|
|
|
|
DROP TABLE t1;
|