mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
MDEV-36425 Extend read_only to also block share locks and super user
The main purpose of this allow one to use the --read-only option to ensure that no one can issue a query that can block replication. The --read-only option can now take 4 different values: 0 No read only (as before). 1 Blocks changes for users without the 'READ ONLY ADMIN' privilege (as before). 2 Blocks in addition LOCK TABLES and SELECT IN SHARE MODE for not 'READ ONLY ADMIN' users. 3 Blocks in addition 'READ_ONLY_ADMIN' users for all the previous statements. read_only is changed to an enum and one can use the following names for the lock levels: OFF, ON, NO_LOCK, NO_LOCK_NO_ADMIN Too keep things compatible with older versions config files, one can still use values FALSE and TRUE, which are mapped to OFF and ON. The main visible changes are: - 'show variables like "read_only"' now returns a string instead of a number. - Error messages related to read_only violations now contains the current value off readonly. Other things: - is_read_only_ctx() renamed to check_read_only_with_error() - Moved TL_READ_SKIP_LOCKED to it's logical place Reviewed by: Sergei Golubchik <serg@mariadb.org>
This commit is contained in:
@@ -31,7 +31,7 @@ SET GLOBAL READ_ONLY=1;
|
||||
connection con1;
|
||||
SELECT @@GLOBAL.READ_ONLY;
|
||||
@@GLOBAL.READ_ONLY
|
||||
1
|
||||
ON
|
||||
COMMIT;
|
||||
connection default;
|
||||
SET GLOBAL READ_ONLY=0;
|
||||
@@ -45,7 +45,7 @@ SET GLOBAL READ_ONLY=1;
|
||||
connection con1;
|
||||
SELECT @@GLOBAL.READ_ONLY;
|
||||
@@GLOBAL.READ_ONLY
|
||||
1
|
||||
ON
|
||||
COMMIT;
|
||||
SELECT * FROM t1;
|
||||
a
|
||||
|
@@ -13,7 +13,7 @@ set global read_only=1;
|
||||
# Ensure that optimize and analyze doesn't log to binary log
|
||||
connect con1,localhost,test,,test;
|
||||
insert into t1 values(3);
|
||||
ERROR HY000: The MariaDB server is running with the --read-only option so it cannot execute this statement
|
||||
ERROR HY000: The MariaDB server is running with the --read-only=ON option so it cannot execute this statement
|
||||
analyze table t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status Engine-independent statistics collected
|
||||
@@ -23,10 +23,10 @@ Table Op Msg_type Msg_text
|
||||
test.t1 check status OK
|
||||
repair table t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 repair Error The MariaDB server is running with the --read-only option so it cannot execute this statement
|
||||
test.t1 repair Error The MariaDB server is running with the --read-only=ON option so it cannot execute this statement
|
||||
test.t1 repair error Corrupt
|
||||
optimize table t1;
|
||||
ERROR HY000: The MariaDB server is running with the --read-only option so it cannot execute this statement
|
||||
ERROR HY000: The MariaDB server is running with the --read-only=ON option so it cannot execute this statement
|
||||
# Ensure that using temporary tables is not logged
|
||||
create temporary table tmp1 (a int) engine=myisam;
|
||||
insert into tmp1 values (1),(2);
|
||||
@@ -48,7 +48,7 @@ a b
|
||||
1 NULL
|
||||
2 NULL
|
||||
insert into t1 select a+100 from tmp2;
|
||||
ERROR HY000: The MariaDB server is running with the --read-only option so it cannot execute this statement
|
||||
ERROR HY000: The MariaDB server is running with the --read-only=ON option so it cannot execute this statement
|
||||
drop table tmp1,tmp2,tmp3;
|
||||
# Clean up test connection
|
||||
disconnect con1;
|
||||
|
@@ -13,7 +13,7 @@ set global read_only=1;
|
||||
# Ensure that optimize and analyze doesn't log to binary log
|
||||
connect con1,localhost,test,,test;
|
||||
insert into t1 values(3);
|
||||
ERROR HY000: The MariaDB server is running with the --read-only option so it cannot execute this statement
|
||||
ERROR HY000: The MariaDB server is running with the --read-only=ON option so it cannot execute this statement
|
||||
analyze table t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status Engine-independent statistics collected
|
||||
@@ -23,10 +23,10 @@ Table Op Msg_type Msg_text
|
||||
test.t1 check status OK
|
||||
repair table t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 repair Error The MariaDB server is running with the --read-only option so it cannot execute this statement
|
||||
test.t1 repair Error The MariaDB server is running with the --read-only=ON option so it cannot execute this statement
|
||||
test.t1 repair error Corrupt
|
||||
optimize table t1;
|
||||
ERROR HY000: The MariaDB server is running with the --read-only option so it cannot execute this statement
|
||||
ERROR HY000: The MariaDB server is running with the --read-only=ON option so it cannot execute this statement
|
||||
# Ensure that using temporary tables is not logged
|
||||
create temporary table tmp1 (a int) engine=myisam;
|
||||
insert into tmp1 values (1),(2);
|
||||
@@ -48,7 +48,7 @@ a b
|
||||
1 NULL
|
||||
2 NULL
|
||||
insert into t1 select a+100 from tmp2;
|
||||
ERROR HY000: The MariaDB server is running with the --read-only option so it cannot execute this statement
|
||||
ERROR HY000: The MariaDB server is running with the --read-only=ON option so it cannot execute this statement
|
||||
drop table tmp1,tmp2,tmp3;
|
||||
# Clean up test connection
|
||||
disconnect con1;
|
||||
|
Reference in New Issue
Block a user