summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNirbhay Choubey <nirbhay@mariadb.com>2015-09-21 20:49:31 -0400
committerNirbhay Choubey <nirbhay@mariadb.com>2015-09-21 20:49:31 -0400
commitd54bc3c0d1ed50b3c5aa3a22b2cb653851315e8a (patch)
tree1457106d3944808ed3747920c6cbf518c4c8b5ee
parent9d5767cf43e1243e039b20c1853f5b7812587f2d (diff)
downloadmariadb-git-d54bc3c0d1ed50b3c5aa3a22b2cb653851315e8a.tar.gz
Cleanup: remove dead code which could also lead to race.
-rw-r--r--mysql-test/suite/galera/r/galera_read_only.result18
-rw-r--r--mysql-test/suite/galera/t/galera_read_only.test39
-rw-r--r--sql/sql_parse.cc20
3 files changed, 59 insertions, 18 deletions
diff --git a/mysql-test/suite/galera/r/galera_read_only.result b/mysql-test/suite/galera/r/galera_read_only.result
new file mode 100644
index 00000000000..82736c5f4ba
--- /dev/null
+++ b/mysql-test/suite/galera/r/galera_read_only.result
@@ -0,0 +1,18 @@
+CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB;
+SET GLOBAL read_only=TRUE;
+INSERT INTO t1 VALUES (1);
+SELECT COUNT(*) = 1 FROM t1;
+COUNT(*) = 1
+1
+CREATE USER foo@localhost;
+# Open connection to node 2 using 'foo' user.
+
+# Connect with foo_node_2
+INSERT INTO t1 VALUES (2);
+ERROR HY000: The MariaDB server is running with the --read-only option so it cannot execute this statement
+SELECT COUNT(*) = 1 FROM t1;
+COUNT(*) = 1
+1
+SET GLOBAL read_only=FALSE;
+DROP TABLE t1;
+DROP USER foo@localhost;
diff --git a/mysql-test/suite/galera/t/galera_read_only.test b/mysql-test/suite/galera/t/galera_read_only.test
new file mode 100644
index 00000000000..c0fa4af07e0
--- /dev/null
+++ b/mysql-test/suite/galera/t/galera_read_only.test
@@ -0,0 +1,39 @@
+--source include/galera_cluster.inc
+--source include/have_innodb.inc
+
+#
+# Ensure that the read_only option does not apply to Galera appliers and that replication
+# continues, the way MySQL replication would.
+#
+
+CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB;
+
+--connection node_2
+SET GLOBAL read_only=TRUE;
+
+--connection node_1
+INSERT INTO t1 VALUES (1);
+
+--connection node_2
+SELECT COUNT(*) = 1 FROM t1;
+
+CREATE USER foo@localhost;
+
+--echo # Open connection to node 2 using 'foo' user.
+--let $port_2= \$NODE_MYPORT_2
+--connect(foo_node_2,127.0.0.1,foo,,test,$port_2,)
+
+--echo
+--echo # Connect with foo_node_2
+--connection foo_node_2
+--error ER_OPTION_PREVENTS_STATEMENT
+INSERT INTO t1 VALUES (2);
+
+--connection node_2
+SELECT COUNT(*) = 1 FROM t1;
+
+# Cleanup
+SET GLOBAL read_only=FALSE;
+DROP TABLE t1;
+DROP USER foo@localhost;
+
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 3629f3dd198..566a50340aa 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -982,22 +982,6 @@ static my_bool deny_updates_if_read_only_option(THD *thd,
}
#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)
{
thd->wsrep_retry_command = thd->command;
@@ -1011,6 +995,7 @@ static void wsrep_copy_query(THD *thd)
thd->wsrep_retry_query[thd->wsrep_retry_query_len] = '\0';
}
#endif /* WITH_WSREP */
+
/**
Perform one connection-level (COM_XXXX) command.
@@ -6355,8 +6340,7 @@ static void wsrep_mysql_parse(THD *thd, char *rawbuf, uint length,
bool is_autocommit=
!thd->in_multi_stmt_transaction_mode() &&
thd->wsrep_conflict_state == NO_CONFLICT &&
- !thd->wsrep_applier &&
- wsrep_read_only_option(thd, thd->lex->query_tables);
+ !thd->wsrep_applier;
do
{