mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03: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>
39 lines
1.3 KiB
Plaintext
39 lines
1.3 KiB
Plaintext
include/master-slave.inc
|
|
[connection master]
|
|
connection slave;
|
|
SET GLOBAL read_only=1;
|
|
connection master;
|
|
CREATE PROCEDURE testproc()
|
|
BEGIN
|
|
DROP TEMPORARY TABLE IF EXISTS t1_tmp;
|
|
DROP TEMPORARY TABLE IF EXISTS t2_tmp;
|
|
CREATE TEMPORARY TABLE IF NOT EXISTS t1_tmp ( t1 varchar(400) DEFAULT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
|
CREATE TEMPORARY TABLE IF NOT EXISTS t2_tmp ( t2 varchar(16) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
|
END|
|
|
SET GLOBAL read_only=1;
|
|
CALL testproc();
|
|
******** None of the above DROP TEMPORARY TABLE statement should be found in binary log ********
|
|
include/show_binlog_events.inc
|
|
Log_name Pos Event_type Server_id End_log_pos Info
|
|
master-bin.000001 # Gtid # # GTID #-#-#
|
|
master-bin.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` PROCEDURE `testproc`()
|
|
BEGIN
|
|
DROP TEMPORARY TABLE IF EXISTS t1_tmp;
|
|
DROP TEMPORARY TABLE IF EXISTS t2_tmp;
|
|
CREATE TEMPORARY TABLE IF NOT EXISTS t1_tmp ( t1 varchar(400) DEFAULT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
|
CREATE TEMPORARY TABLE IF NOT EXISTS t2_tmp ( t2 varchar(16) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
|
END
|
|
connection slave;
|
|
SELECT @@read_only;
|
|
@@read_only
|
|
ON
|
|
======== CLEAN UP =========
|
|
connection master;
|
|
DROP TEMPORARY TABLE t1_tmp;
|
|
DROP TEMPORARY TABLE t2_tmp;
|
|
DROP PROCEDURE testproc;
|
|
SET GLOBAL read_only=0;
|
|
connection slave;
|
|
SET GLOBAL read_only=0;
|
|
include/rpl_end.inc
|