diff --git a/mysql-test/suite/sys_vars/r/super_read_only_basic.result b/mysql-test/suite/sys_vars/r/super_read_only_basic.result index 0df0c11..20e0df4 100644 --- a/mysql-test/suite/sys_vars/r/super_read_only_basic.result +++ b/mysql-test/suite/sys_vars/r/super_read_only_basic.result @@ -213,6 +213,10 @@ connection con1; create table t1 (a int); insert into t1 values(1); create table t2 select * from t1; +update t1, t2 set t1.a=2, t2.a=2; +start transaction read write; +commit; +create trigger trig before insert on t1 for each row set new.a = new.a; connection default; # # Make sure it blocks SUPER @@ -222,6 +226,12 @@ create table t3 (a int); ERROR HY000: The MySQL server is running with the --read-only (super) option so it cannot execute this statement drop table t3; ERROR HY000: The MySQL server is running with the --read-only (super) option so it cannot execute this statement +update t1, t2 set t1.a=3, t2.a=3; +ERROR HY000: The MySQL server is running with the --read-only (super) option so it cannot execute this statement +start transaction read write; +ERROR HY000: The MySQL server is running with the --read-only (super) option so it cannot execute this statement +drop trigger trig; +ERROR HY000: The MySQL server is running with the --read-only (super) option so it cannot execute this statement # # Make sure it still blocks for non-super # @@ -236,6 +246,12 @@ create table t3 (a int); ERROR HY000: The MySQL server is running with the --read-only (super) option so it cannot execute this statement insert into t1 values(1); ERROR HY000: The MySQL server is running with the --read-only (super) option so it cannot execute this statement +update t1, t2 set t1.a=3, t2.a=3; +ERROR HY000: The MySQL server is running with the --read-only (super) option so it cannot execute this statement +start transaction read write; +ERROR HY000: The MySQL server is running with the --read-only (super) option so it cannot execute this statement +drop trigger trig; +ERROR HY000: The MySQL server is running with the --read-only (super) option so it cannot execute this statement # # Cleanup # diff --git a/mysql-test/suite/sys_vars/t/super_read_only_basic.test b/mysql-test/suite/sys_vars/t/super_read_only_basic.test index e05ed04..8e5f324 100644 --- a/mysql-test/suite/sys_vars/t/super_read_only_basic.test +++ b/mysql-test/suite/sys_vars/t/super_read_only_basic.test @@ -159,6 +159,13 @@ insert into t1 values(1); create table t2 select * from t1; +update t1, t2 set t1.a=2, t2.a=2; + +start transaction read write; +commit; + +create trigger trig before insert on t1 for each row set new.a = new.a; + --echo connection default; connection default; @@ -175,6 +182,14 @@ create table t3 (a int); --error ER_OPTION_PREVENTS_STATEMENT drop table t3; +--error ER_OPTION_PREVENTS_STATEMENT +update t1, t2 set t1.a=3, t2.a=3; + +--error ER_OPTION_PREVENTS_STATEMENT +start transaction read write; + +--error ER_OPTION_PREVENTS_STATEMENT +drop trigger trig; --echo # --echo # Make sure it still blocks for non-super @@ -192,6 +207,14 @@ create table t3 (a int); --error ER_OPTION_PREVENTS_STATEMENT insert into t1 values(1); +--error ER_OPTION_PREVENTS_STATEMENT +update t1, t2 set t1.a=3, t2.a=3; + +--error ER_OPTION_PREVENTS_STATEMENT +start transaction read write; + +--error ER_OPTION_PREVENTS_STATEMENT +drop trigger trig; --echo # --echo # Cleanup diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc index 985d2ff..0b87d8b 100644 --- a/sql/sql_trigger.cc +++ b/sql/sql_trigger.cc @@ -444,6 +444,9 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create) if (!create) { bool if_exists= thd->lex->drop_if_exists; + bool enforce_ro= true; + if (!opt_super_readonly) + enforce_ro= !(thd->security_ctx->master_access & SUPER_ACL); /* Protect the query table list from the temporary and potentially @@ -458,11 +461,11 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create) */ thd->lex->sql_command= backup.sql_command; - if (opt_readonly && !(thd->security_ctx->master_access & SUPER_ACL) && - !thd->slave_thread) + if (opt_readonly && enforce_ro && !thd->slave_thread) { - my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--read-only"); - goto end; + my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), + opt_super_readonly ? "--read-only (super)" : "--read-only"); + goto end; } if (add_table_for_trigger(thd, thd->lex->spname, if_exists, & tables)) diff --git a/sql/transaction.cc b/sql/transaction.cc index e756229..fe65ec2 100644 --- a/sql/transaction.cc +++ b/sql/transaction.cc @@ -177,7 +177,8 @@ bool trans_begin(THD *thd, uint flags, bool* need_ok) enforce_ro = !(thd->security_ctx->master_access & SUPER_ACL); if (opt_readonly && enforce_ro) { - my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--read-only"); + my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), + opt_super_readonly ? "--read-only (super)" : "--read-only"); DBUG_RETURN(true); } thd->tx_read_only= false;