mirror of
https://github.com/MariaDB/server.git
synced 2025-09-17 06:35:56 +02:00

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>
53 lines
1.8 KiB
Text
53 lines
1.8 KiB
Text
use performance_schema;
|
|
set @start_read_only= @@global.read_only;
|
|
create user pfsuser@localhost;
|
|
grant SELECT, UPDATE on performance_schema.* to pfsuser@localhost;
|
|
flush privileges;
|
|
connect con1, localhost, pfsuser, ,"*NO-ONE*";
|
|
connection default;
|
|
set global read_only=0;
|
|
connection con1;
|
|
select @@global.read_only;
|
|
@@global.read_only
|
|
OFF
|
|
show grants;
|
|
Grants for pfsuser@localhost
|
|
GRANT USAGE ON *.* TO `pfsuser`@`localhost`
|
|
GRANT SELECT, UPDATE ON `performance_schema`.* TO `pfsuser`@`localhost`
|
|
# Update on perf_schema is allowed in read_only mode.
|
|
select * from performance_schema.setup_instruments;
|
|
update performance_schema.setup_instruments set enabled='NO';
|
|
update performance_schema.setup_instruments set enabled='YES';
|
|
connection default;
|
|
set global read_only=1;
|
|
connection con1;
|
|
select @@global.read_only;
|
|
@@global.read_only
|
|
ON
|
|
show grants;
|
|
Grants for pfsuser@localhost
|
|
GRANT USAGE ON *.* TO `pfsuser`@`localhost`
|
|
GRANT SELECT, UPDATE ON `performance_schema`.* TO `pfsuser`@`localhost`
|
|
select * from performance_schema.setup_instruments;
|
|
update performance_schema.setup_instruments set enabled='NO';
|
|
update performance_schema.setup_instruments set enabled='YES';
|
|
connection default;
|
|
grant READ_ONLY ADMIN on *.* to pfsuser@localhost;
|
|
flush privileges;
|
|
disconnect con1;
|
|
connect con1, localhost, pfsuser, ,"*NO-ONE*";
|
|
select @@global.read_only;
|
|
@@global.read_only
|
|
ON
|
|
show grants;
|
|
Grants for pfsuser@localhost
|
|
GRANT READ_ONLY ADMIN ON *.* TO `pfsuser`@`localhost`
|
|
GRANT SELECT, UPDATE ON `performance_schema`.* TO `pfsuser`@`localhost`
|
|
select * from performance_schema.setup_instruments;
|
|
update performance_schema.setup_instruments set enabled='NO';
|
|
update performance_schema.setup_instruments set enabled='YES';
|
|
disconnect con1;
|
|
connection default;
|
|
set global read_only= @start_read_only;
|
|
drop user pfsuser@localhost;
|
|
flush privileges;
|