mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
MDEV-28546 : Possible to write/update with read_only=ON and not a SUPER privilege
Function wsrep_read_only_option was already removed in commit
d54bc3c0d1
because it could cause race condition on variable
opt_readonly so that value OFF can become permanent.
Removed function again and added test case. Note that writes
to TEMPORARY tables are still allowed when read_only=ON.
This commit is contained in:
@ -17,10 +17,18 @@ connect foo_node_2,127.0.0.1,foo,,test,$port_2,;
|
|||||||
connection foo_node_2;
|
connection foo_node_2;
|
||||||
INSERT INTO t1 VALUES (2);
|
INSERT INTO t1 VALUES (2);
|
||||||
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 option so it cannot execute this statement
|
||||||
|
CREATE TEMPORARY TABLE t2(id int not null primary key) engine=innodb;
|
||||||
|
INSERT INTO t2 values (1);
|
||||||
|
DROP TABLE t2;
|
||||||
connection node_2;
|
connection node_2;
|
||||||
SELECT COUNT(*) = 1 FROM t1;
|
SELECT COUNT(*) AS EXPECT_1 FROM t1;
|
||||||
COUNT(*) = 1
|
EXPECT_1
|
||||||
1
|
1
|
||||||
|
connection node_2;
|
||||||
|
SET GLOBAL read_only=TRUE;
|
||||||
|
CREATE TEMPORARY TABLE t2(id int not null primary key) engine=innodb;
|
||||||
|
INSERT INTO t2 values (1);
|
||||||
|
DROP TABLE t2;
|
||||||
SET GLOBAL read_only=FALSE;
|
SET GLOBAL read_only=FALSE;
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
DROP USER foo@localhost;
|
DROP USER foo@localhost;
|
||||||
|
@ -28,9 +28,20 @@ CREATE USER foo@localhost;
|
|||||||
--connection foo_node_2
|
--connection foo_node_2
|
||||||
--error ER_OPTION_PREVENTS_STATEMENT
|
--error ER_OPTION_PREVENTS_STATEMENT
|
||||||
INSERT INTO t1 VALUES (2);
|
INSERT INTO t1 VALUES (2);
|
||||||
|
# Writes to temporary tables are allowed
|
||||||
|
CREATE TEMPORARY TABLE t2(id int not null primary key) engine=innodb;
|
||||||
|
INSERT INTO t2 values (1);
|
||||||
|
DROP TABLE t2;
|
||||||
|
|
||||||
--connection node_2
|
--connection node_2
|
||||||
SELECT COUNT(*) = 1 FROM t1;
|
SELECT COUNT(*) AS EXPECT_1 FROM t1;
|
||||||
|
|
||||||
|
--connection node_2
|
||||||
|
SET GLOBAL read_only=TRUE;
|
||||||
|
# Writes to temporary tables are allowed
|
||||||
|
CREATE TEMPORARY TABLE t2(id int not null primary key) engine=innodb;
|
||||||
|
INSERT INTO t2 values (1);
|
||||||
|
DROP TABLE t2;
|
||||||
|
|
||||||
# Cleanup
|
# Cleanup
|
||||||
SET GLOBAL read_only=FALSE;
|
SET GLOBAL read_only=FALSE;
|
||||||
|
@ -1468,22 +1468,6 @@ static bool deny_updates_if_read_only_option(THD *thd, TABLE_LIST *all_tables)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WITH_WSREP
|
#ifdef WITH_WSREP
|
||||||
static my_bool wsrep_read_only_option(THD *thd, TABLE_LIST *all_tables)
|
|
||||||
{
|
|
||||||
int opt_readonly_saved = opt_readonly;
|
|
||||||
ulong flag_saved = (ulong)(thd->security_ctx->master_access & SUPER_ACL);
|
|
||||||
|
|
||||||
opt_readonly = 0;
|
|
||||||
thd->security_ctx->master_access &= ~SUPER_ACL;
|
|
||||||
|
|
||||||
my_bool ret = !deny_updates_if_read_only_option(thd, all_tables);
|
|
||||||
|
|
||||||
opt_readonly = opt_readonly_saved;
|
|
||||||
thd->security_ctx->master_access |= flag_saved;
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void wsrep_copy_query(THD *thd)
|
static void wsrep_copy_query(THD *thd)
|
||||||
{
|
{
|
||||||
thd->wsrep_retry_command = thd->get_command();
|
thd->wsrep_retry_command = thd->get_command();
|
||||||
@ -7807,7 +7791,7 @@ static bool wsrep_mysql_parse(THD *thd, char *rawbuf, uint length,
|
|||||||
{
|
{
|
||||||
bool is_autocommit=
|
bool is_autocommit=
|
||||||
!thd->in_multi_stmt_transaction_mode() &&
|
!thd->in_multi_stmt_transaction_mode() &&
|
||||||
wsrep_read_only_option(thd, thd->lex->query_tables);
|
!thd->wsrep_applier;
|
||||||
bool retry_autocommit;
|
bool retry_autocommit;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user