1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-01 03:47:19 +03:00
Files
mariadb/mysql-test/suite/sys_vars/r/read_only_func.result
Monty ce8a74f235 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>
2025-04-28 12:59:39 +03:00

58 lines
1.6 KiB
Plaintext

** Setup **
SET @default_read_only = @@read_only;
'#--------------------FN_DYNVARS_140_01-------------------------#'
SET Global read_only=ON;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1
(
id INT NOT NULL auto_increment,
PRIMARY KEY (id),
name BLOB
);
INSERT into t1(name) values("aaassssssssddddddddffffff");
update t1 set name="jfjdf" where id=1;
select * from t1 where id=1;
id name
1 jfjdf
'#--------------------FN_DYNVARS_140_02-------------------------#'
** Creating new user with out super privilege**
CREATE user sameea;
grant all on test.* to sameea;
CONNECT connn,localhost,sameea,,;
SET Global read_ONLY=ON;
ERROR 42000: Access denied; you need (at least one of) the READ_ONLY ADMIN privilege(s) for this operation
CREATE TABLE t2
(
id INT NOT NULL auto_increment,
PRIMARY KEY (id),
name BLOB
);
ERROR HY000: The MariaDB server is running with the --read-only=ON option so it cannot execute this statement
not updating values
INSERT into t2(name) values("aaassssssssddddddddffffff");
Got one of the listed errors
UPDATE t2 SET name="samia" where id=1;
Got one of the listed errors
'#--------------------FN_DYNVARS_140_03-------------------------#'
CREATE TEMPORARY TABLE t3(a int);
'#--------------------FN_DYNVARS_140_04-------------------------#'
connection default;
SET Global read_only=OFF;
connection connn;
CREATE TABLE t2
(
id INT NOT NULL auto_increment,
PRIMARY KEY (id),
name BLOB
);
updating values
INSERT into t2(name) values("aaassssssssdddddddd");
UPDATE t2 SET name="samia" where id=1;
connection default;
disconnect connn;
DROP USER sameea;
DROP TABLE t1;
DROP TABLE t2;
SET global read_only = @default_read_only;