mariadb/mysql-test/t/rpl_read_only.test
unknown 245b9ad4b3 Make sure tests drops objects created and restore variables to default
mysql-test/extra/rpl_tests/rpl_row_func003.test:
  Fix spelling error
mysql-test/extra/rpl_tests/rpl_row_tabledefs.test:
  Restore sql_mode after test
mysql-test/r/events_logs_tests.result:
  Turn even_scheduleroff before test ends
mysql-test/r/events_scheduling.result:
  Turn even_scheduleroff before test ends
mysql-test/r/insert.result:
  Drop tables t1 before test ends
mysql-test/r/rpl_read_only.result:
  Set read_only flag back to default
mysql-test/r/rpl_row_NOW.result:
  Drop database mysqltest1 before test ends
mysql-test/r/rpl_row_USER.result:
  Drop users created by test
mysql-test/r/rpl_row_basic_11bugs.result:
  Drop table and set query_cache_size back to default
mysql-test/r/rpl_row_func002.result:
  Drop table created by test
mysql-test/r/rpl_row_sp008.result:
  Drop table created by test
mysql-test/r/rpl_row_sp012.result:
  Drop user created by test
mysql-test/r/rpl_row_tabledefs_2myisam.result:
  Restore sql_mode
mysql-test/r/rpl_row_tabledefs_3innodb.result:
  Restore sql_mode
mysql-test/r/rpl_row_tabledefs_7ndb.result:
  Restore sql_mode
mysql-test/r/rpl_row_view01.result:
  Drop database created by test
mysql-test/r/rpl_slave_status.result:
  Remove created users
mysql-test/r/rpl_switch_stm_row_mixed.result:
  Reset binlog_format to default
mysql-test/r/sp.result:
  Drop procedure created by test
mysql-test/r/varbinary.result:
  Drop table created by test
mysql-test/r/variables.result:
  Reset changed variables to their defaults
mysql-test/t/events_logs_tests.test:
  Turn off event_scheduler before test ends
mysql-test/t/events_scheduling.test:
  Turn off event_scheduler
mysql-test/t/insert.test:
  Drop table created by test
mysql-test/t/rpl_read_only.test:
  Reset read_only flag
mysql-test/t/rpl_row_NOW.test:
  Drop db created by test
mysql-test/t/rpl_row_USER.test:
  Drop users created
mysql-test/t/rpl_row_basic_11bugs.test:
  Drop tables created by test
mysql-test/t/rpl_row_func002.test:
  Drop table created by test
mysql-test/t/rpl_row_sp008.test:
  Drop table created by test
mysql-test/t/rpl_row_sp012.test:
  Drop user created by test
mysql-test/t/rpl_row_view01.test:
  Drop db created by test
mysql-test/t/rpl_slave_status.test:
  Remove users created by test
mysql-test/t/rpl_switch_stm_row_mixed.test:
  Reset binlog_format
mysql-test/t/sp.test:
  Drop procedure created by test
mysql-test/t/varbinary.test:
  Drop tables created by test
mysql-test/t/variables.test:
  Restore variables to their default before test ends
2007-03-01 14:16:38 +01:00

113 lines
2.2 KiB
Text

# Test case for BUG #11733
-- source include/master-slave.inc
-- source include/have_innodb.inc
# Create a test and replicate it to slave
connection master;
create user test;
sync_slave_with_master;
# Setting the master readonly :
# - the variable @@readonly is not replicated on the slave
connect (master2,127.0.0.1,test,,test,$MASTER_MYPORT,);
connect (slave2,127.0.0.1,test,,test,$SLAVE_MYPORT,);
connection master1;
create table t1(a int) engine=InnoDB;
create table t2(a int) engine=MyISAM;
insert into t1 values(1001);
insert into t2 values(2001);
connection master;
set global read_only=1;
connection master1;
select @@read_only;
select * from t1;
select * from t2;
sync_slave_with_master;
select @@read_only;
select * from t1;
select * from t2;
# - replication of transactions
connection master;
set global read_only=0;
connection master1;
BEGIN;
insert into t1 values(1002);
insert into t2 values(2002);
connection master2;
BEGIN;
insert into t1 values(1003);
insert into t2 values(2003);
connection master;
set global read_only=1;
connection master1;
## works even with read_only=1, because master1 is root
COMMIT;
connection master2;
--error ER_OPTION_PREVENTS_STATEMENT
COMMIT;
connection master;
set global read_only=0;
connection master1;
insert into t1 values(1004);
insert into t2 values(2004);
select * from t1;
select * from t2;
sync_slave_with_master;
select * from t1;
select * from t2;
# Setting the slave readonly : replication will pass
#
connection slave1;
set global read_only=1;
connection slave;
select @@read_only;
# Make sure the replicated table is also transactional
show create table t1;
# Make sure the replicated table is not transactional
show create table t2;
connection master;
insert into t1 values(1005);
insert into t2 values(2005);
select * from t1;
select * from t2;
sync_slave_with_master;
connection slave;
select * from t1;
select * from t2;
# Non root user can not write on the slave
connection slave2;
--error ER_OPTION_PREVENTS_STATEMENT
insert into t1 values(1006);
--error ER_OPTION_PREVENTS_STATEMENT
insert into t2 values(2006);
## Cleanup
connection master;
drop user test;
drop table t1;
drop table t2;
sync_slave_with_master;
set global read_only=0;